feat(build-system): enhance CMake configuration and introduce new utility files

- Refactored CMakeLists.txt to streamline project configuration and improve readability.
- Introduced new utility functions in `utils.cmake` for setting compiler flags and managing dependencies.
- Added `dependencies.cmake` to centralize third-party dependency management, enhancing modularity.
- Updated CI workflows to include new build options and improved logging for better feedback during configuration.
- Implemented precompiled headers in various libraries to speed up compilation times.

Benefits:
- Improved maintainability and clarity of the build system.
- Enhanced build performance through precompiled headers.
- Streamlined dependency management for easier integration of third-party libraries.
This commit is contained in:
scawful
2025-10-11 02:44:17 -04:00
parent 31d0337b11
commit f54949bdd8
56 changed files with 2673 additions and 4872 deletions

View File

@@ -1,69 +1,3 @@
include(FetchContent)
function(_yaze_ensure_yaml_cpp _out_target)
if(TARGET yaml-cpp::yaml-cpp)
set(${_out_target} yaml-cpp::yaml-cpp PARENT_SCOPE)
return()
endif()
if(TARGET yaml-cpp)
set(${_out_target} yaml-cpp PARENT_SCOPE)
return()
endif()
find_package(yaml-cpp CONFIG QUIET)
if(TARGET yaml-cpp::yaml-cpp)
set(${_out_target} yaml-cpp::yaml-cpp PARENT_SCOPE)
return()
elseif(TARGET yaml-cpp)
set(${_out_target} yaml-cpp PARENT_SCOPE)
return()
endif()
message(STATUS "yaml-cpp not found via package config, fetching from source")
FetchContent_Declare(yaml-cpp
GIT_REPOSITORY https://github.com/jbeder/yaml-cpp.git
GIT_TAG 0.8.0
)
FetchContent_GetProperties(yaml-cpp)
if(NOT yaml-cpp_POPULATED)
FetchContent_Populate(yaml-cpp)
set(_yaml_cpp_cmakelists "${yaml-cpp_SOURCE_DIR}/CMakeLists.txt")
if(EXISTS "${_yaml_cpp_cmakelists}")
file(READ "${_yaml_cpp_cmakelists}" _yaml_cpp_cmake_contents)
if(_yaml_cpp_cmake_contents MATCHES "cmake_minimum_required\\(VERSION 3\\.4\\)")
string(REPLACE "cmake_minimum_required(VERSION 3.4)"
"cmake_minimum_required(VERSION 3.5)"
_yaml_cpp_cmake_contents "${_yaml_cpp_cmake_contents}")
file(WRITE "${_yaml_cpp_cmakelists}" "${_yaml_cpp_cmake_contents}")
endif()
endif()
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)
add_subdirectory(${yaml-cpp_SOURCE_DIR} ${yaml-cpp_BINARY_DIR} EXCLUDE_FROM_ALL)
if(NOT TARGET yaml-cpp)
message(FATAL_ERROR "yaml-cpp target was not created after fetching")
endif()
# Ensure the fetched target exposes its public headers
target_include_directories(yaml-cpp PUBLIC ${yaml-cpp_SOURCE_DIR}/include)
endif()
set(${_out_target} yaml-cpp PARENT_SCOPE)
endfunction()
_yaze_ensure_yaml_cpp(YAZE_YAML_CPP_TARGET)
set(YAZE_AGENT_SOURCES
cli/service/agent/proposal_executor.cc
cli/handlers/agent/todo_commands.cc
@@ -73,6 +7,7 @@ set(YAZE_AGENT_SOURCES
cli/service/agent/tool_dispatcher.cc
cli/service/agent/learned_knowledge_service.cc
cli/service/agent/todo_manager.cc
cli/service/agent/vim_mode.cc
cli/service/ai/ai_service.cc
cli/service/ai/ai_action_parser.cc
cli/service/ai/vision_action_refiner.cc
@@ -91,8 +26,9 @@ set(YAZE_AGENT_SOURCES
cli/service/resources/resource_context_builder.cc
cli/service/resources/command_context.cc
cli/service/resources/command_handler.cc
cli/handlers/command_wrappers.cc
cli/handlers/agent.cc
cli/handlers/command_handlers.cc
cli/handlers/agent/simple_chat_command.cc
cli/handlers/game/overworld_inspect.cc
cli/handlers/game/message.cc
cli/handlers/rom/mock_rom.cc
@@ -107,6 +43,7 @@ set(YAZE_AGENT_SOURCES
cli/handlers/graphics/palette_commands.cc
cli/handlers/tools/emulator_commands.cc
cli/handlers/game/message_commands.cc
cli/handlers/graphics/sprite_commands.cc
# ROM commands
cli/handlers/rom/rom_commands.cc
cli/handlers/rom/project_commands.cc
@@ -122,8 +59,14 @@ add_library(yaze_agent STATIC ${YAZE_AGENT_SOURCES})
set(_yaze_agent_link_targets
yaze_common
yaze_util
yaze_gfx
yaze_gui
yaze_core_lib
yaze_zelda3
yaze_emulator
${ABSL_TARGETS}
${YAZE_YAML_CPP_TARGET}
yaml-cpp
)
target_link_libraries(yaze_agent PUBLIC ${_yaze_agent_link_targets})
@@ -135,15 +78,9 @@ target_include_directories(yaze_agent
${CMAKE_SOURCE_DIR}/third_party/httplib
${CMAKE_SOURCE_DIR}/third_party/json/include
${CMAKE_SOURCE_DIR}/src/lib
${CMAKE_SOURCE_DIR}/src/cli/handlers
)
if(YAZE_YAML_CPP_TARGET)
get_target_property(_yaze_yaml_include_dirs ${YAZE_YAML_CPP_TARGET} INTERFACE_INCLUDE_DIRECTORIES)
if(_yaze_yaml_include_dirs)
target_include_directories(yaze_agent PUBLIC ${_yaze_yaml_include_dirs})
endif()
endif()
if(SDL2_INCLUDE_DIR)
target_include_directories(yaze_agent PUBLIC ${SDL2_INCLUDE_DIR})
endif()