mirror of
https://github.com/reactos/CMake.git
synced 2024-11-24 03:59:58 +00:00
170febac52
This cleans up the 'cmake --build' command-line interface: - Rename --clean to --clean-first to better describe it. - Replace --extra-options with a -- separator to simplify passing of multiple native build tool options. - Document the options in the main CMake man page description of the --build option, and shares this with the usage message. - Require --build to be the first argument when present. - Move implementation into cmakemain where it belongs.
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(RESULT)
|
|
|
|
# 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(RESULT)
|
|
|
|
# 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/COnly")
|
|
else(CMAKE_CONFIGURATION_TYPES)
|
|
set(RUN_TEST "@CMAKE_BUILD_TEST_BINARY_DIR@/COnly")
|
|
endif(CMAKE_CONFIGURATION_TYPES)
|
|
# run the test results
|
|
message("running [${RUN_TEST}]")
|
|
execute_process(COMMAND "${RUN_TEST}" RESULT_VARIABLE RESULT)
|
|
if(RESULT)
|
|
message(FATAL_ERROR "Error running test COnly")
|
|
endif(RESULT)
|
|
|
|
# build it again with clean and only COnly target
|
|
execute_process(COMMAND "${CMAKE_COMMAND}"
|
|
--build "@CMAKE_BUILD_TEST_BINARY_DIR@" --config Debug
|
|
--clean-first --target COnly
|
|
RESULT_VARIABLE RESULT)
|
|
if(RESULT)
|
|
message(FATAL_ERROR "Error running cmake --build")
|
|
endif(RESULT)
|
|
|
|
# run it again after clean
|
|
execute_process(COMMAND "${RUN_TEST}" RESULT_VARIABLE RESULT)
|
|
if(RESULT)
|
|
message(FATAL_ERROR "Error running test COnly after clean ")
|
|
endif(RESULT)
|