Skip to content
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

Sync with current fmt repo #1

Draft
wants to merge 4 commits into
base: develop
Choose a base branch
from
Draft
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
21 changes: 10 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ project(fmt

include(cmake/variables.cmake)

if(CMAKE_BUILD_TYPE STREQUAL Release)
include(cmake/example.cmake)
endif()

set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_EXTENSIONS ON)
set(CMAKE_CXX_STANDARD_REQUIRED YES)
Expand All @@ -31,10 +27,8 @@ set(CPPdefinitions FMT_USE_FCNTL=0)
set(ADD_STDLIB_MODULES)

option(FMT_SEPARATE_COMPILATION "build fmt lib too" ${PROJECT_IS_TOP_LEVEL})
if(UNIX)
option(FMT_USE_MODULES "Export a CXX_MODULE fmt if possible" ${PROJECT_IS_TOP_LEVEL})
endif()
# TODO: option(FMT_IMPORT_STD "Import the module std" ${PROJECT_IS_TOP_LEVEL})
#XXX option(FMT_USE_MODULES "Export a CXX_MODULE fmt if possible" ${PROJECT_IS_TOP_LEVEL})
#XXX option(FMT_IMPORT_STD "Import the module std" ${PROJECT_IS_TOP_LEVEL})

if(FMT_USE_MODULES)
list(APPEND CPPdefinitions FMT_MODULE)
Expand Down Expand Up @@ -81,6 +75,10 @@ else()
set(CMAKE_VERIFY_INTERFACE_HEADER_SETS ${PROJECT_IS_TOP_LEVEL})
endif()

if(ADD_STDLIB_MODULES AND CMAKE_BUILD_TYPE STREQUAL Release)
include(cmake/example.cmake)
endif()

# ---- add dependency libraries ----

include(cmake/CPM.cmake)
Expand All @@ -104,6 +102,7 @@ endif()

configure_file(${fmt_SOURCE_DIR}/src/format.cc ${CMAKE_CURRENT_SOURCE_DIR}/module/format.cc COPYONLY)
configure_file(${fmt_SOURCE_DIR}/src/os.cc ${CMAKE_CURRENT_SOURCE_DIR}/module/os.cc COPYONLY)
configure_file(${fmt_SOURCE_DIR}/src/fmt.cc ${CMAKE_CURRENT_SOURCE_DIR}/module/fmt.cc COPYONLY)
file(GLOB_RECURSE _fmt_all_sources "module/*.cc")

# fmt interface library
Expand Down Expand Up @@ -153,13 +152,13 @@ if(FMT_SEPARATE_COMPILATION)
# cmake-format: on
else()
add_library(fmt::fmt ALIAS fmt)
set(CMAKE_CXX_SCAN_FOR_MODULES OFF)
set_target_properties(fmt PROPERTIES CXX_SCAN_FOR_MODULES OFF)
target_compile_definitions(fmt PUBLIC ${CPPdefinitions})
target_sources(fmt PUBLIC ${_fmt_all_sources})
target_sources(fmt PRIVATE ${_fmt_all_sources})
endif()

if(FMT_WARNINGS_AS_ERRORS AND FMT_DEVELOPER_MODE AND UNIX)
target_compile_options(fmt PUBLIC -Werror)
target_compile_options(fmt PRIVATE -Werror)
endif()
endif()

Expand Down
6 changes: 3 additions & 3 deletions cmake/install-rules.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ mark_as_advanced(FMT_INSTALL_CMAKEDIR)
install(TARGETS fmt-header-only EXPORT fmtTargets FILE_SET HEADERS)

if(FMT_USE_MODULES)
install(TARGETS fmt EXPORT fmtTargets FILE_SET public_headers FILE_SET public_modules
DESTINATION ${FMT_INSTALL_CMAKEDIR}/module
install(TARGETS fmt EXPORT fmtTargets FILE_SET public_headers #
FILE_SET public_modules DESTINATION ${FMT_INSTALL_CMAKEDIR}/module
)
else()
install(FILES module/fmt.cppm DESTINATION ${FMT_INSTALL_CMAKEDIR}/module)
install(TARGETS fmt EXPORT fmtTargets FILE_SET public_headers)
endif()
install(FILES ${_fmt_all_sources} DESTINATION ${FMT_INSTALL_CMAKEDIR}/module)

Expand Down
5 changes: 2 additions & 3 deletions module/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ if(PROJECT_IS_TOP_LEVEL)
endif()
message(STATUS "CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES=${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES}")
endif()
if(USE_MODULES)
if(USE_MODULES AND CMAKE_CXX_MODULE_STD)
if(NOT CMAKE_CXX_COMPILER_IMPORT_STD AND ADD_STDLIB_MODULES)
message(WARNING "ADD_STDLIB_MODULES=${ADD_STDLIB_MODULES}")
add_stdlib_module(${ADD_STDLIB_MODULES})
Expand All @@ -48,9 +48,8 @@ message(STATUS "Module tests to be built: ${ALL_TESTS}")
foreach(_file ${ALL_TESTS})
add_executable(module_${_file})
target_sources(module_${_file} PRIVATE ../../tests/${_file}.cc)
if(USE_MODULES)
if(CMAKE_CXX_MODULE_STD)
target_link_libraries(module_${_file} fmt-module ${ADD_STDLIB_MODULES})
# XXX: NOT USED! target_compile_definitions(module_${_file} PUBLIC USE_MODULES)
else()
target_link_libraries(module_${_file} fmt::fmt-header-only)
endif()
Expand Down
Loading