backend-infra-engineer: Release v0.3.3 snapshot
This commit is contained in:
@@ -1,155 +1,95 @@
|
||||
# This file centralizes the management of all third-party dependencies.
|
||||
# It provides functions to find or fetch dependencies and creates alias targets
|
||||
# for consistent usage throughout the project.
|
||||
# YAZE Dependencies Management
|
||||
# Centralized dependency management using CPM.cmake
|
||||
|
||||
include(FetchContent)
|
||||
# Include CPM and options
|
||||
include(cmake/CPM.cmake)
|
||||
include(cmake/options.cmake)
|
||||
include(cmake/dependencies.lock)
|
||||
|
||||
# ============================================================================
|
||||
# Helper function to add a dependency
|
||||
# ============================================================================
|
||||
function(yaze_add_dependency name)
|
||||
set(options)
|
||||
set(oneValueArgs GIT_REPOSITORY GIT_TAG URL)
|
||||
set(multiValueArgs)
|
||||
cmake_parse_arguments(DEP "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
message(STATUS "=== Setting up YAZE dependencies with CPM.cmake ===")
|
||||
|
||||
if(TARGET yaze::${name})
|
||||
return()
|
||||
endif()
|
||||
# Clear any previous dependency targets
|
||||
set(YAZE_ALL_DEPENDENCIES "")
|
||||
set(YAZE_SDL2_TARGETS "")
|
||||
set(YAZE_YAML_TARGETS "")
|
||||
set(YAZE_IMGUI_TARGETS "")
|
||||
set(YAZE_JSON_TARGETS "")
|
||||
set(YAZE_GRPC_TARGETS "")
|
||||
set(YAZE_FTXUI_TARGETS "")
|
||||
set(YAZE_TESTING_TARGETS "")
|
||||
|
||||
# Try to find the package via find_package first
|
||||
find_package(${name} QUIET)
|
||||
# Core dependencies (always required)
|
||||
include(cmake/dependencies/sdl2.cmake)
|
||||
# Debug: message(STATUS "After SDL2 setup, YAZE_SDL2_TARGETS = '${YAZE_SDL2_TARGETS}'")
|
||||
list(APPEND YAZE_ALL_DEPENDENCIES ${YAZE_SDL2_TARGETS})
|
||||
|
||||
if(${name}_FOUND)
|
||||
message(STATUS "Found ${name} via find_package")
|
||||
if(TARGET ${name}::${name})
|
||||
add_library(yaze::${name} ALIAS ${name}::${name})
|
||||
else()
|
||||
# Handle cases where find_package doesn't create an imported target
|
||||
# This is a simplified approach; more logic may be needed for specific packages
|
||||
add_library(yaze::${name} INTERFACE IMPORTED)
|
||||
target_include_directories(yaze::${name} INTERFACE ${${name}_INCLUDE_DIRS})
|
||||
target_link_libraries(yaze::${name} INTERFACE ${${name}_LIBRARIES})
|
||||
endif()
|
||||
return()
|
||||
endif()
|
||||
include(cmake/dependencies/yaml.cmake)
|
||||
list(APPEND YAZE_ALL_DEPENDENCIES ${YAZE_YAML_TARGETS})
|
||||
|
||||
# If not found, use FetchContent
|
||||
message(STATUS "Could not find ${name}, fetching from source.")
|
||||
FetchContent_Declare(
|
||||
${name}
|
||||
GIT_REPOSITORY ${DEP_GIT_REPOSITORY}
|
||||
GIT_TAG ${DEP_GIT_TAG}
|
||||
)
|
||||
include(cmake/dependencies/imgui.cmake)
|
||||
# Debug: message(STATUS "After ImGui setup, YAZE_IMGUI_TARGETS = '${YAZE_IMGUI_TARGETS}'")
|
||||
list(APPEND YAZE_ALL_DEPENDENCIES ${YAZE_IMGUI_TARGETS})
|
||||
|
||||
FetchContent_GetProperties(${name})
|
||||
if(NOT ${name}_POPULATED)
|
||||
FetchContent_Populate(${name})
|
||||
add_subdirectory(${${name}_SOURCE_DIR} ${${name}_BINARY_DIR})
|
||||
endif()
|
||||
|
||||
if(TARGET ${name})
|
||||
add_library(yaze::${name} ALIAS ${name})
|
||||
elseif(TARGET ${name}::${name})
|
||||
add_library(yaze::${name} ALIAS ${name}::${name})
|
||||
else()
|
||||
message(FATAL_ERROR "Failed to create target for ${name}")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
# ============================================================================
|
||||
# Dependency Declarations
|
||||
# ============================================================================
|
||||
|
||||
# gRPC (must come before Abseil - provides its own compatible Abseil)
|
||||
if(YAZE_WITH_GRPC)
|
||||
include(cmake/grpc.cmake)
|
||||
# Verify ABSL_TARGETS was populated by gRPC
|
||||
list(LENGTH ABSL_TARGETS _absl_count)
|
||||
if(_absl_count EQUAL 0)
|
||||
message(FATAL_ERROR "ABSL_TARGETS is empty after including grpc.cmake!")
|
||||
else()
|
||||
message(STATUS "gRPC provides ${_absl_count} Abseil targets for linking")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Abseil (only if gRPC didn't provide it)
|
||||
if(NOT YAZE_WITH_GRPC)
|
||||
# Abseil is required for failure_signal_handler, status, and other utilities
|
||||
# Only include standalone Abseil when gRPC is disabled - when gRPC is enabled,
|
||||
# it provides its own bundled Abseil via CPM
|
||||
if(NOT YAZE_ENABLE_GRPC)
|
||||
include(cmake/absl.cmake)
|
||||
# Verify ABSL_TARGETS was populated
|
||||
list(LENGTH ABSL_TARGETS _absl_count)
|
||||
if(_absl_count EQUAL 0)
|
||||
message(FATAL_ERROR "ABSL_TARGETS is empty after including absl.cmake!")
|
||||
else()
|
||||
message(STATUS "Abseil provides ${_absl_count} targets for linking")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(YAZE_PROTOBUF_TARGETS)
|
||||
|
||||
if(TARGET protobuf::libprotobuf)
|
||||
list(APPEND YAZE_PROTOBUF_TARGETS protobuf::libprotobuf)
|
||||
else()
|
||||
if(TARGET libprotobuf)
|
||||
list(APPEND YAZE_PROTOBUF_TARGETS libprotobuf)
|
||||
endif()
|
||||
# Optional dependencies based on feature flags
|
||||
if(YAZE_ENABLE_JSON)
|
||||
include(cmake/dependencies/json.cmake)
|
||||
list(APPEND YAZE_ALL_DEPENDENCIES ${YAZE_JSON_TARGETS})
|
||||
endif()
|
||||
|
||||
set(YAZE_PROTOBUF_WHOLEARCHIVE_TARGETS ${YAZE_PROTOBUF_TARGETS})
|
||||
|
||||
if(YAZE_PROTOBUF_TARGETS)
|
||||
list(GET YAZE_PROTOBUF_TARGETS 0 YAZE_PROTOBUF_TARGET)
|
||||
else()
|
||||
set(YAZE_PROTOBUF_TARGET "")
|
||||
# CRITICAL: Load testing dependencies BEFORE gRPC when both are enabled
|
||||
# This ensures gmock is available before Abseil (bundled with gRPC) tries to export test_allocator
|
||||
# which depends on gmock. This prevents CMake export errors.
|
||||
if(YAZE_BUILD_TESTS AND YAZE_ENABLE_GRPC)
|
||||
include(cmake/dependencies/testing.cmake)
|
||||
list(APPEND YAZE_ALL_DEPENDENCIES ${YAZE_TESTING_TARGETS})
|
||||
endif()
|
||||
|
||||
# SDL2
|
||||
include(cmake/sdl2.cmake)
|
||||
if(YAZE_ENABLE_GRPC)
|
||||
include(cmake/dependencies/grpc.cmake)
|
||||
list(APPEND YAZE_ALL_DEPENDENCIES ${YAZE_GRPC_TARGETS})
|
||||
endif()
|
||||
|
||||
# Asar
|
||||
include(cmake/asar.cmake)
|
||||
if(YAZE_BUILD_CLI)
|
||||
include(cmake/dependencies/ftxui.cmake)
|
||||
list(APPEND YAZE_ALL_DEPENDENCIES ${YAZE_FTXUI_TARGETS})
|
||||
endif()
|
||||
|
||||
# Google Test
|
||||
# Load testing dependencies after gRPC if tests are enabled but gRPC is not
|
||||
if(YAZE_BUILD_TESTS AND NOT YAZE_ENABLE_GRPC)
|
||||
include(cmake/dependencies/testing.cmake)
|
||||
list(APPEND YAZE_ALL_DEPENDENCIES ${YAZE_TESTING_TARGETS})
|
||||
endif()
|
||||
|
||||
# ASAR dependency (for ROM assembly) - temporarily disabled
|
||||
# TODO: Add CMakeLists.txt to bundled ASAR or find working repository
|
||||
message(STATUS "ASAR dependency temporarily disabled - will be added later")
|
||||
|
||||
# Print dependency summary
|
||||
message(STATUS "=== YAZE Dependencies Summary ===")
|
||||
message(STATUS "Total dependencies: ${YAZE_ALL_DEPENDENCIES}")
|
||||
message(STATUS "SDL2: ${YAZE_SDL2_TARGETS}")
|
||||
message(STATUS "YAML: ${YAZE_YAML_TARGETS}")
|
||||
message(STATUS "ImGui: ${YAZE_IMGUI_TARGETS}")
|
||||
if(YAZE_ENABLE_JSON)
|
||||
message(STATUS "JSON: ${YAZE_JSON_TARGETS}")
|
||||
endif()
|
||||
if(YAZE_ENABLE_GRPC)
|
||||
message(STATUS "gRPC: ${YAZE_GRPC_TARGETS}")
|
||||
endif()
|
||||
if(YAZE_BUILD_CLI)
|
||||
message(STATUS "FTXUI: ${YAZE_FTXUI_TARGETS}")
|
||||
endif()
|
||||
if(YAZE_BUILD_TESTS)
|
||||
include(cmake/gtest.cmake)
|
||||
message(STATUS "Testing: ${YAZE_TESTING_TARGETS}")
|
||||
endif()
|
||||
message(STATUS "=================================")
|
||||
|
||||
# ImGui
|
||||
include(cmake/imgui.cmake)
|
||||
|
||||
# FTXUI (for z3ed)
|
||||
if(YAZE_BUILD_Z3ED)
|
||||
FetchContent_Declare(ftxui
|
||||
GIT_REPOSITORY https://github.com/ArthurSonzogni/ftxui
|
||||
GIT_TAG v5.0.0
|
||||
)
|
||||
FetchContent_MakeAvailable(ftxui)
|
||||
endif()
|
||||
|
||||
# yaml-cpp (always available for configuration files)
|
||||
set(YAML_CPP_BUILD_TESTS OFF CACHE BOOL "Disable yaml-cpp tests" FORCE)
|
||||
set(YAML_CPP_BUILD_CONTRIB OFF CACHE BOOL "Disable yaml-cpp contrib" FORCE)
|
||||
set(YAML_CPP_BUILD_TOOLS OFF CACHE BOOL "Disable yaml-cpp tools" FORCE)
|
||||
set(YAML_CPP_INSTALL OFF CACHE BOOL "Disable yaml-cpp install" FORCE)
|
||||
set(YAML_CPP_FORMAT_SOURCE OFF CACHE BOOL "Disable yaml-cpp format target" FORCE)
|
||||
|
||||
# yaml-cpp (uses CMAKE_POLICY_VERSION_MINIMUM set in root CMakeLists.txt)
|
||||
FetchContent_Declare(yaml-cpp
|
||||
GIT_REPOSITORY https://github.com/jbeder/yaml-cpp.git
|
||||
GIT_TAG 0.8.0
|
||||
)
|
||||
FetchContent_MakeAvailable(yaml-cpp)
|
||||
|
||||
# Fix MSVC exception handling warning for yaml-cpp
|
||||
if(MSVC AND TARGET yaml-cpp)
|
||||
target_compile_options(yaml-cpp PRIVATE /EHsc)
|
||||
endif()
|
||||
|
||||
# nlohmann_json (header only)
|
||||
if(YAZE_WITH_JSON)
|
||||
set(JSON_BuildTests OFF CACHE INTERNAL "Disable nlohmann_json tests")
|
||||
add_subdirectory(${CMAKE_SOURCE_DIR}/third_party/json ${CMAKE_BINARY_DIR}/third_party/json EXCLUDE_FROM_ALL)
|
||||
endif()
|
||||
|
||||
# httplib (header only)
|
||||
# No action needed here as it's included directly.
|
||||
# Export all dependency targets for use in other CMake files
|
||||
set(YAZE_ALL_DEPENDENCIES ${YAZE_ALL_DEPENDENCIES})
|
||||
Reference in New Issue
Block a user