CMakeLists.txt 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. project (Tutorial)
  2. # The version number.
  3. set (Tutorial_VERSION_MAJOR 1)
  4. set (Tutorial_VERSION_MINOR 0)
  5. # does this system provide the log and exp functions?
  6. include (${CMAKE_ROOT}/Modules/CheckFunctionExists.cmake)
  7. check_function_exists (log HAVE_LOG)
  8. check_function_exists (exp HAVE_EXP)
  9. # should we use our own math functions
  10. option(USE_MYMATH "Use tutorial provided math implementation" ON)
  11. # configure a header file to pass some of the CMake settings
  12. # to the source code
  13. configure_file (
  14. "${PROJECT_SOURCE_DIR}/TutorialConfig.h.in"
  15. "${PROJECT_BINARY_DIR}/TutorialConfig.h"
  16. )
  17. # add the binary tree to the search path for include files
  18. # so that we will find TutorialConfig.h
  19. include_directories ("${PROJECT_BINARY_DIR}")
  20. # add the MathFunctions library?
  21. if (USE_MYMATH)
  22. include_directories ("${PROJECT_SOURCE_DIR}/MathFunctions")
  23. add_subdirectory (MathFunctions)
  24. set (EXTRA_LIBS ${EXTRA_LIBS} MathFunctions)
  25. endif (USE_MYMATH)
  26. # add the executable
  27. add_executable (Tutorial tutorial.cxx)
  28. target_link_libraries (Tutorial ${EXTRA_LIBS})
  29. # add the install targets
  30. install (TARGETS Tutorial DESTINATION bin)
  31. install (FILES "${PROJECT_BINARY_DIR}/TutorialConfig.h"
  32. DESTINATION include)
  33. # enable testing
  34. enable_testing ()
  35. # does the application run
  36. add_test (TutorialRuns Tutorial 25)
  37. # does the usage message work?
  38. add_test (TutorialUsage Tutorial)
  39. set_tests_properties (TutorialUsage
  40. PROPERTIES
  41. PASS_REGULAR_EXPRESSION "Usage:.*number"
  42. )
  43. #define a macro to simplify adding tests
  44. macro (do_test arg result)
  45. add_test (TutorialComp${arg} Tutorial ${arg})
  46. set_tests_properties (TutorialComp${arg}
  47. PROPERTIES PASS_REGULAR_EXPRESSION ${result}
  48. )
  49. endmacro (do_test)
  50. # do a bunch of result based tests
  51. do_test (4 "4 is 2")
  52. do_test (9 "9 is 3")
  53. do_test (5 "5 is 2.236")
  54. do_test (7 "7 is 2.645")
  55. do_test (25 "25 is 5")
  56. do_test (-25 "-25 is 0")
  57. do_test (0.0001 "0.0001 is 0.01")
  58. # build a CPack driven installer package
  59. include (InstallRequiredSystemLibraries)
  60. SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/License.txt")
  61. SET(CPACK_PACKAGE_VERSION_MAJOR "${Tutorial_VERSION_MAJOR}")
  62. SET(CPACK_PACKAGE_VERSION_MINOR "${Tutorial_VERSION_MINOR}")
  63. INCLUDE (CPack)
  64. # enable dashboard scripting
  65. INCLUDE (CTest)