mirror of
https://github.com/fmtlib/fmt.git
synced 2024-11-25 19:50:05 +00:00
cppformat -> fmt
This commit is contained in:
parent
848ab63a2a
commit
5e1576f79f
@ -2,7 +2,7 @@ message(STATUS "CMake version: ${CMAKE_VERSION}")
|
|||||||
|
|
||||||
cmake_minimum_required(VERSION 2.8.12)
|
cmake_minimum_required(VERSION 2.8.12)
|
||||||
|
|
||||||
# Determine if cppformat is built as a subproject (using add_subdirectory)
|
# Determine if fmt is built as a subproject (using add_subdirectory)
|
||||||
# or if it is the master project.
|
# or if it is the master project.
|
||||||
set(MASTER_PROJECT OFF)
|
set(MASTER_PROJECT OFF)
|
||||||
if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
|
if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# Define the cppformat library, its includes and the needed defines.
|
# Define the fmt library, its includes and the needed defines.
|
||||||
# format.cc is added to FMT_HEADERS for the header-only configuration.
|
# format.cc is added to FMT_HEADERS for the header-only configuration.
|
||||||
set(FMT_HEADERS format.h format.cc)
|
set(FMT_HEADERS format.h format.cc)
|
||||||
if (HAVE_OPEN)
|
if (HAVE_OPEN)
|
||||||
@ -6,38 +6,44 @@ if (HAVE_OPEN)
|
|||||||
set(FMT_SOURCES ${FMT_SOURCES} posix.cc)
|
set(FMT_SOURCES ${FMT_SOURCES} posix.cc)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
add_library(cppformat ${FMT_SOURCES} ${FMT_HEADERS})
|
add_library(fmt ${FMT_SOURCES} ${FMT_HEADERS})
|
||||||
|
|
||||||
# Starting with cmake 3.1 the CXX_STANDARD property can be used instead.
|
option(FMT_CPPFORMAT "Build cppformat library for backward compatibility." OFF)
|
||||||
target_compile_options(cppformat PUBLIC ${CPP11_FLAG})
|
if (FMT_CPPFORMAT)
|
||||||
if (FMT_PEDANTIC)
|
message(WARNING "The cppformat library is deprecated, use fmt instead.")
|
||||||
target_compile_options(cppformat PRIVATE ${PEDANTIC_COMPILE_FLAGS})
|
add_library(cppformat ${FMT_SOURCES} ${FMT_HEADERS})
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
target_include_directories(cppformat INTERFACE
|
# Starting with cmake 3.1 the CXX_STANDARD property can be used instead.
|
||||||
|
target_compile_options(fmt PUBLIC ${CPP11_FLAG})
|
||||||
|
if (FMT_PEDANTIC)
|
||||||
|
target_compile_options(fmt PRIVATE ${PEDANTIC_COMPILE_FLAGS})
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
target_include_directories(fmt INTERFACE
|
||||||
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
|
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
|
||||||
$<INSTALL_INTERFACE:include>)
|
$<INSTALL_INTERFACE:include>)
|
||||||
|
|
||||||
set_target_properties(cppformat PROPERTIES
|
set_target_properties(fmt PROPERTIES
|
||||||
VERSION ${FMT_VERSION} SOVERSION ${CPACK_PACKAGE_VERSION_MAJOR})
|
VERSION ${FMT_VERSION} SOVERSION ${CPACK_PACKAGE_VERSION_MAJOR})
|
||||||
|
|
||||||
if (BUILD_SHARED_LIBS)
|
if (BUILD_SHARED_LIBS)
|
||||||
if (UNIX AND NOT APPLE)
|
if (UNIX AND NOT APPLE)
|
||||||
# Fix rpmlint warning:
|
# Fix rpmlint warning:
|
||||||
# unused-direct-shlib-dependency /usr/lib/libformat.so.1.1.0 /lib/libm.so.6.
|
# unused-direct-shlib-dependency /usr/lib/libformat.so.1.1.0 /lib/libm.so.6.
|
||||||
target_link_libraries(cppformat -Wl,--as-needed)
|
target_link_libraries(fmt -Wl,--as-needed)
|
||||||
endif ()
|
endif ()
|
||||||
target_compile_definitions(cppformat PRIVATE FMT_EXPORT INTERFACE FMT_SHARED)
|
target_compile_definitions(fmt PRIVATE FMT_EXPORT INTERFACE FMT_SHARED)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
# additionally define a header only library when cmake is new enough
|
# additionally define a header only library when cmake is new enough
|
||||||
if (CMAKE_VERSION VERSION_GREATER 3.1.0 OR CMAKE_VERSION VERSION_EQUAL 3.1.0)
|
if (CMAKE_VERSION VERSION_GREATER 3.1.0 OR CMAKE_VERSION VERSION_EQUAL 3.1.0)
|
||||||
add_library(cppformat-header-only INTERFACE)
|
add_library(fmt-header-only INTERFACE)
|
||||||
|
|
||||||
target_compile_definitions(cppformat-header-only INTERFACE FMT_HEADER_ONLY=1)
|
target_compile_definitions(fmt-header-only INTERFACE FMT_HEADER_ONLY=1)
|
||||||
|
|
||||||
target_include_directories(cppformat-header-only INTERFACE
|
target_include_directories(fmt-header-only INTERFACE
|
||||||
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
|
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
|
||||||
$<INSTALL_INTERFACE:include>)
|
$<INSTALL_INTERFACE:include>)
|
||||||
endif ()
|
endif ()
|
||||||
@ -45,15 +51,15 @@ endif ()
|
|||||||
# Install targets.
|
# Install targets.
|
||||||
if (FMT_INSTALL)
|
if (FMT_INSTALL)
|
||||||
include(CMakePackageConfigHelpers)
|
include(CMakePackageConfigHelpers)
|
||||||
set(FMT_CMAKE_DIR lib/cmake/cppformat CACHE STRING
|
set(FMT_CMAKE_DIR lib/cmake/fmt CACHE STRING
|
||||||
"Installation directory for cmake files, relative to ${CMAKE_INSTALL_PREFIX}.")
|
"Installation directory for cmake files, relative to ${CMAKE_INSTALL_PREFIX}.")
|
||||||
set(version_config ${PROJECT_BINARY_DIR}/cppformat-config-version.cmake)
|
set(version_config ${PROJECT_BINARY_DIR}/fmt-config-version.cmake)
|
||||||
set(project_config ${PROJECT_BINARY_DIR}/cppformat-config.cmake)
|
set(project_config ${PROJECT_BINARY_DIR}/fmt-config.cmake)
|
||||||
set(targets_export_name cppformat-targets)
|
set(targets_export_name fmt-targets)
|
||||||
|
|
||||||
set (INSTALL_TARGETS cppformat)
|
set (INSTALL_TARGETS fmt)
|
||||||
if (TARGET cppformat-header-only)
|
if (TARGET fmt-header-only)
|
||||||
set(INSTALL_TARGETS ${INSTALL_TARGETS} cppformat-header-only)
|
set(INSTALL_TARGETS ${INSTALL_TARGETS} fmt-header-only)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
set(FMT_LIB_DIR lib CACHE STRING
|
set(FMT_LIB_DIR lib CACHE STRING
|
||||||
@ -65,7 +71,7 @@ if (FMT_INSTALL)
|
|||||||
VERSION ${FMT_VERSION}
|
VERSION ${FMT_VERSION}
|
||||||
COMPATIBILITY AnyNewerVersion)
|
COMPATIBILITY AnyNewerVersion)
|
||||||
configure_package_config_file(
|
configure_package_config_file(
|
||||||
${PROJECT_SOURCE_DIR}/support/cmake/cppformat-config.cmake.in
|
${PROJECT_SOURCE_DIR}/support/cmake/fmt-config.cmake.in
|
||||||
${project_config}
|
${project_config}
|
||||||
INSTALL_DESTINATION ${FMT_CMAKE_DIR})
|
INSTALL_DESTINATION ${FMT_CMAKE_DIR})
|
||||||
export(TARGETS ${INSTALL_TARGETS} FILE ${PROJECT_BINARY_DIR}/${targets_export_name}.cmake)
|
export(TARGETS ${INSTALL_TARGETS} FILE ${PROJECT_BINARY_DIR}/${targets_export_name}.cmake)
|
||||||
@ -79,4 +85,7 @@ if (FMT_INSTALL)
|
|||||||
# Install the library and headers.
|
# Install the library and headers.
|
||||||
install(TARGETS ${INSTALL_TARGETS} EXPORT ${targets_export_name} DESTINATION ${FMT_LIB_DIR})
|
install(TARGETS ${INSTALL_TARGETS} EXPORT ${targets_export_name} DESTINATION ${FMT_LIB_DIR})
|
||||||
install(FILES ${FMT_HEADERS} DESTINATION include/cppformat)
|
install(FILES ${FMT_HEADERS} DESTINATION include/cppformat)
|
||||||
|
if (FMT_CPPFORMAT)
|
||||||
|
install(TARGETS cppformat DESTINATION ${FMT_LIB_DIR})
|
||||||
|
endif ()
|
||||||
endif ()
|
endif ()
|
||||||
|
@ -7,5 +7,4 @@ endif ()
|
|||||||
add_custom_target(doc
|
add_custom_target(doc
|
||||||
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/build.py ${FMT_VERSION})
|
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/build.py ${FMT_VERSION})
|
||||||
|
|
||||||
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html/
|
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html/ DESTINATION share/doc/fmt)
|
||||||
DESTINATION share/doc/cppformat)
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
@PACKAGE_INIT@
|
@PACKAGE_INIT@
|
||||||
|
|
||||||
include(${CMAKE_CURRENT_LIST_DIR}/@targets_export_name@.cmake)
|
include(${CMAKE_CURRENT_LIST_DIR}/@targets_export_name@.cmake)
|
||||||
check_required_components(cppformat)
|
check_required_components(fmt)
|
@ -39,7 +39,7 @@ set(TEST_MAIN_SRC test-main.cc gtest-extra.cc gtest-extra.h util.cc)
|
|||||||
add_library(test-main STATIC ${TEST_MAIN_SRC})
|
add_library(test-main STATIC ${TEST_MAIN_SRC})
|
||||||
target_compile_definitions(test-main PUBLIC
|
target_compile_definitions(test-main PUBLIC
|
||||||
FMT_USE_FILE_DESCRIPTORS=$<BOOL:${HAVE_OPEN}>)
|
FMT_USE_FILE_DESCRIPTORS=$<BOOL:${HAVE_OPEN}>)
|
||||||
target_link_libraries(test-main gmock cppformat)
|
target_link_libraries(test-main gmock fmt)
|
||||||
|
|
||||||
include(CheckCXXCompilerFlag)
|
include(CheckCXXCompilerFlag)
|
||||||
|
|
||||||
@ -97,8 +97,8 @@ endif ()
|
|||||||
add_executable(header-only-test
|
add_executable(header-only-test
|
||||||
header-only-test.cc header-only-test2.cc test-main.cc)
|
header-only-test.cc header-only-test2.cc test-main.cc)
|
||||||
target_link_libraries(header-only-test gmock)
|
target_link_libraries(header-only-test gmock)
|
||||||
if (TARGET cppformat-header-only)
|
if (TARGET fmt-header-only)
|
||||||
target_link_libraries(header-only-test cppformat-header-only)
|
target_link_libraries(header-only-test fmt-header-only)
|
||||||
else ()
|
else ()
|
||||||
target_include_directories(header-only-test PRIVATE ${PROJECT_SOURCE_DIR})
|
target_include_directories(header-only-test PRIVATE ${PROJECT_SOURCE_DIR})
|
||||||
target_compile_definitions(header-only-test PRIVATE FMT_HEADER_ONLY=1)
|
target_compile_definitions(header-only-test PRIVATE FMT_HEADER_ONLY=1)
|
||||||
@ -133,7 +133,7 @@ if (FMT_PEDANTIC)
|
|||||||
"${CMAKE_CURRENT_BINARY_DIR}/find-package-test"
|
"${CMAKE_CURRENT_BINARY_DIR}/find-package-test"
|
||||||
--build-generator ${CMAKE_GENERATOR}
|
--build-generator ${CMAKE_GENERATOR}
|
||||||
--build-makeprogram ${CMAKE_MAKE_PROGRAM}
|
--build-makeprogram ${CMAKE_MAKE_PROGRAM}
|
||||||
--build-options "-Dcppformat_DIR=${PROJECT_BINARY_DIR}"
|
--build-options "-DFMT_DIR=${PROJECT_BINARY_DIR}"
|
||||||
"-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}")
|
"-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}")
|
||||||
|
|
||||||
# test if the targets are findable when add_subdirectory is used
|
# test if the targets are findable when add_subdirectory is used
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
cmake_minimum_required(VERSION 2.8.12)
|
cmake_minimum_required(VERSION 2.8.12)
|
||||||
|
|
||||||
project(cppformat-test)
|
project(fmt-test)
|
||||||
|
|
||||||
add_subdirectory(../.. cppformat)
|
add_subdirectory(../.. fmt)
|
||||||
|
|
||||||
add_executable(library-test "main.cc")
|
add_executable(library-test "main.cc")
|
||||||
target_link_libraries(library-test cppformat)
|
target_link_libraries(library-test fmt)
|
||||||
|
|
||||||
if (TARGET cppformat-header-only)
|
if (TARGET fmt-header-only)
|
||||||
add_executable(header-only-test "main.cc")
|
add_executable(header-only-test "main.cc")
|
||||||
target_link_libraries(header-only-test cppformat-header-only)
|
target_link_libraries(header-only-test fmt-header-only)
|
||||||
endif ()
|
endif ()
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
cmake_minimum_required(VERSION 2.8.12)
|
cmake_minimum_required(VERSION 2.8.12)
|
||||||
|
|
||||||
project(cppformat-test)
|
project(fmt-test)
|
||||||
|
|
||||||
find_package(cppformat REQUIRED)
|
find_package(FMT REQUIRED)
|
||||||
|
|
||||||
add_executable(library-test "main.cc")
|
add_executable(library-test main.cc)
|
||||||
target_link_libraries(library-test cppformat)
|
target_link_libraries(library-test fmt)
|
||||||
|
|
||||||
if (TARGET cppformat-header-only)
|
if (TARGET fmt-header-only)
|
||||||
add_executable(header-only-test "main.cc")
|
add_executable(header-only-test main.cc)
|
||||||
target_link_libraries(header-only-test cppformat-header-only)
|
target_link_libraries(header-only-test fmt-header-only)
|
||||||
endif ()
|
endif ()
|
||||||
|
Loading…
Reference in New Issue
Block a user