11cmake_minimum_required (VERSION 3.23 FATAL_ERROR)
2- project (modern_cpp_project LANGUAGES CXX VERSION 0.1.0)
2+ project (modern_cpp LANGUAGES CXX VERSION 0.1.0)
33
4- # === C++ Standard ===
4+ list (APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR} /cmake" )
5+
6+ # === Project Configuration ===
57set (CMAKE_CXX_STANDARD 20)
8+ set (CMAKE_CXX_EXTENSIONS OFF )
69set (CMAKE_CXX_STANDARD_REQUIRED ON )
710
8- # === Compile Commands ===
9- set (CMAKE_EXPORT_COMPILE_COMMANDS ON )
10-
11- # === Custom Build Types ===
12- if (CMAKE_CONFIGURATION_TYPES )
13- foreach (build_type IN ITEMS Sanitize Coverage)
14- list (APPEND CMAKE_CONFIGURATION_TYPES ${build_type} )
15- endforeach ()
16- list (REMOVE_DUPLICATES CMAKE_CONFIGURATION_TYPES )
17- set (CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES} " CACHE STRING "" FORCE)
18- endif ()
11+ # === Options ===
12+ include (Options )
1913
20- # === Project Options ===
21- option (ENABLE_WARNINGS "Enable compiler warnings" ON )
22- option (ENABLE_STRICT_WARNINGS "Treat warnings as errors" ON )
14+ # === Flags ===
15+ include (CompilerFlags)
2316
24- option (ENABLE_SANITIZERS "Enable sanitizer instrumentation" OFF )
17+ # === Search All Source Files ===
18+ file (GLOB_RECURSE CORE_SOURCES
19+ CONFIGURE_DEPENDS
20+ src/*.cpp
21+ src/*.hpp
22+ include /*.hpp
23+ )
2524
26- option (ENABLE_TESTING "Build unit tests" ON )
27- option (ENABLE_BENCHMARKS "Build benchmarks" ON )
28- option (ENABLE_COVERAGE "Enable coverage instrumentation" OFF )
25+ set (ALL_SOURCE_FILES ${CORE_SOURCES} )
2926
30- option (BUILD_APP "Build the demo app" ON )
31- option (BUILD_DOCS "Build Doxygen documentation" ON )
32-
33- option (ENABLE_CPPCHECK "Enable cppcheck analysis target" ON )
34- option (ENABLE_CLANG_TIDY "Enable clang-tidy analysis target" ON )
35- option (ENABLE_CLANG_FORMAT "Enable clang-format target" ON )
36-
37- # === Normalize Build Type (e.g., for string comparison) ===
38- if (CMAKE_BUILD_TYPE )
39- string (TOLOWER "${CMAKE_BUILD_TYPE} " BUILD_TYPE_LOWER)
40- else ()
41- set (BUILD_TYPE_LOWER "release" )
27+ if (ENABLE_TESTING)
28+ file (GLOB_RECURSE TEST_SOURCES
29+ CONFIGURE_DEPENDS
30+ tests/*.cpp
31+ )
32+ list (APPEND ALL_SOURCE_FILES ${TEST_SOURCES} )
4233endif ()
4334
44- # === Auto-toggle Options for Special Build Types ===
45- if (BUILD_TYPE_LOWER STREQUAL "sanitize" )
46- set (ENABLE_SANITIZERS ON CACHE BOOL "Enable sanitizers" FORCE)
35+ if (ENABLE_BENCHMARKS)
36+ file (GLOB_RECURSE BENCH_SOURCES
37+ CONFIGURE_DEPENDS
38+ benchmarks/*.cpp
39+ )
40+ list (APPEND ALL_SOURCE_FILES ${BENCH_SOURCES} )
4741endif ()
4842
49- if (BUILD_TYPE_LOWER STREQUAL "coverage" )
50- set (ENABLE_COVERAGE ON CACHE BOOL "Enable coverage" FORCE)
51- set (BUILD_APP OFF CACHE BOOL "Disable building app in coverage builds" FORCE)
52- set (ENABLE_BENCHMARKS OFF CACHE BOOL "Disable benchmarks in coverage builds" FORCE)
43+ if (BUILD_APP)
44+ file (GLOB_RECURSE APP_SOURCES
45+ CONFIGURE_DEPENDS
46+ app/*.cpp
47+ )
48+ list (APPEND ALL_SOURCE_FILES ${APP_SOURCES} )
5349endif ()
5450
55- # === CMake Module Path ===
56- list (APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR} /cmake" )
57-
58- # === Core Configuration ===
59- include (options /Warnings)
60- include (options /Sanitizers)
51+ # === Helpers ===
52+ include (Helpers)
6153
62- # === Optional Tooling ===
63- include (tools/Coverage)
64- include (tools/Cppcheck)
65- include (tools/ClangTidy)
66- include (tools/ClangFormat)
54+ # === Core Library ===
55+ add_subdirectory (src)
6756
68- # === Core library ===
69- add_subdirectory (src) # modern_cpp_project::math
70-
71- # === Application ===
57+ # === App ===
7258if (BUILD_APP)
73- add_subdirectory (app) # modern_cpp_project_app
59+ add_subdirectory (app)
7460endif ()
7561
7662# === Unit Tests ===
@@ -84,8 +70,14 @@ if(ENABLE_BENCHMARKS)
8470 add_subdirectory (benchmarks)
8571endif ()
8672
87- # === Documentation ===
88- include (tools/Doxygen)
73+ # === Developer Tooling (formatters, linters, etc.) ===
74+ include (Tooling)
75+
76+ # === Coverage ===
77+ include (Coverage)
8978
90- # === Installation ===
79+ # === Installation & Export ===
9180include (install /InstallConfig)
81+
82+ # === Packaging ===
83+ include (CPackConfig)
0 commit comments