Reputation: 126
I've been using cmake 3.2 for almost a year now, with good success.
I'm trying to install a 'headers' and 'library' component separately, and then use find_package to require each component. The install works just fine using the custom target. But, find_package fails when the COMPONENT keyword is added for the package/component I just installed.
install(FILES
include/sum.h
...
include/sumvmtypes.h
DESTINATION ${APP_INCLUDE_INSTALL_DIR}/sum
COMPONENT headers
)
add_custom_target(install_headers
COMMAND "${CMAKE_COMMAND}" -DCMAKE_INSTALL_COMPONENT=headers
-P "${CMAKE_BINARY_DIR}/cmake_install.cmake" )
I'm using the PackageConfigHelper to create the package configuration file for the project, and it has been working just fine.
configure_package_config_file(${PACKAGE_NAME}-config.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE_NAME}-config.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_DIR}/${PACKAGE_NAME}
PATH_VARS NEOS_INCLUDE_INSTALL_DIR LIB_INSTALL_DIR INCLUDE_INSTALL_DIR APP_INCLUDE_INSTALL_DIR )
I added the macro for checking for the components to the ...cmake.in file.
check_required_components(neo_sumlib)
As a debugging step, I made sure the <package>_FIND_COMPONENTS did include 'headers' at cmake configuration. Even though it can find the <package>.cmake file without issue, the <package>_<comp>_FOUND is not set.
Here's my idea. COMPONENTS for the install command is not the same as COMPONENTS for the find_package command. Is it that COMPONENTS for the find_package is really looking for <package>_<component> library, not the component defined by the install ?
thanks Jerry
Upvotes: 2
Views: 937
Reputation: 17
find_package(Foo COMPONENTS A B C)
refers to libraries which have been packaged into the NAMESPACE Foo and would be linked like Foo::A Foo::B ...
.
Looking at the docs for install(... COMPONENT)
, I don't quite understand what it does either.
Upvotes: 0