[cmake-developers] [Review Request] Topic CMakePackageConfigHelpers_build_tree

Brad King brad.king at kitware.com
Wed Jul 23 14:39:17 EDT 2014


On 07/22/2014 07:44 AM, Stephen Kelly wrote:
> Daniele E. Domenichelli wrote:
>> By the way, is there a reason why file(COPY) does not have an option to
>> copy the file only if the file(s) is(are) different.
> 
> configure_file(COPY_ONLY) does that. file(COPY_IF_DIFFERENT) would just do 
> the same thing but would be more discoverable and might be a good idea.

Our file(INSTALL) command used by scripts for "make install" at one
time did do a copy-if-different but for incremental re-installations
it spent a very long time comparing content.  It was decided instead
to make the re-copy decision based only on the file timestamp comparison.
This makes it very fast.  The file(COPY) command is just a binding to
file(INSTALL) that does not print status messages and has slightly
different defaults.

The file(COPY) command already has many keyword options, so a new
COPY_IF_DIFFERENT to request the time-consuming comparison could be
added.

>> Since you were asking if CMake misses some important feature, I believe
>> that a very useful feature to have would be to be able to have an option
>> for the install(FILES/PROGRAMS/DIRECTORY) command that reproduces the
>> install tree in the binary directory
> 
> Yes, seems like something worth investigating.

I don't think we need to have a build tree, install-in-build-tree, and
install-tree all managed by a single build tree.  Things like
INSTALL_RPATH do not make sense when there are two possible "install"
locations.  An install-in-build-tree directory is not easily defined
in multi-config generators.

If you want to test installation then set CMAKE_INSTALL_PREFIX to
$build/prefix or something and use the normal "make install" target.
Some projects also arrange their layout within the build tree to look
like the install tree by setting CMAKE_RUNTIME_OUTPUT_DIRECTORY[_<CONFIG>]
and related variables appropriately.

Returning to CMakePackageConfigHelpers, I work on several projects
that provide one <pkg>Config.cmake file in the build tree and one
in the install tree.  They are generated by hand.  I do not use
CMakePackageConfigHelpers.  IMO it is good for getting projects
started without having to learn all the details.  For mature projects
that want to do fancy things like supporting applications from the
build tree, manual generation of the package configuration files
becomes worthwhile.

-Brad




More information about the cmake-developers mailing list