forked from facebookincubator/velox
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove ${FOLLY_WITH_DEPENDENCIES} and fix Boost::<component> links (f…
…acebookincubator#4735) Summary: This PR removes the variable `FOLLY_WITH_DEPENDENCIES` that was used to link to folly instead of the more appropriate `Folly::folly` target. A consequence of this change was the proper linking to Boost targets in the form of `Boost::<component>` instead of `BOOST_LIBRARIES` or `BOOST_<component>_LIBRARIES`, this in turn made some changes to the the folly and boost `resolve_dependency` modules necessary: - folly and Boost are now built within a subdirectory. This creates a new, smaller scope. Previously they were built in the root scope. This allows us to use directory scoped thing like `add_compile_options` without affecting the main build. - The FindBoost module and the BoostConfig.cmake create a `Boost::headers` target that contains the include dir with the header only components, there are no single targets for each header library (at least in some installations). Building Boost from source does not create this target but rather creates a target for each library. To align both versions of using Boost the new `FindBoost.cmake` will create the Boost::headers target so we can link to that uniformly if we want to use it. This is to be merged after facebookincubator#4689 (this contains the commits from that PR which I will drop via rebase once it is merged) Pull Request resolved: facebookincubator#4735 Reviewed By: kgpai Differential Revision: D45549132 Pulled By: pedroerp fbshipit-source-id: 08b2b506014013186c4d2dc3f86e40c8dfe823eb
- Loading branch information
1 parent
46aaf40
commit cc14c0c
Showing
92 changed files
with
483 additions
and
435 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# Copyright (c) Facebook, Inc. and its affiliates. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
project(Boost) | ||
cmake_minimum_required(VERSION 3.14) | ||
|
||
# Suppress all warnings (in this subdir) | ||
add_compile_options(-w) | ||
|
||
# We need to use boost > 1.70 to build it with CMake 1.81 was the first to be | ||
# released as a github release INCLUDING the cmake files (which are not in the | ||
# officale releases for some reason) | ||
set(VELOX_BOOST_BUILD_VERSION 1.81.0) | ||
string( | ||
CONCAT VELOX_BOOST_SOURCE_URL | ||
"https://github.com/boostorg/boost/releases/download/" | ||
"boost-${VELOX_BOOST_BUILD_VERSION}/" | ||
"boost-${VELOX_BOOST_BUILD_VERSION}.tar.gz") | ||
set(VELOX_BOOST_BUILD_SHA256_CHECKSUM | ||
121da556b718fd7bd700b5f2e734f8004f1cfa78b7d30145471c526ba75a151c) | ||
|
||
resolve_dependency_url(BOOST) | ||
message(STATUS "Building boost from source") | ||
|
||
# required for Boost::thread | ||
if(NOT TARGET Threads::Threads) | ||
set(THREADS_PREFER_PTHREAD_FLAG ON) | ||
find_package(Threads REQUIRED) | ||
endif() | ||
|
||
FetchContent_Declare( | ||
Boost | ||
URL ${VELOX_BOOST_SOURCE_URL} | ||
URL_HASH ${VELOX_BOOST_BUILD_SHA256_CHECKSUM}) | ||
|
||
# Configure the file before adding the header only libs | ||
configure_file(${CMAKE_CURRENT_LIST_DIR}/FindBoost.cmake.in | ||
${CMAKE_CURRENT_LIST_DIR}/FindBoost.cmake @ONLY) | ||
|
||
set(BOOST_HEADER_ONLY crc circular_buffer multi_index random uuid variant) | ||
list(APPEND BOOST_INCLUDE_LIBRARIES ${BOOST_HEADER_ONLY}) | ||
|
||
# The `headers` target is not created by Boost cmake and leads to a warning | ||
list(REMOVE_ITEM BOOST_INCLUDE_LIBRARIES headers) | ||
set(BUILD_SHARED_LIBS ON) | ||
FetchContent_MakeAvailable(Boost) | ||
|
||
# To aling with Boost system install we create Boost::headers target | ||
add_library(boost_headers INTERFACE) | ||
add_library(Boost::headers ALIAS boost_headers) | ||
list(TRANSFORM BOOST_HEADER_ONLY PREPEND Boost::) | ||
target_link_libraries(boost_headers INTERFACE ${BOOST_HEADER_ONLY}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# Copyright (c) Facebook, Inc. and its affiliates. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
project(Folly) | ||
cmake_minimum_required(VERSION 3.14) | ||
|
||
set(VELOX_FOLLY_BUILD_VERSION v2022.11.14.00) | ||
set(VELOX_FOLLY_BUILD_SHA256_CHECKSUM | ||
b249436cb61b6dfd5288093565438d8da642b07ae021191a4042b221bc1bdc0e) | ||
set(VELOX_FOLLY_SOURCE_URL | ||
"https://github.com/facebook/folly/archive/${VELOX_FOLLY_BUILD_VERSION}.tar.gz" | ||
) | ||
|
||
resolve_dependency_url(FOLLY) | ||
|
||
message(STATUS "Building Folly from source") | ||
|
||
if(gflags_SOURCE STREQUAL "BUNDLED") | ||
set(glog_patch && git apply ${CMAKE_CURRENT_LIST_DIR}/folly-gflags-glog.patch) | ||
endif() | ||
|
||
FetchContent_Declare( | ||
folly | ||
URL ${VELOX_FOLLY_SOURCE_URL} | ||
URL_HASH ${VELOX_FOLLY_BUILD_SHA256_CHECKSUM} | ||
PATCH_COMMAND git apply ${CMAKE_CURRENT_LIST_DIR}/folly-no-export.patch | ||
${glog_patch}) | ||
|
||
if(ON_APPLE_M1) | ||
# folly will wrongly assume x86_64 if this is not set | ||
set(CMAKE_LIBRARY_ARCHITECTURE aarch64) | ||
endif() | ||
# Suppress all warnings | ||
set(FOLLY_CXX_FLAGS -w) | ||
FetchContent_MakeAvailable(folly) | ||
|
||
# Folly::folly is not valid for FC but we want to match FindFolly | ||
add_library(Folly::folly ALIAS folly) | ||
|
||
# The folly target does not contain any include directories, they are propagated | ||
# from folly_base. This marks them as system headers which should suppress | ||
# warnigs generated by them when they are included else where. | ||
get_target_property(_inc folly_base INTERFACE_INCLUDE_DIRECTORIES) | ||
target_include_directories(folly_base SYSTEM INTERFACE ${_inc}) | ||
|
||
if(${gflags_SOURCE} STREQUAL "BUNDLED") | ||
add_dependencies(folly glog gflags) | ||
endif() | ||
|
||
set(FOLLY_BENCHMARK_STATIC_LIB | ||
${folly_BINARY_DIR}/folly/libfollybenchmark${CMAKE_STATIC_LIBRARY_SUFFIX} | ||
PARENT_SCOPE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.