1 cmake_minimum_required (VERSION 2.6)
5 set (Tutorial_VERSION_MAJOR 1)
6 set (Tutorial_VERSION_MINOR 0)
8 # does this system provide the log and exp functions?
9 include (${CMAKE_ROOT}/Modules/CheckFunctionExists.cmake)
10 check_function_exists (log HAVE_LOG)
11 check_function_exists (exp HAVE_EXP)
13 # should we use our own math functions
14 option(USE_MYMATH "Use tutorial provided math implementation" ON)
16 # configure a header file to pass some of the CMake settings
19 "${PROJECT_SOURCE_DIR}/TutorialConfig.h.in"
20 "${PROJECT_BINARY_DIR}/TutorialConfig.h"
23 # add the binary tree to the search path for include files
24 # so that we will find TutorialConfig.h
25 include_directories ("${PROJECT_BINARY_DIR}")
27 # add the MathFunctions library?
29 include_directories ("${PROJECT_SOURCE_DIR}/MathFunctions")
30 add_subdirectory (MathFunctions)
31 set (EXTRA_LIBS ${EXTRA_LIBS} MathFunctions)
35 add_executable (Tutorial tutorial.cxx)
36 target_link_libraries (Tutorial ${EXTRA_LIBS})
38 # add the install targets
39 install (TARGETS Tutorial DESTINATION bin)
40 install (FILES "${PROJECT_BINARY_DIR}/TutorialConfig.h"
46 # does the application run
47 add_test (TutorialRuns Tutorial 25)
49 # does the usage message work?
50 add_test (TutorialUsage Tutorial)
51 set_tests_properties (TutorialUsage
53 PASS_REGULAR_EXPRESSION "Usage:.*number"
56 #define a macro to simplify adding tests
57 macro (do_test arg result)
58 add_test (TutorialComp${arg} Tutorial ${arg})
59 set_tests_properties (TutorialComp${arg}
60 PROPERTIES PASS_REGULAR_EXPRESSION ${result}
64 # do a bunch of result based tests
65 do_test (25 "25 is 5")
66 do_test (-25 "-25 is 0")
67 do_test (0.0001 "0.0001 is 0.01")