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.

79 lines
3.1 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. # overwrite default DartConfiguration.tcl
  21. # The worarounds are different for each version of the MSVC IDE
  22. if(MSVC_IDE)
  23. if(MSVC_VERSION EQUAL 1600) # MSVC 2010
  24. set(EIGEN_MAKECOMMAND_PLACEHOLDER "${CMAKE_MAKE_PROGRAM_SAVE} buildtests.vcxproj /p:Configuration=\${CTEST_CONFIGURATION_TYPE} \n# ")
  25. else() # MSVC 2008 (TODO check MSVC 2005)
  26. set(EIGEN_MAKECOMMAND_PLACEHOLDER "${CMAKE_MAKE_PROGRAM_SAVE} Eigen.sln /build \"Release\" /project buildtests \n# ")
  27. endif()
  28. else()
  29. # for make and nmake
  30. set(EIGEN_MAKECOMMAND_PLACEHOLDER "${CMAKE_MAKE_PROGRAM_SAVE} buildtests")
  31. endif()
  32. # copy ctest properties, which currently
  33. # o raise the warning levels
  34. configure_file(${CMAKE_BINARY_DIR}/DartConfiguration.tcl ${CMAKE_BINARY_DIR}/DartConfiguration.tcl)
  35. # restore default CMAKE_MAKE_PROGRAM
  36. set(CMAKE_MAKE_PROGRAM ${CMAKE_MAKE_PROGRAM_SAVE})
  37. # un-set temporary variables so that it is like they never existed.
  38. # CMake 2.6.3 introduces the more logical unset() syntax for this.
  39. set(CMAKE_MAKE_PROGRAM_SAVE)
  40. set(EIGEN_MAKECOMMAND_PLACEHOLDER)
  41. configure_file(${CMAKE_SOURCE_DIR}/CTestCustom.cmake.in ${CMAKE_BINARY_DIR}/CTestCustom.cmake)
  42. # some documentation of this function would be nice
  43. ei_init_testing()
  44. # configure Eigen related testing options
  45. option(EIGEN_NO_ASSERTION_CHECKING "Disable checking of assertions using exceptions" OFF)
  46. option(EIGEN_DEBUG_ASSERTS "Enable advanced debuging of assertions" OFF)
  47. if(CMAKE_COMPILER_IS_GNUCXX)
  48. option(EIGEN_COVERAGE_TESTING "Enable/disable gcov" OFF)
  49. if(EIGEN_COVERAGE_TESTING)
  50. set(COVERAGE_FLAGS "-fprofile-arcs -ftest-coverage")
  51. set(CTEST_CUSTOM_COVERAGE_EXCLUDE "/test/")
  52. else(EIGEN_COVERAGE_TESTING)
  53. set(COVERAGE_FLAGS "")
  54. endif(EIGEN_COVERAGE_TESTING)
  55. if(EIGEN_TEST_C++0x)
  56. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++0x")
  57. endif(EIGEN_TEST_C++0x)
  58. if(CMAKE_SYSTEM_NAME MATCHES Linux)
  59. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COVERAGE_FLAGS} -g2")
  60. set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} ${COVERAGE_FLAGS} -O2 -g2")
  61. set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${COVERAGE_FLAGS} -fno-inline-functions")
  62. set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${COVERAGE_FLAGS} -O0 -g3")
  63. endif(CMAKE_SYSTEM_NAME MATCHES Linux)
  64. elseif(MSVC)
  65. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D_CRT_SECURE_NO_WARNINGS /D_SCL_SECURE_NO_WARNINGS")
  66. endif(CMAKE_COMPILER_IS_GNUCXX)