Skip to content
This repository has been archived by the owner on Mar 29, 2021. It is now read-only.

Commit

Permalink
Improve CMake config.
Browse files Browse the repository at this point in the history
  • Loading branch information
Isaac Hier committed Sep 28, 2017
1 parent 4d4a26b commit 36f48e7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
15 changes: 12 additions & 3 deletions build/cmake/Config.cmake.in
Original file line number Diff line number Diff line change
@@ -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}/@[email protected]")
9 changes: 7 additions & 2 deletions lib/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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")
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit 36f48e7

Please sign in to comment.