Resync
[CMakeLuaTailorHgBridge.git] / CMakeLua / Tests / Tutorial / Step7 / CMakeLists.txt
blob42f73f221be13f5a550e3423b5ebb47b1fdfaef8
1 cmake_minimum_required (VERSION 2.6)
2 project (Tutorial)
4 # The version number.
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
17 # to the source code
18 configure_file (
19   "${PROJECT_SOURCE_DIR}/TutorialConfig.h.in"
20   "${PROJECT_BINARY_DIR}/TutorialConfig.h"
21   )
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?
28 if (USE_MYMATH)
29   include_directories ("${PROJECT_SOURCE_DIR}/MathFunctions")
30   add_subdirectory (MathFunctions)
31   set (EXTRA_LIBS ${EXTRA_LIBS} MathFunctions)
32 endif (USE_MYMATH)
34 # add the executable
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" 
41   DESTINATION include)
43 # enable testing
44 enable_testing ()
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
52   PROPERTIES 
53   PASS_REGULAR_EXPRESSION "Usage:.*number"
54   )
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}
61     )
62 endmacro (do_test)
64 # do a bunch of result based tests
65 do_test (4 "4 is 2")
66 do_test (9 "9 is 3")
67 do_test (5 "5 is 2.236")
68 do_test (7 "7 is 2.645")
69 do_test (25 "25 is 5")
70 do_test (-25 "-25 is 0")
71 do_test (0.0001 "0.0001 is 0.01")
73 # build a CPack driven installer package
74 include (InstallRequiredSystemLibraries)
75 set (CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/License.txt")
76 set (CPACK_PACKAGE_VERSION_MAJOR "${Tutorial_VERSION_MAJOR}")
77 set (CPACK_PACKAGE_VERSION_MINOR "${Tutorial_VERSION_MINOR}")
78 set (CPACK_PACKAGE_CONTACT       "foo@bar.org")
79 include (CPack)
81 # enable dashboard scripting
82 include (CTest)