Skip to content

Commit 2c695d3

Browse files
committed
Feat: use CMAKE_CXX_STDLIB_MODULES_JSON from preset
1 parent 914e27f commit 2c695d3

File tree

3 files changed

+36
-25
lines changed

3 files changed

+36
-25
lines changed

.CMakeUserPresets.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
2-
"version": 8,
2+
"version": 9,
33
"cmakeMinimumRequired": {
44
"major": 3,
5-
"minor": 28,
5+
"minor": 30,
66
"patch": 0
77
},
88
"configurePresets": [
@@ -32,7 +32,10 @@
3232
"inherits": [
3333
"dev-common",
3434
"ci-Darwin"
35-
]
35+
],
36+
"cacheVariables": {
37+
"CMAKE_CXX_STDLIB_MODULES_JSON": "$env{CMAKE_CXX_STDLIB_MODULES_JSON}"
38+
}
3639
},
3740
{
3841
"name": "dev-Windows",

CMakeLists.txt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ if(CMAKE_CXX_SCAN_FOR_MODULES)
1111
set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD
1212
"d0edc3af-4c50-42ea-a356-e2862fe7a444"
1313
)
14-
if(APPLE AND $ENV{CXX} STREQUAL g++-15)
15-
set(CMAKE_CXX_STDLIB_MODULES_JSON
16-
/usr/local/Cellar/gcc/15.2.0/lib/gcc/current/libstdc++.modules.json
17-
)
18-
else()
19-
set(CMAKE_CXX_STDLIB_MODULES_JSON
20-
$ENV{LLVM_DIR}/lib/c++/libc++.modules.json
21-
)
22-
endif()
14+
# if(APPLE AND $ENV{CXX} STREQUAL g++-15)
15+
# set(CMAKE_CXX_STDLIB_MODULES_JSON
16+
# $ENV{GCC_DIR}/lib/gcc/current/libstdc++.modules.json
17+
# )
18+
# else()
19+
# set(CMAKE_CXX_STDLIB_MODULES_JSON
20+
# $ENV{LLVM_DIR}/lib/c++/libc++.modules.json
21+
# )
22+
# endif()
2323
endif()
2424

2525
#==================================================
@@ -127,7 +127,7 @@ if(CMAKE_GENERATOR STREQUAL "Ninja" AND FMT_USE_MODULES)
127127

128128
# Tell CMake that we explicitly want `import std`.
129129
# This will initialize the property on all targets declared after this to 1
130-
if(NOT APPLE AND 23 IN_LIST CMAKE_CXX_COMPILER_IMPORT_STD)
130+
if(${CMAKE_CXX_STANDARD} IN_LIST CMAKE_CXX_COMPILER_IMPORT_STD)
131131
set(CMAKE_CXX_MODULE_STD ON)
132132
endif()
133133

GNUmakefile

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,35 @@
11
# Standard stuff
22

33
.SUFFIXES:
4-
$(VERBOSE).SILENT:
54

6-
MAKEFLAGS+= --no-builtin-rules
7-
MAKEFLAGS+= --warn-undefined-variables
5+
MAKEFLAGS+= --no-builtin-rules # Disable the built-in implicit rules.
6+
# MAKEFLAGS+= --warn-undefined-variables # Warn when an undefined variable is referenced.
7+
# MAKEFLAGS+= --include-dir=$(CURDIR)/conan # Search DIRECTORY for included makefiles (*.mk).
88

99
export hostSystemName=$(shell uname)
1010

1111
ifeq (${hostSystemName},Darwin)
12-
export LLVM_PREFIX:=$(shell brew --prefix llvm)
13-
export LLVM_DIR?=$(shell realpath ${LLVM_PREFIX})
12+
export LLVM_PREFIX=$(shell brew --prefix llvm)
13+
export LLVM_DIR=$(shell realpath ${LLVM_PREFIX})
1414
export PATH:=${LLVM_DIR}/bin:${PATH}
15-
# export CXX:=clang++
1615

17-
# to test g++-15:
16+
# export CMAKE_CXX_STDLIB_MODULES_JSON=${LLVM_DIR}/lib/c++/libc++.modules.json
17+
# export CXX=clang++
18+
# export LDFLAGS=-L$(LLVM_DIR)/lib/c++ -lc++abi -lc++ -lc++experimental
19+
# export GCOV="llvm-cov gcov"
20+
21+
### TODO: to test g++-15:
22+
export GCC_PREFIX=$(shell brew --prefix gcc)
23+
export GCC_DIR=$(shell realpath ${GCC_PREFIX})
24+
25+
export CMAKE_CXX_STDLIB_MODULES_JSON=${GCC_DIR}/lib/gcc/current/libstdc++.modules.json
1826
export CXX:=g++-15
1927
export CXXFLAGS:=-stdlib=libstdc++
28+
export GCOV="gcov"
2029
else ifeq (${hostSystemName},Linux)
21-
export LLVM_DIR?=/usr/lib/llvm-20
30+
export LLVM_DIR=/usr/lib/llvm-20
2231
export PATH:=${LLVM_DIR}/bin:${PATH}
23-
export CXX:=clang++-20
32+
export CXX=clang++-20
2433
endif
2534

2635
.PHONY: all check test example format clean distclean
@@ -67,6 +76,5 @@ GNUmakefile :: ;
6776
*.json :: ;
6877

6978
# Anything we don't know how to build will use this rule.
70-
# The command is a do-nothing command.
71-
#
72-
% :: ;
79+
% ::
80+
ninja -C build $(@)

0 commit comments

Comments
 (0)