@@ -11,20 +11,37 @@ project(fmt
1111
1212include (cmake/variables .cmake)
1313
14- # XXX NO! set(CPPdefinitions FMT_ATTACH_TO_GLOBAL_MODULE)
15- set (CPPdefinitions)
16-
17- set (CMAKE_VERIFY_INTERFACE_HEADER_SETS ${PROJECT_IS_TOP_LEVEL} )
1814set (CMAKE_DEBUG_POSTFIX D)
15+ set (CPPdefinitions)
1916
20- # TODO: option(FMT_SEPARATE_COMPILATION "build fmt lib too" ${PROJECT_IS_TOP_LEVEL})
21- option (FMT_USE_MODULES "Export a CXX_MODULE asio if possible" ${FMT_SEPARATE_COMPILATION } )
22- option (FMT_IMPORT_STD "Import the CXX_MODULE std if possible" OFF )
17+ 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} )
2320
2421if (FMT_IMPORT_STD)
25- set (CPPdefinitions FMT_IMPORT_STD)
22+ list (APPEND CPPdefinitions FMT_IMPORT_STD)
23+ endif ()
24+
25+ if (FMT_USE_MODULES)
26+ list (APPEND CPPdefinitions FMT_MODULE)
27+ # XXX NO! list(APPEND CPPdefinitions FMT_ATTACH_TO_GLOBAL_MODULE)
28+ # FIXME: add_compile_options(-Wno-reserved-module-identifier -Wno-include-angled-in-module-purview)
29+
30+ if (FMT_IMPORT_STD) # FIXME: clang++ only! AND $ENV{LLVM_ROOT})
31+ set (CMAKE_CXX_COMPILER_IMPORT_STD 23)
32+ add_compile_options (-fexperimental-library)
33+ add_link_options (-lc++experimental)
34+ add_compile_options (-stdlib=libc++)
35+ add_link_options (-stdlib=libc++)
36+
37+ message (STATUS "CMAKE_CXX_COMPILER_IMPORT_STD=${CMAKE_CXX_COMPILER_IMPORT_STD} " )
38+ endif ()
39+
40+ message (STATUS "CPPdefinitions=${CPPdefinitions} " )
41+ else ()
42+ set (CMAKE_VERIFY_INTERFACE_HEADER_SETS ${PROJECT_IS_TOP_LEVEL} )
2643endif ()
27- #
44+
2845# ---- add dependency libraries ----
2946
3047include (cmake/CPM.cmake)
@@ -66,7 +83,6 @@ target_compile_options(fmt-header-only INTERFACE $<$<AND:$<COMPILE_LANGUAGE:CXX>
6683
6784if (FMT_SEPARATE_COMPILATION)
6885 file (GLOB_RECURSE _fmt_all_sources "${fmt_SOURCE_DIR} /src/*.cc" )
69- set (_fmt_sources ${fmt_SOURCE_DIR} /src/fmt.cc)
7086
7187 add_library (fmt)
7288 add_library (fmt::fmt ALIAS fmt)
@@ -79,19 +95,22 @@ if(FMT_SEPARATE_COMPILATION)
7995 )
8096
8197 if (FMT_USE_MODULES)
82- target_compile_definitions (fmt PUBLIC USE_MODULES ${CPPdefinitions} )
98+ target_compile_definitions (fmt PUBLIC ${CPPdefinitions} )
8399 # cmake-format: off
84100 target_sources (fmt PUBLIC
85101 FILE_SET public_modules
86102 TYPE CXX_MODULES
87- BASE_DIRS ${PROJECT_SOURCE_DIR}
103+ BASE_DIRS
104+ #NO! ${fmt_SOURCE_DIR}
105+ ${PROJECT_SOURCE_DIR} /module
88106 FILES
107+ #NO! ${_fmt_all_sources}
89108 ${PROJECT_SOURCE_DIR} /module/fmt.cppm
90109 )
91110 # cmake-format: on
92111 else ()
93- target_compile_definitions (fmt PUBLIC FMT_SEPARATE_COMPILATION ${CPPdefinitions} )
94- target_sources (fmt PUBLIC ${_fmt_sources } )
112+ target_compile_definitions (fmt PUBLIC ${CPPdefinitions} )
113+ target_sources (fmt PUBLIC ${_fmt_all_sources } )
95114 endif ()
96115
97116 if (FMT_WARNINGS_AS_ERRORS AND FMT_DEVELOPER_MODE AND UNIX )
0 commit comments