deps: move json/httplib to CPM
This commit is contained in:
9
.gitmodules
vendored
9
.gitmodules
vendored
@@ -13,12 +13,3 @@
|
||||
[submodule "ext/nativefiledialog-extended"]
|
||||
path = ext/nativefiledialog-extended
|
||||
url = https://github.com/btzy/nativefiledialog-extended.git
|
||||
[submodule "assets/asm/usdasm"]
|
||||
path = assets/asm/usdasm
|
||||
url = https://github.com/spannerisms/usdasm.git
|
||||
[submodule "ext/json"]
|
||||
path = ext/json
|
||||
url = https://github.com/nlohmann/json.git
|
||||
[submodule "ext/httplib"]
|
||||
path = ext/httplib
|
||||
url = https://github.com/yhirose/cpp-httplib.git
|
||||
|
||||
@@ -35,8 +35,12 @@ endif()
|
||||
include(${CPM_DOWNLOAD_LOCATION})
|
||||
|
||||
# Set CPM options for better caching and performance
|
||||
set(CPM_USE_LOCAL_PACKAGES ON)
|
||||
set(CPM_LOCAL_PACKAGES_ONLY OFF)
|
||||
if(NOT DEFINED CPM_USE_LOCAL_PACKAGES)
|
||||
set(CPM_USE_LOCAL_PACKAGES OFF)
|
||||
endif()
|
||||
if(NOT DEFINED CPM_LOCAL_PACKAGES_ONLY)
|
||||
set(CPM_LOCAL_PACKAGES_ONLY OFF)
|
||||
endif()
|
||||
set(CPM_DONT_CREATE_PACKAGE_LOCK ON)
|
||||
set(CPM_DONT_UPDATE_MODULE_PATH ON)
|
||||
set(CPM_DONT_PREPEND_TO_MODULE_PATH ON)
|
||||
@@ -46,4 +50,3 @@ if(DEFINED ENV{GITHUB_ACTIONS})
|
||||
set(CPM_SOURCE_CACHE "$ENV{HOME}/.cpm-cache")
|
||||
message(STATUS "CPM cache directory: ${CPM_SOURCE_CACHE}")
|
||||
endif()
|
||||
|
||||
|
||||
@@ -8,6 +8,9 @@ include(cmake/dependencies.lock)
|
||||
|
||||
message(STATUS "=== Setting up YAZE dependencies with CPM.cmake ===")
|
||||
|
||||
# Only prefer local/system packages when explicitly requested.
|
||||
set(CPM_USE_LOCAL_PACKAGES ${YAZE_USE_SYSTEM_DEPS} CACHE BOOL "" FORCE)
|
||||
|
||||
# Clear any previous dependency targets
|
||||
set(YAZE_ALL_DEPENDENCIES "")
|
||||
set(YAZE_SDL2_TARGETS "")
|
||||
@@ -15,6 +18,7 @@ set(YAZE_YAML_TARGETS "")
|
||||
set(YAZE_IMGUI_TARGETS "")
|
||||
set(YAZE_IMPLOT_TARGETS "")
|
||||
set(YAZE_JSON_TARGETS "")
|
||||
set(YAZE_HTTPLIB_TARGETS "")
|
||||
set(YAZE_GRPC_TARGETS "")
|
||||
set(YAZE_FTXUI_TARGETS "")
|
||||
set(YAZE_TESTING_TARGETS "")
|
||||
@@ -54,6 +58,12 @@ if(YAZE_ENABLE_JSON)
|
||||
list(APPEND YAZE_ALL_DEPENDENCIES ${YAZE_JSON_TARGETS})
|
||||
endif()
|
||||
|
||||
# Native HTTP/HTTPS (cpp-httplib) for non-WASM builds
|
||||
if(NOT EMSCRIPTEN)
|
||||
include(cmake/dependencies/httplib.cmake)
|
||||
list(APPEND YAZE_ALL_DEPENDENCIES ${YAZE_HTTPLIB_TARGETS})
|
||||
endif()
|
||||
|
||||
# CRITICAL: Load testing dependencies BEFORE gRPC when both are enabled
|
||||
# This ensures gmock is available before Abseil (bundled with gRPC) tries to export test_allocator
|
||||
# which depends on gmock. This prevents CMake export errors.
|
||||
@@ -95,6 +105,9 @@ endif()
|
||||
if(YAZE_ENABLE_GRPC)
|
||||
message(STATUS "gRPC: ${YAZE_GRPC_TARGETS}")
|
||||
endif()
|
||||
if(NOT EMSCRIPTEN)
|
||||
message(STATUS "httplib: ${YAZE_HTTPLIB_TARGETS}")
|
||||
endif()
|
||||
if(YAZE_BUILD_CLI AND NOT EMSCRIPTEN)
|
||||
message(STATUS "FTXUI: ${YAZE_FTXUI_TARGETS}")
|
||||
endif()
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
# Core dependencies
|
||||
set(SDL2_VERSION "2.30.0" CACHE STRING "SDL2 version")
|
||||
set(YAML_CPP_VERSION "0.8.0" CACHE STRING "yaml-cpp version")
|
||||
set(NLOHMANN_JSON_VERSION "3.11.3" CACHE STRING "nlohmann/json version")
|
||||
set(HTTPLIB_VERSION "0.26.0" CACHE STRING "cpp-httplib version")
|
||||
|
||||
# gRPC and related
|
||||
# Using v1.67.1 for MSVC compatibility (v1.75.1 has UPB compilation errors on Windows)
|
||||
@@ -26,4 +28,3 @@ set(IMGUI_VERSION "1.90.4" CACHE STRING "Dear ImGui version")
|
||||
|
||||
# ASAR
|
||||
set(ASAR_VERSION "main" CACHE STRING "ASAR version")
|
||||
|
||||
|
||||
55
cmake/dependencies/httplib.cmake
Normal file
55
cmake/dependencies/httplib.cmake
Normal file
@@ -0,0 +1,55 @@
|
||||
# cpp-httplib dependency management
|
||||
|
||||
if(EMSCRIPTEN)
|
||||
set(YAZE_HTTPLIB_TARGETS "" CACHE INTERNAL "cpp-httplib targets")
|
||||
return()
|
||||
endif()
|
||||
|
||||
include(cmake/CPM.cmake)
|
||||
include(cmake/dependencies.lock)
|
||||
|
||||
message(STATUS "Setting up cpp-httplib ${HTTPLIB_VERSION}")
|
||||
|
||||
set(_YAZE_USE_SYSTEM_HTTPLIB ${YAZE_USE_SYSTEM_DEPS})
|
||||
|
||||
# Try to use system packages first
|
||||
if(_YAZE_USE_SYSTEM_HTTPLIB)
|
||||
find_package(httplib QUIET)
|
||||
if(httplib_FOUND)
|
||||
message(STATUS "Using system httplib")
|
||||
set(YAZE_HTTPLIB_TARGETS httplib::httplib CACHE INTERNAL "cpp-httplib targets")
|
||||
return()
|
||||
elseif(YAZE_USE_SYSTEM_DEPS)
|
||||
message(WARNING "System httplib not found despite YAZE_USE_SYSTEM_DEPS=ON; falling back to CPM download")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
CPMAddPackage(
|
||||
NAME httplib
|
||||
VERSION ${HTTPLIB_VERSION}
|
||||
GITHUB_REPOSITORY yhirose/cpp-httplib
|
||||
GIT_TAG v${HTTPLIB_VERSION}
|
||||
OPTIONS
|
||||
"HTTPLIB_INSTALL OFF"
|
||||
"HTTPLIB_TEST OFF"
|
||||
"HTTPLIB_COMPILE OFF"
|
||||
"HTTPLIB_USE_OPENSSL_IF_AVAILABLE OFF"
|
||||
"HTTPLIB_USE_ZLIB_IF_AVAILABLE OFF"
|
||||
"HTTPLIB_USE_BROTLI_IF_AVAILABLE OFF"
|
||||
"HTTPLIB_USE_ZSTD_IF_AVAILABLE OFF"
|
||||
)
|
||||
|
||||
# Verify target is available
|
||||
if(TARGET httplib::httplib)
|
||||
message(STATUS "httplib::httplib target found")
|
||||
elseif(TARGET httplib)
|
||||
add_library(httplib::httplib ALIAS httplib)
|
||||
message(STATUS "Created httplib::httplib alias")
|
||||
else()
|
||||
message(FATAL_ERROR "httplib target not found after CPM fetch")
|
||||
endif()
|
||||
|
||||
set(YAZE_HTTPLIB_TARGETS httplib::httplib)
|
||||
set(YAZE_HTTPLIB_TARGETS httplib::httplib CACHE INTERNAL "cpp-httplib targets")
|
||||
|
||||
message(STATUS "cpp-httplib setup complete")
|
||||
@@ -4,14 +4,43 @@ if(NOT YAZE_ENABLE_JSON)
|
||||
return()
|
||||
endif()
|
||||
|
||||
message(STATUS "Setting up nlohmann_json with local ext directory")
|
||||
include(cmake/CPM.cmake)
|
||||
include(cmake/dependencies.lock)
|
||||
|
||||
message(STATUS "Setting up nlohmann_json ${NLOHMANN_JSON_VERSION}")
|
||||
|
||||
set(_YAZE_USE_SYSTEM_JSON ${YAZE_USE_SYSTEM_DEPS})
|
||||
|
||||
if(NOT _YAZE_USE_SYSTEM_JSON)
|
||||
unset(nlohmann_json_DIR CACHE)
|
||||
endif()
|
||||
|
||||
# Try to use system packages first
|
||||
if(_YAZE_USE_SYSTEM_JSON)
|
||||
find_package(nlohmann_json QUIET)
|
||||
if(nlohmann_json_FOUND)
|
||||
message(STATUS "Using system nlohmann_json")
|
||||
set(YAZE_JSON_TARGETS nlohmann_json::nlohmann_json CACHE INTERNAL "nlohmann_json targets")
|
||||
return()
|
||||
elseif(YAZE_USE_SYSTEM_DEPS)
|
||||
message(WARNING "System nlohmann_json not found despite YAZE_USE_SYSTEM_DEPS=ON; falling back to CPM download")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Use the bundled nlohmann_json from ext/json
|
||||
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}/ext/json EXCLUDE_FROM_ALL)
|
||||
CPMAddPackage(
|
||||
NAME nlohmann_json
|
||||
VERSION ${NLOHMANN_JSON_VERSION}
|
||||
GITHUB_REPOSITORY nlohmann/json
|
||||
GIT_TAG v${NLOHMANN_JSON_VERSION}
|
||||
OPTIONS
|
||||
"JSON_BuildTests OFF"
|
||||
"JSON_Install OFF"
|
||||
"JSON_MultipleHeaders OFF"
|
||||
)
|
||||
|
||||
# Verify target is available
|
||||
if(TARGET nlohmann_json::nlohmann_json)
|
||||
@@ -21,11 +50,11 @@ elseif(TARGET nlohmann_json)
|
||||
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")
|
||||
message(FATAL_ERROR "nlohmann_json target not found after CPM fetch")
|
||||
endif()
|
||||
|
||||
# Export for use in other CMake files
|
||||
set(YAZE_JSON_TARGETS nlohmann_json::nlohmann_json)
|
||||
set(YAZE_JSON_TARGETS nlohmann_json::nlohmann_json CACHE INTERNAL "nlohmann_json targets")
|
||||
|
||||
message(STATUS "nlohmann_json setup complete")
|
||||
|
||||
|
||||
Submodule ext/httplib deleted from 35c52c1ab9
1
ext/json
1
ext/json
Submodule ext/json deleted from 3ed64e502a
Reference in New Issue
Block a user