9db3116226
Ancient versions of CMake required else(), endif(), and similar block termination commands to have arguments matching the command starting the block. This is no longer the preferred style. Run the following shell code: for c in else endif endforeach endfunction endmacro endwhile; do echo 's/\b'"$c"'\(\s*\)(.\+)/'"$c"'\1()/' done >convert.sed && git ls-files -z -- bootstrap '*.cmake' '*.cmake.in' '*CMakeLists.txt' | egrep -z -v '^(Utilities/cm|Source/kwsys/)' | egrep -z -v 'Tests/CMakeTests/While-Endwhile-' | xargs -0 sed -i -f convert.sed && rm convert.sed
60 lines
2.0 KiB
CMake
60 lines
2.0 KiB
CMake
# create the binary directory
|
|
make_directory("@CMAKE_BUILD_TEST_BINARY_DIR@")
|
|
|
|
# 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")
|
|
|
|
# run cmake in the binary directory
|
|
message("running: ${CMAKE_COMMAND}")
|
|
execute_process(COMMAND "${CMAKE_COMMAND}"
|
|
"@CMAKE_BUILD_TEST_SOURCE_DIR@"
|
|
"-G@CMAKE_TEST_GENERATOR@"
|
|
WORKING_DIRECTORY "@CMAKE_BUILD_TEST_BINARY_DIR@"
|
|
RESULT_VARIABLE RESULT)
|
|
if(RESULT)
|
|
message(FATAL_ERROR "Error running cmake command")
|
|
endif()
|
|
|
|
# Now use the --build option to build the project
|
|
message("running: ${CMAKE_COMMAND} --build")
|
|
execute_process(COMMAND "${CMAKE_COMMAND}"
|
|
--build "@CMAKE_BUILD_TEST_BINARY_DIR@" --config Debug
|
|
RESULT_VARIABLE RESULT)
|
|
if(RESULT)
|
|
message(FATAL_ERROR "Error running cmake --build")
|
|
endif()
|
|
|
|
# check for configuration types
|
|
set(CMAKE_CONFIGURATION_TYPES @CMAKE_CONFIGURATION_TYPES@)
|
|
# run the executable out of the Debug directory if there
|
|
# are configuration types
|
|
if(CMAKE_CONFIGURATION_TYPES)
|
|
set(RUN_TEST "@CMAKE_BUILD_TEST_BINARY_DIR@/Debug/@CMAKE_BUILD_TEST_EXE@")
|
|
else()
|
|
set(RUN_TEST "@CMAKE_BUILD_TEST_BINARY_DIR@/@CMAKE_BUILD_TEST_EXE@")
|
|
endif()
|
|
# run the test results
|
|
message("running [${RUN_TEST}]")
|
|
execute_process(COMMAND "${RUN_TEST}" RESULT_VARIABLE RESULT)
|
|
if(RESULT)
|
|
message(FATAL_ERROR "Error running test @CMAKE_BUILD_TEST_EXE@")
|
|
endif()
|
|
|
|
# build it again with clean and only @CMAKE_BUILD_TEST_EXE@ target
|
|
execute_process(COMMAND "${CMAKE_COMMAND}"
|
|
--build "@CMAKE_BUILD_TEST_BINARY_DIR@" --config Debug
|
|
--clean-first --target @CMAKE_BUILD_TEST_EXE@
|
|
RESULT_VARIABLE RESULT)
|
|
if(RESULT)
|
|
message(FATAL_ERROR "Error running cmake --build")
|
|
endif()
|
|
|
|
# run it again after clean
|
|
execute_process(COMMAND "${RUN_TEST}" RESULT_VARIABLE RESULT)
|
|
if(RESULT)
|
|
message(FATAL_ERROR "Error running test @CMAKE_BUILD_TEST_EXE@ after clean ")
|
|
endif()
|