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?

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?

Re: Return an Error Code (or something) from a CMake Script.

> 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?

Hi Mike:

I think you already have a good specific answer to your question, but
just out of curiosity could this CMake script approach be replaced by
executing "/path/to/mkdocs" as the COMMAND in a custom command where
your DREAM3D_MKDOCS_GENERATION custom target DEPENDS on the OUTPUT of
that custom command? Or are there reasons not to implement this more
usual custom command/custom target approach in this case?

Alan
__________________________
Alan W. Irwin

Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).

> 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?

Hi Mike:

I think you already have a good specific answer to your question, but
just out of curiosity could this CMake script approach be replaced by
executing "/path/to/mkdocs" as the COMMAND in a custom command where
your DREAM3D_MKDOCS_GENERATION custom target DEPENDS on the OUTPUT of
that custom command? Or are there reasons not to implement this more
usual custom command/custom target approach in this case?

Alan
__________________________
Alan W. Irwin

Alan,
There was a lot in that .cmake file that I left out. In order for the mkdocs to work all of our documentation has to be in the same folder (At least it makes it much easier) so during cmake time we generate the file with about 30~40 directory copy commands in it. We could do all of that in the mail cmake files but our project is starting to get overwhelmed with targets which makes opening it up on IDE's like Visual Studio and Xcode take a long time and the organization within those IDEs is frightful sometimes. So we factored out "copy" commands into a single file.