[CMake] Cpack Installing extra files depending on generator type
Eric Noulard
eric.noulard at gmail.com
Fri Dec 9 03:37:28 EST 2011
2011/12/9 vivek goel <goelvivek2011 at gmail.com>:
> I want to generate two package type .
>
> So I am using following syntax in my CMakeLists.txt
> SET(CPACK_GENERATOR "TGZ;RPM")
>
> Now problem is that I want to install some extra files in Generator RPM.
> And I want to set different Install RPM prefix.
> How can I do that ?
When you want to do CPack generator specific things you'd better
off using CPACK_PROJECT_CONFIG_FILE
http://www.cmake.org/Wiki/CMake:CPackPackageGenerators#Overall_usage_.28common_to_all_generators.29
this file is loaded **at CPack time** before the CPack generator runs.
in this file you can do something like;
if(CPACK_GENERATOR MATCHES "TGZ")
set(CPACK_ARCHIVE_COMPONENT_INSTALL "OFF")
endif(CPACK_GENERATOR MATCHES "ZIP")
if(CPACK_GENERATOR MATCHES "RPM")
set(CPACK_RPM_COMPONENT_INSTALL "ON")
# change the default install prefix
set(CPACK_PACKAGING_INSTALL_PREFIX "/opt")
endif(CPACK_GENERATOR MATCHES "RPM")
The problem with the "install extra file for RPM" is that install command
are prepared at **CMake time** and launched at **CPack time**
so may be you can use the
install(SCRIPT ...) signature with a cmake script which will check
(at CPack time) the value of CPACK_GENERATOR in the same way
CPACK_PROJECT_CONFIG_FILE does.
--
Erk
Membre de l'April - « promouvoir et défendre le logiciel libre » -
http://www.april.org
More information about the CMake
mailing list