-----Original Message-----
From: "Alan W. Irwin" <ir...@beluga.phys.uvic.ca>
Date: Monday, February 26, 2018 at 6:02 PM
To: Michael Jackson <mike.jack...@bluequartz.net>
Cc: CMake Mail List <cmake@cmake.org>
Subject: Re: [CMake] Return an Error Code (or something) from a CMake Script.

    On 2018-02-26 14:19-0500 Michael Jackson wrote:
    
    > 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.

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/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake

Reply via email to