diff --git a/CMakeLists.txt b/CMakeLists.txt index 30a188a275..44f86883ad 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -98,6 +98,7 @@ OPTION(INDI_BUILD_XISF "Build XISF support" ON) # System provided or bundled libs OPTION(INDI_SYSTEM_HTTPLIB "Use system provided httplib" OFF) +OPTION(INDI_SYSTEM_JSONLIB "Use system provided json library" OFF) if(UNIX AND NOT APPLE) OPTION(INDI_SHARED_MEMORY "Build INDI with support for UNIX protocol with shared memory" ON) @@ -182,6 +183,18 @@ else() message(STATUS "Using bundled httplib") endif(INDI_SYSTEM_HTTPLIB) +if(INDI_SYSTEM_JSONLIB) + find_package(nlohmann_json REQUIRED) + set(SYSTEM_JSONLIB 1) + set(JSONLIB nlohmann_json::nlohmann_json) + add_definitions(-D_USE_SYSTEM_JSONLIB) + message(STATUS "Using system provided Niels Lohmann's json library") +else(INDI_SYSTEM_JSONLIB) + set(SYSTEM_JSONLIB 0) + set(JSONLIB "") + message(STATUS "Using bundled json library") +endif(INDI_SYSTEM_JSONLIB) + # ################################################################################################### # # Component : INDI Core @@ -397,7 +410,6 @@ endif() # Install common dev files for all except server if(INDI_BUILD_DRIVERS OR INDI_BUILD_CLIENT OR INDI_BUILD_QT5_CLIENT) install(FILES - ${CMAKE_CURRENT_SOURCE_DIR}/libs/json.h ${CMAKE_CURRENT_SOURCE_DIR}/libs/inicpp.h ${CMAKE_CURRENT_BINARY_DIR}/indiversion.h DESTINATION ${INCLUDE_INSTALL_DIR}/libindi COMPONENT Devel @@ -408,6 +420,12 @@ if(INDI_BUILD_DRIVERS OR INDI_BUILD_CLIENT OR INDI_BUILD_QT5_CLIENT) DESTINATION ${INCLUDE_INSTALL_DIR}/libindi COMPONENT Devel ) endif(NOT SYSTEM_HTTPLIB) + if(NOT SYSTEM_JSONLIB) + install(FILES + ${CMAKE_CURRENT_SOURCE_DIR}/libs/indijson.hpp + DESTINATION ${INCLUDE_INSTALL_DIR}/libindi COMPONENT Devel + ) + endif(NOT SYSTEM_JSONLIB) endif(INDI_BUILD_DRIVERS OR INDI_BUILD_CLIENT OR INDI_BUILD_QT5_CLIENT) feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) diff --git a/drivers/focuser/CMakeLists.txt b/drivers/focuser/CMakeLists.txt index 7497566279..88f094dc24 100644 --- a/drivers/focuser/CMakeLists.txt +++ b/drivers/focuser/CMakeLists.txt @@ -136,7 +136,7 @@ SET(sesto2_SRC ) add_executable(indi_sestosenso2_focus ${sesto2_SRC}) -target_link_libraries(indi_sestosenso2_focus indidriver) +target_link_libraries(indi_sestosenso2_focus indidriver ${JSONLIB}) install(TARGETS indi_sestosenso2_focus RUNTIME DESTINATION bin) # ############### Esatto Focuser ################ @@ -146,7 +146,7 @@ SET(esatto_SRC ) add_executable(indi_esatto_focus ${esatto_SRC}) -target_link_libraries(indi_esatto_focus indidriver) +target_link_libraries(indi_esatto_focus indidriver ${JSONLIB}) install(TARGETS indi_esatto_focus RUNTIME DESTINATION bin) # ############### Esatto with Arco Focuser ################ @@ -156,7 +156,7 @@ SET(esarc_SRC ) add_executable(indi_esattoarco_focus ${esarc_SRC}) -target_link_libraries(indi_esattoarco_focus indidriver) +target_link_libraries(indi_esattoarco_focus indidriver ${JSONLIB}) install(TARGETS indi_esattoarco_focus RUNTIME DESTINATION bin) # ############### Televue FocusMaster ################ diff --git a/drivers/focuser/esattoarco.cpp b/drivers/focuser/esattoarco.cpp index 30ab73e4c9..9b6bd1c30f 100644 --- a/drivers/focuser/esattoarco.cpp +++ b/drivers/focuser/esattoarco.cpp @@ -25,7 +25,12 @@ #include "esattoarco.h" #include "indicom.h" -#include "json.h" + +#ifdef _USE_SYSTEM_JSONLIB +#include +#else +#include +#endif #include #include diff --git a/drivers/focuser/primalucacommandset.h b/drivers/focuser/primalucacommandset.h index b50a08e0c9..315a7e690a 100644 --- a/drivers/focuser/primalucacommandset.h +++ b/drivers/focuser/primalucacommandset.h @@ -25,7 +25,12 @@ #pragma once #include -#include "json.h" + +#ifdef _USE_SYSTEM_JSONLIB +#include +#else +#include +#endif using json = nlohmann::json; diff --git a/drivers/spectrograph/CMakeLists.txt b/drivers/spectrograph/CMakeLists.txt index e50e52f5a0..6286e4a5f6 100644 --- a/drivers/spectrograph/CMakeLists.txt +++ b/drivers/spectrograph/CMakeLists.txt @@ -14,7 +14,7 @@ set( shelyak_usis_SRCS ) add_executable(shelyak_usis ${shelyak_usis_SRCS}) -target_link_libraries(shelyak_usis indidriver) +target_link_libraries(shelyak_usis indidriver ${JSONLIB}) install(TARGETS shelyak_usis RUNTIME DESTINATION bin) install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/shelyak/shelyak_boards.json DESTINATION ${DATA_INSTALL_DIR}) diff --git a/drivers/spectrograph/shelyak/indi_shelyak_usis.h b/drivers/spectrograph/shelyak/indi_shelyak_usis.h index f819cccb21..e00f9bdf89 100644 --- a/drivers/spectrograph/shelyak/indi_shelyak_usis.h +++ b/drivers/spectrograph/shelyak/indi_shelyak_usis.h @@ -24,7 +24,12 @@ #include "defaultdevice.h" #include "connectionplugins/connectionserial.h" -#include "json.h" + +#ifdef _USE_SYSTEM_JSONLIB +#include +#else +#include +#endif using json = nlohmann::json; diff --git a/drivers/weather/CMakeLists.txt b/drivers/weather/CMakeLists.txt index a2e659ec96..f887a09095 100644 --- a/drivers/weather/CMakeLists.txt +++ b/drivers/weather/CMakeLists.txt @@ -27,7 +27,7 @@ install(TARGETS indi_watcher_weather RUNTIME DESTINATION bin) SET(weathersafetyproxy_SRC weather_safety_proxy.cpp) add_executable(indi_weather_safety_proxy ${weathersafetyproxy_SRC}) -target_link_libraries(indi_weather_safety_proxy indidriver ${CURL}) +target_link_libraries(indi_weather_safety_proxy indidriver ${CURL} ${JSONLIB}) install(TARGETS indi_weather_safety_proxy RUNTIME DESTINATION bin) # ########## MBox Driver ############### @@ -63,5 +63,5 @@ IF(UNITY_BUILD) ENDIF() add_executable(indi_openweathermap_weather ${OpenWeatherMap_SRC}) -target_link_libraries(indi_openweathermap_weather indidriver ${CURL}) +target_link_libraries(indi_openweathermap_weather indidriver ${CURL} ${JSONLIB}) install(TARGETS indi_openweathermap_weather RUNTIME DESTINATION bin) diff --git a/drivers/weather/openweathermap.cpp b/drivers/weather/openweathermap.cpp index 1a7455a2a6..c275c2af64 100644 --- a/drivers/weather/openweathermap.cpp +++ b/drivers/weather/openweathermap.cpp @@ -26,7 +26,12 @@ #include "openweathermap.h" -#include "json.h" +#ifdef _USE_SYSTEM_JSONLIB +#include +#else +#include +#endif + #include "locale_compat.h" #include diff --git a/drivers/weather/weather_safety_proxy.cpp b/drivers/weather/weather_safety_proxy.cpp index 45bff43736..19536d38e1 100644 --- a/drivers/weather/weather_safety_proxy.cpp +++ b/drivers/weather/weather_safety_proxy.cpp @@ -28,7 +28,12 @@ #include #include -#include "json.h" +#ifdef _USE_SYSTEM_JSONLIB +#include +#else +#include +#endif + #include "weather_safety_proxy.h" using json = nlohmann::json; diff --git a/libs/json.h b/libs/indijson.hpp similarity index 100% rename from libs/json.h rename to libs/indijson.hpp