I understand that we need to write our own logic for how to load the components requested, but it would be nice if there were some ways to have more control over the generated PackageTargets.cmake
. For example instead of:
if(DEFINED ${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE_targets)
if(CMAKE_FIND_PACKAGE_NAME)
set( ${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE)
set( ${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE "The following imported targets are referenced, but are missing: ${${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE_targets}")
else()
message(FATAL_ERROR "The following imported targets are referenced, but are missing: ${${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE_targets}")
endif()
endif()
We could have
if(DEFINED ${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE_targets)
if(CMAKE_FIND_PACKAGE_NAME)
set( ${CMAKE_FIND_PACKAGE_NAME}_${CMAKE_FIND_COMPONENT_NAME}_FOUND FALSE)
set( ${CMAKE_FIND_PACKAGE_NAME}_${CMAKE_FIND_COMPONENT_NAME}_NOT_FOUND_MESSAGE "The following imported targets are referenced, but are missing: ${${CMAKE_FIND_PACKAGE_NAME}_${CMAKE_FIND_COMPONENT_NAME}_NOT_FOUND_MESSAGE_targets}")
else()
message(FATAL_ERROR "The following imported targets are referenced, but are missing: ${${CMAKE_FIND_PACKAGE_NAME}_${CMAKE_FIND_COMPONENT_NAME}_NOT_FOUND_MESSAGE_targets}")
endif()
endif()
(Note the additional CMAKE_FIND_COMPONENT_NAME
)