-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support custom FMT_INC_DIR in pkgconfig and cmake configs #1702
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,6 +44,11 @@ if (MASTER_PROJECT AND NOT CMAKE_BUILD_TYPE) | |
"CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel.") | ||
endif () | ||
|
||
include(GNUInstallDirs) | ||
set_verbose(FMT_INC_DIR ${CMAKE_INSTALL_INCLUDEDIR} CACHE STRING | ||
"Installation directory for include files, a relative path " | ||
"that will be joined to ${CMAKE_INSTALL_PREFIX}, or an arbitrary absolute path.") | ||
|
||
option(FMT_PEDANTIC "Enable extra warnings and expensive tests." OFF) | ||
option(FMT_WERROR "Halt the compilation with an error on compiler warnings." | ||
OFF) | ||
|
@@ -198,7 +203,7 @@ target_compile_features(fmt INTERFACE ${FMT_REQUIRED_FEATURES}) | |
|
||
target_include_directories(fmt PUBLIC | ||
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include> | ||
$<INSTALL_INTERFACE:include>) | ||
$<INSTALL_INTERFACE:${FMT_INC_DIR}>) | ||
|
||
set(FMT_DEBUG_POSTFIX d CACHE STRING "Debug library postfix.") | ||
|
||
|
@@ -233,11 +238,10 @@ target_compile_features(fmt-header-only INTERFACE ${FMT_REQUIRED_FEATURES}) | |
|
||
target_include_directories(fmt-header-only INTERFACE | ||
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include> | ||
$<INSTALL_INTERFACE:include>) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto |
||
$<INSTALL_INTERFACE:${FMT_INC_DIR}>) | ||
|
||
# Install targets. | ||
if (FMT_INSTALL) | ||
include(GNUInstallDirs) | ||
include(CMakePackageConfigHelpers) | ||
set_verbose(FMT_CMAKE_DIR ${CMAKE_INSTALL_LIBDIR}/cmake/fmt CACHE STRING | ||
"Installation directory for cmake files, a relative path " | ||
|
@@ -247,19 +251,10 @@ if (FMT_INSTALL) | |
set(pkgconfig ${PROJECT_BINARY_DIR}/fmt.pc) | ||
set(targets_export_name fmt-targets) | ||
|
||
set (INSTALL_TARGETS fmt) | ||
if (TARGET fmt-header-only) | ||
set(INSTALL_TARGETS ${INSTALL_TARGETS} fmt-header-only) | ||
endif () | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fmt-header-only has been always enabled since 691a7a9. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch. |
||
|
||
set_verbose(FMT_LIB_DIR ${CMAKE_INSTALL_LIBDIR} CACHE STRING | ||
"Installation directory for libraries, a relative path " | ||
"that will be joined to ${CMAKE_INSTALL_PREFIX}, or an arbitrary absolute path.") | ||
|
||
set_verbose(FMT_INC_DIR ${CMAKE_INSTALL_INCLUDEDIR}/fmt CACHE STRING | ||
"Installation directory for include files, a relative path " | ||
"that will be joined to ${CMAKE_INSTALL_PREFIX}, or an arbitrary absolute path.") | ||
|
||
set_verbose(FMT_PKGCONFIG_DIR ${CMAKE_INSTALL_LIBDIR}/pkgconfig CACHE PATH | ||
"Installation directory for pkgconfig (.pc) files, a relative path " | ||
"that will be joined to ${CMAKE_INSTALL_PREFIX}, or an arbitrary absolute path.") | ||
|
@@ -270,8 +265,8 @@ if (FMT_INSTALL) | |
VERSION ${FMT_VERSION} | ||
COMPATIBILITY AnyNewerVersion) | ||
|
||
join_paths(libdir_for_pc_file "\${exec_prefix}" "${CMAKE_INSTALL_LIBDIR}") | ||
join_paths(includedir_for_pc_file "\${prefix}" "${CMAKE_INSTALL_INCLUDEDIR}") | ||
join_paths(libdir_for_pc_file "\${exec_prefix}" "${FMT_LIB_DIR}") | ||
join_paths(includedir_for_pc_file "\${prefix}" "${FMT_INC_DIR}") | ||
|
||
configure_file( | ||
"${PROJECT_SOURCE_DIR}/support/cmake/fmt.pc.in" | ||
|
@@ -281,6 +276,8 @@ if (FMT_INSTALL) | |
${PROJECT_SOURCE_DIR}/support/cmake/fmt-config.cmake.in | ||
${project_config} | ||
INSTALL_DESTINATION ${FMT_CMAKE_DIR}) | ||
|
||
set(INSTALL_TARGETS fmt fmt-header-only) | ||
# Use a namespace because CMake provides better diagnostics for namespaced | ||
# imported targets. | ||
export(TARGETS ${INSTALL_TARGETS} NAMESPACE fmt:: | ||
|
@@ -301,7 +298,7 @@ if (FMT_INSTALL) | |
|
||
install(FILES $<TARGET_PDB_FILE:${INSTALL_TARGETS}> | ||
DESTINATION ${FMT_LIB_DIR} OPTIONAL) | ||
install(FILES ${FMT_HEADERS} DESTINATION ${FMT_INC_DIR}) | ||
install(FILES ${FMT_HEADERS} DESTINATION "${FMT_INC_DIR}/fmt") | ||
install(FILES "${pkgconfig}" DESTINATION "${FMT_PKGCONFIG_DIR}") | ||
endif () | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
include
install interface is equivalent to${CMAKE_INSTALL_PREFIX}/include
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest updating
INSTALL_INTERFACE:include
here instead of splittingtarget_include_directories
into two.