Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow using system provided json library #1970

Merged
merged 1 commit into from
Dec 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions drivers/focuser/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 ################
Expand All @@ -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 ################
Expand All @@ -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 ################
Expand Down
7 changes: 6 additions & 1 deletion drivers/focuser/esattoarco.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@
#include "esattoarco.h"

#include "indicom.h"
#include "json.h"

#ifdef _USE_SYSTEM_JSONLIB
#include <nlohmann/json.hpp>
#else
#include <indijson.hpp>
#endif

#include <cmath>
#include <cstring>
Expand Down
7 changes: 6 additions & 1 deletion drivers/focuser/primalucacommandset.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@
#pragma once

#include <cstdint>
#include "json.h"

#ifdef _USE_SYSTEM_JSONLIB
#include <nlohmann/json.hpp>
#else
#include <indijson.hpp>
#endif

using json = nlohmann::json;

Expand Down
2 changes: 1 addition & 1 deletion drivers/spectrograph/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down
7 changes: 6 additions & 1 deletion drivers/spectrograph/shelyak/indi_shelyak_usis.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@

#include "defaultdevice.h"
#include "connectionplugins/connectionserial.h"
#include "json.h"

#ifdef _USE_SYSTEM_JSONLIB
#include <nlohmann/json.hpp>
#else
#include <indijson.hpp>
#endif

using json = nlohmann::json;

Expand Down
4 changes: 2 additions & 2 deletions drivers/weather/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 ###############
Expand Down Expand Up @@ -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)
7 changes: 6 additions & 1 deletion drivers/weather/openweathermap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@

#include "openweathermap.h"

#include "json.h"
#ifdef _USE_SYSTEM_JSONLIB
#include <nlohmann/json.hpp>
#else
#include <indijson.hpp>
#endif

#include "locale_compat.h"

#include <curl/curl.h>
Expand Down
7 changes: 6 additions & 1 deletion drivers/weather/weather_safety_proxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@
#include <cstring>
#include <curl/curl.h>

#include "json.h"
#ifdef _USE_SYSTEM_JSONLIB
#include <nlohmann/json.hpp>
#else
#include <indijson.hpp>
#endif

#include "weather_safety_proxy.h"

using json = nlohmann::json;
Expand Down
File renamed without changes.
Loading