From 63f9a9f9d4c682dd8f983efa8c2c5f9892bf9db7 Mon Sep 17 00:00:00 2001 From: Aaron Kimbre Date: Tue, 23 Apr 2024 16:29:57 -0500 Subject: [PATCH 1/2] feat: add nlohmann/json lib --- CMakeLists.txt | 3 ++- cmake/FindJSON.cmake | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 cmake/FindJSON.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index aa517182..ed1a46f1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -96,6 +96,7 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) find_package(MariaDB) +find_package(JSON) # Create a /resServer directory make_directory(${CMAKE_BINARY_DIR}/resServer) @@ -284,7 +285,7 @@ add_subdirectory(dPhysics) add_subdirectory(dServer) # Create a list of common libraries shared between all binaries -set(COMMON_LIBRARIES "dCommon" "dDatabase" "dNet" "raknet" "MariaDB::ConnCpp" "magic_enum") +set(COMMON_LIBRARIES "dCommon" "dDatabase" "dNet" "raknet" "MariaDB::ConnCpp" "magic_enum" "nlohmann_json::nlohmann_json") # Add platform specific common libraries if(UNIX) diff --git a/cmake/FindJSON.cmake b/cmake/FindJSON.cmake new file mode 100644 index 00000000..2d32a4db --- /dev/null +++ b/cmake/FindJSON.cmake @@ -0,0 +1,21 @@ +include(FetchContent) + +message(STATUS "Fetching json...") + +FetchContent_Declare( + json + GIT_REPOSITORY https://github.com/nlohmann/json + GIT_TAG v3.11.3 +) + +FetchContent_GetProperties(json) +if(NOT json_POPULATED) + set(JSON_BuildTests OFF CACHE INTERNAL "") + FetchContent_Populate(json) + add_subdirectory(${json_SOURCE_DIR} ${json_BINARY_DIR} EXCLUDE_FROM_ALL) +endif() + +FetchContent_MakeAvailable(json) + +message(STATUS "json fetched and is now ready.") +set(JSON_FOUND TRUE) From 29e759f793583bb74ba5c6e41df69f486292aadd Mon Sep 17 00:00:00 2001 From: Aaron Kimbrell Date: Wed, 24 Apr 2024 10:00:37 -0500 Subject: [PATCH 2/2] remove build test off --- cmake/FindJSON.cmake | 1 - 1 file changed, 1 deletion(-) diff --git a/cmake/FindJSON.cmake b/cmake/FindJSON.cmake index 2d32a4db..291ebcd3 100644 --- a/cmake/FindJSON.cmake +++ b/cmake/FindJSON.cmake @@ -10,7 +10,6 @@ FetchContent_Declare( FetchContent_GetProperties(json) if(NOT json_POPULATED) - set(JSON_BuildTests OFF CACHE INTERNAL "") FetchContent_Populate(json) add_subdirectory(${json_SOURCE_DIR} ${json_BINARY_DIR} EXCLUDE_FROM_ALL) endif()