[CMake] Multiple Installers in one project

Eric Noulard eric.noulard at gmail.com
Wed Apr 4 15:41:31 EDT 2012


2012/4/4 David Cole <david.cole at kitware.com>:
> No. It's easy to build a single installer that contains multiple components.

You are speaking of NSIS or Package Maker since archive generators
like ZIP can produce multiple file on a per-component basis.

I may suggest a possibly "easy" solution if you do accept extra building.

You can make your current project "configurable with options", like:

OPTION(BUILD_PACK1 "Used to build package1" OFF)
OPTION(BUILD_PACK2 "Used to build package2" OFF)
OPTION(BUILD_PACK3 "Used to build package3" OFF)

then you make your install rule conditionnal on the option value
(you can make the build rule conditionnal as well if you want
 to save compilation time)

if (BUILD_PACK1)
   INSTALL(TARGET Bin1 RUNTIME DESTINATION .)
endif()

if (BUILD_PACK2 OR BUILD_PACK3)
   INSTALL(TARGET Lib3 RUNTIME DESTINATION .)
endif()

etc....I think you get it.
use BundleUtilities if you want.

mkdir build1; cd build1; cmake -DBUILD_PACK1=ON /path/to/source; make
; make package
mkdir build2; cd build2; cmake -DBUILD_PACK2=ON /path/to/source; make
; make package
mkdir build3; cd build3; cmake -DBUILD_PACK3=ON /path/to/source; make
; make package

you will build things far too much times but
  - you'll keep a single project
  - you'll get your wanted package

You should off course setup some BUILD_PACKx specific values
for CPACK_PACKAGE_NAME so that you'll get package specific name.

You could tune other CPack time parameters/Variables by using a CPack project
config file such that you can change the name, license file, etc... if a
"build specific way".
http://www.cmake.org/Wiki/CMake:CPackPackageGenerators#Overall_usage_.28common_to_all_generators.29

I think you could even be able to play with component
and CPACK_COMPONENTS_ALL at CPack time  in order to avoid
CMake time option, but I shall try before giving such advice.
-- 
Erk
Le gouvernement représentatif n'est pas la démocratie --
http://www.le-message.org


More information about the CMake mailing list