@@ -10,119 +10,27 @@ message("Including Requested CMake Dependencies OK")
1010# cmake -DCMAKE_TOOLCHAIN_FILE=/path/to/toolchain.cmake -S . -B out/build
1111# cmake -DUSE_TOOLCHAIN=windows/llvm -S . -B out/build
1212include (cmake/check_toolchain.cmake )
13- project (CFDesktop VERSION 0.11.0 LANGUAGES CXX C )
1413
15- # ------ Build Type Configuration ------
16- # Validate and set build type
17- if (NOT CMAKE_BUILD_TYPE )
18- set (CMAKE_BUILD_TYPE "Release" CACHE STRING "Build type (Debug Release RelWithDebInfo)" FORCE )
19- message (STATUS "CMAKE_BUILD_TYPE not set, defaulting to: ${CMAKE_BUILD_TYPE } " )
20- endif ()
21-
22- set_property (CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "RelWithDebInfo" )
23-
24- # Set compiler flags for each build type (use CACHE FORCE to override CMake defaults)
25- # Debug: No optimization (-O0), full debug info (-g)
26- set (CMAKE_CXX_FLAGS_DEBUG "-O0 -g -D_CFDESKTOPDEBUG" CACHE STRING "Flags used by the C++ compiler during Debug builds" FORCE )
27- set (CMAKE_EXE_LINKER_FLAGS_DEBUG "" CACHE STRING "Linker flags used during Debug builds" FORCE )
28- # For Static Library Relocatable
29- set (CMAKE_POSITION_INDEPENDENT_CODE ON )
30- # Release: Maximum optimization (-O3), no debug info
31- set (CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG" CACHE STRING "Flags used by the C++ compiler during Release builds" FORCE )
32- set (CMAKE_EXE_LINKER_FLAGS_RELEASE "-s" CACHE STRING "Linker flags used during Release builds" FORCE )
33-
34- # RelWithDebInfo: Optimization (-O2) + full debug info
35- set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g -DNDEBUG" CACHE STRING "Flags used by the C++ compiler during RelWithDebInfo builds" FORCE )
36- set (CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "" CACHE STRING "Linker flags used during RelWithDebInfo builds" FORCE )
37-
38- string (TOUPPER "${CMAKE_BUILD_TYPE } " _build_type_upper)
39-
40- # Log build type and compiler flags (use variable indirection for nested expansion)
41- set (_cxx_flags_var "CMAKE_CXX_FLAGS_${_build_type_upper} " )
42- set (_link_flags_var "CMAKE_EXE_LINKER_FLAGS_${_build_type_upper} " )
43-
44- log_info ("BuildSettings" "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE } " )
45- log_info ("BuildSettings" "CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS } " )
46- log_info ("BuildSettings" "CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE } : ${${_cxx_flags_var} }" )
47- log_info ("BuildSettings" "CMAKE_EXE_LINKER_FLAGS: ${CMAKE_EXE_LINKER_FLAGS } " )
48- log_info ("BuildSettings" "CMAKE_EXE_LINKER_FLAGS_${CMAKE_BUILD_TYPE } : ${${_link_flags_var} }" )
49-
50- # ------ Build Settings ------
51- # Set output directories for all targets to ensure DLLs and executables are together
52- set (CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR } /bin" )
53- set (CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR } /bin" )
54- set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR } /lib" )
55- set (CMAKE_EXPORT_COMPILE_COMMANDS ON )
56- # Disable response files in compile_commands.json for better clangd compatibility
57- set (CMAKE_CXX_RESPONSE_FILE_FLAG "@" )
58- set (CMAKE_CXX_RESPONSE_FILE_LINK_FLAG "@" )
59- set (CMAKE_C_USE_RESPONSE_FILE_FOR_OBJECTS 0)
60- set (CMAKE_CXX_USE_RESPONSE_FILE_FOR_OBJECTS 0)
61- set (CMAKE_C_USE_RESPONSE_FILE_FOR_INCLUDES 0)
62- set (CMAKE_CXX_USE_RESPONSE_FILE_FOR_INCLUDES 0)
63- set (CMAKE_CXX_STANDARD 23)
64- set (CMAKE_CXX_STANDARD_REQUIRED ON )
65- set (CMAKE_AUTOMOC ON )
66- set (CMAKE_AUTORCC ON )
67- set (CMAKE_AUTOUIC ON )
68-
69- # ------ Build Settings ------
70-
71- log_info ("BuildSettings" "CMAKE_CXX_STANDARD: ${CMAKE_CXX_STANDARD } " )
72- log_info ("BuildSettings" "CMAKE_CXX_STANDARD_REQUIRED: ${CMAKE_CXX_STANDARD_REQUIRED } " )
73- log_info ("BuildSettings" "CMAKE_AUTOMOC: ${CMAKE_AUTOMOC } " )
74- log_info ("BuildSettings" "CMAKE_AUTORCC: ${CMAKE_AUTORCC} " )
75- log_info ("BuildSettings" "CMAKE_AUTOUIC: ${CMAKE_AUTOUIC} " )
76- log_info ("BuildSettings" "CMAKE_EXPORT_COMPILE_COMMANDS: ${CMAKE_EXPORT_COMPILE_COMMANDS } " )
77-
78- # find Qt6, As Requested
79- find_package (Qt6 REQUIRED COMPONENTS Core Gui Widgets Network )
80- log_info ("Post Qt Setups" "Run Post Qt Dependencies check" )
81- include (cmake/custom_target_helper.cmake )
82- log_info ("Post Qt Setups" "Run Post Qt Dependencies OK" )
14+ project (CFDesktop
15+ VERSION 0.11.0
16+ DESCRIPTION "CFDesktop: Given Your Device Portable Desktop Anywhere"
17+ HOMEPAGE_URL "https://github.com/Awesome-Embedded-Learning-Studio/CFDesktop"
18+ LANGUAGES CXX C
19+ )
8320
8421# ============================================================
85- # Output Directory Configuration
22+ # Pre-configure Checks and Setup
8623# ============================================================
87- # 配置分类输出目录:bin/, examples/, plugins/, runtimes/
88- log_info ("OutputConfig" "Configuring output directories" )
89- include (cmake/OutputDirectoryConfig.cmake )
24+ include (cmake/check_pre_configure.cmake )
9025
9126# ============================================================
92- # Example Launcher Generator (Windows)
27+ # Generate Meta Information Headers
9328# ============================================================
94- # 为每个 example 生成 Windows 启动脚本
95- if (WIN32 )
96- log_info ("Launcher" "Including Windows launcher generator" )
97- include (cmake/ExampleLauncher.cmake )
98- endif ()
29+ include (cmake/generate_meta_info.cmake )
9930
100- # ============================================================
101- # Qt Shared Deployment (Windows)
102- # ============================================================
103- # 共享 Qt DLLs 部署到 runtimes/ 目录
104- if (WIN32 )
105- log_info ("QtDeploy" "Including shared Qt deployment utilities" )
106- include (cmake/QtDeployUtils.cmake )
107- endif ()
10831
109- # Include development helpers generation
110- include (cmake/generate_develop_helpers.cmake )
111-
112- # Skip VSCode config generation in CI environment (docker builds)
113- if (NOT USE_TOOLCHAIN STREQUAL "linux/ci" )
114- log_info ("DevHelpers" "Will Generate VSCode clangd configuration" )
115- generate_vscode_clangd ()
116-
117- log_info ("DevHelpers" "Will Generate VSCode debug configuration" )
118- generate_vscode_debug_config ()
119- else ()
120- log_info ("DevHelpers" "Skipping VSCode config generation in CI mode" )
121- endif ()
122-
123- # Print build configuration
124- log_config_summary ()
125- log_qt_dir ()
32+ # Generate meta info headers after Qt6 is found
33+ cf_generate_meta_info ()
12634
12735# Log base module start
12836log_module_start ("base" )
@@ -167,4 +75,9 @@ if(WIN32)
16775 cf_setup_shared_qt_deployment ()
16876endif ()
16977
78+ # ============================================================
79+ # Final Configuration Summary
80+ # ============================================================
81+ log_build_summary_table ()
82+
17083log_info ("Final" "Configuration Ends! You can try to build now!" )
0 commit comments