forked from Orphis/boost-cmake
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathGNUmakefile
More file actions
80 lines (61 loc) · 2.38 KB
/
Copy pathGNUmakefile
File metadata and controls
80 lines (61 loc) · 2.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# Standard stuff
.SUFFIXES:
MAKEFLAGS+= --no-builtin-rules
MAKEFLAGS+= --warn-undefined-variables
export hostSystemName=$(shell uname)
ifeq (${hostSystemName},Darwin)
export LLVM_PREFIX:=$(shell brew --prefix llvm)
export LLVM_DIR:=$(shell realpath ${LLVM_PREFIX})
export PATH:=${LLVM_DIR}/bin:${PATH}
# export CMAKE_CXX_STDLIB_MODULES_JSON:=${LLVM_DIR}/lib/c++/libc++.modules.json
# export CXX:=clang++
# export LDFLAGS:=-L$(LLVM_DIR)/lib/c++ -lc++abi # NO! -lc++ -lc++experimental
# export GCOV:="llvm-cov gcov"
### TODO: to test g++-16:
export GCC_PREFIX:=$(shell brew --prefix gcc)
export GCC_DIR:=$(shell realpath ${GCC_PREFIX})
export CMAKE_CXX_STDLIB_MODULES_JSON:=${GCC_DIR}/lib/gcc/current/libstdc++.modules.json
export CXX:=g++-16
export CXXFLAGS:=-stdlib=libstdc++
export GCOV:="gcov"
else ifeq (${hostSystemName},Linux)
export LLVM_DIR:=/usr/lib/llvm-20
export PATH:=${LLVM_DIR}/bin:${PATH}
export CXX:=clang++-20
endif
#####################################################################
.PHONY: all fresh build test install examples format clean distclean
all: test
examples: # XXX install
cmake -S examples -B build -G Ninja --log-level=VERBOSE --fresh \
-D CMAKE_CXX_STDLIB_MODULES_JSON=${CMAKE_CXX_STDLIB_MODULES_JSON} \
-D CMAKE_CXX_MODULE_STD=ON -D CMAKE_CXX_STANDARD=23 \
-D BOOST_USE_MODULES=ON \
--debug-find-pkg=Boost
ninja -C build test -v
fresh:
cmake --workflow --preset Release --fresh
compile_commands.json: build/Release/compile_commands.json
ln -sf $< .
# NOTE: Works only yet on OSX with clang v22.1.7 with this arguments! CK
build/Release/compile_commands.json: GNUmakefile CMakeLists.txt
cmake --version
cmake --preset Release --log-level=VERBOSE -D BOOST_USE_MODULES=ON \
-D CMAKE_CXX_STDLIB_MODULES_JSON=${CMAKE_CXX_STDLIB_MODULES_JSON} \
-D CMAKE_CXX_MODULE_STD=OFF -D CMAKE_CXX_STANDARD=20
build: compile_commands.json
cmake --build --preset Release
test: install
ctest --preset Release
install: build
# XXX cmake --build --preset Release --target install
cmake --install build/Release --prefix=${HOME}/.local/
clean:
-cmake --build --preset Release --target clean
-find . -name '*~' -delete
distclean: # XXX clean
rm -rf build stagedir .cache compile_commands.json
format:
git ls-files ::*.cmake ::*CMakeLists.txt | xargs gersemi -i
git ls-files ::*.json ::*.cpp ::*.hpp | xargs clang-format -i
# git clang-format master