@@ -12,7 +12,44 @@ message("Including Requested CMake Dependencies OK")
1212include (cmake/check_toolchain.cmake )
1313project (CFDesktop VERSION 0.0.1 LANGUAGES CXX )
1414
15+ # ------ Build Type Configuration ------
16+ # Validate and set build type
17+ if (NOT CMAKE_BUILD_TYPE )
18+ message (FATAL_ERROR "CMAKE_BUILD_TYPE is not set. Please specify build_type in build_*.config.ini" )
19+ endif ()
20+
21+ set_property (CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "RelWithDebInfo" )
22+
23+ # Set compiler flags for each build type (use CACHE FORCE to override CMake defaults)
24+ # Debug: No optimization (-O0), full debug info (-g)
25+ set (CMAKE_CXX_FLAGS_DEBUG "-O0 -g" CACHE STRING "Flags used by the C++ compiler during Debug builds" FORCE )
26+ set (CMAKE_EXE_LINKER_FLAGS_DEBUG "" CACHE STRING "Linker flags used during Debug builds" FORCE )
27+
28+ # Release: Maximum optimization (-O3), no debug info
29+ set (CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG" CACHE STRING "Flags used by the C++ compiler during Release builds" FORCE )
30+ set (CMAKE_EXE_LINKER_FLAGS_RELEASE "-s" CACHE STRING "Linker flags used during Release builds" FORCE )
31+
32+ # RelWithDebInfo: Optimization (-O2) + full debug info
33+ set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g -DNDEBUG" CACHE STRING "Flags used by the C++ compiler during RelWithDebInfo builds" FORCE )
34+ set (CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "" CACHE STRING "Linker flags used during RelWithDebInfo builds" FORCE )
35+
36+ string (TOUPPER "${CMAKE_BUILD_TYPE } " _build_type_upper)
37+
38+ # Log build type and compiler flags (use variable indirection for nested expansion)
39+ set (_cxx_flags_var "CMAKE_CXX_FLAGS_${_build_type_upper} " )
40+ set (_link_flags_var "CMAKE_EXE_LINKER_FLAGS_${_build_type_upper} " )
41+
42+ log_info ("BuildSettings" "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE } " )
43+ log_info ("BuildSettings" "CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS } " )
44+ log_info ("BuildSettings" "CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE } : ${${_cxx_flags_var} }" )
45+ log_info ("BuildSettings" "CMAKE_EXE_LINKER_FLAGS: ${CMAKE_EXE_LINKER_FLAGS } " )
46+ log_info ("BuildSettings" "CMAKE_EXE_LINKER_FLAGS_${CMAKE_BUILD_TYPE } : ${${_link_flags_var} }" )
47+
1548# ------ Build Settings ------
49+ # Set output directories for all targets to ensure DLLs and executables are together
50+ set (CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR } /bin" )
51+ set (CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR } /bin" )
52+ set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR } /lib" )
1653set (CMAKE_EXPORT_COMPILE_COMMANDS ON )
1754# Disable response files in compile_commands.json for better clangd compatibility
1855set (CMAKE_CXX_RESPONSE_FILE_FLAG "@" )
@@ -48,15 +85,25 @@ include(cmake/generate_develop_helpers.cmake)
4885log_info ("DevHelpers" "Will Generate VSCode clangd configuration" )
4986generate_vscode_clangd ()
5087
88+ log_info ("DevHelpers" "Will Generate VSCode debug configuration" )
89+ generate_vscode_debug_config ()
90+
5191# Print build configuration
5292log_config_summary ()
5393log_qt_dir ()
94+
5495# Log base module start
5596log_module_start ("base" )
5697add_subdirectory (base )
5798# Log base module end
5899log_module_end ("base" )
59100
101+ # Log base module start
102+ log_module_start ("ui" )
103+ add_subdirectory (ui )
104+ # Log base module end
105+ log_module_end ("ui" )
106+
60107
61108log_module_start ("example" )
62109add_subdirectory ("example" )
0 commit comments