From b3878584006ef27ad6912dee326629c32ff2a499 Mon Sep 17 00:00:00 2001 From: Mattia Verga Date: Fri, 6 Oct 2023 09:39:01 +0200 Subject: [PATCH] Option to use system provided httplib (#1946) --- CMakeLists.txt | 24 +++++++++++++++++++++++- drivers/telescope/planewave_mount.cpp | 2 +- libs/{ => httplib}/httplib-LICENSE | 0 libs/{ => httplib}/httplib.h | 0 4 files changed, 24 insertions(+), 2 deletions(-) rename libs/{ => httplib}/httplib-LICENSE (100%) rename libs/{ => httplib}/httplib.h (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index e4e12c1f31..5a7c2f69fe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -96,6 +96,9 @@ OPTION(INDI_BUILD_SHARED "Build shared library" ON) OPTION(INDI_BUILD_STATIC "Build static library" ON) OPTION(INDI_BUILD_XISF "Build XISF support" ON) +# System provided or bundled libs +OPTION(INDI_SYSTEM_HTTPLIB "Use system provided httplib" OFF) + if(UNIX AND NOT APPLE) OPTION(INDI_SHARED_MEMORY "Build INDI with support for UNIX protocol with shared memory" ON) else() @@ -165,6 +168,20 @@ install(FILES COMPONENT Devel ) +# ################################################################################################## +# #################################### bundled libs ############################################## +# ################################################################################################## +if(INDI_SYSTEM_HTTPLIB) + find_package(httplib REQUIRED) + include_directories(${HTTPLIB_INCLUDE_DIR}) + set(SYSTEM_HTTPLIB 1) + message(STATUS "Using system provided httplib version ${HTTPLIB_VERSION}") +else() + include_directories(${CMAKE_CURRENT_SOURCE_DIR}/libs/httplib) + set(SYSTEM_HTTPLIB 0) + message(STATUS "Using bundled httplib") +endif(INDI_SYSTEM_HTTPLIB) + # ################################################################################################### # # Component : INDI Core @@ -381,11 +398,16 @@ endif() 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/httplib.h ${CMAKE_CURRENT_SOURCE_DIR}/libs/inicpp.h ${CMAKE_CURRENT_BINARY_DIR}/indiversion.h DESTINATION ${INCLUDE_INSTALL_DIR}/libindi COMPONENT Devel ) + if(NOT SYSTEM_HTTPLIB) + install(FILES + ${CMAKE_CURRENT_SOURCE_DIR}/libs/httplib/httplib.h + DESTINATION ${INCLUDE_INSTALL_DIR}/libindi COMPONENT Devel + ) + endif(NOT SYSTEM_HTTPLIB) 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/telescope/planewave_mount.cpp b/drivers/telescope/planewave_mount.cpp index e2cea26f4a..57eae39655 100644 --- a/drivers/telescope/planewave_mount.cpp +++ b/drivers/telescope/planewave_mount.cpp @@ -22,7 +22,7 @@ #include "planewave_mount.h" #include "indicom.h" -#include "httplib.h" +#include #include "connectionplugins/connectiontcp.h" #include #include diff --git a/libs/httplib-LICENSE b/libs/httplib/httplib-LICENSE similarity index 100% rename from libs/httplib-LICENSE rename to libs/httplib/httplib-LICENSE diff --git a/libs/httplib.h b/libs/httplib/httplib.h similarity index 100% rename from libs/httplib.h rename to libs/httplib/httplib.h