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:
@@ -46,3 +46,4 @@ if(DEFINED ENV{GITHUB_ACTIONS})
|
||||
set(CPM_SOURCE_CACHE "$ENV{HOME}/.cpm-cache")
|
||||
message(STATUS "CPM cache directory: ${CPM_SOURCE_CACHE}")
|
||||
endif()
|
||||
|
||||
|
||||
@@ -13,21 +13,29 @@ 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 "")
|
||||
|
||||
# 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})
|
||||
|
||||
include(cmake/dependencies/yaml.cmake)
|
||||
list(APPEND YAZE_ALL_DEPENDENCIES ${YAZE_YAML_TARGETS})
|
||||
|
||||
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})
|
||||
|
||||
# Optional dependencies based on feature flags
|
||||
if(YAZE_ENABLE_JSON)
|
||||
include(cmake/dependencies/json.cmake)
|
||||
list(APPEND YAZE_ALL_DEPENDENCIES ${YAZE_JSON_TARGETS})
|
||||
endif()
|
||||
|
||||
if(YAZE_ENABLE_GRPC)
|
||||
include(cmake/dependencies/grpc.cmake)
|
||||
list(APPEND YAZE_ALL_DEPENDENCIES ${YAZE_GRPC_TARGETS})
|
||||
@@ -53,6 +61,9 @@ 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()
|
||||
|
||||
@@ -23,3 +23,4 @@ set(IMGUI_VERSION "1.90.4" CACHE STRING "Dear ImGui version")
|
||||
|
||||
# ASAR
|
||||
set(ASAR_VERSION "main" CACHE STRING "ASAR version")
|
||||
|
||||
|
||||
@@ -27,45 +27,57 @@ if(YAZE_USE_SYSTEM_DEPS)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Set gRPC options before adding package
|
||||
set(gRPC_BUILD_TESTS OFF CACHE BOOL "" FORCE)
|
||||
set(gRPC_BUILD_CODEGEN ON CACHE BOOL "" FORCE)
|
||||
set(gRPC_BUILD_GRPC_CPP_PLUGIN ON CACHE BOOL "" FORCE)
|
||||
set(gRPC_BUILD_CSHARP_EXT OFF CACHE BOOL "" FORCE)
|
||||
set(gRPC_BUILD_GRPC_CSHARP_PLUGIN OFF CACHE BOOL "" FORCE)
|
||||
set(gRPC_BUILD_GRPC_NODE_PLUGIN OFF CACHE BOOL "" FORCE)
|
||||
set(gRPC_BUILD_GRPC_OBJECTIVE_C_PLUGIN OFF CACHE BOOL "" FORCE)
|
||||
set(gRPC_BUILD_GRPC_PHP_PLUGIN OFF CACHE BOOL "" FORCE)
|
||||
set(gRPC_BUILD_GRPC_PYTHON_PLUGIN OFF CACHE BOOL "" FORCE)
|
||||
set(gRPC_BUILD_GRPC_RUBY_PLUGIN OFF CACHE BOOL "" FORCE)
|
||||
set(gRPC_BUILD_REFLECTION OFF CACHE BOOL "" FORCE)
|
||||
set(gRPC_BUILD_GRPC_REFLECTION OFF CACHE BOOL "" FORCE)
|
||||
set(gRPC_BUILD_GRPC_CPP_REFLECTION OFF CACHE BOOL "" FORCE)
|
||||
set(gRPC_BUILD_GRPCPP_REFLECTION OFF CACHE BOOL "" FORCE)
|
||||
set(gRPC_BENCHMARK_PROVIDER "none" CACHE STRING "" FORCE)
|
||||
set(gRPC_ZLIB_PROVIDER "package" CACHE STRING "" FORCE)
|
||||
set(gRPC_PROTOBUF_PROVIDER "module" CACHE STRING "" FORCE)
|
||||
set(gRPC_ABSL_PROVIDER "module" CACHE STRING "" FORCE)
|
||||
set(protobuf_BUILD_TESTS OFF CACHE BOOL "" FORCE)
|
||||
set(protobuf_BUILD_CONFORMANCE OFF CACHE BOOL "" FORCE)
|
||||
set(protobuf_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
|
||||
set(protobuf_BUILD_PROTOC_BINARIES ON CACHE BOOL "" FORCE)
|
||||
set(protobuf_WITH_ZLIB ON CACHE BOOL "" FORCE)
|
||||
set(ABSL_PROPAGATE_CXX_STD ON CACHE BOOL "" FORCE)
|
||||
set(ABSL_ENABLE_INSTALL ON CACHE BOOL "" FORCE)
|
||||
set(ABSL_BUILD_TESTING OFF CACHE BOOL "" FORCE)
|
||||
set(utf8_range_BUILD_TESTS OFF CACHE BOOL "" FORCE)
|
||||
set(utf8_range_INSTALL OFF CACHE BOOL "" FORCE)
|
||||
|
||||
# Use CPM to fetch gRPC with bundled dependencies
|
||||
CPMAddPackage(
|
||||
NAME grpc
|
||||
VERSION ${GRPC_VERSION}
|
||||
GITHUB_REPOSITORY grpc/grpc
|
||||
GIT_TAG v${GRPC_VERSION}
|
||||
OPTIONS
|
||||
"gRPC_BUILD_TESTS OFF"
|
||||
"gRPC_BUILD_CODEGEN ON"
|
||||
"gRPC_BUILD_GRPC_CPP_PLUGIN ON"
|
||||
"gRPC_BUILD_CSHARP_EXT OFF"
|
||||
"gRPC_BUILD_GRPC_CSHARP_PLUGIN OFF"
|
||||
"gRPC_BUILD_GRPC_NODE_PLUGIN OFF"
|
||||
"gRPC_BUILD_GRPC_OBJECTIVE_C_PLUGIN OFF"
|
||||
"gRPC_BUILD_GRPC_PHP_PLUGIN OFF"
|
||||
"gRPC_BUILD_GRPC_PYTHON_PLUGIN OFF"
|
||||
"gRPC_BUILD_GRPC_RUBY_PLUGIN OFF"
|
||||
"gRPC_BUILD_REFLECTION OFF"
|
||||
"gRPC_BUILD_GRPC_REFLECTION OFF"
|
||||
"gRPC_BUILD_GRPC_CPP_REFLECTION OFF"
|
||||
"gRPC_BUILD_GRPCPP_REFLECTION OFF"
|
||||
"gRPC_BENCHMARK_PROVIDER none"
|
||||
"gRPC_ZLIB_PROVIDER package"
|
||||
"gRPC_PROTOBUF_PROVIDER module"
|
||||
"gRPC_ABSL_PROVIDER module"
|
||||
"protobuf_BUILD_TESTS OFF"
|
||||
"protobuf_BUILD_CONFORMANCE OFF"
|
||||
"protobuf_BUILD_EXAMPLES OFF"
|
||||
"protobuf_BUILD_PROTOC_BINARIES ON"
|
||||
"protobuf_WITH_ZLIB ON"
|
||||
"ABSL_PROPAGATE_CXX_STD ON"
|
||||
"ABSL_ENABLE_INSTALL ON"
|
||||
"ABSL_BUILD_TESTING OFF"
|
||||
"utf8_range_BUILD_TESTS OFF"
|
||||
"utf8_range_INSTALL OFF"
|
||||
)
|
||||
|
||||
# Check which target naming convention is used
|
||||
if(TARGET grpc++)
|
||||
message(STATUS "Found non-namespaced gRPC target grpc++")
|
||||
if(NOT TARGET grpc::grpc++)
|
||||
add_library(grpc::grpc++ ALIAS grpc++)
|
||||
endif()
|
||||
if(NOT TARGET grpc::grpc++_reflection AND TARGET grpc++_reflection)
|
||||
add_library(grpc::grpc++_reflection ALIAS grpc++_reflection)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Verify gRPC targets are available
|
||||
if(NOT TARGET grpc::grpc++)
|
||||
if(NOT TARGET grpc++ AND NOT TARGET grpc::grpc++)
|
||||
message(FATAL_ERROR "gRPC target not found after CPM fetch")
|
||||
endif()
|
||||
|
||||
@@ -77,14 +89,30 @@ if(NOT TARGET grpc_cpp_plugin)
|
||||
message(FATAL_ERROR "grpc_cpp_plugin target not found after gRPC setup")
|
||||
endif()
|
||||
|
||||
# Create convenience targets for the rest of the project
|
||||
add_library(yaze_grpc_support INTERFACE)
|
||||
target_link_libraries(yaze_grpc_support INTERFACE
|
||||
# Create convenience interface for basic gRPC linking (renamed to avoid conflict with yaze_grpc_support STATIC library)
|
||||
add_library(yaze_grpc_deps INTERFACE)
|
||||
target_link_libraries(yaze_grpc_deps INTERFACE
|
||||
grpc::grpc++
|
||||
grpc::grpc++_reflection
|
||||
protobuf::libprotobuf
|
||||
)
|
||||
|
||||
# Export Abseil targets that are commonly used
|
||||
set(ABSL_TARGETS
|
||||
absl::base
|
||||
absl::config
|
||||
absl::core_headers
|
||||
absl::flags
|
||||
absl::flags_parse
|
||||
absl::status
|
||||
absl::statusor
|
||||
absl::strings
|
||||
absl::str_format
|
||||
absl::synchronization
|
||||
absl::time
|
||||
PARENT_SCOPE
|
||||
)
|
||||
|
||||
# Export gRPC targets for use in other CMake files
|
||||
set(YAZE_GRPC_TARGETS
|
||||
grpc::grpc++
|
||||
@@ -96,3 +124,91 @@ set(YAZE_GRPC_TARGETS
|
||||
)
|
||||
|
||||
message(STATUS "gRPC setup complete - targets available: ${YAZE_GRPC_TARGETS}")
|
||||
|
||||
# Setup protobuf generation directory (use CACHE so it's available in functions)
|
||||
set(_gRPC_PROTO_GENS_DIR ${CMAKE_BINARY_DIR}/gens CACHE INTERNAL "Protobuf generated files directory")
|
||||
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/gens)
|
||||
|
||||
# Get protobuf include directories (extract from generator expression or direct path)
|
||||
if(TARGET libprotobuf)
|
||||
get_target_property(_PROTOBUF_INCLUDE_DIRS libprotobuf INTERFACE_INCLUDE_DIRECTORIES)
|
||||
# Handle generator expressions
|
||||
string(REGEX REPLACE "\\$<BUILD_INTERFACE:([^>]+)>" "\\1" _PROTOBUF_INCLUDE_DIR_CLEAN "${_PROTOBUF_INCLUDE_DIRS}")
|
||||
list(GET _PROTOBUF_INCLUDE_DIR_CLEAN 0 _gRPC_PROTOBUF_WELLKNOWN_INCLUDE_DIR)
|
||||
set(_gRPC_PROTOBUF_WELLKNOWN_INCLUDE_DIR ${_gRPC_PROTOBUF_WELLKNOWN_INCLUDE_DIR} CACHE INTERNAL "Protobuf include directory")
|
||||
elseif(TARGET protobuf::libprotobuf)
|
||||
get_target_property(_PROTOBUF_INCLUDE_DIRS protobuf::libprotobuf INTERFACE_INCLUDE_DIRECTORIES)
|
||||
string(REGEX REPLACE "\\$<BUILD_INTERFACE:([^>]+)>" "\\1" _PROTOBUF_INCLUDE_DIR_CLEAN "${_PROTOBUF_INCLUDE_DIRS}")
|
||||
list(GET _PROTOBUF_INCLUDE_DIR_CLEAN 0 _gRPC_PROTOBUF_WELLKNOWN_INCLUDE_DIR)
|
||||
set(_gRPC_PROTOBUF_WELLKNOWN_INCLUDE_DIR ${_gRPC_PROTOBUF_WELLKNOWN_INCLUDE_DIR} CACHE INTERNAL "Protobuf include directory")
|
||||
endif()
|
||||
|
||||
message(STATUS "Protobuf gens dir: ${_gRPC_PROTO_GENS_DIR}")
|
||||
message(STATUS "Protobuf include dir: ${_gRPC_PROTOBUF_WELLKNOWN_INCLUDE_DIR}")
|
||||
|
||||
# Export protobuf targets
|
||||
set(YAZE_PROTOBUF_TARGETS
|
||||
protobuf::libprotobuf
|
||||
PARENT_SCOPE
|
||||
)
|
||||
|
||||
# Function to add protobuf/gRPC code generation to a target
|
||||
function(target_add_protobuf target)
|
||||
if(NOT TARGET ${target})
|
||||
message(FATAL_ERROR "Target ${target} doesn't exist")
|
||||
endif()
|
||||
if(NOT ARGN)
|
||||
message(SEND_ERROR "Error: target_add_protobuf() called without any proto files")
|
||||
return()
|
||||
endif()
|
||||
|
||||
set(_protobuf_include_path -I ${CMAKE_SOURCE_DIR}/src -I ${_gRPC_PROTOBUF_WELLKNOWN_INCLUDE_DIR})
|
||||
foreach(FIL ${ARGN})
|
||||
get_filename_component(ABS_FIL ${FIL} ABSOLUTE)
|
||||
get_filename_component(FIL_WE ${FIL} NAME_WE)
|
||||
file(RELATIVE_PATH REL_FIL ${CMAKE_SOURCE_DIR}/src ${ABS_FIL})
|
||||
get_filename_component(REL_DIR ${REL_FIL} DIRECTORY)
|
||||
if(NOT REL_DIR OR REL_DIR STREQUAL ".")
|
||||
set(RELFIL_WE "${FIL_WE}")
|
||||
else()
|
||||
set(RELFIL_WE "${REL_DIR}/${FIL_WE}")
|
||||
endif()
|
||||
|
||||
message(STATUS " Proto file: ${FIL_WE}")
|
||||
message(STATUS " ABS_FIL = ${ABS_FIL}")
|
||||
message(STATUS " REL_FIL = ${REL_FIL}")
|
||||
message(STATUS " REL_DIR = ${REL_DIR}")
|
||||
message(STATUS " RELFIL_WE = ${RELFIL_WE}")
|
||||
message(STATUS " Output = ${_gRPC_PROTO_GENS_DIR}/${RELFIL_WE}.pb.h")
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT "${_gRPC_PROTO_GENS_DIR}/${RELFIL_WE}.grpc.pb.cc"
|
||||
"${_gRPC_PROTO_GENS_DIR}/${RELFIL_WE}.grpc.pb.h"
|
||||
"${_gRPC_PROTO_GENS_DIR}/${RELFIL_WE}_mock.grpc.pb.h"
|
||||
"${_gRPC_PROTO_GENS_DIR}/${RELFIL_WE}.pb.cc"
|
||||
"${_gRPC_PROTO_GENS_DIR}/${RELFIL_WE}.pb.h"
|
||||
COMMAND $<TARGET_FILE:protoc>
|
||||
ARGS --grpc_out=generate_mock_code=true:${_gRPC_PROTO_GENS_DIR}
|
||||
--cpp_out=${_gRPC_PROTO_GENS_DIR}
|
||||
--plugin=protoc-gen-grpc=$<TARGET_FILE:grpc_cpp_plugin>
|
||||
${_protobuf_include_path}
|
||||
${ABS_FIL}
|
||||
DEPENDS ${ABS_FIL} protoc grpc_cpp_plugin
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/src
|
||||
COMMENT "Running gRPC C++ protocol buffer compiler on ${FIL}"
|
||||
VERBATIM)
|
||||
|
||||
target_sources(${target} PRIVATE
|
||||
"${_gRPC_PROTO_GENS_DIR}/${RELFIL_WE}.grpc.pb.cc"
|
||||
"${_gRPC_PROTO_GENS_DIR}/${RELFIL_WE}.grpc.pb.h"
|
||||
"${_gRPC_PROTO_GENS_DIR}/${RELFIL_WE}_mock.grpc.pb.h"
|
||||
"${_gRPC_PROTO_GENS_DIR}/${RELFIL_WE}.pb.cc"
|
||||
"${_gRPC_PROTO_GENS_DIR}/${RELFIL_WE}.pb.h"
|
||||
)
|
||||
target_include_directories(${target} PUBLIC
|
||||
$<BUILD_INTERFACE:${_gRPC_PROTO_GENS_DIR}>
|
||||
$<BUILD_INTERFACE:${_gRPC_PROTOBUF_WELLKNOWN_INCLUDE_DIR}>
|
||||
)
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
|
||||
@@ -1,39 +1,69 @@
|
||||
# Dear ImGui dependency management
|
||||
# Uses CPM.cmake for consistent cross-platform builds
|
||||
# Uses the bundled ImGui in src/lib/imgui
|
||||
|
||||
include(cmake/CPM.cmake)
|
||||
include(cmake/dependencies.lock)
|
||||
message(STATUS "Setting up Dear ImGui from bundled sources")
|
||||
|
||||
message(STATUS "Setting up Dear ImGui ${IMGUI_VERSION} with CPM.cmake")
|
||||
# Use the bundled ImGui from src/lib/imgui
|
||||
set(IMGUI_DIR ${CMAKE_SOURCE_DIR}/src/lib/imgui)
|
||||
|
||||
# Use CPM to fetch Dear ImGui
|
||||
CPMAddPackage(
|
||||
NAME imgui
|
||||
VERSION ${IMGUI_VERSION}
|
||||
GITHUB_REPOSITORY ocornut/imgui
|
||||
GIT_TAG v${IMGUI_VERSION}
|
||||
OPTIONS
|
||||
"IMGUI_BUILD_EXAMPLES OFF"
|
||||
"IMGUI_BUILD_DEMO OFF"
|
||||
# Create ImGui library with core files from bundled source
|
||||
add_library(ImGui STATIC
|
||||
${IMGUI_DIR}/imgui.cpp
|
||||
${IMGUI_DIR}/imgui_demo.cpp
|
||||
${IMGUI_DIR}/imgui_draw.cpp
|
||||
${IMGUI_DIR}/imgui_tables.cpp
|
||||
${IMGUI_DIR}/imgui_widgets.cpp
|
||||
# SDL2 backend
|
||||
${IMGUI_DIR}/backends/imgui_impl_sdl2.cpp
|
||||
${IMGUI_DIR}/backends/imgui_impl_sdlrenderer2.cpp
|
||||
# C++ stdlib helpers (for std::string support)
|
||||
${IMGUI_DIR}/misc/cpp/imgui_stdlib.cpp
|
||||
)
|
||||
|
||||
# ImGui doesn't create targets during CPM fetch, they're created during build
|
||||
# We'll create our own interface target and link to ImGui when it's available
|
||||
add_library(yaze_imgui INTERFACE)
|
||||
target_include_directories(ImGui PUBLIC
|
||||
${IMGUI_DIR}
|
||||
${IMGUI_DIR}/backends
|
||||
)
|
||||
|
||||
# Note: ImGui targets will be available after the build phase
|
||||
# For now, we'll create a placeholder that can be linked later
|
||||
# Link to SDL2
|
||||
target_link_libraries(ImGui PUBLIC ${YAZE_SDL2_TARGETS})
|
||||
|
||||
# Add platform-specific backends
|
||||
if(TARGET imgui_impl_sdl2)
|
||||
target_link_libraries(yaze_imgui INTERFACE imgui_impl_sdl2)
|
||||
message(STATUS "Created ImGui target from bundled source at ${IMGUI_DIR}")
|
||||
|
||||
# Create ImGui Test Engine for test automation (if tests are enabled)
|
||||
if(YAZE_BUILD_TESTS)
|
||||
set(IMGUI_TEST_ENGINE_DIR ${CMAKE_SOURCE_DIR}/src/lib/imgui_test_engine/imgui_test_engine)
|
||||
|
||||
if(EXISTS ${IMGUI_TEST_ENGINE_DIR})
|
||||
set(IMGUI_TEST_ENGINE_SOURCES
|
||||
${IMGUI_TEST_ENGINE_DIR}/imgui_te_context.cpp
|
||||
${IMGUI_TEST_ENGINE_DIR}/imgui_te_coroutine.cpp
|
||||
${IMGUI_TEST_ENGINE_DIR}/imgui_te_engine.cpp
|
||||
${IMGUI_TEST_ENGINE_DIR}/imgui_te_exporters.cpp
|
||||
${IMGUI_TEST_ENGINE_DIR}/imgui_te_perftool.cpp
|
||||
${IMGUI_TEST_ENGINE_DIR}/imgui_te_ui.cpp
|
||||
${IMGUI_TEST_ENGINE_DIR}/imgui_te_utils.cpp
|
||||
${IMGUI_TEST_ENGINE_DIR}/imgui_capture_tool.cpp
|
||||
)
|
||||
|
||||
add_library(ImGuiTestEngine STATIC ${IMGUI_TEST_ENGINE_SOURCES})
|
||||
target_include_directories(ImGuiTestEngine PUBLIC
|
||||
${IMGUI_DIR}
|
||||
${IMGUI_TEST_ENGINE_DIR}
|
||||
${CMAKE_SOURCE_DIR}/src/lib
|
||||
)
|
||||
target_link_libraries(ImGuiTestEngine PUBLIC ImGui ${YAZE_SDL2_TARGETS})
|
||||
target_compile_definitions(ImGuiTestEngine PUBLIC
|
||||
IMGUI_ENABLE_TEST_ENGINE=1
|
||||
IMGUI_TEST_ENGINE_ENABLE_COROUTINE_STDTHREAD_IMPL=1
|
||||
)
|
||||
|
||||
message(STATUS "Created ImGuiTestEngine target for test automation")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(TARGET imgui_impl_opengl3)
|
||||
target_link_libraries(yaze_imgui INTERFACE imgui_impl_opengl3)
|
||||
endif()
|
||||
# Export ImGui targets for use in other CMake files
|
||||
set(YAZE_IMGUI_TARGETS ImGui PARENT_SCOPE)
|
||||
set(YAZE_IMGUI_TARGETS ImGui)
|
||||
|
||||
# Export ImGui targets for use in other CMake files
|
||||
set(YAZE_IMGUI_TARGETS yaze_imgui)
|
||||
|
||||
message(STATUS "Dear ImGui setup complete")
|
||||
message(STATUS "Dear ImGui setup complete - YAZE_IMGUI_TARGETS = ${YAZE_IMGUI_TARGETS}")
|
||||
|
||||
34
cmake/dependencies/json.cmake
Normal file
34
cmake/dependencies/json.cmake
Normal file
@@ -0,0 +1,34 @@
|
||||
# nlohmann_json dependency management
|
||||
|
||||
if(NOT YAZE_ENABLE_JSON)
|
||||
return()
|
||||
endif()
|
||||
|
||||
message(STATUS "Setting up nlohmann_json with local third_party")
|
||||
|
||||
# Use the bundled nlohmann_json from third_party
|
||||
set(JSON_BuildTests OFF CACHE BOOL "" FORCE)
|
||||
set(JSON_Install OFF CACHE BOOL "" FORCE)
|
||||
set(JSON_MultipleHeaders OFF CACHE BOOL "" FORCE)
|
||||
|
||||
add_subdirectory(${CMAKE_SOURCE_DIR}/third_party/json EXCLUDE_FROM_ALL)
|
||||
|
||||
# Verify target is available
|
||||
if(TARGET nlohmann_json::nlohmann_json)
|
||||
message(STATUS "nlohmann_json target found")
|
||||
elseif(TARGET nlohmann_json)
|
||||
# Create alias if only non-namespaced target exists
|
||||
add_library(nlohmann_json::nlohmann_json ALIAS nlohmann_json)
|
||||
message(STATUS "Created nlohmann_json::nlohmann_json alias")
|
||||
else()
|
||||
message(FATAL_ERROR "nlohmann_json target not found after add_subdirectory")
|
||||
endif()
|
||||
|
||||
# Export for use in other CMake files
|
||||
set(YAZE_JSON_TARGETS
|
||||
nlohmann_json::nlohmann_json
|
||||
PARENT_SCOPE
|
||||
)
|
||||
|
||||
message(STATUS "nlohmann_json setup complete")
|
||||
|
||||
@@ -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}")
|
||||
|
||||
@@ -10,23 +10,27 @@ include(cmake/dependencies.lock)
|
||||
|
||||
message(STATUS "Setting up testing dependencies with CPM.cmake")
|
||||
|
||||
# Google Test
|
||||
# Google Test (includes GMock)
|
||||
CPMAddPackage(
|
||||
NAME googletest
|
||||
VERSION ${GTEST_VERSION}
|
||||
GITHUB_REPOSITORY google/googletest
|
||||
GIT_TAG v${GTEST_VERSION}
|
||||
OPTIONS
|
||||
"BUILD_GMOCK OFF"
|
||||
"BUILD_GMOCK ON"
|
||||
"INSTALL_GTEST OFF"
|
||||
"gtest_force_shared_crt ON"
|
||||
)
|
||||
|
||||
# Verify GTest targets are available
|
||||
# Verify GTest and GMock targets are available
|
||||
if(NOT TARGET gtest)
|
||||
message(FATAL_ERROR "GTest target not found after CPM fetch")
|
||||
endif()
|
||||
|
||||
if(NOT TARGET gmock)
|
||||
message(FATAL_ERROR "GMock target not found after CPM fetch")
|
||||
endif()
|
||||
|
||||
# Google Benchmark (optional, for performance tests)
|
||||
if(YAZE_ENABLE_COVERAGE OR DEFINED ENV{YAZE_ENABLE_BENCHMARKS})
|
||||
CPMAddPackage(
|
||||
@@ -48,13 +52,19 @@ endif()
|
||||
|
||||
# Create convenience targets for the rest of the project
|
||||
add_library(yaze_testing INTERFACE)
|
||||
target_link_libraries(yaze_testing INTERFACE gtest)
|
||||
target_link_libraries(yaze_testing INTERFACE
|
||||
gtest
|
||||
gtest_main
|
||||
gmock
|
||||
gmock_main
|
||||
)
|
||||
|
||||
if(TARGET benchmark::benchmark)
|
||||
target_link_libraries(yaze_testing INTERFACE benchmark::benchmark)
|
||||
endif()
|
||||
|
||||
# Export testing targets for use in other CMake files
|
||||
set(YAZE_TESTING_TARGETS yaze_testing PARENT_SCOPE)
|
||||
set(YAZE_TESTING_TARGETS yaze_testing)
|
||||
|
||||
message(STATUS "Testing dependencies setup complete")
|
||||
message(STATUS "Testing dependencies setup complete - GTest + GMock available")
|
||||
|
||||
@@ -59,3 +59,4 @@ message(STATUS "LTO: ${YAZE_ENABLE_LTO}")
|
||||
message(STATUS "Sanitizers: ${YAZE_ENABLE_SANITIZERS}")
|
||||
message(STATUS "Coverage: ${YAZE_ENABLE_COVERAGE}")
|
||||
message(STATUS "=================================")
|
||||
|
||||
|
||||
@@ -32,3 +32,4 @@ set(CPACK_RESOURCE_FILE_README "${CMAKE_SOURCE_DIR}/README.md")
|
||||
set(CPACK_COMPONENTS_ALL yaze)
|
||||
set(CPACK_COMPONENT_YAZE_DISPLAY_NAME "YAZE Editor")
|
||||
set(CPACK_COMPONENT_YAZE_DESCRIPTION "Main YAZE application and libraries")
|
||||
|
||||
|
||||
@@ -14,3 +14,4 @@ set(CPACK_RPM_PACKAGE_REQUIRES "glibc, libstdc++, SDL2")
|
||||
|
||||
# Tarball
|
||||
set(CPACK_TGZ_PACKAGE_NAME "yaze-${CPACK_PACKAGE_VERSION}-linux-x64")
|
||||
|
||||
|
||||
@@ -21,3 +21,4 @@ endif()
|
||||
if(DEFINED ENV{NOTARIZATION_CREDENTIALS})
|
||||
set(CPACK_BUNDLE_APPLE_NOTARIZATION_CREDENTIALS "$ENV{NOTARIZATION_CREDENTIALS}")
|
||||
endif()
|
||||
|
||||
|
||||
@@ -19,3 +19,4 @@ if(DEFINED ENV{SIGNTOOL_CERTIFICATE})
|
||||
set(CPACK_NSIS_SIGN_TOOL "signtool.exe")
|
||||
set(CPACK_NSIS_SIGN_COMMAND "${ENV{SIGNTOOL_CERTIFICATE}}")
|
||||
endif()
|
||||
|
||||
|
||||
@@ -19,3 +19,4 @@ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--as-needed")
|
||||
|
||||
# Find packages
|
||||
find_package(PkgConfig REQUIRED)
|
||||
|
||||
|
||||
@@ -22,3 +22,4 @@ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-dead_strip")
|
||||
|
||||
# Find packages
|
||||
find_package(PkgConfig REQUIRED)
|
||||
|
||||
|
||||
@@ -23,3 +23,4 @@ set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /LTCG")
|
||||
# Windows-specific definitions
|
||||
add_definitions(-DWIN32_LEAN_AND_MEAN)
|
||||
add_definitions(-DNOMINMAX)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user