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
13 changes: 12 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,14 @@ setup_target(fmt-header-only INTERFACE)

add_library(fmt-c src/fmt-c.cc)
target_compile_features(fmt-c INTERFACE c_std_11)

# Set FMT_C_LIB_NAME for pkg-config fmt-c.pc. We cannot use the OUTPUT_NAME
# target property because it's not set by default.
set(FMT_C_LIB_NAME fmt-c)
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
set(FMT_C_LIB_NAME ${FMT_C_LIB_NAME}${FMT_DEBUG_POSTFIX})
endif ()

if (BUILD_SHARED_LIBS)
target_compile_definitions(
fmt-c
Expand Down Expand Up @@ -462,6 +470,7 @@ if (FMT_INSTALL)
set(version_config ${PROJECT_BINARY_DIR}/fmt-config-version.cmake)
set(project_config ${PROJECT_BINARY_DIR}/fmt-config.cmake)
set(pkgconfig ${PROJECT_BINARY_DIR}/fmt.pc)
set(pkgconfig_c ${PROJECT_BINARY_DIR}/fmt-c.pc)

set_verbose(
FMT_LIB_DIR ${CMAKE_INSTALL_LIBDIR} CACHE STRING
Expand All @@ -488,6 +497,8 @@ if (FMT_INSTALL)

configure_file("${PROJECT_SOURCE_DIR}/support/cmake/fmt.pc.in" "${pkgconfig}"
@ONLY)
configure_file("${PROJECT_SOURCE_DIR}/support/cmake/fmt-c.pc.in"
"${pkgconfig_c}" @ONLY)
configure_package_config_file(
${PROJECT_SOURCE_DIR}/support/cmake/fmt-config.cmake.in ${project_config}
INSTALL_DESTINATION ${FMT_CMAKE_DIR})
Expand Down Expand Up @@ -517,7 +528,7 @@ if (FMT_INSTALL)
COMPONENT fmt_core)

install(
FILES "${pkgconfig}"
FILES "${pkgconfig}" "${pkgconfig_c}"
DESTINATION "${FMT_PKGCONFIG_DIR}"
COMPONENT fmt_core)
endif ()
Expand Down
11 changes: 11 additions & 0 deletions support/cmake/fmt-c.pc.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=@CMAKE_INSTALL_PREFIX@
libdir=@libdir_for_pc_file@
includedir=@includedir_for_pc_file@

Name: fmt-c
Description: C interface for fmt, a modern formatting library
Version: @FMT_VERSION@
Libs: -L${libdir} -l@FMT_C_LIB_NAME@
Cflags: -I${includedir}
Requires.private: fmt = @FMT_VERSION@
Loading