You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

81 lines
3.3 KiB

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