CMakeLists.txt 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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 (/bin Tutorial)
  27. install_files (/include FILES "${PROJECT_BINARY_DIR}/TutorialConfig.h")
  28. # enable testing
  29. enable_testing ()
  30. # does the application run
  31. add_test (TutorialRuns Tutorial 25)
  32. # does it sqrt of 25
  33. add_test (TutorialComp25 Tutorial 25)
  34. set_tests_properties (TutorialComp25
  35. PROPERTIES PASS_REGULAR_EXPRESSION "25 is 5"
  36. )
  37. # does it handle negative numbers
  38. add_test (TutorialNegative Tutorial -25)
  39. set_tests_properties (TutorialNegative
  40. PROPERTIES PASS_REGULAR_EXPRESSION "-25 is 0"
  41. )
  42. # does it handle small numbers
  43. add_test (TutorialSmall Tutorial 0.0001)
  44. set_tests_properties (TutorialSmall
  45. PROPERTIES PASS_REGULAR_EXPRESSION "0.0001 is 0.01"
  46. )
  47. # does the usage message work?
  48. add_test (TutorialUsage Tutorial)
  49. set_tests_properties (TutorialUsage
  50. PROPERTIES
  51. PASS_REGULAR_EXPRESSION "Usage:.*number"
  52. )