[CMake] Return an Error Code (or something) from a CMake Script.

Eric Noulard eric.noulard at gmail.com
Mon Feb 26 16:10:59 EST 2018


cmake -P usually do the right thing. Here  you ignore the error because you
only message (STATUS ...)
Try adding message (ERROR ...) or message (FATAL_ERROR ...) when
execute_process producer error and tout custom command should faim.

Le 26 févr. 2018 20:19, "Michael Jackson" <mike.jackson at bluequartz.net> a
écrit :

> 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/D
> REAM3D-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
>
>
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more
> information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensou
> rce/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> https://cmake.org/mailman/listinfo/cmake
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20180226/c99ecab4/attachment.html>


More information about the CMake mailing list