chore: Enhance CMake and CI configurations for improved vcpkg integration
- Updated CMakeLists.txt to provide clearer logging and error messages for vcpkg integration, including detailed status reports for toolchain and triplet settings. - Modified CI workflows to utilize manifest mode for vcpkg installations, improving dependency management and build reliability. - Enhanced SDL2 and gRPC configurations to prioritize vcpkg packages, ensuring faster builds and clearer fallback mechanisms. - Improved overall CMake structure for better readability and maintainability, including updated messages for build configurations and warnings.
This commit is contained in:
@@ -1,40 +1,54 @@
|
||||
# vcpkg configuration reporting for Windows builds
|
||||
# This file is included AFTER vcpkg toolchain has run, so we can only report and validate
|
||||
#
|
||||
# IMPORTANT: vcpkg configuration variables (VCPKG_TARGET_TRIPLET, etc.) must be set:
|
||||
# 1. On the CMake command line: -DVCPKG_TARGET_TRIPLET=x64-windows-static
|
||||
# 2. Via environment variables: set VCPKG_DEFAULT_TRIPLET=x64-windows-static
|
||||
# 3. In vcpkg-configuration.json in the project root
|
||||
|
||||
# vcpkg configuration for Windows builds
|
||||
# Windows-specific macro definitions to avoid conflicts
|
||||
add_definitions("-DMICROSOFT_WINDOWS_WINBASE_H_DEFINE_INTERLOCKED_CPLUSPLUS_OVERLOADS=0")
|
||||
|
||||
# vcpkg settings
|
||||
set(VCPKG_CRT_LINKAGE dynamic)
|
||||
set(VCPKG_LIBRARY_LINKAGE dynamic)
|
||||
# Determine what triplet is being used (for reporting)
|
||||
set(_vcpkg_triplet "unknown")
|
||||
if(DEFINED VCPKG_TARGET_TRIPLET)
|
||||
set(_vcpkg_triplet "${VCPKG_TARGET_TRIPLET}")
|
||||
elseif(DEFINED ENV{VCPKG_DEFAULT_TRIPLET})
|
||||
set(_vcpkg_triplet "$ENV{VCPKG_DEFAULT_TRIPLET}")
|
||||
endif()
|
||||
|
||||
# Enable vcpkg manifest mode for automatic dependency management
|
||||
set(VCPKG_MANIFEST_MODE ON)
|
||||
# Detect installed directory
|
||||
set(_vcpkg_installed "${CMAKE_BINARY_DIR}/vcpkg_installed")
|
||||
if(DEFINED VCPKG_INSTALLED_DIR)
|
||||
set(_vcpkg_installed "${VCPKG_INSTALLED_DIR}")
|
||||
endif()
|
||||
|
||||
# Auto-detect target architecture and set vcpkg triplet
|
||||
if(NOT DEFINED VCPKG_TARGET_TRIPLET)
|
||||
if(CMAKE_SYSTEM_PROCESSOR MATCHES "ARM64|aarch64")
|
||||
set(VCPKG_TARGET_TRIPLET "arm64-windows" CACHE STRING "vcpkg target triplet")
|
||||
set(VCPKG_TARGET_ARCHITECTURE arm64)
|
||||
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "AMD64|x86_64")
|
||||
set(VCPKG_TARGET_TRIPLET "x64-windows" CACHE STRING "vcpkg target triplet")
|
||||
set(VCPKG_TARGET_ARCHITECTURE x64)
|
||||
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "i386|i686|x86")
|
||||
set(VCPKG_TARGET_TRIPLET "x86-windows" CACHE STRING "vcpkg target triplet")
|
||||
set(VCPKG_TARGET_ARCHITECTURE x86)
|
||||
# Detect manifest mode
|
||||
set(_vcpkg_manifest "ON (auto)")
|
||||
if(DEFINED VCPKG_MANIFEST_MODE)
|
||||
if(VCPKG_MANIFEST_MODE)
|
||||
set(_vcpkg_manifest "ON")
|
||||
else()
|
||||
# Fallback to x64 if architecture detection fails
|
||||
set(VCPKG_TARGET_TRIPLET "x64-windows" CACHE STRING "vcpkg target triplet")
|
||||
set(VCPKG_TARGET_ARCHITECTURE x64)
|
||||
message(WARNING "Could not detect target architecture, defaulting to x64")
|
||||
set(_vcpkg_manifest "OFF")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Set vcpkg installation directory if not already set
|
||||
if(NOT DEFINED VCPKG_INSTALLED_DIR)
|
||||
set(VCPKG_INSTALLED_DIR "${CMAKE_BINARY_DIR}/vcpkg_installed" CACHE PATH "vcpkg installed directory")
|
||||
# Report vcpkg configuration
|
||||
message(STATUS "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━")
|
||||
message(STATUS "vcpkg Post-Toolchain Report:")
|
||||
message(STATUS " ├─ Active triplet: ${_vcpkg_triplet}")
|
||||
message(STATUS " ├─ Manifest mode: ${_vcpkg_manifest}")
|
||||
message(STATUS " └─ Installed directory: ${_vcpkg_installed}")
|
||||
message(STATUS "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━")
|
||||
|
||||
# Validation warnings
|
||||
if(_vcpkg_triplet STREQUAL "unknown")
|
||||
message(WARNING "vcpkg triplet not detected! Build may fail.")
|
||||
message(WARNING "Set VCPKG_TARGET_TRIPLET on command line or VCPKG_DEFAULT_TRIPLET env var")
|
||||
endif()
|
||||
|
||||
message(STATUS "vcpkg configuration:")
|
||||
message(STATUS " Target architecture: ${VCPKG_TARGET_ARCHITECTURE}")
|
||||
message(STATUS " Target triplet: ${VCPKG_TARGET_TRIPLET}")
|
||||
message(STATUS " Installed directory: ${VCPKG_INSTALLED_DIR}")
|
||||
message(STATUS " Manifest mode: ${VCPKG_MANIFEST_MODE}")
|
||||
# Ensure manifest file exists
|
||||
if(NOT EXISTS "${CMAKE_SOURCE_DIR}/vcpkg.json")
|
||||
message(WARNING "vcpkg.json manifest not found in ${CMAKE_SOURCE_DIR}")
|
||||
message(WARNING "vcpkg dependency installation may fail!")
|
||||
endif()
|
||||
|
||||
Reference in New Issue
Block a user