2008-10-15 17:56:07 +00:00
|
|
|
# create the binary directory
|
|
|
|
make_directory("@CMAKE_BUILD_TEST_BINARY_DIR@")
|
|
|
|
|
2008-10-18 14:31:16 +00: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 17:42:58 +00:00
|
|
|
# run cmake in the binary directory
|
2008-10-15 20:50:55 +00:00
|
|
|
message("running: ${CMAKE_COMMAND}")
|
|
|
|
execute_process(COMMAND "${CMAKE_COMMAND}"
|
2012-08-13 17:42:58 +00:00
|
|
|
"@CMAKE_BUILD_TEST_SOURCE_DIR@"
|
2014-03-03 19:06:34 +00:00
|
|
|
"-G@CMAKE_GENERATOR@"
|
2014-09-12 14:38:32 +00:00
|
|
|
-A "@CMAKE_GENERATOR_PLATFORM@"
|
2014-03-03 19:06:34 +00:00
|
|
|
-T "@CMAKE_GENERATOR_TOOLSET@"
|
2008-10-15 17:56:07 +00:00
|
|
|
WORKING_DIRECTORY "@CMAKE_BUILD_TEST_BINARY_DIR@"
|
|
|
|
RESULT_VARIABLE RESULT)
|
|
|
|
if(RESULT)
|
|
|
|
message(FATAL_ERROR "Error running cmake command")
|
2012-08-13 17:50:14 +00:00
|
|
|
endif()
|
2008-10-15 17:56:07 +00:00
|
|
|
|
|
|
|
# Now use the --build option to build the project
|
2008-10-15 20:50:55 +00:00
|
|
|
message("running: ${CMAKE_COMMAND} --build")
|
2012-08-13 17:42:58 +00:00
|
|
|
execute_process(COMMAND "${CMAKE_COMMAND}"
|
2008-10-15 17:56:07 +00:00
|
|
|
--build "@CMAKE_BUILD_TEST_BINARY_DIR@" --config Debug
|
|
|
|
RESULT_VARIABLE RESULT)
|
|
|
|
if(RESULT)
|
|
|
|
message(FATAL_ERROR "Error running cmake --build")
|
2012-08-13 17:50:14 +00:00
|
|
|
endif()
|
2008-10-15 17:56:07 +00:00
|
|
|
|
|
|
|
# check for configuration types
|
|
|
|
set(CMAKE_CONFIGURATION_TYPES @CMAKE_CONFIGURATION_TYPES@)
|
2012-08-13 17:42:58 +00:00
|
|
|
# run the executable out of the Debug directory if there
|
2008-10-15 17:56:07 +00:00
|
|
|
# are configuration types
|
|
|
|
if(CMAKE_CONFIGURATION_TYPES)
|
2011-12-16 02:56:34 +00:00
|
|
|
set(RUN_TEST "@CMAKE_BUILD_TEST_BINARY_DIR@/Debug/@CMAKE_BUILD_TEST_EXE@")
|
2012-08-13 17:50:14 +00:00
|
|
|
else()
|
2011-12-16 02:56:34 +00:00
|
|
|
set(RUN_TEST "@CMAKE_BUILD_TEST_BINARY_DIR@/@CMAKE_BUILD_TEST_EXE@")
|
2012-08-13 17:50:14 +00:00
|
|
|
endif()
|
2008-10-15 17:56:07 +00:00
|
|
|
# run the test results
|
|
|
|
message("running [${RUN_TEST}]")
|
|
|
|
execute_process(COMMAND "${RUN_TEST}" RESULT_VARIABLE RESULT)
|
|
|
|
if(RESULT)
|
2011-12-16 02:56:34 +00:00
|
|
|
message(FATAL_ERROR "Error running test @CMAKE_BUILD_TEST_EXE@")
|
2012-08-13 17:50:14 +00:00
|
|
|
endif()
|
2008-10-15 17:56:07 +00:00
|
|
|
|
2011-12-16 02:56:34 +00:00
|
|
|
# build it again with clean and only @CMAKE_BUILD_TEST_EXE@ target
|
2012-08-13 17:42:58 +00:00
|
|
|
execute_process(COMMAND "${CMAKE_COMMAND}"
|
|
|
|
--build "@CMAKE_BUILD_TEST_BINARY_DIR@" --config Debug
|
2011-12-16 02:56:34 +00:00
|
|
|
--clean-first --target @CMAKE_BUILD_TEST_EXE@
|
2008-10-15 17:56:07 +00:00
|
|
|
RESULT_VARIABLE RESULT)
|
|
|
|
if(RESULT)
|
|
|
|
message(FATAL_ERROR "Error running cmake --build")
|
2012-08-13 17:50:14 +00:00
|
|
|
endif()
|
2008-10-15 17:56:07 +00:00
|
|
|
|
2012-08-13 17:42:58 +00:00
|
|
|
# run it again after clean
|
2008-10-15 17:56:07 +00:00
|
|
|
execute_process(COMMAND "${RUN_TEST}" RESULT_VARIABLE RESULT)
|
|
|
|
if(RESULT)
|
2011-12-16 02:56:34 +00:00
|
|
|
message(FATAL_ERROR "Error running test @CMAKE_BUILD_TEST_EXE@ after clean ")
|
2012-08-13 17:50:14 +00:00
|
|
|
endif()
|