Hi all,

After some hallway conversation, here is a follow-up:

The consensus was that there were 2 options for the documentation target:

+ Leave documentation out of the install step when documentation is not built 
as part of the ALL target.
+ Change the configuration option for documentation from a boolean to a 
tri-state enum, i.e.,

    set(${PROJECT}_BUILD_DOCUMENTATION "never" CACHE STRING "When to build 
documentation.")
    set_property(CACHE ${PROJECT}_BUILD_DOCUMENTATION PROPERTY STRINGS never 
manual always)

 so that automated builds for continuous integration can function (using 
"always" or "never")
 while developers can enable documentation but not be forced to refresh it 
every time they
 modify source code (using "manual").

For the latter, a recent change[1] to CMake has made the execution of 
install-rules consistently ordered when processing subdirectories, so it is 
possible to make the INSTALL target build documentation as needed with 
something like:

   if (${PROJECT}_BUILD_DOCUMENTATION STREQUAL "manual")
     install(CODE "execute_process(COMMAND \"${CMAKE_COMMAND}\" cmake --build 
\"${CMAKE_BINARY_DIR}\" --target docs --config $<CONFIG>)")
   endif()

so long as care is taken within each directory's CMakeLists.txt to place the 
above before any install() directives related to the generated documentation.

        David

[1]: https://gitlab.kitware.com/cmake/cmake/merge_requests/2434

> On Oct 11, 2018, at 09:09, David Thompson <david.thomp...@kitware.com> wrote:
> 
> Hi all,
> 
> Is there a way to force a custom target (i.e., ADD_CUSTOM_TARGET) to be built 
> just before installation?
> 
> We have documentation added as a custom target that is **not** passed the 
> "ALL" keyword because generating the documentation is slow. However, that 
> target creates files that have a matching INSTALL, so "make install" or 
> "ninja install" will fail unless the target is built before installation. We 
> want to encourage developers to configure with documentation turned on, but 
> want buildbot/dashboard builds to work without magic options or special 
> configuration.
> 
> Along those lines:
> 
> 1. Is there any ordering of INSTALL(CODE ...) relative to INSTALL(FILES ...)? 
> If it is guaranteed to run first, we could force the target to build that way.
> 
> 2. Is there really nothing to replace the deprecated PRE_INSTALL_SCRIPT 
> property?
> 
>       Thanks,
>       David

-- 

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