1 include(EigenTesting) 2 include(CheckCXXSourceCompiles) 3 4 # configure the "site" and "buildname" 5 ei_set_sitename() 6 7 # retrieve and store the build string 8 ei_set_build_string() 9 10 add_custom_target(buildtests) 11 add_custom_target(check COMMAND "ctest") 12 add_dependencies(check buildtests) 13 14 # check whether /bin/bash exists 15 find_file(EIGEN_BIN_BASH_EXISTS "/bin/bash" PATHS "/" NO_DEFAULT_PATH) 16 17 # CMake/Ctest does not allow us to change the build command, 18 # so we have to workaround by directly editing the generated DartConfiguration.tcl file 19 # save CMAKE_MAKE_PROGRAM 20 set(CMAKE_MAKE_PROGRAM_SAVE ${CMAKE_MAKE_PROGRAM}) 21 # and set a fake one 22 set(CMAKE_MAKE_PROGRAM "@EIGEN_MAKECOMMAND_PLACEHOLDER@") 23 24 # This call activates testing and generates the DartConfiguration.tcl 25 include(CTest) 26 27 # overwrite default DartConfiguration.tcl 28 # The worarounds are different for each version of the MSVC IDE 29 if(MSVC_IDE) 30 if(MSVC_VERSION EQUAL 1600) # MSVC 2010 31 set(EIGEN_MAKECOMMAND_PLACEHOLDER "${CMAKE_MAKE_PROGRAM_SAVE} buildtests.vcxproj /p:Configuration=\${CTEST_CONFIGURATION_TYPE} \n# ") 32 else() # MSVC 2008 (TODO check MSVC 2005) 33 set(EIGEN_MAKECOMMAND_PLACEHOLDER "${CMAKE_MAKE_PROGRAM_SAVE} Eigen.sln /build \"Release\" /project buildtests \n# ") 34 endif() 35 else() 36 # for make and nmake 37 set(EIGEN_MAKECOMMAND_PLACEHOLDER "${CMAKE_MAKE_PROGRAM_SAVE} buildtests") 38 endif() 39 40 # copy ctest properties, which currently 41 # o raise the warning levels 42 configure_file(${CMAKE_BINARY_DIR}/DartConfiguration.tcl ${CMAKE_BINARY_DIR}/DartConfiguration.tcl) 43 44 # restore default CMAKE_MAKE_PROGRAM 45 set(CMAKE_MAKE_PROGRAM ${CMAKE_MAKE_PROGRAM_SAVE}) 46 # un-set temporary variables so that it is like they never existed. 47 # CMake 2.6.3 introduces the more logical unset() syntax for this. 48 set(CMAKE_MAKE_PROGRAM_SAVE) 49 set(EIGEN_MAKECOMMAND_PLACEHOLDER) 50 51 configure_file(${CMAKE_SOURCE_DIR}/CTestCustom.cmake.in ${CMAKE_BINARY_DIR}/CTestCustom.cmake) 52 53 # some documentation of this function would be nice 54 ei_init_testing() 55 56 # configure Eigen related testing options 57 option(EIGEN_NO_ASSERTION_CHECKING "Disable checking of assertions using exceptions" OFF) 58 option(EIGEN_DEBUG_ASSERTS "Enable advanced debuging of assertions" OFF) 59 60 if(CMAKE_COMPILER_IS_GNUCXX) 61 option(EIGEN_COVERAGE_TESTING "Enable/disable gcov" OFF) 62 if(EIGEN_COVERAGE_TESTING) 63 set(COVERAGE_FLAGS "-fprofile-arcs -ftest-coverage") 64 set(CTEST_CUSTOM_COVERAGE_EXCLUDE "/test/") 65 else(EIGEN_COVERAGE_TESTING) 66 set(COVERAGE_FLAGS "") 67 endif(EIGEN_COVERAGE_TESTING) 68 if(EIGEN_TEST_C++0x) 69 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++0x") 70 endif(EIGEN_TEST_C++0x) 71 if(CMAKE_SYSTEM_NAME MATCHES Linux) 72 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COVERAGE_FLAGS} -g2") 73 set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} ${COVERAGE_FLAGS} -O2 -g2") 74 set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${COVERAGE_FLAGS} -fno-inline-functions") 75 set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${COVERAGE_FLAGS} -O0 -g3") 76 endif(CMAKE_SYSTEM_NAME MATCHES Linux) 77 elseif(MSVC) 78 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D_CRT_SECURE_NO_WARNINGS /D_SCL_SECURE_NO_WARNINGS") 79 endif(CMAKE_COMPILER_IS_GNUCXX) 80