Skip to content

Commit da4c68f

Browse files
committed
That works at least on Darwin with g++-15
1 parent 3630a66 commit da4c68f

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

CMakeLists.txt

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@ if(CMAKE_CXX_SCAN_FOR_MODULES)
1111
set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD
1212
"d0edc3af-4c50-42ea-a356-e2862fe7a444"
1313
)
14-
if(APPLE)
14+
if(APPLE AND $ENV{CXX} STREQUAL g++-15)
1515
set(CMAKE_CXX_STDLIB_MODULES_JSON
1616
/usr/local/Cellar/gcc/15.2.0/lib/gcc/current/libstdc++.modules.json
1717
)
18-
# set(CMAKE_CXX_STDLIB_MODULES_JSON $ENV{LLVM_DIR}/lib/c++/libc++.modules.json)
18+
else()
19+
set(CMAKE_CXX_STDLIB_MODULES_JSON $ENV{LLVM_DIR}/lib/c++/libc++.modules.json)
1920
endif()
2021
endif()
2122

@@ -79,11 +80,11 @@ if(CMAKE_GENERATOR STREQUAL "Ninja" AND FMT_USE_MODULES)
7980
set(LLVM_DIR ${LLVM_DIR} CACHE PATH "")
8081
message(STATUS "LLVM_DIR=${LLVM_DIR}")
8182

82-
if(LINUX AND EXISTS ${LLVM_LIBC_SOURCE}/std.cppm)
83-
message(WARNING "LLVM_LIBC_SOURCE=${LLVM_LIBC_SOURCE}")
84-
set(ADD_STDLIB_MODULES stdc++)
85-
list(APPEND CMAKE_CXX_COMPILER_IMPORT_STD 23)
86-
endif()
83+
# if(LINUX AND EXISTS ${LLVM_LIBC_SOURCE}/std.cppm)
84+
# message(WARNING "LLVM_LIBC_SOURCE=${LLVM_LIBC_SOURCE}")
85+
# set(ADD_STDLIB_MODULES stdc++)
86+
# list(APPEND CMAKE_CXX_COMPILER_IMPORT_STD 23)
87+
# endif()
8788

8889
# Build the stdlib module
8990
function(add_stdlib_module NAME)
@@ -122,7 +123,7 @@ if(CMAKE_GENERATOR STREQUAL "Ninja" AND FMT_USE_MODULES)
122123

123124
# Tell CMake that we explicitly want `import std`.
124125
# This will initialize the property on all targets declared after this to 1
125-
if(23 IN_LIST CMAKE_CXX_COMPILER_IMPORT_STD)
126+
if(NOT APPLE AND 23 IN_LIST CMAKE_CXX_COMPILER_IMPORT_STD)
126127
set(CMAKE_CXX_MODULE_STD ON)
127128
endif()
128129

module/tests/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 4.0...4.2)
22

33
project(fmt_moddule_examples LANGUAGES CXX)
44

5-
set(USE_MODULES ${CMAKE_CXX_MODULE_STD})
5+
set(USE_MODULES ON)
66

77
if(PROJECT_IS_TOP_LEVEL)
88
enable_testing()

tests/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ if(PROJECT_IS_TOP_LEVEL)
1616
set(CMAKE_CXX_STANDARD_REQUIRED ON)
1717

1818
#XXX find_package(fmt 12.0.0.2 EXACT REQUIRED HINT ../stagedir/lib)
19+
#XXX set(ADD_STDLIB_MODULES stdc++)
1920

20-
set(ADD_STDLIB_MODULES stdc++)
2121
add_subdirectory(.. fmt_module)
2222
endif()
2323

0 commit comments

Comments
 (0)