From 4ea29e57895f7cc2b50327d467aca2d25d7685c7 Mon Sep 17 00:00:00 2001 From: rexy712 Date: Mon, 23 May 2022 18:24:30 -0700 Subject: [PATCH] Remove deprecated rexy::static_string. Add pkg-config to CMake for librexy --- CMakeLists.txt | 16 ++++++++++++---- include/response.hpp | 4 +++- include/types.hpp | 6 +++--- src/curl_easy_handle.cpp | 2 +- 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ef08209..87f4b73 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,8 @@ project(librcw) cmake_minimum_required(VERSION 3.0.2) + include(GNUInstallDirs) +find_package(PkgConfig) set(librcw_VERSION_STRING "000003000L") set(librcw_VERSION_MAJOR 0) @@ -15,16 +17,21 @@ option(ENABLE_PROFILING "Enable asan" OFF) option(BUILD_TESTS "Enable testing" OFF) mark_as_advanced(ENABLE_PROFILING) +pkg_check_modules(LIBREXY REQUIRED librexy) + +set(LIBREXY_REAL_LIBRARIES ${LIBREXY_LIBRARIES}) +list(TRANSFORM LIBREXY_REAL_LIBRARIES PREPEND "-l") + set(SOURCE_LIST "src/async.cpp" "src/curl_easy_handle.cpp" "src/curl_header_list.cpp" "src/httpint.cpp" "src/read_write_cback.cpp" "src/response.cpp" "src/sync.cpp" "src/types.cpp") if(ENABLE_SHARED) add_library(rcw SHARED ${SOURCE_LIST}) set_target_properties(rcw PROPERTIES SOVERSION "${librcw_VERSION_MAJOR}.${librcw_VERSION_MINOR}") set(LIBRCW_LIBFLAGS "-lrcw") - target_link_libraries(rcw "-lcurl -lrexy -lpthread") + target_link_libraries(rcw "-lcurl -lpthread ${LIBREXY_LINK_LIBRARIES}") else() add_library(rcw STATIC ${SOURCE_LIST}) - set(LIBRCW_LIBFLAGS "-lrcw -lcurl -lrexy -lpthread") - target_link_libraries(rcw "-lcurl -lrexy -lpthread") + set(LIBRCW_LIBFLAGS "-lrcw -lcurl -lpthread ${LIBREXY_REAL_LIBRARIES}") + target_link_libraries(rcw "-lcurl -lpthread ${LIBREXY_LINK_LIBRARIES}") endif() set_target_properties(rcw PROPERTIES VERSION "${librcw_VERSION_MAJOR}.${librcw_VERSION_MINOR}.${librcw_VERSION_REVISION}") @@ -38,7 +45,8 @@ if(BUILD_TESTS) endif() set(LIBRCW_PUBLIC_HEADERS "include/async.hpp" "include/curl_easy_handle.hpp" "include/curl_header_list.hpp" "include/httpint.hpp" "include/rcw.hpp" "include/read_write_cback.hpp" "include/response.hpp" "include/string.hpp" "include/sync.hpp" "include/types.hpp") -target_compile_options(rcw PRIVATE -Wall -Wextra -pedantic -std=c++17) +target_compile_options(rcw PRIVATE -Wall -Wextra -pedantic -std=c++17 ${LIBREXY_CFLAGS_OTHER}) +target_include_directories(rcw PUBLIC ${LIBREXY_INCLUDE_DIRS}) install(TARGETS rcw ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} diff --git a/include/response.hpp b/include/response.hpp index d36fb58..658f9c9 100644 --- a/include/response.hpp +++ b/include/response.hpp @@ -22,6 +22,8 @@ #include "httpint.hpp" #include "string.hpp" +#include + namespace rcw{ class response @@ -31,7 +33,7 @@ namespace rcw{ size_t elapsed_time_us; //CURLINFO_TOTAL_TIME_T size_t uploaded_bytes; //CURLINFO_SIZE_UPLOAD_T size_t downloaded_bytes; //CURLINFO_SIZE_DOWNLOAD_T - rexy::static_string content_type; //CURLINFO_CONTENT_TYPE + rexy::string_view content_type; //CURLINFO_CONTENT_TYPE int liberror = 0; string text; diff --git a/include/types.hpp b/include/types.hpp index 8968051..8411a82 100644 --- a/include/types.hpp +++ b/include/types.hpp @@ -20,7 +20,7 @@ #define RCW_TYPES_HPP #include //size_t -#include +#include namespace rcw{ @@ -34,14 +34,14 @@ namespace rcw{ class url { public: - rexy::static_string data; + rexy::string_view data; explicit url(const char*, size_t len = 0); }; class body { public: - rexy::static_string data; + rexy::string_view data; explicit body(const char*, size_t len = 0); }; diff --git a/src/curl_easy_handle.cpp b/src/curl_easy_handle.cpp index b1a6b1f..fac2b6a 100644 --- a/src/curl_easy_handle.cpp +++ b/src/curl_easy_handle.cpp @@ -144,7 +144,7 @@ namespace rcw{ curl_easy_getinfo(m_curl, CURLINFO_SIZE_DOWNLOAD_T, &x); retval.downloaded_bytes = x; curl_easy_getinfo(m_curl, CURLINFO_CONTENT_TYPE, &y); - retval.content_type = rexy::static_string(y); + retval.content_type = rexy::string_view(y); return retval; }