Skip to content

Commit

Permalink
WIP: Make TriBITS package with raw CMake work (TriBITSPub#582)
Browse files Browse the repository at this point in the history
NOTE: This does not pass all of the existing tests yet but the new tests pass.
  • Loading branch information
bartlettroscoe committed Jul 18, 2023
1 parent 4803328 commit 41f794f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 10 deletions.
9 changes: 6 additions & 3 deletions tribits/core/package_arch/TribitsGlobalMacros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}::
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 41f794f

Please sign in to comment.