-
-
Notifications
You must be signed in to change notification settings - Fork 16
/
CMakeLists.txt
55 lines (40 loc) · 1.35 KB
/
CMakeLists.txt
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
cmake_minimum_required(VERSION 3.25...3.30)
# CMake 3.25 for try_run() new syntax
# CMake 3.30+ for C++26
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
message(FATAL_ERROR "Please use out of source build:
cmake -Bbuild")
endif()
project(Cpp23examples LANGUAGES CXX)
enable_testing()
set(CMAKE_CXX_SCAN_FOR_MODULES OFF)
# This project isn't using C++ modules; avoid bugs in module scanning CMake 3.28, 3.29 with GCC >= 14.
option(cppcheck "run cppcheck")
option(tidy "Run clang-tidy")
message(STATUS "CMake ${CMAKE_VERSION}")
# set(CMAKE_CXX_STANDARD_REQUIRED ON) causes configure errors if not known for the compiler
set(CMAKE_CXX_EXTENSIONS OFF)
# CPPcheck
if(cppcheck)
find_program(cppcheck_exe NAMES cppcheck REQUIRED)
set(cppcheck_opts --enable=all --inline-suppr --quiet --suppressions-list=${PROJECT_SOURCE_DIR}/cppcheck.supp)
set(CMAKE_CXX_CPPCHECK ${cppcheck_exe} --std=c++${CMAKE_CXX_STANDARD} ${cppcheck_opts})
endif()
if(tidy)
find_program(CLANG_TIDY
NAMES clang-tidy
REQUIRED
PATHS /opt/homebrew/opt/llvm/bin
)
set(CMAKE_CXX_CLANG_TIDY ${CLANG_TIDY})
endif()
include(cmake/compilers.cmake)
add_subdirectory(cpp11)
add_subdirectory(cpp14)
add_subdirectory(cpp17)
add_subdirectory(cpp20)
add_subdirectory(cpp23)
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.30)
add_subdirectory(cpp26)
endif()
file(GENERATE OUTPUT .gitignore CONTENT "*")