Skip to content

Commit

Permalink
cmake: find folly using its CMake package configuration file
Browse files Browse the repository at this point in the history
Summary:
Update thrift's CMakeLists.txt to find folly using its installed CMake package
configuration file, and depend on it via the `Folly::folly` target.

By using the `Folly::folly` target all include directories required to use
folly are automatically included in the include paths, and all libraries that
folly depends on are automatically added to the link line.  Since wangle only
requires double-conversion indirectly via folly I also deleted the explicit
checks for double-conversion.

Note that this change does require that folly was built and installed with
CMake, rather than with its older autoconf build system.

Reviewed By: wez

Differential Revision: D7479054

fbshipit-source-id: 093a69d83e9f1c62718d22cec8d6b180d84e4325
  • Loading branch information
simpkins authored and facebook-github-bot committed Apr 23, 2018
1 parent e11059b commit 16844d9
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 83 deletions.
5 changes: 1 addition & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ endif(compiler_only OR build_all)

# Find required dependencies for thrift/lib
if(lib_only OR build_all)
find_package(DoubleConversion REQUIRED)
find_package(Folly REQUIRED)
find_package(folly CONFIG REQUIRED)
find_package(GFlags REQUIRED)
find_package(Glog REQUIRED)
find_package(Krb5 REQUIRED gssapi)
Expand All @@ -87,8 +86,6 @@ if(lib_only OR build_all)
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads)
include_directories(
${DOUBLE_CONVERSION_INCLUDE_DIR}
${FOLLY_INCLUDE_DIR}
${GFLAGS_INCLUDE_DIRS}
${GLOG_INCLUDE_DIRS}
${KRB5_INCLUDE_DIRS}
Expand Down
36 changes: 0 additions & 36 deletions thrift/cmake/FindDoubleConversion.cmake

This file was deleted.

30 changes: 0 additions & 30 deletions thrift/cmake/FindFolly.cmake

This file was deleted.

17 changes: 8 additions & 9 deletions thrift/lib/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ target_include_directories(
target_link_libraries(
thrift-core
PUBLIC
${FOLLY_LIBRARY}
Folly::folly
)

add_library(
Expand All @@ -29,7 +29,7 @@ add_library(
target_link_libraries(
concurrency
PUBLIC
${FOLLY_LIBRARY}
Folly::folly
${GFLAGS_LIBRARIES}
${GLOG_LIBRARIES}
)
Expand All @@ -49,8 +49,7 @@ add_dependencies(protocol reflection-cpp2-target)
target_link_libraries(
protocol
PUBLIC
${DOUBLE_CONVERSION_LIBRARY}
${FOLLY_LIBRARY}
Folly::folly
${GLOG_LIBRARIES}
)

Expand Down Expand Up @@ -85,7 +84,7 @@ target_link_libraries(
PUBLIC
concurrency
thrift-core
${FOLLY_LIBRARY}
Folly::folly
${OPENSSL_LIBRARIES}
${ZLIB_LIBRARIES}
${ZSTD_LIBRARIES}
Expand All @@ -110,7 +109,7 @@ target_link_libraries(
concurrency
transport
${Boost_LIBRARIES}
${FOLLY_LIBRARY}
Folly::folly
${GLOG_LIBRARIES}
${OPENSSL_LIBRARIES}
)
Expand All @@ -135,7 +134,7 @@ target_link_libraries(
PUBLIC
${KRB5_LIBRARIES}
${Boost_LIBRARIES}
${FOLLY_LIBRARY}
Folly::folly
${GFLAGS_LIBRARIES}
${GLOG_LIBRARIES}
)
Expand All @@ -148,7 +147,7 @@ add_library(
target_link_libraries(
server
PUBLIC
${FOLLY_LIBRARY}
Folly::folly
)

add_library(
Expand All @@ -163,7 +162,7 @@ target_link_libraries(
concurrency
protocol
transport
${FOLLY_LIBRARY}
Folly::folly
${GLOG_LIBRARIES}
)

Expand Down
6 changes: 2 additions & 4 deletions thrift/lib/cpp2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ add_dependencies(thriftfrozen2 frozen-cpp2-target)
target_link_libraries(
thriftfrozen2
PUBLIC
${DOUBLE_CONVERSION_LIBRARY}
${FOLLY_LIBRARY}
Folly::folly
${GLOG_LIBRARIES}
${GFLAGS_LIBRARIES}
)
Expand All @@ -51,9 +50,8 @@ target_link_libraries(
thriftprotocol
PUBLIC
thrift
${FOLLY_LIBRARY}
Folly::folly
${WANGLE_LIBRARIES}
${DOUBLE_CONVERSION_LIBRARY}
)

thrift_generate(
Expand Down

0 comments on commit 16844d9

Please sign in to comment.