[CMake] Component specific installation

Shead, Timothy tshead at sandia.gov
Mon Jun 30 11:50:19 EDT 2008


On 6/27/08 8:58 PM, "Daniel Stonier" <d.stonier at gmail.com> wrote:

> How do you actually trigger component specific installations though?
> I've currently got a 'headers' component. On a normal cmake with unix
> makefiles, there's a makefile target for
>
> make list_all_components
>
> but no way of actually installing the components. The install still
> installs everything.

The "make install" and "make package" targets are there to handle the most
common scenario, which is "install everything".  If you want to control
components or build-type, you have to call cmake/cpack yourself, with the
correct command-line arguments.  You can use ADD_CUSTOM_COMMAND to make this
part of your build.  Here's an example of providing debug- and release-
installation of a specific component on Win32:

ADD_CUSTOM_TARGET(Install-Foo-Debug
  ${CMAKE_COMMAND}
  -D "BUILD_TYPE=Debug"
  -D "CMAKE_INSTALL_COMPONENT=Foo"
  -D "CMAKE_INSTALL_PREFIX=c:/program files/Foo-Debug"
  -P "${Foo_BINARY_DIR}/cmake_install.cmake"
  )

ADD_CUSTOM_TARGET(Install-Foo-Release
  ${CMAKE_COMMAND}
  -D "BUILD_TYPE=Release"
  -D "CMAKE_INSTALL_COMPONENT=Foo"
  -D "CMAKE_INSTALL_PREFIX=c:/program files/Foo-Release"
  -P "${Foo_BINARY_DIR}/cmake_install.cmake"
  )

Adjust the build-type and component to match your needs.  You can use a
similar approach with CPack for packaging.

Cheers,
Tim

--
Timothy M. Shead
Scalable Analytics & Visualization (1424)
Sandia National Laboratories
505-284-0139





More information about the CMake mailing list