diff --git a/build/cmake/Config.cmake.in b/build/cmake/Config.cmake.in index c80a7f63ad5..3f4c5945c89 100644 --- a/build/cmake/Config.cmake.in +++ b/build/cmake/Config.cmake.in @@ -1,8 +1,17 @@ @PACKAGE_INIT@ -include(CMakeFindDependencyMacro) -find_dependency(ZLIB) -find_dependency(Libevent) +set(package_deps @package_deps@) +foreach(dep IN LISTS package_deps) + if(dep STREQUAL "OpenSSL") + find_package(OpenSSL REQUIRED) + else() + find_package(${dep} CONFIG REQUIRED) + endif() +endforeach() + +set(boost_components @boost_components@) +find_package(Boost CONFIG REQUIRED ${boost_components}) + check_required_components("@PROJECT_NAME@") include("${CMAKE_CURRENT_LIST_DIR}/@TARGETS_EXPORT_NAME@.cmake") diff --git a/lib/cpp/CMakeLists.txt b/lib/cpp/CMakeLists.txt index d45ab722c40..c29ebaf4396 100755 --- a/lib/cpp/CMakeLists.txt +++ b/lib/cpp/CMakeLists.txt @@ -21,6 +21,8 @@ include_directories(src) # SYSLIBS contains libraries that need to be linked to all lib targets set(SYSLIBS "") +set(package_deps Boost) +set(boost_components) # Create the thrift C++ library set( thriftcpp_SOURCES @@ -96,8 +98,8 @@ if(WITH_OPENSSL) src/thrift/transport/TSSLSocket.cpp src/thrift/transport/TSSLServerSocket.cpp ) - include_directories(SYSTEM "${OPENSSL_INCLUDE_DIR}") - list(APPEND SYSLIBS "${OPENSSL_LIBRARIES}") + list(APPEND SYSLIBS OpenSSL::SSL OpenSSL::Crypto) + list(APPEND package_deps OpenSSL) endif() # WITH_*THREADS selects which threading library to use @@ -108,6 +110,7 @@ if(WITH_BOOSTTHREADS) src/thrift/concurrency/BoostMutex.cpp ) list(APPEND SYSLIBS "${Boost_LIBRARIES}") + list(APPEND boost_components thread) elseif(UNIX AND NOT WITH_STDTHREADS) if(ANDROID) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread") @@ -175,6 +178,7 @@ if(WITH_LIBEVENT) ADD_LIBRARY_THRIFT(thriftnb ${thriftcppnb_SOURCES}) TARGET_LINK_LIBRARIES_THRIFT(thriftnb ${SYSLIBS} Libevent::event_core Libevent::event_extra) TARGET_LINK_LIBRARIES_THRIFT_AGAINST_THRIFT_LIBRARY(thriftnb thrift) + list(APPEND package_deps Libevent) endif() if(WITH_ZLIB) @@ -185,6 +189,7 @@ if(WITH_ZLIB) ADD_LIBRARY_THRIFT(thriftz ${thriftcppz_SOURCES}) TARGET_LINK_LIBRARIES_THRIFT(thriftz ${SYSLIBS} ZLIB::zlib) TARGET_LINK_LIBRARIES_THRIFT_AGAINST_THRIFT_LIBRARY(thriftz thrift) + list(APPEND package_deps ZLIB) endif() if(WITH_QT4)