-
Notifications
You must be signed in to change notification settings - Fork 547
Replace autotools with CMake + fbcode_builder #449
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mszabo-wikia
wants to merge
20
commits into
facebook:main
Choose a base branch
from
mszabo-wikia:introduce-cmake
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+18,229
−371
Open
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
60c3e53
Bootstrap fbcode_builder
mszabo-wikia 6b04c31
Add CMake build system
mszabo-wikia 7fd68c8
Add GitHub Action generated by getdeps.py
mszabo-wikia 7266ef4
Hack: Eliminate fb303 dependency from example service
mszabo-wikia a91c2c9
Skip CompressionCodecManagerTest when compression is disabled
mszabo-wikia 5b96e33
Skip ServiceRouter tests when SR is not linked
mszabo-wikia c0c723b
Update test certificates to work with newer OpenSSL
mszabo-wikia d01e9a7
Run Python integration tests as well
mszabo-wikia f205cec
Fix tests
mszabo-wikia 142a0cd
Use folly::Init for mock servers to avoid glog warnings
mszabo-wikia 04577e7
Set timeout for flaky tests in lib/network
mszabo-wikia 37cb172
Add basic CPack packaging
mszabo-wikia ecc921a
Update the README
mszabo-wikia 7b8d7c3
Fix refill lease-get test for OSS
mszabo-wikia 88fe60d
Lower timeout for integration tests
mszabo-wikia 004d5f6
Fix OSS compiler warnings
mszabo-wikia a387596
Fix flaky CarbonRouterClient.basicUsageSameThreadClient test
mszabo-wikia 6259bfa
Exclude configerator-related test code in OSS build
mszabo-wikia cb6a31d
Update tests after miss-on-get removal
mszabo-wikia dbb6c3b
Don't use libfast-float-dev on bookworm
mszabo-wikia File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or 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 @@ | ||
| compile_commands.json |
This file contains hidden or 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,109 @@ | ||
| # Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| # | ||
| # This source code is licensed under the MIT license found in the LICENSE file | ||
| # in the root directory of this source tree. | ||
|
|
||
| cmake_minimum_required(VERSION 3.19) | ||
|
|
||
| project(mcrouter VERSION 1.0.0) | ||
|
|
||
| set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/build/fbcode_builder/CMake" | ||
| ${CMAKE_MODULE_PATH}) | ||
|
|
||
| set(CMAKE_CXX_STANDARD 20) | ||
| set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
| set(CMAKE_CXX_EXTENSIONS OFF) | ||
| set(CMAKE_EXPORT_COMPILE_COMMANDS ON) | ||
| set(CMAKE_OPTIMIZE_DEPENDENCIES ON) | ||
|
|
||
| option(BUILD_TESTS "If enabled, compile the tests." OFF) | ||
| option(USE_CCACHE "Use ccache for compiler caching, if available" OFF) | ||
| option(PROFILE_BUILD "Profile build times (requires clang)" OFF) | ||
|
|
||
| # Opt out of using the upstream BoostConfig module with CMake >= 3.30, | ||
| # since GitHub Actions provides Boost < 1.70 and therefore is missing the upstream module. | ||
| if(POLICY CMP0167) | ||
| cmake_policy(SET CMP0167 OLD) | ||
| endif() | ||
|
|
||
| # Disable Meta-specific functionality for the OSS build. | ||
| add_compile_definitions(LIBMC_FBTRACE_DISABLE DISABLE_COMPRESSION | ||
| MCROUTER_OSS_BUILD) | ||
|
|
||
| # Allow using a compiler cache locally on an opt-in basis. | ||
| if(USE_CCACHE) | ||
| find_program(CCACHE_EXECUTABLE ccache) | ||
| if(CCACHE_EXECUTABLE) | ||
| set(ccacheEnv CCACHE_SLOPPINESS=pch_defines,time_macros) | ||
|
|
||
| foreach(lang IN ITEMS C CXX) | ||
| set(CMAKE_${lang}_COMPILER_LAUNCHER ${CMAKE_COMMAND} -E env ${ccacheEnv} | ||
| ${CCACHE_EXECUTABLE}) | ||
| endforeach() | ||
| endif() | ||
| endif() | ||
|
|
||
| # Allow profiling build performance with clang. | ||
| if(PROFILE_BUILD) | ||
| if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") | ||
| add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-ftime-trace>) | ||
| message("Enabling build time profiling") | ||
| else() | ||
| message( | ||
| "${CMAKE_CXX_COMPILER_ID} compiler detected, cannot enable build time profiling" | ||
| ) | ||
| endif() | ||
| endif() | ||
|
|
||
| if(WIN32) | ||
| include(FBCompilerSettingsMSVC) | ||
| else() | ||
| include(FBCompilerSettingsUnix) | ||
|
|
||
| # Create symlink to compile_commands.json for IDE to pick it up | ||
| execute_process( | ||
| COMMAND | ||
| ${CMAKE_COMMAND} -E create_symlink | ||
| ${CMAKE_BINARY_DIR}/compile_commands.json | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/compile_commands.json) | ||
| endif() | ||
|
|
||
| # Set up options for generated Thrift client code | ||
| include(FBThriftLibrary) | ||
| set(THRIFT_OPTIONS stack_arguments sync_methods_return_try | ||
| deprecated_terse_writes) | ||
|
|
||
| find_package(Boost 1.65.1 REQUIRED COMPONENTS system thread filesystem regex | ||
| context program_options) | ||
|
|
||
| find_package(fmt REQUIRED) | ||
| find_package(folly REQUIRED) | ||
| find_package(Fizz REQUIRED) | ||
| find_package(Glog REQUIRED) | ||
| find_package(gflags REQUIRED) | ||
| find_package(wangle REQUIRED) | ||
| find_package(FBThrift REQUIRED) | ||
|
|
||
| include_directories(.) | ||
| include_directories(${CMAKE_CURRENT_BINARY_DIR}) | ||
|
|
||
| if(BUILD_TESTS) | ||
| enable_testing() | ||
| include(CTest) | ||
|
|
||
| find_package(GTest MODULE REQUIRED) | ||
|
|
||
| include(GoogleTest) | ||
| endif() | ||
|
|
||
| add_subdirectory(mcrouter) | ||
|
|
||
| install(TARGETS mcrouter mcpiper) | ||
|
|
||
| # Provide a basic CPack integration to allow easily creating packages for Linux | ||
| # distributions. | ||
| set(CPACK_PACKAGE_DESCRIPTION_SUMMARY | ||
| "mcrouter - a memcached protocol router for scaling memcached deployments.") | ||
| set(CPACK_PACKAGE_VENDOR "Meta Platforms, Inc.") | ||
| set(CPACK_VERBATIM_VARIABLES ON) | ||
| include(CPack) | ||
This file contains hidden or 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 hidden or 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 @@ | ||
| {"requests":[{"kind":"codemodel","version":[{"major":2,"minor":7}]},{"kind":"configureLog","version":[{"major":1,"minor":0}]},{"kind":"cache","version":[{"major":2,"minor":0}]},{"kind":"cmakeFiles","version":[{"major":1,"minor":1}]},{"kind":"toolchains","version":[{"major":1,"minor":0}]}]} |
This file contains hidden or 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,5 @@ | ||
| # Facebook-internal CI builds don't have write permission outside of the | ||
| # source tree, so we install all projects into this directory. | ||
| /facebook_ci | ||
| __pycache__/ | ||
| *.pyc |
This file contains hidden or 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,27 @@ | ||
| # Copyright (c) Facebook, Inc. and its affiliates. | ||
|
|
||
| function (fb_activate_static_library_option) | ||
| option(USE_STATIC_DEPS_ON_UNIX | ||
| "If enabled, use static dependencies on unix systems. This is generally discouraged." | ||
| OFF | ||
| ) | ||
| # Mark USE_STATIC_DEPS_ON_UNIX as an "advanced" option, since enabling it | ||
| # is generally discouraged. | ||
| mark_as_advanced(USE_STATIC_DEPS_ON_UNIX) | ||
|
|
||
| if(UNIX AND USE_STATIC_DEPS_ON_UNIX) | ||
| SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a" PARENT_SCOPE) | ||
| endif() | ||
|
|
||
| option(PREFER_STATIC_DEPS_ON_UNIX | ||
| "If enabled, use static dependencies on unix systems as possible as we can. This is generally discouraged." | ||
| OFF | ||
| ) | ||
| # Mark PREFER_STATIC_DEPS_ON_UNIX as an "advanced" option, since enabling it | ||
| # is generally discouraged. | ||
| mark_as_advanced(PREFER_STATIC_DEPS_ON_UNIX) | ||
|
|
||
| if(UNIX AND PREFER_STATIC_DEPS_ON_UNIX) | ||
| SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a" ".so" PARENT_SCOPE) | ||
| endif() | ||
| endfunction() |
This file contains hidden or 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,141 @@ | ||
| # | ||
| # Copyright (c) Facebook, Inc. and its affiliates. | ||
| # | ||
| # Helper function for parsing arguments to a CMake function. | ||
| # | ||
| # This function is very similar to CMake's built-in cmake_parse_arguments() | ||
| # function, with some improvements: | ||
| # - This function correctly handles empty arguments. (cmake_parse_arguments() | ||
| # ignores empty arguments.) | ||
| # - If a multi-value argument is specified more than once, the subsequent | ||
| # arguments are appended to the original list rather than replacing it. e.g. | ||
| # if "SOURCES" is a multi-value argument, and the argument list contains | ||
| # "SOURCES a b c SOURCES x y z" then the resulting value for SOURCES will be | ||
| # "a;b;c;x;y;z" rather than "x;y;z" | ||
| # - This function errors out by default on unrecognized arguments. You can | ||
| # pass in an extra "ALLOW_UNPARSED_ARGS" argument to make it behave like | ||
| # cmake_parse_arguments(), and return the unparsed arguments in a | ||
| # <prefix>_UNPARSED_ARGUMENTS variable instead. | ||
| # | ||
| # It does look like cmake_parse_arguments() handled empty arguments correctly | ||
| # from CMake 3.0 through 3.3, but it seems like this was probably broken when | ||
| # it was turned into a built-in function in CMake 3.4. Here is discussion and | ||
| # patches that fixed this behavior prior to CMake 3.0: | ||
| # https://cmake.org/pipermail/cmake-developers/2013-November/020607.html | ||
| # | ||
| # The one downside to this function over the built-in cmake_parse_arguments() | ||
| # is that I don't think we can achieve the PARSE_ARGV behavior in a non-builtin | ||
| # function, so we can't properly handle arguments that contain ";". CMake will | ||
| # treat the ";" characters as list element separators, and treat it as multiple | ||
| # separate arguments. | ||
| # | ||
| function(fb_cmake_parse_args PREFIX OPTIONS ONE_VALUE_ARGS MULTI_VALUE_ARGS ARGS) | ||
| foreach(option IN LISTS ARGN) | ||
| if ("${option}" STREQUAL "ALLOW_UNPARSED_ARGS") | ||
| set(ALLOW_UNPARSED_ARGS TRUE) | ||
| else() | ||
| message( | ||
| FATAL_ERROR | ||
| "unknown optional argument for fb_cmake_parse_args(): ${option}" | ||
| ) | ||
| endif() | ||
| endforeach() | ||
|
|
||
| # Define all options as FALSE in the parent scope to start with | ||
| foreach(var_name IN LISTS OPTIONS) | ||
| set("${PREFIX}_${var_name}" "FALSE" PARENT_SCOPE) | ||
| endforeach() | ||
|
|
||
| # TODO: We aren't extremely strict about error checking for one-value | ||
| # arguments here. e.g., we don't complain if a one-value argument is | ||
| # followed by another option/one-value/multi-value name rather than an | ||
| # argument. We also don't complain if a one-value argument is the last | ||
| # argument and isn't followed by a value. | ||
|
|
||
| list(APPEND all_args ${ONE_VALUE_ARGS}) | ||
| list(APPEND all_args ${MULTI_VALUE_ARGS}) | ||
| set(current_variable) | ||
| set(unparsed_args) | ||
| foreach(arg IN LISTS ARGS) | ||
| list(FIND OPTIONS "${arg}" opt_index) | ||
| if("${opt_index}" EQUAL -1) | ||
| list(FIND all_args "${arg}" arg_index) | ||
| if("${arg_index}" EQUAL -1) | ||
| # This argument does not match an argument name, | ||
| # must be an argument value | ||
| if("${current_variable}" STREQUAL "") | ||
| list(APPEND unparsed_args "${arg}") | ||
| else() | ||
| # Ugh, CMake lists have a pretty fundamental flaw: they cannot | ||
| # distinguish between an empty list and a list with a single empty | ||
| # element. We track our own SEEN_VALUES_arg setting to help | ||
| # distinguish this and behave properly here. | ||
| if ("${SEEN_${current_variable}}" AND "${${current_variable}}" STREQUAL "") | ||
| set("${current_variable}" ";${arg}") | ||
| else() | ||
| list(APPEND "${current_variable}" "${arg}") | ||
| endif() | ||
| set("SEEN_${current_variable}" TRUE) | ||
| endif() | ||
| else() | ||
| # We found a single- or multi-value argument name | ||
| set(current_variable "VALUES_${arg}") | ||
| set("SEEN_${arg}" TRUE) | ||
| endif() | ||
| else() | ||
| # We found an option variable | ||
| set("${PREFIX}_${arg}" "TRUE" PARENT_SCOPE) | ||
| set(current_variable) | ||
| endif() | ||
| endforeach() | ||
|
|
||
| foreach(arg_name IN LISTS ONE_VALUE_ARGS) | ||
| if(NOT "${SEEN_${arg_name}}") | ||
| unset("${PREFIX}_${arg_name}" PARENT_SCOPE) | ||
| elseif(NOT "${SEEN_VALUES_${arg_name}}") | ||
| # If the argument was seen but a value wasn't specified, error out. | ||
| # We require exactly one value to be specified. | ||
| message( | ||
| FATAL_ERROR "argument ${arg_name} was specified without a value" | ||
| ) | ||
| else() | ||
| list(LENGTH "VALUES_${arg_name}" num_args) | ||
| if("${num_args}" EQUAL 0) | ||
| # We know an argument was specified and that we called list(APPEND). | ||
| # If CMake thinks the list is empty that means there is really a single | ||
| # empty element in the list. | ||
| set("${PREFIX}_${arg_name}" "" PARENT_SCOPE) | ||
| elseif("${num_args}" EQUAL 1) | ||
| list(GET "VALUES_${arg_name}" 0 arg_value) | ||
| set("${PREFIX}_${arg_name}" "${arg_value}" PARENT_SCOPE) | ||
| else() | ||
| message( | ||
| FATAL_ERROR "too many arguments specified for ${arg_name}: " | ||
| "${VALUES_${arg_name}}" | ||
| ) | ||
| endif() | ||
| endif() | ||
| endforeach() | ||
|
|
||
| foreach(arg_name IN LISTS MULTI_VALUE_ARGS) | ||
| # If this argument name was never seen, then unset the parent scope | ||
| if (NOT "${SEEN_${arg_name}}") | ||
| unset("${PREFIX}_${arg_name}" PARENT_SCOPE) | ||
| else() | ||
| # TODO: Our caller still won't be able to distinguish between an empty | ||
| # list and a list with a single empty element. We can tell which is | ||
| # which, but CMake lists don't make it easy to show this to our caller. | ||
| set("${PREFIX}_${arg_name}" "${VALUES_${arg_name}}" PARENT_SCOPE) | ||
| endif() | ||
| endforeach() | ||
|
|
||
| # By default we fatal out on unparsed arguments, but return them to the | ||
| # caller if ALLOW_UNPARSED_ARGS was specified. | ||
| if (DEFINED unparsed_args) | ||
| if ("${ALLOW_UNPARSED_ARGS}") | ||
| set("${PREFIX}_UNPARSED_ARGUMENTS" "${unparsed_args}" PARENT_SCOPE) | ||
| else() | ||
| message(FATAL_ERROR "unrecognized arguments: ${unparsed_args}") | ||
| endif() | ||
| endif() | ||
| endfunction() |
This file contains hidden or 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,13 @@ | ||
| # Copyright (c) Facebook, Inc. and its affiliates. | ||
|
|
||
| # This file applies common compiler settings that are shared across | ||
| # a number of Facebook opensource projects. | ||
| # Please use caution and your best judgement before making changes | ||
| # to these shared compiler settings in order to avoid accidentally | ||
| # breaking a build in another project! | ||
|
|
||
| if (WIN32) | ||
| include(FBCompilerSettingsMSVC) | ||
| else() | ||
| include(FBCompilerSettingsUnix) | ||
| endif() |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not super sure about this, but this seems like the best way to support the current
#includestyle.