Skip to content

Commit

Permalink
Merge branch 'develop' into feature/use_cxx_module_std
Browse files Browse the repository at this point in the history
  • Loading branch information
ClausKlein authored Jan 2, 2025
2 parents 1343909 + e7be420 commit 27c6443
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
11 changes: 11 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,17 @@ if(FMT_USE_MODULES)
list(APPEND CPPdefinitions HAS_STDLIB_MODULES)
endif()

# Tell CMake that we explicitly want `import std`.
# This will initialize the property on all targets declared after this to 1
if(CMAKE_CXX_COMPILER_IMPORT_STD)
set(CMAKE_CXX_MODULE_STD ON)
endif()

if(CMAKE_CXX_MODULE_STD OR ADD_STDLIB_MODULES)
# FIXME: NO! list(APPEND CPPdefinitions FMT_IMPORT_STD)
list(APPEND CPPdefinitions HAS_STDLIB_MODULES)
endif()

message(STATUS "CMAKE_CXX_COMPILER_IMPORT_STD=${CMAKE_CXX_COMPILER_IMPORT_STD}")
message(STATUS "CMAKE_CXX_SCAN_FOR_MODULES=${CMAKE_CXX_SCAN_FOR_MODULES}")
message(STATUS "CMAKE_CXX_MODULE_STD=${CMAKE_CXX_MODULE_STD}")
Expand Down
2 changes: 1 addition & 1 deletion cmake/dev-mode.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ if(FMT_BUILD_TESTING)

add_subdirectory(tests)

if(NOT CMAKE_CXX_COMPILER_IMPORT_STD)
if(CMAKE_CXX_MODULE_STD)
add_subdirectory(module/tests)
endif()

Expand Down
6 changes: 5 additions & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ if(FMT_USE_MODULES)
add_stdlib_module(${ADD_STDLIB_MODULES})
target_link_libraries(header-only-test ${ADD_STDLIB_MODULES})
endif()
target_link_libraries(header-only-test fmt::fmt_module)
if(TARGET fmt::fmt_module)
target_link_libraries(header-only-test fmt::fmt_module)
else()
target_link_libraries(header-only-test fmt::fmt)
endif()
else()
target_link_libraries(header-only-test fmt::fmt-header-only)
endif()
Expand Down

0 comments on commit 27c6443

Please sign in to comment.