[CMake] CMAKE Install Configurations

Eddy Ilg me at eddy-ilg.net
Wed Dec 17 06:19:57 EST 2014


Hi,


I am trying to set up a project that has fine-grained installation 
control. The hierarchy is like this:

Project
     Group
         Component

There should be three install variants:
1. "make install" should install the whole project.
2. "make Group1-install" should install everything that is in group 1
3. "make Component1-install" should install component 1 only

I created custom targets for Group1-install:
     install( TARGETS ${component} DESTINATION bin COMPONENT ${group} )
add_custom_target( ${group}-install
         DEPENDS ${group}
         COMMAND
         "${CMAKE_COMMAND}" -DCOMPONENT=${group}
         -P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
     )

and  Component1-install:
     install( TARGETS ${component} DESTINATION bin COMPONENT ${component} )
     add_custom_target( ${component}-install
         DEPENDS ${component}
         COMMAND
         "${CMAKE_COMMAND}" -DCOMPONENT=${component}
         -P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
     )

Variants 2 and 3 work, 3 also works but installs everything twice 
(because of the two install commands). I tried to make one OPTIONAL, but 
no luck. When leaving the second install command out, "make 
Component1-install" does nothing.

Any hints how I could solve the duplicate installation problem with 
"make install"?


Cheers,



Eddy



More information about the CMake mailing list