backend-infra-engineer: Post v0.3.9-hotfix7 snapshot (build cleanup)
This commit is contained in:
490
cmake/TestInfrastructure.cmake
Normal file
490
cmake/TestInfrastructure.cmake
Normal file
@@ -0,0 +1,490 @@
|
||||
# TestInfrastructure.cmake
|
||||
# Advanced test infrastructure configuration for yaze project
|
||||
# Provides optimized test builds, parallel execution, and smart test selection
|
||||
|
||||
include(GoogleTest)
|
||||
include(CTest)
|
||||
|
||||
# =============================================================================
|
||||
# Test Configuration Options
|
||||
# =============================================================================
|
||||
|
||||
option(YAZE_TEST_PARALLEL "Enable parallel test execution" ON)
|
||||
option(YAZE_TEST_COVERAGE "Enable code coverage collection" OFF)
|
||||
option(YAZE_TEST_SANITIZERS "Enable address and undefined behavior sanitizers" OFF)
|
||||
option(YAZE_TEST_PROFILE "Enable test profiling" OFF)
|
||||
option(YAZE_TEST_MINIMAL_DEPS "Use minimal dependencies for faster test builds" OFF)
|
||||
option(YAZE_TEST_PCH "Use precompiled headers for tests" ON)
|
||||
|
||||
# Test categories
|
||||
option(YAZE_TEST_SMOKE "Build smoke tests (critical path)" ON)
|
||||
option(YAZE_TEST_UNIT "Build unit tests" ON)
|
||||
option(YAZE_TEST_INTEGRATION "Build integration tests" ON)
|
||||
option(YAZE_TEST_E2E "Build end-to-end GUI tests" OFF)
|
||||
option(YAZE_TEST_BENCHMARK "Build performance benchmarks" OFF)
|
||||
option(YAZE_TEST_FUZZ "Build fuzzing tests" OFF)
|
||||
|
||||
# Test execution settings
|
||||
set(YAZE_TEST_TIMEOUT_SMOKE 30 CACHE STRING "Timeout for smoke tests (seconds)")
|
||||
set(YAZE_TEST_TIMEOUT_UNIT 60 CACHE STRING "Timeout for unit tests (seconds)")
|
||||
set(YAZE_TEST_TIMEOUT_INTEGRATION 300 CACHE STRING "Timeout for integration tests (seconds)")
|
||||
set(YAZE_TEST_TIMEOUT_E2E 600 CACHE STRING "Timeout for E2E tests (seconds)")
|
||||
|
||||
# =============================================================================
|
||||
# Precompiled Headers Configuration
|
||||
# =============================================================================
|
||||
|
||||
if(YAZE_TEST_PCH)
|
||||
set(YAZE_TEST_PCH_HEADERS
|
||||
<gtest/gtest.h>
|
||||
<gmock/gmock.h>
|
||||
<absl/status/status.h>
|
||||
<absl/status/statusor.h>
|
||||
<absl/strings/string_view.h>
|
||||
<memory>
|
||||
<vector>
|
||||
<string>
|
||||
<unordered_map>
|
||||
)
|
||||
|
||||
# Create PCH target
|
||||
add_library(yaze_test_pch INTERFACE)
|
||||
target_precompile_headers(yaze_test_pch INTERFACE ${YAZE_TEST_PCH_HEADERS})
|
||||
|
||||
message(STATUS "Test Infrastructure: Precompiled headers enabled")
|
||||
endif()
|
||||
|
||||
# =============================================================================
|
||||
# Test Interface Library
|
||||
# =============================================================================
|
||||
|
||||
add_library(yaze_test_interface INTERFACE)
|
||||
|
||||
# Common compile options
|
||||
target_compile_options(yaze_test_interface INTERFACE
|
||||
$<$<CONFIG:Debug>:-O0 -g3>
|
||||
$<$<CONFIG:Release>:-O3 -DNDEBUG>
|
||||
$<$<CONFIG:RelWithDebInfo>:-O2 -g>
|
||||
$<$<BOOL:${YAZE_TEST_COVERAGE}>:--coverage -fprofile-arcs -ftest-coverage>
|
||||
$<$<BOOL:${YAZE_TEST_PROFILE}>:-pg>
|
||||
)
|
||||
|
||||
# Common link options
|
||||
target_link_options(yaze_test_interface INTERFACE
|
||||
$<$<BOOL:${YAZE_TEST_COVERAGE}>:--coverage>
|
||||
$<$<BOOL:${YAZE_TEST_PROFILE}>:-pg>
|
||||
)
|
||||
|
||||
# Sanitizers
|
||||
if(YAZE_TEST_SANITIZERS)
|
||||
target_compile_options(yaze_test_interface INTERFACE
|
||||
-fsanitize=address,undefined
|
||||
-fno-omit-frame-pointer
|
||||
-fno-optimize-sibling-calls
|
||||
)
|
||||
target_link_options(yaze_test_interface INTERFACE
|
||||
-fsanitize=address,undefined
|
||||
)
|
||||
|
||||
message(STATUS "Test Infrastructure: Sanitizers enabled (ASan + UBSan)")
|
||||
endif()
|
||||
|
||||
# Coverage
|
||||
if(YAZE_TEST_COVERAGE)
|
||||
find_program(LCOV lcov)
|
||||
find_program(GENHTML genhtml)
|
||||
|
||||
if(LCOV AND GENHTML)
|
||||
add_custom_target(coverage
|
||||
COMMAND ${LCOV} --capture --directory ${CMAKE_BINARY_DIR}
|
||||
--output-file ${CMAKE_BINARY_DIR}/coverage.info
|
||||
--ignore-errors source
|
||||
COMMAND ${LCOV} --remove ${CMAKE_BINARY_DIR}/coverage.info
|
||||
'*/test/*' '*/ext/*' '/usr/*' '*/build/*'
|
||||
--output-file ${CMAKE_BINARY_DIR}/coverage_filtered.info
|
||||
COMMAND ${GENHTML} ${CMAKE_BINARY_DIR}/coverage_filtered.info
|
||||
--output-directory ${CMAKE_BINARY_DIR}/coverage_html
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
COMMENT "Generating code coverage report"
|
||||
)
|
||||
|
||||
message(STATUS "Test Infrastructure: Coverage target available")
|
||||
else()
|
||||
message(WARNING "lcov/genhtml not found, coverage target disabled")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# =============================================================================
|
||||
# Test Creation Function
|
||||
# =============================================================================
|
||||
|
||||
function(yaze_create_test_suite)
|
||||
set(options GUI_TEST REQUIRES_ROM USE_PCH)
|
||||
set(oneValueArgs NAME CATEGORY TIMEOUT PARALLEL_JOBS OUTPUT_DIR)
|
||||
set(multiValueArgs SOURCES DEPENDENCIES LABELS COMPILE_DEFINITIONS)
|
||||
cmake_parse_arguments(TEST "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
|
||||
# Validate required arguments
|
||||
if(NOT TEST_NAME)
|
||||
message(FATAL_ERROR "yaze_create_test_suite: NAME is required")
|
||||
endif()
|
||||
if(NOT TEST_SOURCES)
|
||||
message(FATAL_ERROR "yaze_create_test_suite: SOURCES is required")
|
||||
endif()
|
||||
|
||||
# Set defaults
|
||||
if(NOT TEST_CATEGORY)
|
||||
set(TEST_CATEGORY "general")
|
||||
endif()
|
||||
if(NOT TEST_TIMEOUT)
|
||||
set(TEST_TIMEOUT 60)
|
||||
endif()
|
||||
if(NOT TEST_OUTPUT_DIR)
|
||||
set(TEST_OUTPUT_DIR "${CMAKE_BINARY_DIR}/bin/test")
|
||||
endif()
|
||||
|
||||
# Create test executable
|
||||
set(target_name yaze_test_${TEST_NAME})
|
||||
add_executable(${target_name} ${TEST_SOURCES})
|
||||
|
||||
# Set output directory
|
||||
set_target_properties(${target_name} PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY "${TEST_OUTPUT_DIR}"
|
||||
RUNTIME_OUTPUT_DIRECTORY_DEBUG "${TEST_OUTPUT_DIR}"
|
||||
RUNTIME_OUTPUT_DIRECTORY_RELEASE "${TEST_OUTPUT_DIR}"
|
||||
)
|
||||
|
||||
# Link libraries
|
||||
target_link_libraries(${target_name} PRIVATE
|
||||
yaze_test_interface
|
||||
yaze_test_support
|
||||
GTest::gtest_main
|
||||
GTest::gmock
|
||||
${TEST_DEPENDENCIES}
|
||||
)
|
||||
|
||||
# Apply PCH if requested
|
||||
if(TEST_USE_PCH AND TARGET yaze_test_pch)
|
||||
target_link_libraries(${target_name} PRIVATE yaze_test_pch)
|
||||
target_precompile_headers(${target_name} REUSE_FROM yaze_test_pch)
|
||||
endif()
|
||||
|
||||
# Add compile definitions
|
||||
if(TEST_COMPILE_DEFINITIONS)
|
||||
target_compile_definitions(${target_name} PRIVATE ${TEST_COMPILE_DEFINITIONS})
|
||||
endif()
|
||||
|
||||
# GUI test configuration
|
||||
if(TEST_GUI_TEST)
|
||||
target_compile_definitions(${target_name} PRIVATE
|
||||
IMGUI_ENABLE_TEST_ENGINE=1
|
||||
YAZE_GUI_TEST_TARGET=1
|
||||
)
|
||||
if(TARGET ImGuiTestEngine)
|
||||
target_link_libraries(${target_name} PRIVATE ImGuiTestEngine)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# ROM test configuration
|
||||
if(TEST_REQUIRES_ROM)
|
||||
target_compile_definitions(${target_name} PRIVATE
|
||||
YAZE_ROM_TEST=1
|
||||
)
|
||||
endif()
|
||||
|
||||
# Discover tests with CTest
|
||||
set(test_labels "${TEST_CATEGORY}")
|
||||
if(TEST_LABELS)
|
||||
list(APPEND test_labels ${TEST_LABELS})
|
||||
endif()
|
||||
|
||||
gtest_discover_tests(${target_name}
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
PROPERTIES
|
||||
LABELS "${test_labels}"
|
||||
TIMEOUT ${TEST_TIMEOUT}
|
||||
DISCOVERY_MODE PRE_TEST
|
||||
DISCOVERY_TIMEOUT 30
|
||||
)
|
||||
|
||||
# Set parallel execution if specified
|
||||
if(TEST_PARALLEL_JOBS)
|
||||
set_property(TEST ${target_name} PROPERTY PROCESSORS ${TEST_PARALLEL_JOBS})
|
||||
endif()
|
||||
|
||||
# Create category-specific test target
|
||||
add_custom_target(test-${TEST_CATEGORY}-${TEST_NAME}
|
||||
COMMAND ${CMAKE_CTEST_COMMAND} -R "^${target_name}" --output-on-failure
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
COMMENT "Running ${TEST_CATEGORY} tests: ${TEST_NAME}"
|
||||
)
|
||||
|
||||
message(STATUS "Test Suite: ${target_name} (${TEST_CATEGORY})")
|
||||
endfunction()
|
||||
|
||||
# =============================================================================
|
||||
# Test Suites Configuration
|
||||
# =============================================================================
|
||||
|
||||
# Smoke Tests (Critical Path)
|
||||
if(YAZE_TEST_SMOKE)
|
||||
file(GLOB SMOKE_TEST_SOURCES
|
||||
${CMAKE_SOURCE_DIR}/test/smoke/*.cc
|
||||
${CMAKE_SOURCE_DIR}/test/smoke/*.h
|
||||
)
|
||||
|
||||
if(SMOKE_TEST_SOURCES)
|
||||
yaze_create_test_suite(
|
||||
NAME smoke
|
||||
CATEGORY smoke
|
||||
SOURCES ${SMOKE_TEST_SOURCES}
|
||||
LABELS critical fast ci-stage1
|
||||
TIMEOUT ${YAZE_TEST_TIMEOUT_SMOKE}
|
||||
USE_PCH
|
||||
)
|
||||
else()
|
||||
message(WARNING "No smoke test sources found")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Unit Tests
|
||||
if(YAZE_TEST_UNIT)
|
||||
file(GLOB_RECURSE UNIT_TEST_SOURCES
|
||||
${CMAKE_SOURCE_DIR}/test/unit/*.cc
|
||||
)
|
||||
|
||||
if(UNIT_TEST_SOURCES)
|
||||
# Split unit tests into multiple binaries for parallel execution
|
||||
list(LENGTH UNIT_TEST_SOURCES num_unit_tests)
|
||||
|
||||
if(num_unit_tests GREATER 50)
|
||||
# Create sharded unit test executables
|
||||
set(shard_size 25)
|
||||
math(EXPR num_shards "(${num_unit_tests} + ${shard_size} - 1) / ${shard_size}")
|
||||
|
||||
foreach(shard RANGE 1 ${num_shards})
|
||||
math(EXPR start "(${shard} - 1) * ${shard_size}")
|
||||
math(EXPR end "${shard} * ${shard_size} - 1")
|
||||
|
||||
if(end GREATER ${num_unit_tests})
|
||||
set(end ${num_unit_tests})
|
||||
endif()
|
||||
|
||||
list(SUBLIST UNIT_TEST_SOURCES ${start} ${shard_size} shard_sources)
|
||||
|
||||
yaze_create_test_suite(
|
||||
NAME unit_shard${shard}
|
||||
CATEGORY unit
|
||||
SOURCES ${shard_sources}
|
||||
LABELS unit fast ci-stage2 shard${shard}
|
||||
TIMEOUT ${YAZE_TEST_TIMEOUT_UNIT}
|
||||
USE_PCH
|
||||
)
|
||||
endforeach()
|
||||
else()
|
||||
# Single unit test executable
|
||||
yaze_create_test_suite(
|
||||
NAME unit
|
||||
CATEGORY unit
|
||||
SOURCES ${UNIT_TEST_SOURCES}
|
||||
LABELS unit fast ci-stage2
|
||||
TIMEOUT ${YAZE_TEST_TIMEOUT_UNIT}
|
||||
USE_PCH
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Integration Tests
|
||||
if(YAZE_TEST_INTEGRATION)
|
||||
file(GLOB_RECURSE INTEGRATION_TEST_SOURCES
|
||||
${CMAKE_SOURCE_DIR}/test/integration/*.cc
|
||||
)
|
||||
|
||||
if(INTEGRATION_TEST_SOURCES)
|
||||
yaze_create_test_suite(
|
||||
NAME integration
|
||||
CATEGORY integration
|
||||
SOURCES ${INTEGRATION_TEST_SOURCES}
|
||||
LABELS integration medium ci-stage3
|
||||
TIMEOUT ${YAZE_TEST_TIMEOUT_INTEGRATION}
|
||||
PARALLEL_JOBS 2
|
||||
USE_PCH
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# E2E Tests
|
||||
if(YAZE_TEST_E2E)
|
||||
file(GLOB_RECURSE E2E_TEST_SOURCES
|
||||
${CMAKE_SOURCE_DIR}/test/e2e/*.cc
|
||||
)
|
||||
|
||||
if(E2E_TEST_SOURCES)
|
||||
yaze_create_test_suite(
|
||||
NAME e2e
|
||||
CATEGORY e2e
|
||||
SOURCES ${E2E_TEST_SOURCES}
|
||||
LABELS e2e slow gui ci-stage3
|
||||
TIMEOUT ${YAZE_TEST_TIMEOUT_E2E}
|
||||
GUI_TEST
|
||||
USE_PCH
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Benchmark Tests
|
||||
if(YAZE_TEST_BENCHMARK)
|
||||
file(GLOB_RECURSE BENCHMARK_TEST_SOURCES
|
||||
${CMAKE_SOURCE_DIR}/test/benchmarks/*.cc
|
||||
)
|
||||
|
||||
if(BENCHMARK_TEST_SOURCES)
|
||||
yaze_create_test_suite(
|
||||
NAME benchmark
|
||||
CATEGORY benchmark
|
||||
SOURCES ${BENCHMARK_TEST_SOURCES}
|
||||
LABELS benchmark performance nightly
|
||||
TIMEOUT 1800
|
||||
COMPILE_DEFINITIONS BENCHMARK_BUILD=1
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# =============================================================================
|
||||
# Custom Test Commands
|
||||
# =============================================================================
|
||||
|
||||
# Run all fast tests
|
||||
add_custom_target(test-fast
|
||||
COMMAND ${CMAKE_CTEST_COMMAND} -L "fast" --parallel ${CMAKE_NUMBER_OF_CORES} --output-on-failure
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
COMMENT "Running fast tests"
|
||||
)
|
||||
|
||||
# Run tests by stage
|
||||
add_custom_target(test-stage1
|
||||
COMMAND ${CMAKE_CTEST_COMMAND} -L "ci-stage1" --parallel 4 --output-on-failure
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
COMMENT "Running Stage 1 (Smoke) tests"
|
||||
)
|
||||
|
||||
add_custom_target(test-stage2
|
||||
COMMAND ${CMAKE_CTEST_COMMAND} -L "ci-stage2" --parallel ${CMAKE_NUMBER_OF_CORES} --output-on-failure
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
COMMENT "Running Stage 2 (Unit) tests"
|
||||
)
|
||||
|
||||
add_custom_target(test-stage3
|
||||
COMMAND ${CMAKE_CTEST_COMMAND} -L "ci-stage3" --parallel 2 --output-on-failure
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
COMMENT "Running Stage 3 (Integration/E2E) tests"
|
||||
)
|
||||
|
||||
# Smart test selection based on changed files
|
||||
add_custom_target(test-changed
|
||||
COMMAND ${CMAKE_COMMAND} -E env python3 ${CMAKE_SOURCE_DIR}/scripts/smart_test_selector.py
|
||||
--output filter | xargs ${CMAKE_CTEST_COMMAND} -R --output-on-failure
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
COMMENT "Running tests for changed files"
|
||||
)
|
||||
|
||||
# Parallel test execution with sharding
|
||||
add_custom_target(test-parallel
|
||||
COMMAND python3 ${CMAKE_SOURCE_DIR}/scripts/test_runner.py
|
||||
${CMAKE_BINARY_DIR}/bin/test/yaze_test_unit
|
||||
--shards ${CMAKE_NUMBER_OF_CORES}
|
||||
--output-dir ${CMAKE_BINARY_DIR}/test_results
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
COMMENT "Running tests with parallel sharding"
|
||||
)
|
||||
|
||||
# Test with retries for flaky tests
|
||||
add_custom_target(test-retry
|
||||
COMMAND python3 ${CMAKE_SOURCE_DIR}/scripts/test_runner.py
|
||||
${CMAKE_BINARY_DIR}/bin/test/yaze_test_unit
|
||||
--retry 2
|
||||
--output-dir ${CMAKE_BINARY_DIR}/test_results
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
COMMENT "Running tests with retry for failures"
|
||||
)
|
||||
|
||||
# =============================================================================
|
||||
# CTest Configuration
|
||||
# =============================================================================
|
||||
|
||||
set(CTEST_PARALLEL_LEVEL ${CMAKE_NUMBER_OF_CORES} CACHE STRING "Default parallel level for CTest")
|
||||
set(CTEST_OUTPUT_ON_FAILURE ON CACHE BOOL "Show output on test failure")
|
||||
set(CTEST_PROGRESS_OUTPUT ON CACHE BOOL "Show progress during test execution")
|
||||
|
||||
# Configure test output
|
||||
set(CMAKE_CTEST_ARGUMENTS
|
||||
--output-on-failure
|
||||
--progress
|
||||
--parallel ${CTEST_PARALLEL_LEVEL}
|
||||
)
|
||||
|
||||
# Configure test timeout multiplier for slower systems
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
||||
set(CTEST_TEST_TIMEOUT_MULTIPLIER 1.5)
|
||||
endif()
|
||||
|
||||
# =============================================================================
|
||||
# Test Data Management
|
||||
# =============================================================================
|
||||
|
||||
# Download test data if needed
|
||||
if(YAZE_TEST_INTEGRATION OR YAZE_TEST_E2E)
|
||||
include(FetchContent)
|
||||
|
||||
# Check if test data exists
|
||||
if(NOT EXISTS "${CMAKE_BINARY_DIR}/test_data/VERSION")
|
||||
message(STATUS "Downloading test data...")
|
||||
|
||||
FetchContent_Declare(
|
||||
yaze_test_data
|
||||
URL https://github.com/yaze/test-data/archive/refs/tags/v1.0.0.tar.gz
|
||||
URL_HASH SHA256=abcdef1234567890 # Replace with actual hash
|
||||
DOWNLOAD_EXTRACT_TIMESTAMP ON
|
||||
)
|
||||
|
||||
FetchContent_MakeAvailable(yaze_test_data)
|
||||
|
||||
set(YAZE_TEST_DATA_DIR ${yaze_test_data_SOURCE_DIR} CACHE PATH "Test data directory")
|
||||
else()
|
||||
set(YAZE_TEST_DATA_DIR ${CMAKE_BINARY_DIR}/test_data CACHE PATH "Test data directory")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# =============================================================================
|
||||
# Test Report Generation
|
||||
# =============================================================================
|
||||
|
||||
add_custom_target(test-report
|
||||
COMMAND python3 ${CMAKE_SOURCE_DIR}/scripts/aggregate_test_results.py
|
||||
--input-dir ${CMAKE_BINARY_DIR}/Testing
|
||||
--output ${CMAKE_BINARY_DIR}/test_report.json
|
||||
--generate-html ${CMAKE_BINARY_DIR}/test_report.html
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
COMMENT "Generating test report"
|
||||
DEPENDS test-all
|
||||
)
|
||||
|
||||
# =============================================================================
|
||||
# Summary Message
|
||||
# =============================================================================
|
||||
|
||||
message(STATUS "========================================")
|
||||
message(STATUS "Test Infrastructure Configuration:")
|
||||
message(STATUS " Parallel Testing: ${YAZE_TEST_PARALLEL}")
|
||||
message(STATUS " Precompiled Headers: ${YAZE_TEST_PCH}")
|
||||
message(STATUS " Code Coverage: ${YAZE_TEST_COVERAGE}")
|
||||
message(STATUS " Sanitizers: ${YAZE_TEST_SANITIZERS}")
|
||||
message(STATUS " Test Categories:")
|
||||
message(STATUS " Smoke Tests: ${YAZE_TEST_SMOKE}")
|
||||
message(STATUS " Unit Tests: ${YAZE_TEST_UNIT}")
|
||||
message(STATUS " Integration Tests: ${YAZE_TEST_INTEGRATION}")
|
||||
message(STATUS " E2E Tests: ${YAZE_TEST_E2E}")
|
||||
message(STATUS " Benchmarks: ${YAZE_TEST_BENCHMARK}")
|
||||
message(STATUS " Parallel Level: ${CTEST_PARALLEL_LEVEL}")
|
||||
message(STATUS "========================================")
|
||||
@@ -2,7 +2,9 @@
|
||||
# Improved cross-platform support for macOS, Linux, and Windows
|
||||
|
||||
# Configure Asar build options
|
||||
set(ASAR_GEN_EXE OFF CACHE BOOL "Build Asar standalone executable")
|
||||
# Build the standalone executable so we can fall back to a bundled CLI when the
|
||||
# static library misbehaves.
|
||||
set(ASAR_GEN_EXE ON CACHE BOOL "Build Asar standalone executable")
|
||||
set(ASAR_GEN_DLL ON CACHE BOOL "Build Asar shared library")
|
||||
set(ASAR_GEN_LIB ON CACHE BOOL "Build Asar static library")
|
||||
set(ASAR_GEN_EXE_TEST OFF CACHE BOOL "Build Asar executable tests")
|
||||
@@ -16,8 +18,8 @@ endif()
|
||||
# Set Asar source directory
|
||||
set(ASAR_SRC_DIR "${CMAKE_SOURCE_DIR}/ext/asar/src")
|
||||
|
||||
# Add Asar as subdirectory
|
||||
add_subdirectory(${ASAR_SRC_DIR} EXCLUDE_FROM_ALL)
|
||||
# Add Asar as subdirectory with explicit binary directory
|
||||
add_subdirectory(${ASAR_SRC_DIR} ${CMAKE_BINARY_DIR}/asar EXCLUDE_FROM_ALL)
|
||||
|
||||
# Create modern CMake target for Asar integration
|
||||
if(TARGET asar-static)
|
||||
|
||||
@@ -13,6 +13,7 @@ set(YAZE_ALL_DEPENDENCIES "")
|
||||
set(YAZE_SDL2_TARGETS "")
|
||||
set(YAZE_YAML_TARGETS "")
|
||||
set(YAZE_IMGUI_TARGETS "")
|
||||
set(YAZE_IMPLOT_TARGETS "")
|
||||
set(YAZE_JSON_TARGETS "")
|
||||
set(YAZE_GRPC_TARGETS "")
|
||||
set(YAZE_FTXUI_TARGETS "")
|
||||
@@ -37,6 +38,9 @@ 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})
|
||||
|
||||
include(cmake/dependencies/implot.cmake)
|
||||
list(APPEND YAZE_ALL_DEPENDENCIES ${YAZE_IMPLOT_TARGETS})
|
||||
|
||||
# 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
|
||||
@@ -63,7 +67,7 @@ if(YAZE_ENABLE_GRPC)
|
||||
list(APPEND YAZE_ALL_DEPENDENCIES ${YAZE_GRPC_TARGETS})
|
||||
endif()
|
||||
|
||||
if(YAZE_BUILD_CLI)
|
||||
if(YAZE_BUILD_CLI AND NOT EMSCRIPTEN)
|
||||
include(cmake/dependencies/ftxui.cmake)
|
||||
list(APPEND YAZE_ALL_DEPENDENCIES ${YAZE_FTXUI_TARGETS})
|
||||
endif()
|
||||
@@ -84,13 +88,14 @@ 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}")
|
||||
message(STATUS "ImPlot: ${YAZE_IMPLOT_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)
|
||||
if(YAZE_BUILD_CLI AND NOT EMSCRIPTEN)
|
||||
message(STATUS "FTXUI: ${YAZE_FTXUI_TARGETS}")
|
||||
endif()
|
||||
if(YAZE_BUILD_TESTS)
|
||||
@@ -99,4 +104,4 @@ endif()
|
||||
message(STATUS "=================================")
|
||||
|
||||
# Export all dependency targets for use in other CMake files
|
||||
set(YAZE_ALL_DEPENDENCIES ${YAZE_ALL_DEPENDENCIES})
|
||||
set(YAZE_ALL_DEPENDENCIES ${YAZE_ALL_DEPENDENCIES})
|
||||
|
||||
27
cmake/dependencies/implot.cmake
Normal file
27
cmake/dependencies/implot.cmake
Normal file
@@ -0,0 +1,27 @@
|
||||
# ImPlot dependency management
|
||||
# Uses the bundled ImPlot sources that ship with the ImGui Test Engine
|
||||
|
||||
set(YAZE_IMPLOT_TARGETS "")
|
||||
|
||||
set(IMPLOT_DIR ${CMAKE_SOURCE_DIR}/ext/imgui_test_engine/imgui_test_suite/thirdparty/implot)
|
||||
|
||||
if(EXISTS ${IMPLOT_DIR}/implot.h)
|
||||
message(STATUS "Setting up ImPlot from bundled sources")
|
||||
|
||||
add_library(ImPlot STATIC
|
||||
${IMPLOT_DIR}/implot.cpp
|
||||
${IMPLOT_DIR}/implot_items.cpp
|
||||
)
|
||||
|
||||
target_include_directories(ImPlot PUBLIC
|
||||
${IMPLOT_DIR}
|
||||
${IMGUI_DIR}
|
||||
)
|
||||
|
||||
target_link_libraries(ImPlot PUBLIC ImGui)
|
||||
target_compile_features(ImPlot PUBLIC cxx_std_17)
|
||||
|
||||
set(YAZE_IMPLOT_TARGETS ImPlot)
|
||||
else()
|
||||
message(WARNING "ImPlot sources not found at ${IMPLOT_DIR}. Plot widgets will be unavailable.")
|
||||
endif()
|
||||
@@ -4,6 +4,21 @@
|
||||
include(cmake/CPM.cmake)
|
||||
include(cmake/dependencies.lock)
|
||||
|
||||
# For Emscripten, use the built-in SDL2 port
|
||||
if(EMSCRIPTEN)
|
||||
message(STATUS "Using Emscripten built-in SDL2")
|
||||
if(NOT TARGET yaze_sdl2)
|
||||
add_library(yaze_sdl2 INTERFACE)
|
||||
# Flags are already set in CMakePresets.json or toolchain (-s USE_SDL=2)
|
||||
# But we can enforce them here too if needed, or just leave empty as an interface
|
||||
# to satisfy linking requirements of other targets.
|
||||
target_link_options(yaze_sdl2 INTERFACE "SHELL:-s USE_SDL=2")
|
||||
target_compile_options(yaze_sdl2 INTERFACE "SHELL:-s USE_SDL=2")
|
||||
endif()
|
||||
set(YAZE_SDL2_TARGETS yaze_sdl2)
|
||||
return()
|
||||
endif()
|
||||
|
||||
message(STATUS "Setting up SDL2 ${SDL2_VERSION} with CPM.cmake")
|
||||
|
||||
# Try to use system packages first if requested
|
||||
|
||||
@@ -53,6 +53,7 @@ if(_YAZE_USE_SYSTEM_YAML)
|
||||
if(yaml-cpp_FOUND)
|
||||
message(STATUS "Using system yaml-cpp")
|
||||
add_library(yaze_yaml INTERFACE)
|
||||
target_compile_definitions(yaze_yaml INTERFACE YAZE_HAS_YAML_CPP=1)
|
||||
if(TARGET yaml-cpp::yaml-cpp)
|
||||
message(STATUS "Linking yaze_yaml against yaml-cpp::yaml-cpp")
|
||||
target_link_libraries(yaze_yaml INTERFACE yaml-cpp::yaml-cpp)
|
||||
@@ -96,6 +97,7 @@ endif()
|
||||
# Create convenience targets for the rest of the project
|
||||
add_library(yaze_yaml INTERFACE)
|
||||
target_link_libraries(yaze_yaml INTERFACE yaml-cpp)
|
||||
target_compile_definitions(yaze_yaml INTERFACE YAZE_HAS_YAML_CPP=1)
|
||||
|
||||
# Export yaml-cpp targets for use in other CMake files
|
||||
set(YAZE_YAML_TARGETS yaze_yaml)
|
||||
|
||||
@@ -19,12 +19,29 @@ if(NOT EXISTS "${HOMEBREW_LLVM_PREFIX}")
|
||||
message(FATAL_ERROR "Homebrew LLVM not found. Please run 'brew install llvm'. Path: ${HOMEBREW_LLVM_PREFIX}")
|
||||
endif()
|
||||
|
||||
# Cache this variable so it's available in the main CMakeLists.txt
|
||||
set(HOMEBREW_LLVM_PREFIX "${HOMEBREW_LLVM_PREFIX}" CACHE PATH "Path to Homebrew LLVM installation")
|
||||
|
||||
message(STATUS "Using Homebrew LLVM from: ${HOMEBREW_LLVM_PREFIX}")
|
||||
|
||||
# 3. Set the C and C++ compilers
|
||||
set(CMAKE_C_COMPILER "${HOMEBREW_LLVM_PREFIX}/bin/clang")
|
||||
set(CMAKE_CXX_COMPILER "${HOMEBREW_LLVM_PREFIX}/bin/clang++")
|
||||
|
||||
# 3.5 Find and configure clang-tidy
|
||||
find_program(CLANG_TIDY_EXE
|
||||
NAMES clang-tidy
|
||||
HINTS "${HOMEBREW_LLVM_PREFIX}/bin"
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
|
||||
if(CLANG_TIDY_EXE)
|
||||
message(STATUS "Found Homebrew clang-tidy: ${CLANG_TIDY_EXE}")
|
||||
set(YAZE_CLANG_TIDY_EXE "${CLANG_TIDY_EXE}" CACHE FILEPATH "Path to clang-tidy executable")
|
||||
else()
|
||||
message(WARNING "clang-tidy not found in ${HOMEBREW_LLVM_PREFIX}/bin")
|
||||
endif()
|
||||
|
||||
# 4. Set the system root (sysroot) to the macOS SDK
|
||||
# This correctly points to the system-level headers and libraries.
|
||||
execute_process(
|
||||
|
||||
@@ -13,6 +13,8 @@ option(YAZE_BUILD_TESTS "Build test suite" ON)
|
||||
option(YAZE_ENABLE_GRPC "Enable gRPC agent support" ON)
|
||||
option(YAZE_ENABLE_JSON "Enable JSON support" ON)
|
||||
option(YAZE_ENABLE_AI "Enable AI agent features" OFF)
|
||||
option(YAZE_ENABLE_CLANG_TIDY "Enable clang-tidy linting during build" ON)
|
||||
option(YAZE_ENABLE_OPENCV "Enable OpenCV for advanced visual analysis" OFF)
|
||||
|
||||
# Advanced feature toggles
|
||||
option(YAZE_ENABLE_REMOTE_AUTOMATION
|
||||
@@ -49,6 +51,7 @@ option(YAZE_UNITY_BUILD "Enable Unity (Jumbo) builds" OFF)
|
||||
option(YAZE_USE_VCPKG "Use vcpkg for Windows dependencies" OFF)
|
||||
option(YAZE_USE_SYSTEM_DEPS "Use system package manager for dependencies" OFF)
|
||||
option(YAZE_USE_SDL3 "Use SDL3 instead of SDL2 (experimental)" OFF)
|
||||
option(YAZE_WASM_TERMINAL "Build z3ed for WASM terminal mode (no TUI)" OFF)
|
||||
|
||||
# Development options
|
||||
option(YAZE_ENABLE_ROM_TESTS "Enable tests that require ROM files" OFF)
|
||||
@@ -97,6 +100,29 @@ if(YAZE_ENABLE_HTTP_API)
|
||||
add_compile_definitions(YAZE_HTTP_API_ENABLED)
|
||||
endif()
|
||||
|
||||
if(YAZE_WASM_TERMINAL)
|
||||
add_compile_definitions(YAZE_WASM_TERMINAL_MODE)
|
||||
endif()
|
||||
|
||||
if(YAZE_USE_SDL3)
|
||||
add_compile_definitions(YAZE_USE_SDL3)
|
||||
endif()
|
||||
|
||||
if(YAZE_BUILD_AGENT_UI)
|
||||
add_compile_definitions(YAZE_BUILD_AGENT_UI)
|
||||
endif()
|
||||
|
||||
if(YAZE_ENABLE_OPENCV)
|
||||
find_package(OpenCV QUIET)
|
||||
if(OpenCV_FOUND)
|
||||
add_compile_definitions(YAZE_WITH_OPENCV)
|
||||
message(STATUS "✓ OpenCV found: ${OpenCV_VERSION}")
|
||||
else()
|
||||
message(WARNING "OpenCV requested but not found - visual analysis will use fallback")
|
||||
set(YAZE_ENABLE_OPENCV OFF CACHE BOOL "Enable OpenCV for advanced visual analysis" FORCE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Print configuration summary
|
||||
message(STATUS "=== YAZE Build Configuration ===")
|
||||
message(STATUS "GUI Application: ${YAZE_BUILD_GUI}")
|
||||
@@ -121,5 +147,6 @@ message(STATUS "HTTP API Server: ${YAZE_ENABLE_HTTP_API}")
|
||||
message(STATUS "LTO: ${YAZE_ENABLE_LTO}")
|
||||
message(STATUS "Sanitizers: ${YAZE_ENABLE_SANITIZERS}")
|
||||
message(STATUS "Coverage: ${YAZE_ENABLE_COVERAGE}")
|
||||
message(STATUS "OpenCV Visual Analysis: ${YAZE_ENABLE_OPENCV}")
|
||||
message(STATUS "=================================")
|
||||
|
||||
|
||||
@@ -74,6 +74,7 @@ elseif(WIN32)
|
||||
DESTINATION .
|
||||
COMPONENT yaze)
|
||||
|
||||
# Bundle MSVC/UCRT runtime dependencies if detected
|
||||
if(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS)
|
||||
install(FILES ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS}
|
||||
DESTINATION .
|
||||
|
||||
Reference in New Issue
Block a user