@@ -14,115 +14,12 @@ if(EXISTS "${CMAKE_SOURCE_DIR}/.githooks")
1414 )
1515endif ()
1616
17- # Set C++23 standard
18- set (CMAKE_CXX_STANDARD 23)
19- set (CMAKE_CXX_STANDARD_REQUIRED ON )
20- set (CMAKE_CXX_EXTENSIONS OFF )
21-
22- # Export compile commands for IDEs
23- set (CMAKE_EXPORT_COMPILE_COMMANDS ON )
24-
25- # Set default build type if not specified
26- if (NOT CMAKE_BUILD_TYPE )
27- set (CMAKE_BUILD_TYPE Release)
28- endif ()
29-
30- # Build options
31- option (BUILD_EXAMPLES "Build examples" ON )
32- option (ENABLE_COVERAGE "Enable code coverage" OFF )
33- option (SKIP_DOCKER_MANAGEMENT "Skip Docker container lifecycle in CTest (use when DB is externally provided, e.g. CI)" OFF )
34- option (BUILD_INTEGRATION_TESTS "Build integration tests" ON )
35-
36- # Compiler options
37- if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang" )
38- add_compile_options (
39- -Wall
40- -Wextra
41- -Wpedantic
42- -Werror
43- )
44- elseif (MSVC )
45- add_compile_options (
46- /W4 # High warning level
47- /WX # Warnings as errors
48- /permissive- # Strict standards conformance
49- /Zc:preprocessor # Enable standards-conforming preprocessor (__VA_OPT__)
50- )
51- endif ()
52-
53- # Coverage flags
54- if (ENABLE_COVERAGE)
55- if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang" )
56- add_compile_options (--coverage )
57- add_link_options (--coverage )
58- message (STATUS "Coverage enabled with --coverage flags" )
59- else ()
60- message (WARNING "Coverage is not supported with ${CMAKE_CXX_COMPILER_ID } " )
61- endif ()
62- endif ()
63-
64- # Include FetchContent for dependency management
65- include (FetchContent )
66-
6717# Make local CMake helper modules available early (needed by fetched deps).
6818list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR } /cmake" )
6919
70- # MySQL client library
71- if (WIN32 )
72- # On Windows, search common MySQL Server installation paths.
73- # Override by passing -DMYSQL_ROOT_DIR=<path> to cmake.
74- set (MYSQL_ROOT_DIR "" CACHE PATH "MySQL installation root (e.g. C:/Program Files/MySQL/MySQL Server 8.0)" )
75- if (NOT MYSQL_ROOT_DIR)
76- file (GLOB _mysql_dirs "C:/Program Files/MySQL/MySQL Server *" )
77- if (_mysql_dirs)
78- list (SORT _mysql_dirs ORDER DESCENDING )
79- list (GET _mysql_dirs 0 MYSQL_ROOT_DIR)
80- set (MYSQL_ROOT_DIR "${MYSQL_ROOT_DIR} " CACHE PATH "" FORCE )
81- else ()
82- message (FATAL_ERROR "MySQL not found. Set -DMYSQL_ROOT_DIR=<path> to the MySQL installation directory." )
83- endif ()
84- endif ()
85-
86- find_path (MYSQL_INCLUDE_DIR mysql.h PATHS "${MYSQL_ROOT_DIR} /include" NO_DEFAULT_PATH REQUIRED )
87- find_library (MYSQL_LIBRARY libmysql PATHS "${MYSQL_ROOT_DIR} /lib" NO_DEFAULT_PATH REQUIRED )
88- set (MYSQL_INCLUDE_DIRS "${MYSQL_INCLUDE_DIR} " )
89- set (MYSQL_LIBRARIES "${MYSQL_LIBRARY} " )
90- message (STATUS "MySQL found at: ${MYSQL_ROOT_DIR} " )
91- else ()
92- find_package (PkgConfig REQUIRED )
93- pkg_check_modules (MYSQL REQUIRED mysqlclient )
94- endif ()
95-
96- # Note: Boost.PFR is header-only and doesn't have a standard CMake config package yet,
97- # so we fetch it directly without find_package. Once Boost.PFR is officially integrated
98- # into Boost's CMake build system, we can use: find_package(Boost REQUIRED COMPONENTS pfr CONFIG)
99-
100- # Boost.PFR (header-only, for compile-time reflection without macros)
101- # We only need the headers; FetchContent_Populate avoids processing Boost.PFR's own
102- # CMake build system, whose tests require Boost::core which is unavailable here.
103- FetchContent_Declare (
104- boost_pfr_headers
105- GIT_REPOSITORY https://github.com/boostorg/pfr.git
106- GIT_TAG master
107- GIT_SHALLOW TRUE
108- )
109- # CMP0169 OLD: suppress the single-arg FetchContent_Populate deprecation warning.
110- # This is intentional — we want headers only, not add_subdirectory behaviour.
111- cmake_policy (PUSH )
112- if (POLICY CMP0169)
113- cmake_policy (SET CMP0169 OLD )
114- endif ()
115- FetchContent_Populate (boost_pfr_headers)
116- cmake_policy (POP )
117-
118- # Create Boost.PFR target if not already provided by Boost.PFR's own CMake
119- if (NOT TARGET Boost::pfr)
120- add_library (Boost::pfr INTERFACE IMPORTED )
121- set_target_properties (Boost::pfr PROPERTIES
122- INTERFACE_INCLUDE_DIRECTORIES "${boost_pfr_headers_SOURCE_DIR } /include"
123- INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${boost_pfr_headers_SOURCE_DIR } /include"
124- )
125- endif ()
20+ include (ProjectOptions )
21+ include (CompilerOptions )
22+ include (Dependencies )
12623
12724# Auto-create .env from .env.example in tests/integration if missing
12825if (NOT EXISTS "${CMAKE_SOURCE_DIR } /tests/integration/.env" )
0 commit comments