diff --git a/.travis.yml b/.travis.yml index fdcf38746..48f0e6437 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,9 +14,6 @@ addons: packages: &common_deps - lcov # Folly dependencies - - autoconf - - autoconf-archive - - automake - binutils-dev - g++ - libboost-all-dev @@ -29,9 +26,7 @@ addons: - liblzma-dev - libsnappy-dev - libssl-dev - - libtool - make - - pkg-config - zlib1g-dev matrix: @@ -82,10 +77,6 @@ env: eHz/lHAoLXWg/BhtgQbPmMYYKRrQaH7EKzBbqEHv6PhOk7vLMtdx5X7KmhVuFjpAMbaYoj zwxxH0u+VAnVB5iazzyjhySjvzkvx6pGzZtTnjLJHxKcp9633z4OU= -cache: - directories: - - $HOME/folly - before_script: # Install lcov to coveralls conversion + upload tool. - gem install coveralls-lcov diff --git a/CMakeLists.txt b/CMakeLists.txt index 82fb206da..4ff9abf92 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -306,7 +306,9 @@ add_library( rsocket/transports/tcp/TcpDuplexConnection.cpp rsocket/transports/tcp/TcpDuplexConnection.h) -target_link_libraries(ReactiveSocket yarpl ${GFLAGS_LIBRARY} ${GLOG_LIBRARY}) +target_link_libraries(ReactiveSocket + PUBLIC yarpl ${GFLAGS_LIBRARY} ${GLOG_LIBRARY} + INTERFACE ${EXTRA_LINK_FLAGS}) target_compile_options( ReactiveSocket diff --git a/cmake/FindFolly.cmake b/cmake/FindFolly.cmake deleted file mode 100644 index 30736a77f..000000000 --- a/cmake/FindFolly.cmake +++ /dev/null @@ -1,15 +0,0 @@ -cmake_minimum_required(VERSION 3.2) - -include(FindPackageHandleStandardArgs) - -if (FOLLY_INSTALL_DIR) - set(lib_paths ${FOLLY_INSTALL_DIR}/lib) - set(include_paths ${FOLLY_INSTALL_DIR}/include) -endif () - -find_library(FOLLY_LIBRARY folly PATHS ${lib_paths}) -find_library(FOLLY_BENCHMARK_LIBRARY follybenchmark PATHS ${lib_paths}) -find_path(FOLLY_INCLUDE_DIR "folly/String.h" PATHS ${include_paths}) - -find_package_handle_standard_args(Folly - DEFAULT_MSG FOLLY_LIBRARY FOLLY_BENCHMARK_LIBRARY FOLLY_INCLUDE_DIR) diff --git a/cmake/InstallFolly.cmake b/cmake/InstallFolly.cmake index b7d8622f5..f7aaf46e2 100644 --- a/cmake/InstallFolly.cmake +++ b/cmake/InstallFolly.cmake @@ -1,73 +1,19 @@ if (NOT FOLLY_INSTALL_DIR) - set(FOLLY_INSTALL_DIR $ENV{HOME}/folly) + set(FOLLY_INSTALL_DIR ${CMAKE_BINARY_DIR}/folly-install) endif () -# Check if the correct version of folly is already installed. -set(FOLLY_VERSION v2018.06.25.00) -set(FOLLY_VERSION_FILE ${FOLLY_INSTALL_DIR}/${FOLLY_VERSION}) if (RSOCKET_INSTALL_DEPS) - if (NOT EXISTS ${FOLLY_VERSION_FILE}) - # Remove the old version of folly. - file(REMOVE_RECURSE ${FOLLY_INSTALL_DIR}) - set(INSTALL_FOLLY True) - endif () -endif () - -if (INSTALL_FOLLY) - # Build and install folly. - ExternalProject_Add( - folly-ext - GIT_REPOSITORY https://github.com/facebook/folly - GIT_TAG ${FOLLY_VERSION} - BINARY_DIR folly-ext-prefix/src/folly-ext/folly - CONFIGURE_COMMAND autoreconf -ivf - COMMAND ./configure CXX=${CMAKE_CXX_COMPILER} - --prefix=${FOLLY_INSTALL_DIR} - BUILD_COMMAND make -j4 - INSTALL_COMMAND make install - COMMAND cmake -E touch ${FOLLY_VERSION_FILE}) - - set(FOLLY_INCLUDE_DIR ${FOLLY_INSTALL_DIR}/include) - set(lib ${CMAKE_SHARED_LIBRARY_PREFIX}folly${CMAKE_SHARED_LIBRARY_SUFFIX}) - set(benchlib ${CMAKE_SHARED_LIBRARY_PREFIX}follybenchmark${CMAKE_SHARED_LIBRARY_SUFFIX}) - set(FOLLY_LIBRARY ${FOLLY_INSTALL_DIR}/lib/${lib}) - set(FOLLY_BENCHMARK_LIBRARY ${FOLLY_INSTALL_DIR}/lib/${benchlib}) - - # CMake requires directories listed in INTERFACE_INCLUDE_DIRECTORIES to exist. - file(MAKE_DIRECTORY ${FOLLY_INCLUDE_DIR}) -else () - # Use installed folly. - find_package(Folly REQUIRED) + execute_process( + COMMAND + ${CMAKE_SOURCE_DIR}/scripts/build_folly.sh + ${CMAKE_BINARY_DIR}/folly-src + ${FOLLY_INSTALL_DIR} + RESULT_VARIABLE folly_result + ) + if (NOT "${folly_result}" STREQUAL "0") + message(FATAL_ERROR "failed to build folly") + endif() endif () find_package(Threads) -find_library(EVENT_LIBRARY event) - -add_library(folly SHARED IMPORTED) -set_property(TARGET folly PROPERTY IMPORTED_LOCATION ${FOLLY_LIBRARY}) -set_property(TARGET folly - APPEND PROPERTY INTERFACE_LINK_LIBRARIES - ${EXTRA_LINK_FLAGS} ${EVENT_LIBRARY} ${CMAKE_THREAD_LIBS_INIT}) -if (TARGET folly-ext) - add_dependencies(folly folly-ext) -endif () - -add_library(folly-benchmark SHARED IMPORTED) -set_property(TARGET folly-benchmark PROPERTY IMPORTED_LOCATION ${FOLLY_BENCHMARK_LIBRARY}) -set_property(TARGET folly-benchmark - APPEND PROPERTY INTERFACE_LINK_LIBRARIES - ${EXTRA_LINK_FLAGS} ${EVENT_LIBRARY} ${CMAKE_THREAD_LIBS_INIT}) -if (TARGET folly-ext) - add_dependencies(folly-benchmark folly-ext) -endif () - -# Folly includes are marked as system to prevent errors on non-standard -# extensions when compiling with -pedantic and -Werror. -set_property(TARGET folly - APPEND PROPERTY INTERFACE_SYSTEM_INCLUDE_DIRECTORIES ${FOLLY_INCLUDE_DIR}) -set_property(TARGET folly - APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${FOLLY_INCLUDE_DIR}) -set_property(TARGET folly-benchmark - APPEND PROPERTY INTERFACE_SYSTEM_INCLUDE_DIRECTORIES ${FOLLY_INCLUDE_DIR}) -set_property(TARGET folly-benchmark - APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${FOLLY_INCLUDE_DIR}) +find_package(folly CONFIG REQUIRED PATHS ${FOLLY_INSTALL_DIR}) diff --git a/rsocket/benchmarks/CMakeLists.txt b/rsocket/benchmarks/CMakeLists.txt index 172309927..2ff59a03c 100644 --- a/rsocket/benchmarks/CMakeLists.txt +++ b/rsocket/benchmarks/CMakeLists.txt @@ -1,5 +1,5 @@ add_library(fixture Fixture.cpp Fixture.h) -target_link_libraries(fixture ReactiveSocket folly) +target_link_libraries(fixture ReactiveSocket Folly::folly) function(benchmark NAME FILE) add_executable(${NAME} ${FILE} Benchmarks.cpp) @@ -7,7 +7,7 @@ function(benchmark NAME FILE) ${NAME} fixture ReactiveSocket - folly-benchmark + Folly::follybenchmark ${GFLAGS_LIBRARY} ${GLOG_LIBRARY}) endfunction() diff --git a/scripts/build_folly.sh b/scripts/build_folly.sh new file mode 100755 index 000000000..091e328e9 --- /dev/null +++ b/scripts/build_folly.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# +# Copyright 2004-present Facebook. All Rights Reserved. +# +CHECKOUT_DIR=$1 +INSTALL_DIR=$2 +if [[ -z $INSTALL_DIR ]]; then + echo "usage: $0 CHECKOUT_DIR INSTALL_DIR" >&2 + exit 1 +fi + +# If folly was already installed, just return early +INSTALL_MARKER_FILE="$INSTALL_DIR/folly.installed" +if [[ -f $INSTALL_MARKER_FILE ]]; then + echo "folly was previously built" + exit 0 +fi + +set -e +set -x + +if [[ -d "$CHECKOUT_DIR" ]]; then + git -C "$CHECKOUT_DIR" fetch + git -C "$CHECKOUT_DIR" checkout master +else + git clone https://github.com/facebook/folly "$CHECKOUT_DIR" +fi + +mkdir -p "$CHECKOUT_DIR/_build" +cd "$CHECKOUT_DIR/_build" +cmake "-DCMAKE_INSTALL_PREFIX=${INSTALL_DIR}" .. +make -j4 +make install +touch "$INSTALL_MARKER_FILE" diff --git a/yarpl/CMakeLists.txt b/yarpl/CMakeLists.txt index 14d1c5f74..98dbdc710 100644 --- a/yarpl/CMakeLists.txt +++ b/yarpl/CMakeLists.txt @@ -119,8 +119,8 @@ message("yarpl source dir: ${CMAKE_CURRENT_SOURCE_DIR}") target_link_libraries( yarpl - folly - ${GLOG_LIBRARY}) + PUBLIC Folly::folly ${GLOG_LIBRARY} + INTERFACE ${EXTRA_LINK_FLAGS}) install(TARGETS yarpl DESTINATION lib) install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} DESTINATION include FILES_MATCHING PATTERN "*.h")