1 # create the binary directory
2 make_directory("@CMAKE_BUILD_TEST_BINARY_DIR@")
4 # remove the CMakeCache.txt file from the source dir
5 # if there is one, so that in-source cmake tests
7 message("Remove: @CMAKE_BUILD_TEST_SOURCE_DIR@/CMakeCache.txt")
8 file(REMOVE "@CMAKE_BUILD_TEST_SOURCE_DIR@/CMakeCache.txt")
10 # run cmake in the binary directory
11 message("running: ${CMAKE_COMMAND}")
12 execute_process(COMMAND "${CMAKE_COMMAND}"
13 "@CMAKE_BUILD_TEST_SOURCE_DIR@"
14 "-G@CMAKE_TEST_GENERATOR@"
15 WORKING_DIRECTORY "@CMAKE_BUILD_TEST_BINARY_DIR@"
16 RESULT_VARIABLE RESULT)
18 message(FATAL_ERROR "Error running cmake command")
21 # Now use the --build option to build the project
22 message("running: ${CMAKE_COMMAND} --build")
23 execute_process(COMMAND "${CMAKE_COMMAND}"
24 --build "@CMAKE_BUILD_TEST_BINARY_DIR@" --config Debug
25 RESULT_VARIABLE RESULT)
27 message(FATAL_ERROR "Error running cmake --build")
30 # check for configuration types
31 set(CMAKE_CONFIGURATION_TYPES @CMAKE_CONFIGURATION_TYPES@)
32 # run the executable out of the Debug directory if there
33 # are configuration types
34 if(CMAKE_CONFIGURATION_TYPES)
35 set(RUN_TEST "@CMAKE_BUILD_TEST_BINARY_DIR@/Debug/COnly")
36 else(CMAKE_CONFIGURATION_TYPES)
37 set(RUN_TEST "@CMAKE_BUILD_TEST_BINARY_DIR@/COnly")
38 endif(CMAKE_CONFIGURATION_TYPES)
39 # run the test results
40 message("running [${RUN_TEST}]")
41 execute_process(COMMAND "${RUN_TEST}" RESULT_VARIABLE RESULT)
43 message(FATAL_ERROR "Error running test COnly")
46 # build it again with clean and only COnly target
47 execute_process(COMMAND "${CMAKE_COMMAND}"
48 --build "@CMAKE_BUILD_TEST_BINARY_DIR@" --config Debug
49 --clean-first --target COnly
50 RESULT_VARIABLE RESULT)
52 message(FATAL_ERROR "Error running cmake --build")
55 # run it again after clean
56 execute_process(COMMAND "${RUN_TEST}" RESULT_VARIABLE RESULT)
58 message(FATAL_ERROR "Error running test COnly after clean ")