-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use cmake to generate fizz-config.h (#127)
Summary: Pull Request resolved: #127 We can not directly commit the internal version of the file: D57595374 Reviewed By: bigfootjon Differential Revision: D58003320 fbshipit-source-id: 8d0b447b8afa74f054c04cfd552dd77895a64830
- Loading branch information
1 parent
477b04f
commit 6c45bae
Showing
3 changed files
with
142 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
load("@fbcode_macros//build_defs:native_rules.bzl", "buck_genrule") | ||
|
||
oncall("secure_pipes") | ||
|
||
buck_genrule( | ||
name = "fizz-config.h", | ||
srcs = {file: file for file in glob([ | ||
"fizz/cmake/*", | ||
"build/fbcode_builder/CMake/*", | ||
])} | | ||
{ | ||
"CMakeLists.txt": "//fizz:CMakeListsForBuck2.txt", | ||
"fizz/cmake/CheckAtomic.cmake": "//fizz:cmake/CheckAtomic.cmake", | ||
"fizz/cmake/FizzOptions.cmake": "//fizz:cmake/FizzOptions.cmake", | ||
"fizz/fizz-config.h.in": "//fizz:fizz-config.h.in", | ||
}, | ||
out = "fizz-config.h", | ||
cmd = "cmake . && mv fizz/fizz-config.h $OUT", | ||
default_target_platform = "prelude//platforms:default", | ||
labels = ["third-party:homebrew:cmake"], | ||
remote = False, | ||
) |
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 |
---|---|---|
@@ -1,11 +1,22 @@ | ||
load("@fbcode_macros//build_defs:cpp_library.bzl", "cpp_library") | ||
load("@fbcode_macros//build_defs:export_files.bzl", "export_files") | ||
|
||
oncall("secure_pipes") | ||
|
||
cpp_library( | ||
name = "config", | ||
headers = select({ | ||
"DEFAULT": {"fizz-config.h": "facebook/fizz-config-fbcode.h"}, | ||
# @fb-only: "DEFAULT": {"fizz-config.h": "facebook/fizz-config-fbcode.h"}, | ||
"DEFAULT": {"fizz-config.h": "//:fizz-config.h"}, # @oss-only | ||
# @fb-only: "ovr_config//toolchain/fb:arista": {"fizz-config.h": "facebook/fizz-config-xplat.h"}, | ||
}), | ||
) | ||
|
||
export_files( | ||
files = glob([ | ||
"cmake/*", | ||
] + [ | ||
"fizz-config.h.in", | ||
"CMakeListsForBuck2.txt", | ||
]), | ||
) |
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,108 @@ | ||
# Copyright (c) 2018, Facebook, Inc. | ||
# All rights reserved. | ||
|
||
cmake_minimum_required(VERSION 3.1) | ||
|
||
if (NOT DEFINED PACKAGE_VERSION) | ||
set(PACKAGE_VERSION "1.0.0") | ||
endif() | ||
|
||
project("fizz" VERSION ${PACKAGE_VERSION} LANGUAGES CXX C) | ||
|
||
if (NOT DEFINED CPACK_GENERATOR) | ||
set(CPACK_GENERATOR "RPM") | ||
endif() | ||
include(CPack) | ||
|
||
set(CMAKE_CXX_STANDARD 17) | ||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
set(CMAKE_CXX_EXTENSIONS OFF) | ||
|
||
set(CMAKE_POSITION_INDEPENDENT_CODE ON) | ||
set(CMAKE_MODULE_PATH | ||
"${CMAKE_CURRENT_SOURCE_DIR}/fizz/cmake" | ||
# for in-fbsource builds | ||
"${CMAKE_CURRENT_SOURCE_DIR}/../opensource/fbcode_builder/CMake" | ||
# For shipit-transformed builds | ||
"${CMAKE_CURRENT_SOURCE_DIR}/build/fbcode_builder/CMake" | ||
${CMAKE_MODULE_PATH}) | ||
|
||
include(FBBuildOptions) | ||
fb_activate_static_library_option() | ||
|
||
# When installing Folly & Fizz in a non-default prefix, this will let | ||
# projects linking against libfizz.so to find libfolly.so automatically. | ||
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) | ||
|
||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) | ||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) | ||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) | ||
set(INCLUDE_INSTALL_DIR include CACHE STRING | ||
"The subdirectory where header files should be installed") | ||
set(LIB_INSTALL_DIR lib CACHE STRING | ||
"The subdirectory where libraries should be installed") | ||
set(BIN_INSTALL_DIR bin CACHE STRING | ||
"The subdirectory where binaries should be installed") | ||
set(CMAKE_INSTALL_DIR lib/cmake/fizz CACHE STRING | ||
"The subdirectory where CMake package config files should be installed") | ||
|
||
find_package(folly CONFIG REQUIRED) | ||
find_package(fmt CONFIG REQUIRED) | ||
|
||
find_package(OpenSSL REQUIRED) | ||
find_package(Glog REQUIRED) | ||
find_package(DoubleConversion REQUIRED) | ||
find_package(Threads REQUIRED) | ||
find_package(Zstd REQUIRED) | ||
if (UNIX AND NOT APPLE) | ||
find_package(Librt) | ||
endif() | ||
|
||
include(CheckAtomic) | ||
|
||
find_package(Sodium REQUIRED) | ||
|
||
SET(FIZZ_SHINY_DEPENDENCIES "") | ||
SET(FIZZ_LINK_LIBRARIES "") | ||
SET(FIZZ_INCLUDE_DIRECTORIES "") | ||
|
||
find_package(gflags CONFIG QUIET) | ||
if (gflags_FOUND) | ||
message(STATUS "Found gflags from package config") | ||
if (TARGET gflags-shared) | ||
list(APPEND FIZZ_SHINY_DEPENDENCIES gflags-shared) | ||
elseif (TARGET gflags) | ||
list(APPEND FIZZ_SHINY_DEPENDENCIES gflags) | ||
else() | ||
message(FATAL_ERROR "Unable to determine the target name for the GFlags package.") | ||
endif() | ||
list(APPEND CMAKE_REQUIRED_LIBRARIES ${GFLAGS_LIBRARIES}) | ||
list(APPEND CMAKE_REQUIRED_INCLUDES ${GFLAGS_INCLUDE_DIR}) | ||
else() | ||
find_package(Gflags REQUIRED MODULE) | ||
list(APPEND FIZZ_LINK_LIBRARIES ${LIBGFLAGS_LIBRARY}) | ||
list(APPEND FIZZ_INCLUDE_DIRECTORIES ${LIBGFLAGS_INCLUDE_DIR}) | ||
list(APPEND CMAKE_REQUIRED_LIBRARIES ${LIBGFLAGS_LIBRARY}) | ||
list(APPEND CMAKE_REQUIRED_INCLUDES ${LIBGFLAGS_INCLUDE_DIR}) | ||
endif() | ||
|
||
find_package(ZLIB REQUIRED) | ||
|
||
find_package(Libevent CONFIG QUIET) | ||
if(TARGET event) | ||
message(STATUS "Found libevent from package config") | ||
list(APPEND FIZZ_SHINY_DEPENDENCIES event) | ||
else() | ||
find_package(Libevent MODULE REQUIRED) | ||
list(APPEND FIZZ_LINK_LIBRARIES ${LIBEVENT_LIB}) | ||
list(APPEND FIZZ_INCLUDE_DIRECTORIES ${LIBEVENT_INCLUDE_DIR}) | ||
endif() | ||
|
||
find_package(liboqs CONFIG) | ||
if (liboqs_FOUND) | ||
set(FIZZ_HAVE_OQS TRUE) | ||
endif() | ||
|
||
# Fizz build time options | ||
include(FizzOptions) | ||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/fizz/fizz-config.h.in ${CMAKE_CURRENT_BINARY_DIR}/fizz/fizz-config.h) |