Skip to content

Commit

Permalink
Merge pull request #57935 from m-kuhn/externalize_nlohmann_json
Browse files Browse the repository at this point in the history
Externalize nlohmann
  • Loading branch information
m-kuhn authored Jun 30, 2024
2 parents 87d9a3e + c268fb1 commit efd29ee
Show file tree
Hide file tree
Showing 21 changed files with 28 additions and 21 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,8 @@ if(WITH_CORE)
find_package(EXPAT REQUIRED)
find_package(Spatialindex REQUIRED)
find_package(LibZip REQUIRED)
set (WITH_INTERNAL_NLOHMANN_JSON ON CACHE BOOL "Determines whether the vendored copy of nlohmann-json should be used")
find_package(nlohmann_json REQUIRED)

find_package(Sqlite3)
if (NOT SQLITE3_FOUND)
Expand Down
12 changes: 12 additions & 0 deletions cmake/Findnlohmann_json.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
if(WITH_INTERNAL_NLOHMANN_JSON)
# Create imported target nlohmann_json::nlohmann_json
add_library(nlohmann_json::nlohmann_json INTERFACE IMPORTED)

set_target_properties(nlohmann_json::nlohmann_json PROPERTIES
INTERFACE_COMPILE_DEFINITIONS "\$<\$<NOT:\$<BOOL:ON>>:JSON_USE_GLOBAL_UDLS=0>;\$<\$<NOT:\$<BOOL:ON>>:JSON_USE_IMPLICIT_CONVERSIONS=0>;\$<\$<BOOL:OFF>:JSON_DISABLE_ENUM_SERIALIZATION=1>;\$<\$<BOOL:OFF>:JSON_DIAGNOSTICS=1>;\$<\$<BOOL:OFF>:JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON=1>"
INTERFACE_COMPILE_FEATURES "cxx_std_11"
INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${CMAKE_SOURCE_DIR}/external/nlohmann/"
)
else()
find_package(nlohmann_json CONFIG REQUIRED)
endif()
2 changes: 1 addition & 1 deletion external/tinygltf/tiny_gltf.h
Original file line number Diff line number Diff line change
Expand Up @@ -1703,7 +1703,7 @@ class TinyGLTF {

#ifndef TINYGLTF_NO_INCLUDE_JSON
#ifndef TINYGLTF_USE_RAPIDJSON
#include "json.hpp"
#include <nlohmann/json.hpp>
#else
#ifndef TINYGLTF_NO_INCLUDE_RAPIDJSON
#include "document.h"
Expand Down
4 changes: 1 addition & 3 deletions src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1064,8 +1064,6 @@ else()
endif()

set(QGIS_CORE_HDRS
${CMAKE_SOURCE_DIR}/external/nlohmann/json_fwd.hpp

${CMAKE_BINARY_DIR}/qgsconfig.h

../plugins/qgisplugin.h
Expand Down Expand Up @@ -2371,7 +2369,6 @@ target_include_directories(qgis_core PUBLIC
web
${CMAKE_SOURCE_DIR}/external
${CMAKE_SOURCE_DIR}/external/delaunator-cpp
${CMAKE_SOURCE_DIR}/external/nlohmann
${CMAKE_SOURCE_DIR}/external/kdbush/include
${CMAKE_SOURCE_DIR}/external/nmea
${CMAKE_SOURCE_DIR}/external/rtree/include
Expand Down Expand Up @@ -2485,6 +2482,7 @@ target_link_libraries(qgis_core
${ZLIB_LIBRARIES}
${EXIV2_LIBRARY}
PROJ::proj
nlohmann_json::nlohmann_json
)

if(BUILD_WITH_QT6)
Expand Down
2 changes: 1 addition & 1 deletion src/core/geometry/qgsabstractgeometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ email : marco.hugentobler at sourcepole dot com
#include "qgswkbptr.h"

#ifndef SIP_RUN
#include "json_fwd.hpp"
#include <nlohmann/json_fwd.hpp>
using namespace nlohmann;
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/core/geometry/qgsgeometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ email : morb at ozemail dot com dot au
#include "qgsvertexid.h"

#ifndef SIP_RUN
#include "json_fwd.hpp"
#include <nlohmann/json_fwd.hpp>
using namespace nlohmann;
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsgml.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include <string>

#ifndef SIP_RUN
#include "json.hpp"
#include <nlohmann/json.hpp>
#endif

class QgsCoordinateReferenceSystem;
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsjsonutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include <QJsonObject>

#ifndef SIP_RUN
#include "json_fwd.hpp"
#include <nlohmann/json_fwd.hpp>
using namespace nlohmann;
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/core/tiledscene/qgscesiumutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include "qgsbox3d.h"
#include "qgsvector3d.h"
#include "qgis_sip.h"
#include "nlohmann/json_fwd.hpp"
#include <nlohmann/json_fwd.hpp>

#ifndef SIP_RUN
using namespace nlohmann;
Expand Down
1 change: 0 additions & 1 deletion src/process/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
set(QGIS_PROCESS_SRCS
main.cpp
qgsprocess.cpp
${CMAKE_SOURCE_DIR}/external/nlohmann/json_fwd.hpp
)

if (UNIX AND NOT ANDROID)
Expand Down
2 changes: 1 addition & 1 deletion src/process/qgsprocess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
#include <ogr_api.h>
#include <gdal_version.h>
#include <proj.h>
#include <json.hpp>
#include <nlohmann/json.hpp>

ConsoleFeedback::ConsoleFeedback( bool useJson )
: mUseJson( useJson )
Expand Down
1 change: 0 additions & 1 deletion src/providers/mdal/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ if (WITH_INTERNAL_MDAL)
${CMAKE_SOURCE_DIR}/external/mdal/3rdparty/libplyxx.h
${CMAKE_SOURCE_DIR}/external/mdal/3rdparty/libplyxx/libplyxx_internal.h
${CMAKE_SOURCE_DIR}/external/mdal/3rdparty/textio.h
${CMAKE_SOURCE_DIR}/external/nlohmann/json.hpp
)

if(HDF5_FOUND)
Expand Down
2 changes: 1 addition & 1 deletion src/providers/pdal/qgspdalprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include "qgsapplication.h"
#include "qgslogger.h"
#include "qgsjsonutils.h"
#include "json.hpp"
#include <nlohmann/json.hpp>
#include "qgspdalindexingtask.h"
#include "qgseptpointcloudindex.h"
#include "qgstaskmanager.h"
Expand Down
1 change: 0 additions & 1 deletion src/providers/wfs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# Files

set(WFS_SRCS
${CMAKE_SOURCE_DIR}/external/nlohmann/json.hpp
qgswfsprovider.cpp
qgswfsprovidermetadata.cpp
qgswfscapabilities.cpp
Expand Down
2 changes: 1 addition & 1 deletion src/server/qgsserverapiutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class QgsCoordinateReferenceSystem;
class QgsVectorLayer;

#ifndef SIP_RUN
#include "nlohmann/json_fwd.hpp"
#include <nlohmann/json_fwd.hpp>
using namespace nlohmann;
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/server/qgsserverogcapihandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include "qgis_server.h"
#include "qgsserverquerystringparameter.h"
#include "qgsserverogcapi.h"
#include "nlohmann/json_fwd.hpp"
#include <nlohmann/json_fwd.hpp>
#include "inja/inja.hpp"

#ifndef SIP_RUN
Expand Down
2 changes: 1 addition & 1 deletion src/server/qgsserverquerystringparameter.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include <QObject>


#include "nlohmann/json_fwd.hpp"
#include <nlohmann/json_fwd.hpp>

#ifndef SIP_RUN
using namespace nlohmann;
Expand Down
1 change: 0 additions & 1 deletion src/server/services/landingpage/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# Files

set (LANDINGPAGE_SRCS
${CMAKE_SOURCE_DIR}/external/nlohmann/json.hpp
${CMAKE_SOURCE_DIR}/external/inja/inja.hpp
qgslandingpage.cpp
qgslandingpageutils.cpp
Expand Down
2 changes: 1 addition & 1 deletion src/server/services/landingpage/qgslandingpageutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include <QStringList>
#include <QRegularExpression>

#include "nlohmann/json_fwd.hpp"
#include <nlohmann/json_fwd.hpp>
#include "qgsserversettings.h"
#include "qgsserverrequest.h"

Expand Down
1 change: 0 additions & 1 deletion src/server/services/wfs3/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# Files

set (WFS3_SRCS
${CMAKE_SOURCE_DIR}/external/nlohmann/json.hpp
${CMAKE_SOURCE_DIR}/external/inja/inja.hpp
qgswfs3.cpp
qgswfs3handlers.cpp
Expand Down
2 changes: 1 addition & 1 deletion tests/src/analysis/testqgsprocessing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
#include "qgspointcloudlayer.h"
#include "qgsannotationlayer.h"
#include "qgsjsonutils.h"
#include "json.hpp"
#include <nlohmann/json.hpp>
#include "qgsspatialindex.h"
#include "qgstiledscenelayer.h"
#include "qgsalignrasterdata.h"
Expand Down

0 comments on commit efd29ee

Please sign in to comment.