2008-10-15 21:56:07 +04:00
|
|
|
# create the binary directory
|
|
|
|
make_directory("@CMAKE_BUILD_TEST_BINARY_DIR@")
|
|
|
|
|
2008-10-18 18:31:16 +04:00
|
|
|
# remove the CMakeCache.txt file from the source dir
|
|
|
|
# if there is one, so that in-source cmake tests
|
|
|
|
# still pass
|
|
|
|
message("Remove: @CMAKE_BUILD_TEST_SOURCE_DIR@/CMakeCache.txt")
|
|
|
|
file(REMOVE "@CMAKE_BUILD_TEST_SOURCE_DIR@/CMakeCache.txt")
|
|
|
|
|
2012-08-13 21:42:58 +04:00
|
|
|
# run cmake in the binary directory
|
2008-10-16 00:50:55 +04:00
|
|
|
message("running: ${CMAKE_COMMAND}")
|
|
|
|
execute_process(COMMAND "${CMAKE_COMMAND}"
|
2012-08-13 21:42:58 +04:00
|
|
|
"@CMAKE_BUILD_TEST_SOURCE_DIR@"
|
2014-03-03 23:06:34 +04:00
|
|
|
"-G@CMAKE_GENERATOR@"
|
|
|
|
-T "@CMAKE_GENERATOR_TOOLSET@"
|
2008-10-15 21:56:07 +04:00
|
|
|
WORKING_DIRECTORY "@CMAKE_BUILD_TEST_BINARY_DIR@"
|
|
|
|
RESULT_VARIABLE RESULT)
|
|
|
|
if(RESULT)
|
|
|
|
message(FATAL_ERROR "Error running cmake command")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2008-10-15 21:56:07 +04:00
|
|
|
|
|
|
|
# Now use the --build option to build the project
|
2008-10-16 00:50:55 +04:00
|
|
|
message("running: ${CMAKE_COMMAND} --build")
|
2012-08-13 21:42:58 +04:00
|
|
|
execute_process(COMMAND "${CMAKE_COMMAND}"
|
2008-10-15 21:56:07 +04:00
|
|
|
--build "@CMAKE_BUILD_TEST_BINARY_DIR@" --config Debug
|
|
|
|
RESULT_VARIABLE RESULT)
|
|
|
|
if(RESULT)
|
|
|
|
message(FATAL_ERROR "Error running cmake --build")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2008-10-15 21:56:07 +04:00
|
|
|
|
|
|
|
# check for configuration types
|
|
|
|
set(CMAKE_CONFIGURATION_TYPES @CMAKE_CONFIGURATION_TYPES@)
|
2012-08-13 21:42:58 +04:00
|
|
|
# run the executable out of the Debug directory if there
|
2008-10-15 21:56:07 +04:00
|
|
|
# are configuration types
|
|
|
|
if(CMAKE_CONFIGURATION_TYPES)
|
2011-12-16 06:56:34 +04:00
|
|
|
set(RUN_TEST "@CMAKE_BUILD_TEST_BINARY_DIR@/Debug/@CMAKE_BUILD_TEST_EXE@")
|
2012-08-13 21:50:14 +04:00
|
|
|
else()
|
2011-12-16 06:56:34 +04:00
|
|
|
set(RUN_TEST "@CMAKE_BUILD_TEST_BINARY_DIR@/@CMAKE_BUILD_TEST_EXE@")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2008-10-15 21:56:07 +04:00
|
|
|
# run the test results
|
|
|
|
message("running [${RUN_TEST}]")
|
|
|
|
execute_process(COMMAND "${RUN_TEST}" RESULT_VARIABLE RESULT)
|
|
|
|
if(RESULT)
|
2011-12-16 06:56:34 +04:00
|
|
|
message(FATAL_ERROR "Error running test @CMAKE_BUILD_TEST_EXE@")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2008-10-15 21:56:07 +04:00
|
|
|
|
2011-12-16 06:56:34 +04:00
|
|
|
# build it again with clean and only @CMAKE_BUILD_TEST_EXE@ target
|
2012-08-13 21:42:58 +04:00
|
|
|
execute_process(COMMAND "${CMAKE_COMMAND}"
|
|
|
|
--build "@CMAKE_BUILD_TEST_BINARY_DIR@" --config Debug
|
2011-12-16 06:56:34 +04:00
|
|
|
--clean-first --target @CMAKE_BUILD_TEST_EXE@
|
2008-10-15 21:56:07 +04:00
|
|
|
RESULT_VARIABLE RESULT)
|
|
|
|
if(RESULT)
|
|
|
|
message(FATAL_ERROR "Error running cmake --build")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2008-10-15 21:56:07 +04:00
|
|
|
|
2012-08-13 21:42:58 +04:00
|
|
|
# run it again after clean
|
2008-10-15 21:56:07 +04:00
|
|
|
execute_process(COMMAND "${RUN_TEST}" RESULT_VARIABLE RESULT)
|
|
|
|
if(RESULT)
|
2011-12-16 06:56:34 +04:00
|
|
|
message(FATAL_ERROR "Error running test @CMAKE_BUILD_TEST_EXE@ after clean ")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|