CMakeLists.txt 1.7 KB

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