CMakeLists.txt 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. cmake_minimum_required (VERSION 2.6)
  2. project (Tutorial)
  3. # The version number.
  4. set (Tutorial_VERSION_MAJOR 1)
  5. set (Tutorial_VERSION_MINOR 0)
  6. # should we use our own math functions
  7. option(USE_MYMATH "Use tutorial provided math implementation" ON)
  8. # configure a header file to pass some of the CMake settings
  9. # to the source code
  10. configure_file (
  11. "${PROJECT_SOURCE_DIR}/TutorialConfig.h.in"
  12. "${PROJECT_BINARY_DIR}/TutorialConfig.h"
  13. )
  14. # add the binary tree to the search path for include files
  15. # so that we will find TutorialConfig.h
  16. include_directories ("${PROJECT_BINARY_DIR}")
  17. # add the MathFunctions library?
  18. if (USE_MYMATH)
  19. include_directories ("${PROJECT_SOURCE_DIR}/MathFunctions")
  20. add_subdirectory (MathFunctions)
  21. set (EXTRA_LIBS ${EXTRA_LIBS} MathFunctions)
  22. endif ()
  23. # add the executable
  24. add_executable (Tutorial tutorial.cxx)
  25. target_link_libraries (Tutorial ${EXTRA_LIBS})
  26. # add the install targets
  27. install (TARGETS Tutorial DESTINATION bin)
  28. install (FILES "${PROJECT_BINARY_DIR}/TutorialConfig.h"
  29. DESTINATION include)
  30. # enable testing
  31. enable_testing ()
  32. # does the application run
  33. add_test (TutorialRuns Tutorial 25)
  34. # does it sqrt of 25
  35. add_test (TutorialComp25 Tutorial 25)
  36. set_tests_properties (TutorialComp25
  37. PROPERTIES PASS_REGULAR_EXPRESSION "25 is 5"
  38. )
  39. # does it handle negative numbers
  40. add_test (TutorialNegative Tutorial -25)
  41. set_tests_properties (TutorialNegative
  42. PROPERTIES PASS_REGULAR_EXPRESSION "-25 is 0"
  43. )
  44. # does it handle small numbers
  45. add_test (TutorialSmall Tutorial 0.0001)
  46. set_tests_properties (TutorialSmall
  47. PROPERTIES PASS_REGULAR_EXPRESSION "0.0001 is 0.01"
  48. )
  49. # does the usage message work?
  50. add_test (TutorialUsage Tutorial)
  51. set_tests_properties (TutorialUsage
  52. PROPERTIES
  53. PASS_REGULAR_EXPRESSION "Usage:.*number"
  54. )