From be417d36d009f258a6e118842f627b587afb8860 Mon Sep 17 00:00:00 2001 From: John Jones Date: Fri, 26 Jul 2019 10:48:36 -0500 Subject: [PATCH 1/2] modified CMakeLists.txt for static linking of libcurl --- libraries/plugins/elasticsearch/CMakeLists.txt | 11 ++++++++++- libraries/plugins/es_objects/CMakeLists.txt | 12 +++++++++++- libraries/utilities/CMakeLists.txt | 12 +++++++++++- 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/libraries/plugins/elasticsearch/CMakeLists.txt b/libraries/plugins/elasticsearch/CMakeLists.txt index ce9c7c1d1d..06eb6384ef 100644 --- a/libraries/plugins/elasticsearch/CMakeLists.txt +++ b/libraries/plugins/elasticsearch/CMakeLists.txt @@ -3,7 +3,16 @@ file(GLOB HEADERS "include/graphene/elasticsearch/*.hpp") add_library( graphene_elasticsearch elasticsearch_plugin.cpp ) -find_package(CURL REQUIRED) +if (NOT WIN32 AND NOT APPLE AND CURL_STATICLIB) + set (OLD_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) + set (CMAKE_FIND_LIBRARY_SUFFIXES .a) + find_package(CURL REQUIRED) + list(APPEND CURL_LIBRARIES ssl crypto) + set (CMAKE_FIND_LIBRARY_SUFFIXES ${OLD_SUFFIXES}) +else (NOT WIN32 AND NOT APPLE AND CURL_STATICLIB) + find_package(CURL REQUIRED) +endif (NOT WIN32 AND NOT APPLE AND CURL_STATICLIB) + include_directories(${CURL_INCLUDE_DIRS}) if(MSVC) set_source_files_properties(elasticsearch_plugin.cpp PROPERTIES COMPILE_FLAGS "/bigobj" ) diff --git a/libraries/plugins/es_objects/CMakeLists.txt b/libraries/plugins/es_objects/CMakeLists.txt index 42d18a6580..60971c8e35 100644 --- a/libraries/plugins/es_objects/CMakeLists.txt +++ b/libraries/plugins/es_objects/CMakeLists.txt @@ -3,7 +3,17 @@ file(GLOB HEADERS "include/graphene/es_objects/*.hpp") add_library( graphene_es_objects es_objects.cpp ) -find_package(CURL REQUIRED) + +if (NOT WIN32 AND NOT APPLE AND CURL_STATICLIB) + set (OLD_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) + set (CMAKE_FIND_LIBRARY_SUFFIXES .a) + find_package(CURL REQUIRED) + list(APPEND CURL_LIBRARIES ssl crypto) + set (CMAKE_FIND_LIBRARY_SUFFIXES ${OLD_SUFFIXES}) +else (NOT WIN32 AND NOT APPLE AND CURL_STATICLIB) + find_package(CURL REQUIRED) +endif (NOT WIN32 AND NOT APPLE AND CURL_STATICLIB) + include_directories(${CURL_INCLUDE_DIRS}) if(CURL_STATICLIB) SET_TARGET_PROPERTIES(graphene_es_objects PROPERTIES diff --git a/libraries/utilities/CMakeLists.txt b/libraries/utilities/CMakeLists.txt index 4311ef46cb..4f166e18c4 100644 --- a/libraries/utilities/CMakeLists.txt +++ b/libraries/utilities/CMakeLists.txt @@ -19,7 +19,17 @@ set(sources configure_file("${CMAKE_CURRENT_SOURCE_DIR}/git_revision.cpp.in" "${CMAKE_CURRENT_BINARY_DIR}/git_revision.cpp" @ONLY) list(APPEND sources "${CMAKE_CURRENT_BINARY_DIR}/git_revision.cpp") -find_package(CURL REQUIRED) + +if (NOT WIN32 AND NOT APPLE AND CURL_STATICLIB) + set (OLD_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) + set (CMAKE_FIND_LIBRARY_SUFFIXES .a) + find_package(CURL REQUIRED) + list(APPEND CURL_LIBRARIES ssl crypto) + set (CMAKE_FIND_LIBRARY_SUFFIXES ${OLD_SUFFIXES}) +else (NOT WIN32 AND NOT APPLE AND CURL_STATICLIB) + find_package(CURL REQUIRED) +endif (NOT WIN32 AND NOT APPLE AND CURL_STATICLIB) + include_directories(${CURL_INCLUDE_DIRS}) add_library( graphene_utilities ${sources} From 98bd37e6b325b3106c25294502063ac42f28c67e Mon Sep 17 00:00:00 2001 From: John Jones Date: Mon, 29 Jul 2019 13:07:51 -0500 Subject: [PATCH 2/2] move logic to main CMakeLists.txt --- CMakeLists.txt | 13 +++++++++++++ libraries/plugins/elasticsearch/CMakeLists.txt | 11 ++--------- libraries/plugins/es_objects/CMakeLists.txt | 10 +--------- libraries/utilities/CMakeLists.txt | 10 +--------- 4 files changed, 17 insertions(+), 27 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 91f4dd95d0..4540350f8e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,6 +29,19 @@ list( APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules" ) include(CheckCCompilerFlag) include(Utils) +# function to help with cUrl +macro(FIND_CURL) + if (NOT WIN32 AND NOT APPLE AND CURL_STATICLIB) + set (OLD_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) + set (CMAKE_FIND_LIBRARY_SUFFIXES .a) + find_package(CURL REQUIRED) + list(APPEND CURL_LIBRARIES ssl crypto) + set (CMAKE_FIND_LIBRARY_SUFFIXES ${OLD_SUFFIXES}) + else (NOT WIN32 AND NOT APPLE AND CURL_STATICLIB) + find_package(CURL REQUIRED) + endif (NOT WIN32 AND NOT APPLE AND CURL_STATICLIB) +endmacro() + # Fortify source if (CMAKE_COMPILER_IS_GNUCXX) if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") diff --git a/libraries/plugins/elasticsearch/CMakeLists.txt b/libraries/plugins/elasticsearch/CMakeLists.txt index 06eb6384ef..c7810f4eb3 100644 --- a/libraries/plugins/elasticsearch/CMakeLists.txt +++ b/libraries/plugins/elasticsearch/CMakeLists.txt @@ -3,15 +3,8 @@ file(GLOB HEADERS "include/graphene/elasticsearch/*.hpp") add_library( graphene_elasticsearch elasticsearch_plugin.cpp ) -if (NOT WIN32 AND NOT APPLE AND CURL_STATICLIB) - set (OLD_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) - set (CMAKE_FIND_LIBRARY_SUFFIXES .a) - find_package(CURL REQUIRED) - list(APPEND CURL_LIBRARIES ssl crypto) - set (CMAKE_FIND_LIBRARY_SUFFIXES ${OLD_SUFFIXES}) -else (NOT WIN32 AND NOT APPLE AND CURL_STATICLIB) - find_package(CURL REQUIRED) -endif (NOT WIN32 AND NOT APPLE AND CURL_STATICLIB) + +find_curl() include_directories(${CURL_INCLUDE_DIRS}) if(MSVC) diff --git a/libraries/plugins/es_objects/CMakeLists.txt b/libraries/plugins/es_objects/CMakeLists.txt index 60971c8e35..2cae2ffde4 100644 --- a/libraries/plugins/es_objects/CMakeLists.txt +++ b/libraries/plugins/es_objects/CMakeLists.txt @@ -4,15 +4,7 @@ add_library( graphene_es_objects es_objects.cpp ) -if (NOT WIN32 AND NOT APPLE AND CURL_STATICLIB) - set (OLD_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) - set (CMAKE_FIND_LIBRARY_SUFFIXES .a) - find_package(CURL REQUIRED) - list(APPEND CURL_LIBRARIES ssl crypto) - set (CMAKE_FIND_LIBRARY_SUFFIXES ${OLD_SUFFIXES}) -else (NOT WIN32 AND NOT APPLE AND CURL_STATICLIB) - find_package(CURL REQUIRED) -endif (NOT WIN32 AND NOT APPLE AND CURL_STATICLIB) +find_curl() include_directories(${CURL_INCLUDE_DIRS}) if(CURL_STATICLIB) diff --git a/libraries/utilities/CMakeLists.txt b/libraries/utilities/CMakeLists.txt index 4f166e18c4..c4c01cd212 100644 --- a/libraries/utilities/CMakeLists.txt +++ b/libraries/utilities/CMakeLists.txt @@ -20,15 +20,7 @@ set(sources configure_file("${CMAKE_CURRENT_SOURCE_DIR}/git_revision.cpp.in" "${CMAKE_CURRENT_BINARY_DIR}/git_revision.cpp" @ONLY) list(APPEND sources "${CMAKE_CURRENT_BINARY_DIR}/git_revision.cpp") -if (NOT WIN32 AND NOT APPLE AND CURL_STATICLIB) - set (OLD_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) - set (CMAKE_FIND_LIBRARY_SUFFIXES .a) - find_package(CURL REQUIRED) - list(APPEND CURL_LIBRARIES ssl crypto) - set (CMAKE_FIND_LIBRARY_SUFFIXES ${OLD_SUFFIXES}) -else (NOT WIN32 AND NOT APPLE AND CURL_STATICLIB) - find_package(CURL REQUIRED) -endif (NOT WIN32 AND NOT APPLE AND CURL_STATICLIB) +find_curl() include_directories(${CURL_INCLUDE_DIRS}) add_library( graphene_utilities