[CMake] Install targets and component

Nils Gladitz nilsgladitz at gmail.com
Tue Aug 11 03:41:22 EDT 2015


On 08/11/2015 09:05 AM, Lars wrote:
> Hello,
>
> The following cmake script appears to work but the target is associated
> with "Unspecified" group according to cmake_install.cmake file.
> INSTALL(
>    TARGETS MyLib
>    RUNTIME DESTINATION "${BIN_PATH}"
>    LIBRARY DESTINATION "${LIB_PATH}"
>    COMPONENT COMP_APP)
>
> By removing the following section the target is associated with COMP_APP
> as expected.
> LIBRARY DESTINATION "${LIB_PATH}"
>
> We are now using CMake 3.3. This worked great with CMake 2.8.12.

The behavior should be the same in 2.8.12 and 3.3.

Like DESTINATION the COMPONENT option is scoped by the RUNTIME, LIBRARY, 
ARCHIVE etc. keywords.

The last of those in your call is LIBRARY hence the COMPONENT will apply 
only to "LIBRARY" files installed by this command.

If you want COMPONENT to apply to all kinds of installed target files 
list it before any of the scoping options e.g.

install(
    TARGETS MyLib
    COMPONENT COMP_APP
    RUNTIME DESTINATION "${BIN_PATH}"
    LIBRARY DESTINATION "${LIB_PATH}"
)

or repeat it for each scope:

install(
    TARGETS MyLib

    RUNTIME
        DESTINATION "${BIN_PATH}"
        COMPONENT COMP_APP
    LIBRARY
        DESTINATION "${LIB_PATH}"
        COMPONENT COMP_APP
)

Nils


More information about the CMake mailing list