-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
65 lines (52 loc) · 1.86 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
cmake_minimum_required(VERSION 3.8.0)
project(flower)
include(CheckPrototypeDefinition)
include(GNUInstallDirs)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_EXTENSIONS OFF)
option(BUILD_TESTS "Build test programs, using Google Test" ON)
find_package(PkgConfig REQUIRED)
find_package(Threads REQUIRED)
pkg_check_modules(JSONCPP REQUIRED jsoncpp)
check_prototype_definition(program_main
"void program_main(const argdata_t *ad)"
""
"program.h"
HAVE_PROGRAM_MAIN)
if(HAVE_PROGRAM_MAIN)
set(MAIN_SOURCEFILE "program_main.cc")
else()
set(MAIN_SOURCEFILE "main.cc")
endif()
set(APROTOC_NAME "aprotoc" CACHE STRING "Name of the aprotoc command")
find_program(APROTOC_COMMAND ${APROTOC_NAME})
mark_as_advanced(APROTOC_COMMAND)
if(NOT APROTOC_COMMAND)
message(FATAL_ERROR "Could not find aprotoc, set APROTOC_NAME")
endif()
function(add_aprotoc base)
get_filename_component(base_dir ${base} DIRECTORY)
add_custom_command(
OUTPUT ${base}.ad.h
COMMAND mkdir -p ${CMAKE_BINARY_DIR}/${base_dir} && ${APROTOC_COMMAND} <${CMAKE_SOURCE_DIR}/${base}.proto >${CMAKE_BINARY_DIR}/${base}.ad.h
DEPENDS ${CMAKE_SOURCE_DIR}/${base}.proto
)
install(
FILES ${base}.proto ${CMAKE_BINARY_DIR}/${base}.ad.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${base_dir}
)
endfunction()
include_directories(${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR})
include(flower/cat/CMakeLists.txt)
include(flower/egress/connect/CMakeLists.txt)
include(flower/ingress/accept/CMakeLists.txt)
include(flower/ls/CMakeLists.txt)
include(flower/protocol/CMakeLists.txt)
include(flower/resolver/getaddrinfo/CMakeLists.txt)
include(flower/switchboard/CMakeLists.txt)
if(BUILD_TESTS)
add_subdirectory(contrib/googletest-release-1.8.0/googletest EXCLUDE_FROM_ALL)
include_directories(${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR})
include(flower/unittests/CMakeLists.txt)
endif(BUILD_TESTS)