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:
14
.github/workflows/ci.yml
vendored
14
.github/workflows/ci.yml
vendored
@@ -53,18 +53,24 @@ jobs:
|
||||
uses: lukka/run-vcpkg@v11
|
||||
id: vcpkg
|
||||
continue-on-error: true
|
||||
env:
|
||||
VCPKG_DEFAULT_TRIPLET: x64-windows-static
|
||||
VCPKG_BINARY_SOURCES: 'clear;x-gha,readwrite'
|
||||
with:
|
||||
vcpkgDirectory: '${{ github.workspace }}/vcpkg'
|
||||
vcpkgGitCommitId: 'a42af01b72c28a8e1d7b48107b33e4f286a55ef6' # 2024.07.12 release
|
||||
runVcpkgInstall: true
|
||||
runVcpkgInstall: false # Let CMake handle installation via manifest mode
|
||||
|
||||
- name: Retry vcpkg setup (Windows only)
|
||||
if: runner.os == 'Windows' && steps.vcpkg.outcome == 'failure'
|
||||
uses: lukka/run-vcpkg@v11
|
||||
env:
|
||||
VCPKG_DEFAULT_TRIPLET: x64-windows-static
|
||||
VCPKG_BINARY_SOURCES: 'clear;x-gha,readwrite'
|
||||
with:
|
||||
vcpkgDirectory: '${{ github.workspace }}/vcpkg'
|
||||
vcpkgGitCommitId: 'a42af01b72c28a8e1d7b48107b33e4f286a55ef6'
|
||||
runVcpkgInstall: true
|
||||
runVcpkgInstall: false
|
||||
doNotUpdateVcpkg: true # Use existing clone on retry
|
||||
|
||||
- name: Install Dependencies
|
||||
@@ -113,6 +119,8 @@ jobs:
|
||||
- name: Configure
|
||||
id: configure
|
||||
shell: bash
|
||||
env:
|
||||
VCPKG_DEFAULT_TRIPLET: x64-windows-static
|
||||
run: |
|
||||
set -e
|
||||
echo "::group::CMake Configuration"
|
||||
@@ -120,6 +128,8 @@ jobs:
|
||||
cmake -B build -G "Visual Studio 17 2022" -A x64 \
|
||||
-DCMAKE_BUILD_TYPE=$BUILD_TYPE \
|
||||
-DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake \
|
||||
-DVCPKG_TARGET_TRIPLET=x64-windows-static \
|
||||
-DVCPKG_MANIFEST_MODE=ON \
|
||||
-DYAZE_MINIMAL_BUILD=ON \
|
||||
-DYAZE_ENABLE_ROM_TESTS=OFF 2>&1 | tee cmake_config.log
|
||||
else
|
||||
|
||||
@@ -220,40 +220,58 @@ elseif(YAZE_PLATFORM_MACOS)
|
||||
set(CMAKE_INSTALL_PREFIX /usr/local)
|
||||
target_compile_definitions(yaze_common INTERFACE MACOS)
|
||||
elseif(YAZE_PLATFORM_WINDOWS)
|
||||
# Only include vcpkg configuration if vcpkg toolchain is available
|
||||
# vcpkg configuration must be done early (in CMakeLists.txt or via command line)
|
||||
# The vcpkg.cmake file contains post-toolchain configuration and reporting
|
||||
if(DEFINED CMAKE_TOOLCHAIN_FILE AND EXISTS "${CMAKE_TOOLCHAIN_FILE}")
|
||||
# vcpkg toolchain is active
|
||||
# Note: VCPKG_TARGET_TRIPLET and other settings should be set via command line
|
||||
# or will be auto-detected by our cmake/vcpkg.cmake include
|
||||
message(STATUS "✓ Using vcpkg integration")
|
||||
message(STATUS " ├─ Toolchain: ${CMAKE_TOOLCHAIN_FILE}")
|
||||
if(DEFINED VCPKG_TARGET_TRIPLET)
|
||||
message(STATUS " └─ Triplet: ${VCPKG_TARGET_TRIPLET}")
|
||||
endif()
|
||||
|
||||
# Include our vcpkg configuration for additional settings
|
||||
include(cmake/vcpkg.cmake)
|
||||
message(STATUS "Using vcpkg integration")
|
||||
message(STATUS " - Toolchain: ${CMAKE_TOOLCHAIN_FILE}")
|
||||
else()
|
||||
message(STATUS "vcpkg not available - using system packages or bundled dependencies")
|
||||
message(STATUS " Tip: Set VCPKG_ROOT environment variable to enable vcpkg")
|
||||
message(STATUS "○ vcpkg not available - using system packages or bundled dependencies")
|
||||
message(STATUS " Tip: Set VCPKG_ROOT environment variable or CMAKE_TOOLCHAIN_FILE to enable vcpkg")
|
||||
endif()
|
||||
target_compile_definitions(yaze_common INTERFACE WINDOWS)
|
||||
|
||||
# Windows-specific build guidance
|
||||
message(STATUS "===========================================")
|
||||
message(STATUS "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━")
|
||||
message(STATUS "Windows Build Configuration:")
|
||||
message(STATUS " - Generator: ${CMAKE_GENERATOR}")
|
||||
message(STATUS " - Architecture: ${CMAKE_GENERATOR_PLATFORM}")
|
||||
message(STATUS " - JSON Support: ${YAZE_WITH_JSON}")
|
||||
message(STATUS " - AI Features: ${Z3ED_AI}")
|
||||
message(STATUS " - gRPC Support: ${YAZE_WITH_GRPC}")
|
||||
message(STATUS "===========================================")
|
||||
message(STATUS " ├─ Generator: ${CMAKE_GENERATOR}")
|
||||
message(STATUS " ├─ Architecture: ${CMAKE_GENERATOR_PLATFORM}")
|
||||
message(STATUS " ├─ Build Type: ${CMAKE_BUILD_TYPE}")
|
||||
message(STATUS " ├─ Minimal Build: ${YAZE_MINIMAL_BUILD}")
|
||||
message(STATUS " ├─ JSON Support: ${YAZE_WITH_JSON}")
|
||||
message(STATUS " ├─ AI Features: ${Z3ED_AI}")
|
||||
message(STATUS " └─ gRPC Support: ${YAZE_WITH_GRPC}")
|
||||
message(STATUS "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━")
|
||||
|
||||
# Helpful messages about build configuration
|
||||
if(NOT Z3ED_AI)
|
||||
message(STATUS "Note: AI agent features disabled (JSON is enabled)")
|
||||
message(STATUS " To enable AI: cmake --preset windows-ai-debug")
|
||||
if(YAZE_MINIMAL_BUILD)
|
||||
message(STATUS "ℹ️ Minimal Build Mode:")
|
||||
message(STATUS " • gRPC disabled for faster CI builds")
|
||||
message(STATUS " • UI tests disabled")
|
||||
message(STATUS " • JSON support enabled (header-only, lightweight)")
|
||||
endif()
|
||||
|
||||
if(NOT Z3ED_AI AND NOT YAZE_MINIMAL_BUILD)
|
||||
message(STATUS "Note: AI agent features disabled")
|
||||
message(STATUS " To enable: cmake -DYAZE_WITH_GRPC=ON -DZ3ED_AI=ON ...")
|
||||
endif()
|
||||
|
||||
if(NOT YAZE_WITH_JSON)
|
||||
message(STATUS "Warning: JSON disabled - some features may not compile")
|
||||
message(STATUS " Recommend keeping JSON enabled (it's header-only)")
|
||||
message(WARNING "JSON disabled - some features may not compile")
|
||||
message(WARNING "Recommend keeping JSON enabled (it's header-only)")
|
||||
endif()
|
||||
|
||||
# Note about httplib and AI features
|
||||
message(STATUS "httplib: Header-only mode (compression libs disabled)")
|
||||
# Note about httplib
|
||||
message(STATUS "httplib: Header-only mode (compression features disabled)")
|
||||
if(Z3ED_AI)
|
||||
message(STATUS " For Gemini API: curl.exe must be in PATH")
|
||||
message(STATUS " (Usually included with Windows 10/11 or Git)")
|
||||
|
||||
@@ -6,12 +6,18 @@ set(YAZE_ABSL_GIT_TAG "20240116.2" CACHE STRING "Abseil release tag used when fe
|
||||
# missing the required components (e.g. macOS).
|
||||
set(_yaze_use_fetched_absl ${YAZE_FORCE_BUNDLED_ABSL})
|
||||
if(NOT _yaze_use_fetched_absl)
|
||||
find_package(absl QUIET CONFIG)
|
||||
# Try to find via vcpkg first on Windows
|
||||
if(WIN32 AND DEFINED CMAKE_TOOLCHAIN_FILE)
|
||||
find_package(absl CONFIG QUIET)
|
||||
else()
|
||||
find_package(absl QUIET CONFIG)
|
||||
endif()
|
||||
|
||||
if(absl_FOUND)
|
||||
message(STATUS "Using system-provided Abseil package")
|
||||
message(STATUS "✓ Using system/vcpkg Abseil package")
|
||||
else()
|
||||
set(_yaze_use_fetched_absl TRUE)
|
||||
message(STATUS "System Abseil not found. Fetching release ${YAZE_ABSL_GIT_TAG}.")
|
||||
message(STATUS "○ System Abseil not found. Will fetch release ${YAZE_ABSL_GIT_TAG}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ option(YAZE_USE_VCPKG_GRPC "Use vcpkg pre-compiled gRPC packages (Windows only)"
|
||||
|
||||
if(WIN32 AND YAZE_USE_VCPKG_GRPC)
|
||||
message(STATUS "Attempting to use vcpkg gRPC packages for faster Windows builds...")
|
||||
message(STATUS " Note: This is only for full builds with YAZE_WITH_GRPC=ON")
|
||||
|
||||
# Try to find gRPC via vcpkg
|
||||
find_package(gRPC CONFIG QUIET)
|
||||
@@ -26,7 +27,9 @@ if(WIN32 AND YAZE_USE_VCPKG_GRPC)
|
||||
|
||||
# Verify required targets exist
|
||||
if(NOT TARGET grpc++)
|
||||
message(FATAL_ERROR "gRPC found but grpc++ target missing")
|
||||
message(WARNING "gRPC found but grpc++ target missing - falling back to FetchContent")
|
||||
set(YAZE_GRPC_CONFIGURED FALSE PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
|
||||
if(NOT TARGET protoc)
|
||||
|
||||
@@ -1,16 +1,31 @@
|
||||
# SDL2
|
||||
# On Windows, try to use vcpkg first, then fall back to bundled SDL
|
||||
# On Windows with vcpkg, prefer vcpkg packages for faster builds
|
||||
if(WIN32)
|
||||
# Try to find SDL2 via vcpkg first
|
||||
find_package(SDL2 QUIET)
|
||||
if(SDL2_FOUND)
|
||||
# Use vcpkg SDL2
|
||||
set(SDL_TARGETS SDL2::SDL2)
|
||||
list(PREPEND SDL_TARGETS SDL2::SDL2main ws2_32)
|
||||
add_definitions("-DSDL_MAIN_HANDLED")
|
||||
message(STATUS "Using vcpkg SDL2")
|
||||
else()
|
||||
# Fall back to bundled SDL
|
||||
# Try to find SDL2 via vcpkg first if toolchain is available
|
||||
if(DEFINED CMAKE_TOOLCHAIN_FILE AND EXISTS "${CMAKE_TOOLCHAIN_FILE}")
|
||||
find_package(SDL2 CONFIG QUIET)
|
||||
if(SDL2_FOUND OR TARGET SDL2::SDL2)
|
||||
# Use vcpkg SDL2
|
||||
if(TARGET SDL2::SDL2)
|
||||
set(SDL_TARGETS SDL2::SDL2)
|
||||
if(TARGET SDL2::SDL2main)
|
||||
list(PREPEND SDL_TARGETS SDL2::SDL2main)
|
||||
endif()
|
||||
list(APPEND SDL_TARGETS ws2_32)
|
||||
add_definitions("-DSDL_MAIN_HANDLED")
|
||||
message(STATUS "✓ Using vcpkg SDL2")
|
||||
|
||||
# Get SDL2 include directories for reference
|
||||
get_target_property(SDL2_INCLUDE_DIR SDL2::SDL2 INTERFACE_INCLUDE_DIRECTORIES)
|
||||
set(SDL2_INCLUDE_DIRS ${SDL2_INCLUDE_DIR})
|
||||
return()
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Fall back to bundled SDL if vcpkg not available or SDL2 not found
|
||||
if(EXISTS "${CMAKE_SOURCE_DIR}/src/lib/SDL/CMakeLists.txt")
|
||||
message(STATUS "○ vcpkg SDL2 not found, using bundled SDL2")
|
||||
add_subdirectory(src/lib/SDL)
|
||||
set(SDL_TARGETS SDL2-static)
|
||||
set(SDL2_INCLUDE_DIR
|
||||
@@ -19,9 +34,13 @@ if(WIN32)
|
||||
${CMAKE_BINARY_DIR}/src/lib/SDL/include-config-${CMAKE_BUILD_TYPE}
|
||||
)
|
||||
set(SDL2_INCLUDE_DIRS ${SDL2_INCLUDE_DIR})
|
||||
list(PREPEND SDL_TARGETS SDL2main ws2_32)
|
||||
if(TARGET SDL2main)
|
||||
list(PREPEND SDL_TARGETS SDL2main)
|
||||
endif()
|
||||
list(APPEND SDL_TARGETS ws2_32)
|
||||
add_definitions("-DSDL_MAIN_HANDLED")
|
||||
message(STATUS "Using bundled SDL2")
|
||||
else()
|
||||
message(FATAL_ERROR "SDL2 not found via vcpkg and bundled SDL2 not available. Please install via vcpkg or ensure submodules are initialized.")
|
||||
endif()
|
||||
elseif(UNIX OR MINGW)
|
||||
# Non-Windows: use bundled SDL
|
||||
@@ -36,7 +55,7 @@ elseif(UNIX OR MINGW)
|
||||
message(STATUS "Using bundled SDL2")
|
||||
else()
|
||||
# Fallback: try to find system SDL
|
||||
find_package(SDL2)
|
||||
find_package(SDL2 REQUIRED)
|
||||
set(SDL_TARGETS SDL2::SDL2)
|
||||
message(STATUS "Using system SDL2")
|
||||
endif()
|
||||
|
||||
@@ -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