chore: update configuration files and enhance dependency management
- Added new entries to `.pre-commit-config.yaml`, `cmake-format.yaml`, and `.github/dependabot.yml` to improve code quality checks and dependency updates. - Enhanced GitHub Actions workflows by adding new steps for testing and build retention. - Introduced support for the nlohmann_json library in CMake, allowing for conditional inclusion based on the `YAZE_ENABLE_JSON` option. - Updated CMake configurations to streamline SDL2 and gRPC integration, ensuring proper linking and target management. Benefits: - Improves code quality and consistency through automated checks and formatting. - Enhances dependency management and build reliability across platforms. - Provides flexibility for users to enable optional features, improving overall functionality.
This commit is contained in:
@@ -11,12 +11,14 @@ if(YAZE_USE_SYSTEM_DEPS)
|
||||
find_package(SDL2 QUIET)
|
||||
if(SDL2_FOUND)
|
||||
message(STATUS "Using system SDL2")
|
||||
add_library(yaze_sdl2 INTERFACE IMPORTED)
|
||||
target_link_libraries(yaze_sdl2 INTERFACE SDL2::SDL2)
|
||||
if(TARGET SDL2::SDL2main)
|
||||
target_link_libraries(yaze_sdl2 INTERFACE SDL2::SDL2main)
|
||||
if(NOT TARGET yaze_sdl2)
|
||||
add_library(yaze_sdl2 INTERFACE)
|
||||
target_link_libraries(yaze_sdl2 INTERFACE SDL2::SDL2)
|
||||
if(TARGET SDL2::SDL2main)
|
||||
target_link_libraries(yaze_sdl2 INTERFACE SDL2::SDL2main)
|
||||
endif()
|
||||
endif()
|
||||
set(YAZE_SDL2_TARGETS yaze_sdl2 PARENT_SCOPE)
|
||||
set(YAZE_SDL2_TARGETS yaze_sdl2 CACHE INTERNAL "")
|
||||
return()
|
||||
endif()
|
||||
endif()
|
||||
@@ -35,14 +37,37 @@ CPMAddPackage(
|
||||
"SDL_CMAKE_DEBUG_POSTFIX d"
|
||||
)
|
||||
|
||||
# Verify SDL2 targets are available
|
||||
if(NOT TARGET SDL2::SDL2)
|
||||
# Verify SDL2 targets are available
|
||||
if(NOT TARGET SDL2-static AND NOT TARGET SDL2::SDL2-static AND NOT TARGET SDL2::SDL2)
|
||||
message(FATAL_ERROR "SDL2 target not found after CPM fetch")
|
||||
endif()
|
||||
|
||||
# Create convenience targets for the rest of the project
|
||||
add_library(yaze_sdl2 INTERFACE)
|
||||
target_link_libraries(yaze_sdl2 INTERFACE SDL2::SDL2)
|
||||
if(NOT TARGET yaze_sdl2)
|
||||
add_library(yaze_sdl2 INTERFACE)
|
||||
# SDL2 from CPM might use SDL2-static or SDL2::SDL2-static
|
||||
if(TARGET SDL2-static)
|
||||
message(STATUS "Using SDL2-static target")
|
||||
target_link_libraries(yaze_sdl2 INTERFACE SDL2-static)
|
||||
# Also explicitly add include directories if they exist
|
||||
if(SDL2_SOURCE_DIR)
|
||||
target_include_directories(yaze_sdl2 INTERFACE ${SDL2_SOURCE_DIR}/include)
|
||||
message(STATUS "Added SDL2 include: ${SDL2_SOURCE_DIR}/include")
|
||||
endif()
|
||||
elseif(TARGET SDL2::SDL2-static)
|
||||
message(STATUS "Using SDL2::SDL2-static target")
|
||||
target_link_libraries(yaze_sdl2 INTERFACE SDL2::SDL2-static)
|
||||
# For local Homebrew SDL2, also add include path explicitly
|
||||
# SDL headers are in the SDL2 subdirectory
|
||||
if(APPLE AND EXISTS "/opt/homebrew/opt/sdl2/include/SDL2")
|
||||
target_include_directories(yaze_sdl2 INTERFACE /opt/homebrew/opt/sdl2/include/SDL2)
|
||||
message(STATUS "Added Homebrew SDL2 include path: /opt/homebrew/opt/sdl2/include/SDL2")
|
||||
endif()
|
||||
else()
|
||||
message(STATUS "Using SDL2::SDL2 target")
|
||||
target_link_libraries(yaze_sdl2 INTERFACE SDL2::SDL2)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Add platform-specific libraries
|
||||
if(WIN32)
|
||||
@@ -71,6 +96,9 @@ elseif(UNIX)
|
||||
endif()
|
||||
|
||||
# Export SDL2 targets for use in other CMake files
|
||||
# Use PARENT_SCOPE to set in the calling scope (dependencies.cmake)
|
||||
set(YAZE_SDL2_TARGETS yaze_sdl2 PARENT_SCOPE)
|
||||
# Also set locally for use in this file
|
||||
set(YAZE_SDL2_TARGETS yaze_sdl2)
|
||||
|
||||
message(STATUS "SDL2 setup complete")
|
||||
message(STATUS "SDL2 setup complete - YAZE_SDL2_TARGETS = ${YAZE_SDL2_TARGETS}")
|
||||
|
||||
Reference in New Issue
Block a user