Skip to content

Commit 69f9c7e

Browse files
committed
The fmt module is a nightmare
1 parent 6c85396 commit 69f9c7e

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

CMakeLists.txt

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ set(CMAKE_DEBUG_POSTFIX D)
1515
set(CPPdefinitions)
1616

1717
option(FMT_SEPARATE_COMPILATION "build fmt lib too" ${PROJECT_IS_TOP_LEVEL})
18-
option(FMT_USE_MODULES "Export a CXX_MODULE asio if possible" ${PROJECT_IS_TOP_LEVEL})
19-
# TODO: option(FMT_IMPORT_STD "Import the CXX_MODULE std if possible" ${FMT_USE_MODULES})
18+
# FIXME: option(FMT_USE_MODULES "Export a CXX_MODULE asio if possible" ${PROJECT_IS_TOP_LEVEL})
19+
option(FMT_IMPORT_STD "Import the CXX_MODULE std if possible" NO)
2020

2121
if(FMT_IMPORT_STD)
2222
list(APPEND CPPdefinitions FMT_IMPORT_STD)
@@ -63,6 +63,10 @@ if(EXISTS ${fmt_SOURCE_DIR}/src/fmt.cc AND NOT EXISTS ${PROJECT_SOURCE_DIR}/modu
6363
configure_file(${fmt_SOURCE_DIR}/src/fmt.cc ${PROJECT_SOURCE_DIR}/module/fmt.cppm COPYONLY)
6464
endif()
6565

66+
configure_file(${fmt_SOURCE_DIR}/src/format.cc ${PROJECT_SOURCE_DIR}/module/format.cc COPYONLY)
67+
configure_file(${fmt_SOURCE_DIR}/src/os.cc ${PROJECT_SOURCE_DIR}/module/os.cc COPYONLY)
68+
file(GLOB_RECURSE _fmt_all_sources "module/*.cc")
69+
6670
# fmt interface library
6771
add_library(fmt-header-only INTERFACE)
6872
add_library(fmt::fmt-header-only ALIAS fmt-header-only)
@@ -82,7 +86,7 @@ target_compile_features(
8286
target_compile_options(fmt-header-only INTERFACE $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CXX_COMPILER_ID:MSVC>>:/utf-8>)
8387

8488
if(FMT_SEPARATE_COMPILATION)
85-
file(GLOB_RECURSE _fmt_all_sources "${fmt_SOURCE_DIR}/src/*.cc")
89+
# file(GLOB_RECURSE _fmt_all_sources "${fmt_SOURCE_DIR}/src/*.cc")
8690

8791
add_library(fmt)
8892
add_library(fmt::fmt ALIAS fmt)
@@ -94,17 +98,17 @@ if(FMT_SEPARATE_COMPILATION)
9498
fmt INTERFACE "$<$<COMPILE_FEATURES:cxx_std_23>:cxx_std_23>" "$<$<NOT:$<COMPILE_FEATURES:cxx_std_23>>:cxx_std_20>"
9599
)
96100

101+
target_compile_options(fmt PUBLIC $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CXX_COMPILER_ID:MSVC>>:/utf-8>)
102+
97103
if(FMT_USE_MODULES)
98104
target_compile_definitions(fmt PUBLIC ${CPPdefinitions})
99105
# cmake-format: off
100106
target_sources(fmt PUBLIC
101107
FILE_SET public_modules
102108
TYPE CXX_MODULES
103109
BASE_DIRS
104-
#NO! ${fmt_SOURCE_DIR}
105110
${PROJECT_SOURCE_DIR}/module
106111
FILES
107-
#NO! ${_fmt_all_sources}
108112
${PROJECT_SOURCE_DIR}/module/fmt.cppm
109113
)
110114
# cmake-format: on

cmake/install-rules.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ if(FMT_USE_MODULES)
2121
install(TARGETS fmt EXPORT fmtTargets FILE_SET public_headers FILE_SET public_modules
2222
DESTINATION ${FMT_INSTALL_CMAKEDIR}/module
2323
)
24-
install(FILES ${_fmt_all_sources} DESTINATION ${FMT_INSTALL_CMAKEDIR}/module)
2524
else()
2625
install(FILES module/fmt.cppm DESTINATION ${FMT_INSTALL_CMAKEDIR}/module)
2726
endif()
27+
install(FILES ${_fmt_all_sources} DESTINATION ${FMT_INSTALL_CMAKEDIR}/module)
2828

2929
write_basic_package_version_file("${_package}ConfigVersion.cmake" COMPATIBILITY SameMajorVersion ARCH_INDEPENDENT)
3030

0 commit comments

Comments
 (0)