diff --git a/tribits/core/package_arch/TribitsGlobalMacros.cmake b/tribits/core/package_arch/TribitsGlobalMacros.cmake index 28c0fa807..2a6565d96 100644 --- a/tribits/core/package_arch/TribitsGlobalMacros.cmake +++ b/tribits/core/package_arch/TribitsGlobalMacros.cmake @@ -2072,17 +2072,20 @@ macro(tribits_configure_enabled_packages) tribits_trace_file_processing(PACKAGE ADD_SUBDIR "${TRIBITS_PACKAGE_CMAKELIST_FILE}") if (NOT ${TRIBITS_PACKAGE}_SOURCE_DIR STREQUAL ${PROJECT_NAME}_SOURCE_DIR) - add_subdirectory(${${TRIBITS_PACKAGE}_SOURCE_DIR} ${${TRIBITS_PACKAGE}_BINARY_DIR}) + add_subdirectory(${${TRIBITS_PACKAGE}_SOURCE_DIR} + ${${TRIBITS_PACKAGE}_BINARY_DIR}) else() include("${TRIBITS_PACKAGE_CMAKELIST_FILE}") endif() - if (NOT ${PACKAGE_NAME}_TRIBITS_PACKAGE_POSTPROCESS) + if ((NOT ${PACKAGE_NAME}_TRIBITS_PACKAGE_POSTPROCESS) AND + (NOT TARGET ${PACKAGE_NAME}::all_libs) + ) tribits_report_invalid_tribits_usage( "ERROR: Forgot to call tribits_package_postprocess() in" " ${TRIBITS_PACKAGE_CMAKELIST_FILE}") endif() - list(APPEND ENABLED_PACKAGE_LIBS_TARGETS ${TRIBITS_PACKAGE}_libs) + list(APPEND ENABLED_PACKAGE_LIBS_TARGETS ${TRIBITS_PACKAGE}::all_libs) list(APPEND ${PROJECT_NAME}_LIBRARIES ${${TRIBITS_PACKAGE}_LIBRARIES}) tribits_package_config_code_stop_timer(PROCESS_THIS_PACKAGE_TIME_START_SECONDS diff --git a/tribits/examples/TribitsExampleProject2/packages/package1/CMakeLists.txt b/tribits/examples/TribitsExampleProject2/packages/package1/CMakeLists.txt index 2344a4ef8..426f937f3 100644 --- a/tribits/examples/TribitsExampleProject2/packages/package1/CMakeLists.txt +++ b/tribits/examples/TribitsExampleProject2/packages/package1/CMakeLists.txt @@ -32,17 +32,29 @@ else() add_subdirectory(test) endif() - # Generate the all_libs target + # Generate the all_libs target(s) add_library(Package1_all_libs INTERFACE) set_target_properties(Package1_all_libs PROPERTIES EXPORT_NAME all_libs) target_link_libraries(Package1_all_libs INTERFACE Package1_package1) - install( - TARGETS Package1_all_libs + install(TARGETS Package1_all_libs EXPORT ${PROJECT_NAME} - INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) + INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} + COMPONENT ${PROJECT_NAME} ) + add_library(Package1::all_libs ALIAS Package1_all_libs) + + # Generate Package1Config.cmake file for the build tree + set(packageBuildDirCMakePackagesDir + "${${CMAKE_PROJECT_NAME}_BINARY_DIR}/cmake_packages/${PROJECT_NAME}") + export(EXPORT ${PROJECT_NAME} + NAMESPACE ${PROJECT_NAME}:: + FILE "${packageBuildDirCMakePackagesDir}/${PROJECT_NAME}ConfigTargets.cmake" ) + configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/cmake/raw/Package1Config.cmake.in" + "${packageBuildDirCMakePackagesDir}/${PROJECT_NAME}/Package1Config.cmake" + @ONLY ) - # Generate and install the Package1Config.cmake file + # Generate and install the Package1Config.cmake file for the install tree install(EXPORT ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME} NAMESPACE ${PROJECT_NAME}:: diff --git a/tribits/examples/TribitsExampleProject2/packages/package1/src/CMakeLists.raw.cmake b/tribits/examples/TribitsExampleProject2/packages/package1/src/CMakeLists.raw.cmake index aa5dffd55..f15cdc589 100644 --- a/tribits/examples/TribitsExampleProject2/packages/package1/src/CMakeLists.raw.cmake +++ b/tribits/examples/TribitsExampleProject2/packages/package1/src/CMakeLists.raw.cmake @@ -7,8 +7,7 @@ target_link_libraries(Package1_package1 set_target_properties(Package1_package1 PROPERTIES EXPORT_NAME package1) add_library(Package1::package1 ALIAS Package1_package1) -install( - TARGETS Package1_package1 +install(TARGETS Package1_package1 EXPORT ${PROJECT_NAME} INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) install(