From d6b3606bd60b6efb4515fc4f6fe7f94a033b8cb5 Mon Sep 17 00:00:00 2001 From: Martin Brodbeck Date: Mon, 17 Mar 2025 14:34:54 +0100 Subject: [PATCH] Simplyfy nlohmann_json integration --- .gitmodules | 3 --- CMakeLists.txt | 4 ++-- src/core/CMakeLists.txt | 7 +++---- src/gui/CMakeLists.txt | 1 - subprojects/CMakeLists.txt | 5 ----- subprojects/nlohmann_json | 1 - 6 files changed, 5 insertions(+), 16 deletions(-) delete mode 100644 subprojects/CMakeLists.txt delete mode 160000 subprojects/nlohmann_json diff --git a/.gitmodules b/.gitmodules index 23e007e..e69de29 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +0,0 @@ -[submodule "subprojects/nlohmann_json"] - path = subprojects/nlohmann_json - url = https://github.com/nlohmann/json.git diff --git a/CMakeLists.txt b/CMakeLists.txt index d8d0cb3..8a76d26 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,7 +7,8 @@ set(CMAKE_MODULE_PATH "${CMAKE_HOME_DIRECTORY}/cmake") set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) -#include(InstallRequiredSystemLibraries) +# For SingleApplication and nlohmann_json +include(FetchContent) if(MSVC) add_compile_options(/W4 /WX) @@ -29,7 +30,6 @@ if(KIMA2_USE_EXTERNAL_JSON) find_package(nlohmann_json REQUIRED) endif() -add_subdirectory(subprojects) add_subdirectory(src) #if(NOT CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE MATCHES Debug) diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 402c687..b4934ca 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -3,9 +3,8 @@ set(Boost_USE_STATIC_LIBS ON) find_package(Boost 1.78 REQUIRED) find_package(SQLite3 REQUIRED) -# Because csv-parser needs threads: - -find_package(fmt) +FetchContent_Declare(json URL https://github.com/nlohmann/json/releases/download/v3.11.3/json.tar.xz) +FetchContent_MakeAvailable(json) set(CORE_SOURCES database.cpp @@ -23,7 +22,7 @@ set(CORE_SOURCES add_library(core STATIC ${CORE_SOURCES}) -#target_include_directories(core PRIVATE ${PROJECT_SOURCE_DIR}/subprojects/csv-parser/single_include) + if (WIN32) target_link_libraries(core PRIVATE sqlite3 nlohmann_json::nlohmann_json) target_link_libraries(core PRIVATE bcrypt) diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index 54f3c40..9edba98 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -11,7 +11,6 @@ set(CMAKE_AUTORCC ON) find_package(Qt6 COMPONENTS Widgets Network PrintSupport CONFIG REQUIRED) # For SingleApplication: -include(FetchContent) set(QT_DEFAULT_MAJOR_VERSION 6 CACHE STRING "Qt version to use, defaults to 6") set(QAPPLICATION_CLASS QApplication CACHE STRING "Inheritance class for SingleApplication") FetchContent_Declare( diff --git a/subprojects/CMakeLists.txt b/subprojects/CMakeLists.txt deleted file mode 100644 index 6ef42eb..0000000 --- a/subprojects/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -if(NOT KIMA2_USE_EXTERNAL_JSON) - set(JSON_BuildTests OFF CACHE INTERNAL "") - add_subdirectory(nlohmann_json EXCLUDE_FROM_ALL) -endif() -#add_subdirectory(csv-parser) diff --git a/subprojects/nlohmann_json b/subprojects/nlohmann_json deleted file mode 160000 index 9cca280..0000000 --- a/subprojects/nlohmann_json +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 9cca280a4d0ccf0c08f47a99aa71d1b0e52f8d03