[CMake] How do I install targets?
Brad King
brad.king at kitware.com
Thu Aug 11 13:11:30 EDT 2005
wedekind wrote:
> I do not only want to build the sources, but also want to create the
> installable archive file (e.g. a tarball) from the compiled sources in one
> step. How do I do this (call ALL_BUILD which automatically triggers
> INSTALL)?
>
> Do I have to throw away all the great INSTALL_TARGET-support of cmake and
> add a POST_BUILD custom command that copies the created files to the install
> tree?
If you use CMake 2.2 then the INSTALL target automatically depends on
the ALL_BUILD target on all platforms. You could add a post-install
rule to the last target that gets installed to create the tarball. Then
the trick is to get the testing process to build using the INSTALL
target. This will probably require some ctest changes. Please submit a
feature request here:
http://www.cmake.org/Bug
For now you can instead get the ALL_BUILD target to run the INSTALL
target as part of the build. You can create a custom target that
depends on all other targets:
ADD_CUSTOM_TARGET(auto_install ALL)
ADD_DEPENDENCIES(auto_install
...all targets to be installed...
)
Then add a post-build rule to build the INSTALL target:
ADD_CUSTOM_COMMAND(
TARGET auto_install
POST_BUILD
COMMAND ${CMAKE_CTEST_COMMAND}
ARGS --build-and-test
${CMAKE_SOURCE_DIR}
${CMAKE_BINARY_DIR}
--build-generator ${CMAKE_GENERATOR}
--build-project ${PROJECT_NAME}
--build-makeprogram ${CMAKE_MAKE_PROGRAM}
--build-noclean
--build-target install
COMMENT "Install Project"
)
-Brad
More information about the CMake
mailing list