1cmake_minimum_required(VERSION 2.8.7) 2 3project(GSLTests CXX) 4 5if (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/unittest-cpp/tests) 6 execute_process(COMMAND git submodule update --init WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}") 7endif() 8 9add_subdirectory(unittest-cpp) 10 11include_directories( 12 .. 13 ./unittest-cpp 14) 15 16add_definitions(-DGSL_THROW_ON_CONTRACT_VIOLATION) 17 18if(MSVC14 OR MSVC12) # has the support we need 19 # remove unnecessary warnings about unchecked iterators 20 add_definitions(-D_SCL_SECURE_NO_WARNINGS) 21 add_compile_options(/W4) 22else() 23 include(CheckCXXCompilerFlag) 24 CHECK_CXX_COMPILER_FLAG("-std=c++14" COMPILER_SUPPORTS_CXX14) 25 CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11) 26 if(COMPILER_SUPPORTS_CXX14) 27 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-strict-aliasing -std=c++14 -O3 -Wall -Wno-missing-braces") 28 elseif(COMPILER_SUPPORTS_CXX11) 29 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-strict-aliasing -std=c++11 -O3 -Wall -Wno-missing-braces") 30 else() 31 message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.") 32 endif() 33endif() 34 35function(add_gsl_test name) 36 add_executable(${name} ${name}.cpp ../gsl/gsl ../gsl/gsl_assert ../gsl/gsl_util ../gsl/multi_span ../gsl/span ../gsl/string_span) 37 target_link_libraries(${name} UnitTest++) 38 add_test( 39 ${name} 40 ${name} 41 ) 42endfunction() 43 44add_gsl_test(span_tests) 45add_gsl_test(multi_span_tests) 46add_gsl_test(strided_span_tests) 47add_gsl_test(string_span_tests) 48add_gsl_test(at_tests) 49add_gsl_test(bounds_tests) 50add_gsl_test(notnull_tests) 51add_gsl_test(assertion_tests) 52add_gsl_test(utils_tests) 53add_gsl_test(owner_tests) 54add_gsl_test(byte_tests) 55