CMakeLists.txt 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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 (/bin Tutorial)
  31. install_files (/include FILES "${PROJECT_BINARY_DIR}/TutorialConfig.h")
  32. # enable testing
  33. enable_testing ()
  34. # does the application run
  35. add_test (TutorialRuns Tutorial 25)
  36. # does the usage message work?
  37. add_test (TutorialUsage Tutorial)
  38. set_tests_properties (TutorialUsage
  39. PROPERTIES
  40. PASS_REGULAR_EXPRESSION "Usage:.*number"
  41. )
  42. #define a macro to simplify adding tests
  43. macro (do_test arg result)
  44. add_test (TutorialComp${arg} Tutorial ${arg})
  45. set_tests_properties (TutorialComp${arg}
  46. PROPERTIES PASS_REGULAR_EXPRESSION ${result}
  47. )
  48. endmacro (do_test)
  49. # do a bunch of result based tests
  50. do_test (25 "25 is 5")
  51. do_test (-25 "-25 is 0")
  52. do_test (0.0001 "0.0001 is 0.01")