diff --git a/CMakeLists.txt b/CMakeLists.txt index fefd7458..93db2091 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -110,7 +110,6 @@ set(BUILD_SHARED_LIBS OFF) add_subdirectory(src) # Tools -option(YAZE_BUILD_TOOLS "Build development utility tools" OFF) if(YAZE_BUILD_TOOLS) message(STATUS "Building development tools") add_subdirectory(tools) diff --git a/CMakeUserPresets.json.example b/CMakeUserPresets.json.example index 69ff0b2f..74edf500 100644 --- a/CMakeUserPresets.json.example +++ b/CMakeUserPresets.json.example @@ -4,17 +4,32 @@ { "name": "dev-local", "inherits": "dev", - "binaryDir": "$env{YAZE_BUILD_ROOT}/build" + "binaryDir": "$env{YAZE_BUILD_ROOT}/build", + "environment": { + "CPM_SOURCE_CACHE": "$env{HOME}/.cpm-cache", + "VCPKG_DOWNLOADS": "$env{HOME}/.cache/vcpkg/downloads", + "VCPKG_BINARY_SOURCES": "clear;files,$env{HOME}/.cache/vcpkg/bincache,readwrite" + } }, { "name": "wasm-debug-local", "inherits": "wasm-debug", - "binaryDir": "$env{YAZE_BUILD_ROOT}/build-wasm" + "binaryDir": "$env{YAZE_BUILD_ROOT}/build-wasm", + "environment": { + "CPM_SOURCE_CACHE": "$env{HOME}/.cpm-cache", + "VCPKG_DOWNLOADS": "$env{HOME}/.cache/vcpkg/downloads", + "VCPKG_BINARY_SOURCES": "clear;files,$env{HOME}/.cache/vcpkg/bincache,readwrite" + } }, { "name": "wasm-release-local", "inherits": "wasm-release", - "binaryDir": "$env{YAZE_BUILD_ROOT}/build-wasm" + "binaryDir": "$env{YAZE_BUILD_ROOT}/build-wasm", + "environment": { + "CPM_SOURCE_CACHE": "$env{HOME}/.cpm-cache", + "VCPKG_DOWNLOADS": "$env{HOME}/.cache/vcpkg/downloads", + "VCPKG_BINARY_SOURCES": "clear;files,$env{HOME}/.cache/vcpkg/bincache,readwrite" + } } ], "buildPresets": [ diff --git a/cmake/dependencies/testing.cmake b/cmake/dependencies/testing.cmake index fd62734f..f2719ea8 100644 --- a/cmake/dependencies/testing.cmake +++ b/cmake/dependencies/testing.cmake @@ -14,9 +14,24 @@ set(_YAZE_USE_SYSTEM_GTEST ${YAZE_USE_SYSTEM_DEPS}) # Detect Homebrew installation automatically (helps offline builds) if(APPLE AND NOT _YAZE_USE_SYSTEM_GTEST) - set(_YAZE_GTEST_PREFIX_CANDIDATES - /opt/homebrew/opt/googletest - /usr/local/opt/googletest) + set(_YAZE_GTEST_PREFIX_CANDIDATES) + set(_YAZE_HOST_ARCH "${CMAKE_SYSTEM_PROCESSOR}") + if(NOT _YAZE_HOST_ARCH) + execute_process( + COMMAND uname -m + OUTPUT_VARIABLE _YAZE_HOST_ARCH + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_QUIET) + endif() + + if(_YAZE_HOST_ARCH STREQUAL "arm64") + list(APPEND _YAZE_GTEST_PREFIX_CANDIDATES + /opt/homebrew/opt/googletest) + else() + list(APPEND _YAZE_GTEST_PREFIX_CANDIDATES + /usr/local/opt/googletest + /opt/homebrew/opt/googletest) + endif() foreach(_prefix IN LISTS _YAZE_GTEST_PREFIX_CANDIDATES) if(EXISTS "${_prefix}") @@ -37,9 +52,13 @@ if(APPLE AND NOT _YAZE_USE_SYSTEM_GTEST) RESULT_VARIABLE HOMEBREW_GTEST_RESULT ERROR_QUIET) if(HOMEBREW_GTEST_RESULT EQUAL 0 AND EXISTS "${HOMEBREW_GTEST_PREFIX}") + if(_YAZE_HOST_ARCH STREQUAL "arm64" AND NOT HOMEBREW_GTEST_PREFIX MATCHES "^/opt/homebrew") + message(STATUS "Skipping Homebrew googletest prefix on arm64: ${HOMEBREW_GTEST_PREFIX}") + else() list(APPEND CMAKE_PREFIX_PATH "${HOMEBREW_GTEST_PREFIX}") message(STATUS "Added Homebrew googletest prefix: ${HOMEBREW_GTEST_PREFIX}") set(_YAZE_USE_SYSTEM_GTEST ON) + endif() endif() endif() endif() diff --git a/cmake/llvm-brew.toolchain.cmake b/cmake/llvm-brew.toolchain.cmake index e488265f..4717e1a8 100644 --- a/cmake/llvm-brew.toolchain.cmake +++ b/cmake/llvm-brew.toolchain.cmake @@ -7,16 +7,39 @@ # 1. Set the target system (macOS) set(CMAKE_SYSTEM_NAME Darwin) +# Ensure a non-empty system version for third-party CMake logic. +if(NOT CMAKE_SYSTEM_VERSION) + execute_process( + COMMAND sw_vers -productVersion + OUTPUT_VARIABLE _yaze_macos_version + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_QUIET + ) + if(_yaze_macos_version) + set(CMAKE_SYSTEM_VERSION "${_yaze_macos_version}") + else() + set(CMAKE_SYSTEM_VERSION "0") + endif() +endif() + # 2. Find the Homebrew LLVM installation path # We use execute_process to make this portable across machine architectures. -execute_process( - COMMAND brew --prefix llvm@18 - OUTPUT_VARIABLE HOMEBREW_LLVM_PREFIX - OUTPUT_STRIP_TRAILING_WHITESPACE -) +set(_yaze_llvm_candidates llvm@21 llvm@20 llvm@19 llvm@18 llvm) +foreach(_yaze_llvm_candidate IN LISTS _yaze_llvm_candidates) + execute_process( + COMMAND brew --prefix ${_yaze_llvm_candidate} + OUTPUT_VARIABLE _yaze_llvm_prefix + OUTPUT_STRIP_TRAILING_WHITESPACE + RESULT_VARIABLE _yaze_llvm_result + ) + if(_yaze_llvm_result EQUAL 0 AND EXISTS "${_yaze_llvm_prefix}") + set(HOMEBREW_LLVM_PREFIX "${_yaze_llvm_prefix}") + break() + endif() +endforeach() if(NOT EXISTS "${HOMEBREW_LLVM_PREFIX}") - message(FATAL_ERROR "Homebrew LLVM not found. Please run 'brew install llvm'. Path: ${HOMEBREW_LLVM_PREFIX}") + message(FATAL_ERROR "Homebrew LLVM not found. Please run 'brew install llvm'.") endif() # Cache this variable so it's available in the main CMakeLists.txt @@ -52,18 +75,29 @@ execute_process( set(CMAKE_SYSROOT "${CMAKE_OSX_SYSROOT}") message(STATUS "Using macOS SDK at: ${CMAKE_SYSROOT}") -# 5. **[THE CRITICAL FIX]** Explicitly define the C++ standard library include directory. -# This forces CMake to add Homebrew's libc++ headers to the search path *before* -# any other system paths, resolving the header conflict for the main project - # and all dependencies. -set(CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES "${HOMEBREW_LLVM_PREFIX}/include/c++/v1") +# 5. Ensure Homebrew libc++ + Clang resource headers are searched before SDK headers. +execute_process( + COMMAND "${HOMEBREW_LLVM_PREFIX}/bin/clang++" -print-resource-dir + OUTPUT_VARIABLE HOMEBREW_LLVM_RESOURCE_DIR + OUTPUT_STRIP_TRAILING_WHITESPACE +) +set(HOMEBREW_LLVM_RESOURCE_INCLUDE "${HOMEBREW_LLVM_RESOURCE_DIR}/include") + +if(EXISTS "${HOMEBREW_LLVM_PREFIX}/include/c++/v1") + set(CMAKE_INCLUDE_DIRECTORIES_BEFORE ON) + include_directories(BEFORE SYSTEM "${HOMEBREW_LLVM_PREFIX}/include/c++/v1") +endif() +if(EXISTS "${HOMEBREW_LLVM_RESOURCE_INCLUDE}") + include_directories(BEFORE SYSTEM "${HOMEBREW_LLVM_RESOURCE_INCLUDE}") +endif() # 5.5 Ensure Homebrew libc++ is linked to avoid mixing ABI with system libc++. set(_yaze_llvm_lib_dir "${HOMEBREW_LLVM_PREFIX}/lib") +set(_yaze_llvm_libcxx_dir "${HOMEBREW_LLVM_PREFIX}/lib/c++") set(CMAKE_CXX_FLAGS_INIT "${CMAKE_CXX_FLAGS_INIT} -stdlib=libc++") -set(CMAKE_EXE_LINKER_FLAGS_INIT "${CMAKE_EXE_LINKER_FLAGS_INIT} -L${_yaze_llvm_lib_dir} -Wl,-rpath,${_yaze_llvm_lib_dir}") -set(CMAKE_SHARED_LINKER_FLAGS_INIT "${CMAKE_SHARED_LINKER_FLAGS_INIT} -L${_yaze_llvm_lib_dir} -Wl,-rpath,${_yaze_llvm_lib_dir}") -set(CMAKE_MODULE_LINKER_FLAGS_INIT "${CMAKE_MODULE_LINKER_FLAGS_INIT} -L${_yaze_llvm_lib_dir} -Wl,-rpath,${_yaze_llvm_lib_dir}") +set(CMAKE_EXE_LINKER_FLAGS_INIT "${CMAKE_EXE_LINKER_FLAGS_INIT} -L${_yaze_llvm_lib_dir} -Wl,-rpath,${_yaze_llvm_lib_dir} -L${_yaze_llvm_libcxx_dir} -Wl,-rpath,${_yaze_llvm_libcxx_dir}") +set(CMAKE_SHARED_LINKER_FLAGS_INIT "${CMAKE_SHARED_LINKER_FLAGS_INIT} -L${_yaze_llvm_lib_dir} -Wl,-rpath,${_yaze_llvm_lib_dir} -L${_yaze_llvm_libcxx_dir} -Wl,-rpath,${_yaze_llvm_libcxx_dir}") +set(CMAKE_MODULE_LINKER_FLAGS_INIT "${CMAKE_MODULE_LINKER_FLAGS_INIT} -L${_yaze_llvm_lib_dir} -Wl,-rpath,${_yaze_llvm_lib_dir} -L${_yaze_llvm_libcxx_dir} -Wl,-rpath,${_yaze_llvm_libcxx_dir}") # 6. Set the default installation path for macOS frameworks set(CMAKE_FIND_FRAMEWORK FIRST) diff --git a/cmake/options.cmake b/cmake/options.cmake index 829e7159..06b0fdcc 100644 --- a/cmake/options.cmake +++ b/cmake/options.cmake @@ -8,6 +8,7 @@ option(YAZE_BUILD_Z3ED "Build z3ed CLI executable" ON) option(YAZE_BUILD_EMU "Build emulator components" ON) option(YAZE_BUILD_LIB "Build static library" ON) option(YAZE_BUILD_TESTS "Build test suite" ON) +option(YAZE_BUILD_TOOLS "Build development utility tools" ${YAZE_BUILD_TESTS}) # Feature flags option(YAZE_ENABLE_GRPC "Enable gRPC agent support" ON) @@ -149,4 +150,3 @@ message(STATUS "Sanitizers: ${YAZE_ENABLE_SANITIZERS}") message(STATUS "Coverage: ${YAZE_ENABLE_COVERAGE}") message(STATUS "OpenCV Visual Analysis: ${YAZE_ENABLE_OPENCV}") message(STATUS "=================================") - diff --git a/scripts/verify-build-environment.ps1 b/scripts/verify-build-environment.ps1 index f02f2123..e670cc2b 100644 --- a/scripts/verify-build-environment.ps1 +++ b/scripts/verify-build-environment.ps1 @@ -60,8 +60,6 @@ function Test-GitSubmodules { "src/lib/abseil-cpp", "ext/asar", "ext/imgui", - "ext/json", - "ext/httplib", "ext/imgui_test_engine", "ext/nativefiledialog-extended" ) diff --git a/scripts/verify-build-environment.sh b/scripts/verify-build-environment.sh index d0e24476..9de0bbe6 100755 --- a/scripts/verify-build-environment.sh +++ b/scripts/verify-build-environment.sh @@ -94,8 +94,6 @@ function test_git_submodules() { "src/lib/abseil-cpp" "ext/asar" "ext/imgui" - "ext/json" - "ext/httplib" "ext/imgui_test_engine" "ext/nativefiledialog-extended" ) @@ -274,17 +272,27 @@ function sync_git_submodules() { function test_dependency_compatibility() { write_status "Testing dependency configuration..." "Step" - - # Check httplib configuration - if [[ -f "ext/httplib/CMakeLists.txt" ]]; then - write_status "httplib found in ext/" "Success" - SUCCESS+=("httplib header-only library available") - fi - - # Check json library - if [[ -d "ext/json/include" ]]; then - write_status "nlohmann/json found in ext/" "Success" - SUCCESS+=("nlohmann/json header-only library available") + + local deps_found=0 + local build_dirs=( + "build" + "build-wasm" + "build-test" + "build-grpc-test" + "build_agent" + "build_ci" + ) + + for dir in "${build_dirs[@]}"; do + if [[ -d "$dir/_deps/nlohmann_json-src" ]] || [[ -d "$dir/_deps/httplib-src" ]]; then + write_status "CPM dependencies present in $dir/_deps" "Success" + SUCCESS+=("CPM dependencies available in $dir") + deps_found=1 + fi + done + + if [[ $deps_found -eq 0 ]]; then + write_status "cpp-httplib and nlohmann/json are fetched by CPM during configure" "Info" fi } diff --git a/src/app/app_core.cmake b/src/app/app_core.cmake index aea2ccf8..804f1a27 100644 --- a/src/app/app_core.cmake +++ b/src/app/app_core.cmake @@ -109,8 +109,9 @@ if(APPLE) ) if(YAZE_ENABLE_JSON) - target_include_directories(yaze_app_objcxx PUBLIC - ${CMAKE_SOURCE_DIR}/ext/json/include) + if(TARGET nlohmann_json::nlohmann_json) + target_link_libraries(yaze_app_objcxx PUBLIC nlohmann_json::nlohmann_json) + endif() target_compile_definitions(yaze_app_objcxx PUBLIC YAZE_WITH_JSON) endif() @@ -121,7 +122,7 @@ if(APPLE) if(NOT COCOA_LIBRARY) message(FATAL_ERROR "Cocoa not found") endif() - set(CMAKE_EXE_LINKER_FLAGS "-framework ServiceManagement -framework Foundation -framework Cocoa") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -framework ServiceManagement -framework Foundation -framework Cocoa") endif() # Create the application core library @@ -139,13 +140,13 @@ target_include_directories(yaze_app_core_lib PUBLIC ${CMAKE_SOURCE_DIR}/src/app ${CMAKE_SOURCE_DIR}/ext ${CMAKE_SOURCE_DIR}/ext/imgui - ${CMAKE_SOURCE_DIR}/ext/json/include ${CMAKE_SOURCE_DIR}/incl ${SDL2_INCLUDE_DIR} ${PROJECT_BINARY_DIR} ) if(YAZE_ENABLE_JSON) + target_link_libraries(yaze_app_core_lib PUBLIC nlohmann_json::nlohmann_json) target_compile_definitions(yaze_app_core_lib PUBLIC YAZE_WITH_JSON) endif() @@ -174,8 +175,6 @@ endif() # gRPC Services (Optional) if(YAZE_WITH_GRPC) - target_include_directories(yaze_app_core_lib PRIVATE - ${CMAKE_SOURCE_DIR}/ext/json/include) target_compile_definitions(yaze_app_core_lib PRIVATE YAZE_WITH_JSON) # Link to consolidated gRPC support library target_link_libraries(yaze_app_core_lib PUBLIC yaze_grpc_support) diff --git a/src/app/editor/editor_library.cmake b/src/app/editor/editor_library.cmake index 67c38143..f2148d7f 100644 --- a/src/app/editor/editor_library.cmake +++ b/src/app/editor/editor_library.cmake @@ -112,6 +112,7 @@ set( app/editor/layout_designer/widget_code_generator.cc app/editor/layout_designer/theme_properties.cc app/editor/layout_designer/yaze_widgets.cc + yaze.cc ) # Agent UI Theme is always needed (used by dungeon editor, etc.) @@ -193,9 +194,6 @@ endif() # Note: yaze_test_support linking is deferred to test.cmake to ensure proper ordering if(YAZE_ENABLE_JSON) - target_include_directories(yaze_editor PUBLIC - ${CMAKE_SOURCE_DIR}/ext/json/include) - if(TARGET nlohmann_json::nlohmann_json) target_link_libraries(yaze_editor PUBLIC nlohmann_json::nlohmann_json) endif() diff --git a/src/app/net/net_library.cmake b/src/app/net/net_library.cmake index 6cb20045..23ceca44 100644 --- a/src/app/net/net_library.cmake +++ b/src/app/net/net_library.cmake @@ -57,8 +57,6 @@ target_include_directories(yaze_net PUBLIC ${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/ext ${CMAKE_SOURCE_DIR}/ext/imgui - ${CMAKE_SOURCE_DIR}/ext/json/include - ${CMAKE_SOURCE_DIR}/ext/httplib ${PROJECT_BINARY_DIR} ) @@ -69,6 +67,10 @@ target_link_libraries(yaze_net PUBLIC ${YAZE_SDL2_TARGETS} ) +if(NOT EMSCRIPTEN AND YAZE_HTTPLIB_TARGETS) + target_link_libraries(yaze_net PUBLIC ${YAZE_HTTPLIB_TARGETS}) +endif() + # Add Emscripten-specific flags for WASM builds if(EMSCRIPTEN) # Enable Fetch API for HTTP requests @@ -87,7 +89,6 @@ endif() if(YAZE_ENABLE_JSON) # Link nlohmann_json which provides the include directories automatically target_link_libraries(yaze_net PUBLIC nlohmann_json::nlohmann_json) - target_include_directories(yaze_net PUBLIC ${CMAKE_SOURCE_DIR}/ext/httplib) target_compile_definitions(yaze_net PUBLIC YAZE_WITH_JSON) # Add threading support (cross-platform) diff --git a/src/app/service/grpc_support.cmake b/src/app/service/grpc_support.cmake index 17593d7b..edbfde33 100644 --- a/src/app/service/grpc_support.cmake +++ b/src/app/service/grpc_support.cmake @@ -58,8 +58,7 @@ target_link_libraries(yaze_grpc_support PUBLIC # Add JSON support if(YAZE_ENABLE_JSON) - target_include_directories(yaze_grpc_support PUBLIC - ${CMAKE_SOURCE_DIR}/ext/json/include) + target_link_libraries(yaze_grpc_support PUBLIC nlohmann_json::nlohmann_json) target_compile_definitions(yaze_grpc_support PUBLIC YAZE_WITH_JSON) endif() diff --git a/src/app/test/test.cmake b/src/app/test/test.cmake index 5e093a3c..ca0a5a93 100644 --- a/src/app/test/test.cmake +++ b/src/app/test/test.cmake @@ -45,8 +45,6 @@ target_link_libraries(yaze_test_support PUBLIC # Add gRPC dependencies if test harness is enabled if(YAZE_WITH_GRPC) - target_include_directories(yaze_test_support PRIVATE - ${CMAKE_SOURCE_DIR}/ext/json/include) target_compile_definitions(yaze_test_support PRIVATE YAZE_WITH_JSON) # Link to consolidated gRPC support library @@ -80,4 +78,4 @@ message(STATUS "✓ yaze_test_support library configured") # Note: yaze_editor needs yaze_test_support for TestManager, but we can't link it here # because this happens BEFORE yaze and yaze_emu are configured. # Instead, each executable (yaze, yaze_emu) must explicitly link yaze_test_support -# in their respective .cmake files (app.cmake, emu.cmake). \ No newline at end of file +# in their respective .cmake files (app.cmake, emu.cmake). diff --git a/src/cli/agent.cmake b/src/cli/agent.cmake index fb443aa2..7feec7f1 100644 --- a/src/cli/agent.cmake +++ b/src/cli/agent.cmake @@ -87,7 +87,6 @@ if(EMSCRIPTEN) # Add JSON support for API communication if(YAZE_ENABLE_JSON) - target_include_directories(yaze_agent PUBLIC ${CMAKE_SOURCE_DIR}/ext/json/include) target_link_libraries(yaze_agent PUBLIC nlohmann_json::nlohmann_json) target_compile_definitions(yaze_agent PUBLIC YAZE_WITH_JSON) endif() @@ -288,6 +287,10 @@ endif() target_link_libraries(yaze_agent PUBLIC ${_yaze_agent_link_targets}) +if(NOT EMSCRIPTEN AND YAZE_HTTPLIB_TARGETS) + target_link_libraries(yaze_agent PUBLIC ${YAZE_HTTPLIB_TARGETS}) +endif() + # Ensure yaml-cpp include paths propagate even when using system packages if(YAZE_ENABLE_AI_RUNTIME) set(_yaml_targets_to_check ${YAZE_YAML_TARGETS} yaml-cpp yaml-cpp::yaml-cpp) @@ -306,24 +309,21 @@ target_include_directories(yaze_agent PUBLIC ${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/incl - ${CMAKE_SOURCE_DIR}/ext/httplib ${CMAKE_SOURCE_DIR}/src/lib ${CMAKE_SOURCE_DIR}/src/cli/handlers ${CMAKE_BINARY_DIR}/gens ) -if(YAZE_ENABLE_AI_RUNTIME AND YAZE_ENABLE_JSON) - target_include_directories(yaze_agent PUBLIC ${CMAKE_SOURCE_DIR}/ext/json/include) -endif() - if(SDL2_INCLUDE_DIR) target_include_directories(yaze_agent PUBLIC ${SDL2_INCLUDE_DIR}) endif() -if(YAZE_ENABLE_AI_RUNTIME AND YAZE_ENABLE_JSON) +if(YAZE_ENABLE_JSON) target_link_libraries(yaze_agent PUBLIC nlohmann_json::nlohmann_json) target_compile_definitions(yaze_agent PUBLIC YAZE_WITH_JSON) +endif() +if(YAZE_ENABLE_AI_RUNTIME AND YAZE_ENABLE_JSON) # Only link OpenSSL if gRPC is NOT enabled (to avoid duplicate symbol errors) # When gRPC is enabled, it brings its own OpenSSL which we'll use instead if(NOT YAZE_ENABLE_REMOTE_AUTOMATION) diff --git a/src/cli/service/api/README.md b/src/cli/service/api/README.md index 75ad5416..981dbac3 100644 --- a/src/cli/service/api/README.md +++ b/src/cli/service/api/README.md @@ -155,7 +155,7 @@ Access-Control-Allow-Origin: * ### Architecture The HTTP API is built using: -- **cpp-httplib** - Header-only HTTP server library (`ext/httplib/`) +- **cpp-httplib** - Header-only HTTP server library (fetched via CPM) - **nlohmann/json** - JSON serialization/deserialization - **ModelRegistry** - Unified model management across providers diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 3b2c308b..8ac844a5 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -48,9 +48,6 @@ target_link_libraries(yaze_core_lib PUBLIC # JSON support for project serialization if(TARGET nlohmann_json::nlohmann_json) target_link_libraries(yaze_core_lib PUBLIC nlohmann_json::nlohmann_json) - target_include_directories(yaze_core_lib PUBLIC - ${CMAKE_SOURCE_DIR}/ext/json/include - ) endif() # Add Asar support (links asar-static and adds YAZE_ENABLE_ASAR definition) diff --git a/src/zelda3/zelda3_library.cmake b/src/zelda3/zelda3_library.cmake index b65d16b0..f45e21dc 100644 --- a/src/zelda3/zelda3_library.cmake +++ b/src/zelda3/zelda3_library.cmake @@ -76,7 +76,6 @@ target_include_directories(yaze_zelda3 PUBLIC ${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/src/lib ${CMAKE_SOURCE_DIR}/incl - ${CMAKE_SOURCE_DIR}/ext/json/include ${PROJECT_BINARY_DIR} ) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 890025e3..04cfb14d 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -17,6 +17,7 @@ if(YAZE_BUILD_TESTS) endif() target_include_directories(${suite_name} PUBLIC + ${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/incl ${CMAKE_SOURCE_DIR}/test @@ -26,7 +27,6 @@ if(YAZE_BUILD_TESTS) ${CMAKE_SOURCE_DIR}/ext/imgui/backends ${CMAKE_SOURCE_DIR}/ext/imgui_test_engine ${CMAKE_SOURCE_DIR}/ext/SDL/include - ${CMAKE_SOURCE_DIR}/ext/json/include ${CMAKE_BINARY_DIR}/ext/SDL/include ${PROJECT_BINARY_DIR} ) @@ -42,6 +42,13 @@ if(YAZE_BUILD_TESTS) ${YAZE_SDL2_TARGETS} ) + if(YAZE_ENABLE_JSON AND TARGET nlohmann_json::nlohmann_json) + target_link_libraries(${suite_name} PRIVATE nlohmann_json::nlohmann_json) + endif() + if(TARGET httplib::httplib) + target_link_libraries(${suite_name} PRIVATE httplib::httplib) + endif() + # Link ImGui Test Engine for GUI tests (always available when tests are built) if(is_gui_test AND TARGET ImGuiTestEngine) target_link_libraries(${suite_name} PRIVATE ImGuiTestEngine) @@ -92,6 +99,7 @@ if(YAZE_BUILD_TESTS) # Unit Tests unit/core/asar_wrapper_test.cc unit/core/hex_test.cc + unit/deps/dependency_smoke_test.cc unit/cli/resource_catalog_test.cc unit/rom/rom_test.cc unit/gfx/snes_tile_test.cc diff --git a/test/unit/deps/dependency_smoke_test.cc b/test/unit/deps/dependency_smoke_test.cc new file mode 100644 index 00000000..5cfd9328 --- /dev/null +++ b/test/unit/deps/dependency_smoke_test.cc @@ -0,0 +1,21 @@ +#include "httplib.h" +#include "nlohmann/json.hpp" +#include "testing.h" + +namespace yaze { +namespace test { + +TEST(DependencySmokeTest, JsonAndHttpLibAvailable) { + nlohmann::json payload = nlohmann::json::parse(R"({"ok":true})"); + EXPECT_TRUE(payload["ok"].get()); + + httplib::Client client("example.com"); + httplib::Headers headers{{"X-Test", "1"}}; + client.set_default_headers(headers); + auto header_it = headers.find("X-Test"); + ASSERT_NE(header_it, headers.end()); + EXPECT_EQ(header_it->second, "1"); +} + +} // namespace test +} // namespace yaze