From 2ed57d3120aec545779e37002adbd8e1ed35def8 Mon Sep 17 00:00:00 2001 From: "Alan M. Carroll" Date: Wed, 16 Mar 2022 13:46:51 -0500 Subject: [PATCH] Update CMake to build libswoc. --- CMakeLists.txt | 19 ++++++++++--------- plugin/CMakeLists.txt | 4 ++-- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index be46d52..e1e01e5 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,6 +3,7 @@ Project(TxnBox) set(CMAKE_CXX_STANDARD 17) include(GNUInstallDirs) include(FindOpenSSL) +include(FetchContent) set(INSTALL_DIR ${CMAKE_HOME_DIRECTORY}) set(CMAKE_PREFIX_PATH ${INSTALL_DIR}) @@ -12,16 +13,16 @@ endif() find_package(PkgConfig REQUIRED) -# libSWOC -#pkg_check_modules(swoc IMPORTED_TARGET libswoc.static) -#if(NOT swoc_FOUND) -# message("Building libSWOC") -# execute_process(COMMAND git clone https://github.com/solidwallofcode/libswoc extern/libswoc) -# # cmake -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} -DCMAKE_INSTALL_LIBDIR=lib extern/libswoc -#endif() +FetchContent_Declare( + libSWOC + GIT_REPOSITORY "https://github.com/solidwallofcode/libswoc" + GIT_TAG "master" +) +set(LIBSWOC_INSTALL off) +FetchContent_MakeAvailable(libSWOC) -pkg_check_modules(swoc REQUIRED IMPORTED_TARGET libswoc.static) -pkg_check_modules(yaml-cpp REQUIRED IMPORTED_TARGET yaml-cpp) +#pkg_check_modules(swoc REQUIRED IMPORTED_TARGET libswoc.static) +#pkg_check_modules(yaml-cpp REQUIRED IMPORTED_TARGET yaml-cpp) pkg_check_modules(trafficserver REQUIRED IMPORTED_TARGET trafficserver) add_subdirectory(plugin) diff --git a/plugin/CMakeLists.txt b/plugin/CMakeLists.txt index 9f9a49c..9147658 100644 --- a/plugin/CMakeLists.txt +++ b/plugin/CMakeLists.txt @@ -34,9 +34,9 @@ add_library(plugin SHARED set_property(TARGET plugin PROPERTY PREFIX "") set_property(TARGET plugin PROPERTY OUTPUT_NAME "txn_box") -target_link_libraries(plugin PUBLIC PkgConfig::swoc PkgConfig::yaml-cpp pcre2-8) +target_link_libraries(plugin PRIVATE libswoc pcre2-8) target_include_directories(plugin PUBLIC include) -target_include_directories(plugin PRIVATE ${PLUGIN_SOURCE_DIR}/include ${trafficserver_INCLUDE_DIRS} ${OPENSSL_INCLUDE_DIR}) +target_include_directories(plugin PRIVATE ${PLUGIN_SOURCE_DIR}/include ${trafficserver_INCLUDE_DIRS} ${OPENSSL_INCLUDE_DIR}, libswoc) if (CMAKE_COMPILER_IS_GNUCXX) target_compile_options(plugin PRIVATE -Wall -Wextra -Werror -Wnon-virtual-dtor) endif()