Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 11 additions & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -342,28 +342,25 @@ endif()
# ---------------------------------------------------------------------------------------
if(SPDLOG_INSTALL)
message(STATUS "Generating install")
if(DEFINED XP_NAMESPACE)
if(COMMAND xpExternPackage)
set(targetsFile "spdlogConfigTargets")
xpExternPackage(NAMESPACE ${XP_NAMESPACE} ALIAS_NAMESPACE spdlog
TARGETS_FILE ${targetsFile} LIBRARIES spdlog spdlog_header_only
xpExternPackage(TARGETS_FILE ${targetsFile} LIBRARIES spdlog spdlog_header_only
BASE v${SPDLOG_VERSION} XPDIFF "patch" FIND_THREADS DEPS fmt
WEB "https://github.com/gabime/spdlog/wiki" UPSTREAM "github.com/gabime/spdlog"
DESC "Fast C++ logging library"
LICENSE "[MIT](https://github.com/gabime/spdlog?tab=License-1-ov-file 'MIT License')"
)
set(config_targets_file "${targetsFile}.cmake")
set(export_dest_dir "${CMAKE_INSTALL_CMAKEDIR}")
set(CMAKE_NAMESPACE ${XP_NAMESPACE})
else()
set(CMAKE_NAMESPACE spdlog)
set(project_config_in "${CMAKE_CURRENT_LIST_DIR}/cmake/spdlogConfig.cmake.in")
set(project_config_out "${CMAKE_CURRENT_BINARY_DIR}/spdlogConfig.cmake")
set(config_targets_file "spdlogConfigTargets.cmake")
set(version_config_file "${CMAKE_CURRENT_BINARY_DIR}/spdlogConfigVersion.cmake")
set(export_dest_dir "${CMAKE_INSTALL_LIBDIR}/cmake/spdlog")
set(pkgconfig_install_dir "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
set(pkg_config "${CMAKE_BINARY_DIR}/${PROJECT_NAME}.pc")
endif() # XP_NAMESPACE
endif()

# ---------------------------------------------------------------------------------------
# Include files
Expand All @@ -384,7 +381,7 @@ if(SPDLOG_INSTALL)
# ---------------------------------------------------------------------------------------
# Install pkg-config file
# ---------------------------------------------------------------------------------------
if(NOT DEFINED XP_NAMESPACE)
if(NOT COMMAND xpExternPackage)
if(IS_ABSOLUTE "${CMAKE_INSTALL_INCLUDEDIR}")
set(PKG_CONFIG_INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR}")
else()
Expand All @@ -400,27 +397,27 @@ if(SPDLOG_INSTALL)
string(CONCAT PKG_CONFIG_DEFINES "-D" "${PKG_CONFIG_DEFINES}")
configure_file("cmake/${PROJECT_NAME}.pc.in" "${pkg_config}" @ONLY)
install(FILES "${pkg_config}" DESTINATION "${pkgconfig_install_dir}")
endif() # XP_NAMESPACE
endif()

# ---------------------------------------------------------------------------------------
# Install CMake config files
# ---------------------------------------------------------------------------------------
export(TARGETS spdlog spdlog_header_only NAMESPACE ${CMAKE_NAMESPACE}::
export(TARGETS spdlog spdlog_header_only NAMESPACE spdlog::
FILE "${CMAKE_CURRENT_BINARY_DIR}/${config_targets_file}")
install(EXPORT spdlog DESTINATION ${export_dest_dir} NAMESPACE ${CMAKE_NAMESPACE}:: FILE ${config_targets_file})
install(EXPORT spdlog DESTINATION ${export_dest_dir} NAMESPACE spdlog:: FILE ${config_targets_file})

if(NOT DEFINED XP_NAMESPACE)
if(NOT COMMAND xpExternPackage)
include(CMakePackageConfigHelpers)
configure_package_config_file("${project_config_in}" "${project_config_out}" INSTALL_DESTINATION ${export_dest_dir})

write_basic_package_version_file("${version_config_file}" COMPATIBILITY SameMajorVersion)
install(FILES "${project_config_out}" "${version_config_file}" DESTINATION "${export_dest_dir}")
endif() # XP_NAMESPACE
endif()

# ---------------------------------------------------------------------------------------
# Support creation of installable packages
# ---------------------------------------------------------------------------------------
if(NOT DEFINED XP_NAMESPACE)
if(NOT COMMAND xpExternPackage)
include(cmake/spdlogCPack.cmake)
endif() # XP_NAMESPACE
endif()
endif()
3 changes: 1 addition & 2 deletions CMakePresetsBase.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
"hidden": true,
"binaryDir": "${sourceDir}/_bld-${presetName}",
"cacheVariables": {
"SPDLOG_FMT_EXTERNAL": "ON",
"XP_NAMESPACE": "xpro"
"SPDLOG_FMT_EXTERNAL": "ON"
}
}
],
Expand Down