[CMake] Return an Error Code (or something) from a CMake Script.
Michael Jackson
mike.jackson at bluequartz.net
Mon Feb 26 14:19:01 EST 2018
In our CMake based project I generate a *.cmake file which I call with the following bit of code:
add_custom_target(DREAM3D_MKDOCS_GENERATION ALL
COMMAND "${CMAKE_COMMAND}" -P "${docsCmakeFile}"
COMMENT "using mkdocs to generate the documentation"
)
Inside the generated file is the following cmake command:
message(STATUS "Starting mkdocs execution. This can take a while.....")
execute_process(COMMAND "/path/to/mkdocs" build
OUTPUT_VARIABLE mkdocs_gen_output
RESULT_VARIABLE mkdocs_gen_result
ERROR_VARIABLE mkdocs_gen_error
WORKING_DIRECTORY "/Users/mjackson/DREAM3D-Dev/DREAM3D-Build/Debug/Documentation/mkdocs"
)
message(STATUS "mkdocs_gen_result: ${mkdocs_gen_result}")
message(STATUS "mkdocs_gen_error: ${mkdocs_gen_error}")
message(STATUS "**************************************************************************")
message(STATUS "mkdocs_gen_output: ${mkdocs_gen_output}")
message(STATUS "**************************************************************************")
The issue that I am having is that if the mkdocs command fails, the build does NOT show the failure. Is there a way to have the "cmake -P" command pick up the fact that the cmake script failed so that the build fails or throws a warning/error?
Thanks
Mike Jackson
More information about the CMake
mailing list