externals: allow system cpp-cttplib to be used with both meson and cpp-httplib builds (#7062)
Co-authored-by: Violet Purcell <vimproved@inventati.org>
This commit is contained in:
parent
897d1fa957
commit
775a25b492
2 changed files with 33 additions and 16 deletions
2
externals/CMakeLists.txt
vendored
2
externals/CMakeLists.txt
vendored
|
@ -230,7 +230,7 @@ add_library(httplib INTERFACE)
|
||||||
if(USE_SYSTEM_CPP_HTTPLIB)
|
if(USE_SYSTEM_CPP_HTTPLIB)
|
||||||
find_package(CppHttp 0.14.1)
|
find_package(CppHttp 0.14.1)
|
||||||
if(CppHttp_FOUND)
|
if(CppHttp_FOUND)
|
||||||
target_link_libraries(httplib SYSTEM INTERFACE cpp-httplib::cpp-httplib)
|
target_link_libraries(httplib INTERFACE httplib::httplib)
|
||||||
else()
|
else()
|
||||||
message(STATUS "Cpp-httplib not found or not suitable version! Falling back to bundled...")
|
message(STATUS "Cpp-httplib not found or not suitable version! Falling back to bundled...")
|
||||||
target_include_directories(httplib SYSTEM INTERFACE ./httplib)
|
target_include_directories(httplib SYSTEM INTERFACE ./httplib)
|
||||||
|
|
47
externals/cmake-modules/FindCppHttp.cmake
vendored
47
externals/cmake-modules/FindCppHttp.cmake
vendored
|
@ -1,21 +1,38 @@
|
||||||
if(NOT CppHttp_FOUND)
|
if(NOT CppHttp_FOUND)
|
||||||
pkg_check_modules(HTTP_TMP cpp-httplib)
|
pkg_check_modules(CPP_HTTPLIB cpp-httplib)
|
||||||
|
|
||||||
find_path(CPP-HTTP_INCLUDE_DIR NAMES httplib.h
|
if (CPP_HTTPLIB_FOUND)
|
||||||
PATHS
|
find_path(HTTPLIB_INCLUDE_DIR NAMES httplib.h
|
||||||
${HTTP_TMP_INCLUDE_DIRS}
|
PATHS
|
||||||
/usr/include
|
${CPP_HTTPLIB_INCLUDE_DIRS}
|
||||||
/usr/local/include
|
/usr/include
|
||||||
)
|
/usr/local/include
|
||||||
|
)
|
||||||
find_library(CPP-HTTP_LIBRARIES NAMES cpp-httplib
|
|
||||||
PATHS
|
|
||||||
${HTTP_TMP_LIBRARY_DIRS}
|
|
||||||
/usr/lib
|
|
||||||
/usr/local/lib
|
|
||||||
)
|
|
||||||
|
|
||||||
find_package_handle_standard_args(CppHttp REQUIRED_VARS CPP-HTTP_INCLUDE_DIR CPP-HTTP_LIBRARIES VERSION_VAR HTTP_TMP_VERSION)
|
find_library(HTTPLIB_LIBRARY NAMES cpp-httplib
|
||||||
|
PATHS
|
||||||
|
${CPP_HTTPLIB_LIBRARY_DIRS}
|
||||||
|
/usr/lib
|
||||||
|
/usr/local/lib
|
||||||
|
)
|
||||||
|
|
||||||
|
set(HTTPLIB_VERSION ${CPP_HTTPLIB_VERSION})
|
||||||
|
|
||||||
|
if (NOT TARGET cpp-httplib::cpp-httplib)
|
||||||
|
add_library(cpp-httplib::cpp-httplib INTERFACE IMPORTED)
|
||||||
|
set_target_properties(cpp-httplib::cpp-httplib PROPERTIES
|
||||||
|
INTERFACE_INCLUDE_DIRECTORIES "${HTTPLIB_INCLUDE_DIR}"
|
||||||
|
INTERFACE_LINK_LIBRARIES "${HTTPLIB_LIBRARY}"
|
||||||
|
IMPORTED_LOCATION "${HTTPLIB_LIBRARY}"
|
||||||
|
)
|
||||||
|
add_library(httplib::httplib ALIAS cpp-httplib::cpp-httplib)
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
message(STATUS "Cpp-httplib not found via pkg-config, trying CMake...")
|
||||||
|
find_package(httplib)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
find_package_handle_standard_args(CppHttp REQUIRED_VARS HTTPLIB_INCLUDE_DIR HTTPLIB_LIBRARY VERSION_VAR HTTPLIB_VERSION)
|
||||||
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue