-
Notifications
You must be signed in to change notification settings - Fork 13
/
CMakeLists.txt
105 lines (83 loc) · 3.05 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# 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 Project setup
cmake_minimum_required(VERSION 3.8)
set_property(GLOBAL PROPERTY GLOBAL_DEPENDS_NO_CYCLES ON)
project("edencommon" LANGUAGES CXX C)
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 17)
message(STATUS "setting C++ standard to C++${CMAKE_CXX_STANDARD}")
endif()
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# Explicitly enable coroutine support, since GCC does not enable it
# by default when targeting C++17.
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-fcoroutines>)
endif()
if (WIN32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DWIN32_LEAN_AND_MEAN -DNOMINMAX -DSTRICT")
endif()
# Setup directories for build and install
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(CMAKE_INSTALL_DIR lib/cmake/edencommon CACHE STRING
"The subdirectory where CMake package config files should be installed")
# CMake include directories
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake"
# For shipit-transformed builds
"${CMAKE_CURRENT_SOURCE_DIR}/build/fbcode_builder/CMake"
${CMAKE_MODULE_PATH})
include(FBCompilerSettings)
# Setup all the CMake include directories so we can access all the
# dependenciew we need.
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake"
"${CMAKE_CURRENT_SOURCE_DIR}/build/fbcode_builder/CMake"
${CMAKE_MODULE_PATH})
find_package(Glog MODULE REQUIRED)
include_directories(${GLOG_INCLUDE_DIR})
find_package(Gflags REQUIRED)
include_directories(${GFLAGS_INCLUDE_DIR})
find_package(folly CONFIG REQUIRED)
include_directories(${FOLLY_INCLUDE_DIR})
find_package(fb303 CONFIG REQUIRED)
include_directories(${FB303_INCLUDE_DIR})
find_package(wangle CONFIG REQUIRED)
include_directories(${WANGLE_INCLUDE_DIR})
find_package(FBThrift CONFIG REQUIRED COMPONENTS cpp2 py)
include_directories(${FBTHRIFT_INCLUDE_DIR})
find_package(GMock MODULE REQUIRED)
include_directories(${GMOCK_INCLUDEDIR} ${LIBGMOCK_INCLUDE_DIR})
include(GoogleTest)
enable_testing()
add_subdirectory(eden/common/os)
add_subdirectory(eden/common/telemetry)
add_subdirectory(eden/common/testharness)
add_subdirectory(eden/common/utils)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/CMake/eden-config.h.in
${CMAKE_CURRENT_SOURCE_DIR}/eden/common/eden-config.h
)
# Install our own CMake package files for dependent projects.
include(CMakePackageConfigHelpers)
configure_package_config_file(
CMake/edencommon-config.cmake.in
edencommon-config.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_DIR}
PATH_VARS
CMAKE_INSTALL_DIR
)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/edencommon-config.cmake
DESTINATION ${CMAKE_INSTALL_DIR}
)
install(
EXPORT edencommon-exports
FILE edencommon-targets.cmake
NAMESPACE edencommon::
DESTINATION ${CMAKE_INSTALL_DIR}
)