Skip to content

Commit

Permalink
[thrift] Add FindProxygen cmake module
Browse files Browse the repository at this point in the history
Proxygen uses autoconf at the moment (soon to switch to cmake)
  • Loading branch information
mingtaoy committed Dec 5, 2018
1 parent ca0f918 commit 3757551
Showing 1 changed file with 85 additions and 0 deletions.
85 changes: 85 additions & 0 deletions thrift/cmake/FindProxygen.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# This will go away as soon as Proxygen switches over to cmake.
#
# Hints:
# Set PROXYGEN_ROOT_DIR to the installation prefix of proxygen
#
# Results:
# Sets proxygen_FOUND and defines the proxygen::proxygen TARGET

include(FindPackageHandleStandardArgs)
set(CMAKE_FIND_LIBRARY_SUFFIXES .a)

find_path(
PROXYGEN_INCLUDE_DIR
NAMES
proxygen/lib/http/HTTPMessage.h
HINTS
${PROXYGEN_ROOT_DIR}
)

find_library(
PROXYGEN_LIBRARY
NAMES
proxygenlib
HINTS
${PROXYGEN_ROOT_DIR}
)

find_library(
PROXYGEN_LIBRARY_HTTPSERVER
NAMES
proxygenhttpserver
HINTS
${PROXYGEN_ROOT_DIR}
)

find_package_handle_standard_args(proxygen
REQUIRED_VARS
PROXYGEN_INCLUDE_DIR
PROXYGEN_LIBRARY
PROXYGEN_LIBRARY_HTTPSERVER
FAIL_MESSAGE
"Could not find proxygen. Try setting the proxygen installation prefix with PROXYGEN_ROOT_DIR"
)
if(proxygen_FOUND)
if(NOT TARGET proxygen::lib)
add_library(proxygen::lib STATIC IMPORTED)
set_target_properties(proxygen::lib PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES "CXX"
IMPORTED_LOCATION "${PROXYGEN_LIBRARY}"
)
set_property(
TARGET proxygen::lib
APPEND
PROPERTY INTERFACE_LINK_LIBRARIES
Folly::folly
wangle::wangle
fizz::fizz
)
endif()

if (NOT TARGET proxygen::httpserver)
add_library(proxygen::httpserver STATIC IMPORTED)
set_target_properties(proxygen::httpserver PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES "CXX"
IMPORTED_LOCATION "${PROXYGEN_LIBRARY_HTTPSERVER}"
INTERFACE_LINK_LIBRARIES proxygen::lib
)
endif()

if (NOT TARGET proxygen::proxygen)
add_library(proxygen::proxygen INTERFACE IMPORTED)
set_property(TARGET proxygen::proxygen APPEND PROPERTY INTERFACE_LINK_LIBRARIES proxygen::httpserver proxygen::lib)
get_target_property(things proxygen::proxygen INTERFACE_LINK_LIBRARIES)
message(wut "${things}")
set_target_properties(
proxygen::proxygen
PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES
${PROXYGEN_INCLUDE_DIR}
)
endif()

message("Found proxygen")
endif()

0 comments on commit 3757551

Please sign in to comment.