forked from awslabs/aws-lambda-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
118 lines (94 loc) · 3.47 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
106
107
108
109
110
111
112
113
114
115
116
117
cmake_minimum_required(VERSION 3.5)
set(CMAKE_CXX_STANDARD 11)
project(aws-lambda-runtime
VERSION 0.2.4
LANGUAGES CXX)
option(ENABLE_TESTS "Enables building the test project, requires AWS C++ SDK." OFF)
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag("-Wl,-flto" LTO_CAPABLE)
add_library(${PROJECT_NAME}
"src/logging.cpp"
"src/runtime.cpp"
"src/backward.cpp"
"${CMAKE_CURRENT_BINARY_DIR}/version.cpp"
)
set_target_properties(${PROJECT_NAME} PROPERTIES VERSION ${PROJECT_VERSION})
target_include_directories(${PROJECT_NAME} PUBLIC
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)
find_package(CURL REQUIRED)
if (CMAKE_VERSION VERSION_LESS 3.12)
target_link_libraries(${PROJECT_NAME} PRIVATE ${CURL_LIBRARIES})
else()
target_link_libraries(${PROJECT_NAME} PRIVATE CURL::libcurl)
endif()
target_include_directories(${PROJECT_NAME} PRIVATE ${CURL_INCLUDE_DIRS})
target_compile_options(${PROJECT_NAME} PRIVATE
"-fno-exceptions"
"-fno-rtti"
"-fvisibility=hidden"
"-Wall"
"-Wextra"
"-Werror"
"-Wconversion"
"-Wno-sign-conversion")
find_library(DW_LIB NAMES dw)
if (NOT DW_LIB STREQUAL DW_LIB-NOTFOUND)
message("-- Enhanced stack-traces are enabled via libdw: ${DW_LIB}")
target_compile_definitions(${PROJECT_NAME} PRIVATE "BACKWARD_HAS_DW=1")
target_link_libraries(${PROJECT_NAME} PUBLIC "${DW_LIB}")
else()
find_library(BFD_LIB NAMES bfd)
if (NOT BFD_LIB STREQUAL BFD_LIB-NOTFOUND)
message("-- Enhanced stack-traces are enabled via libbfd: ${BFD_LIB}")
target_compile_definitions(${PROJECT_NAME} PRIVATE "BACKWARD_HAS_BFD=1")
target_link_libraries(${PROJECT_NAME} PRIVATE "${BFD_LIB}")
endif()
endif()
if (LOG_VERBOSITY)
target_compile_definitions(${PROJECT_NAME} PRIVATE "AWS_LAMBDA_LOG=${LOG_VERBOSITY}")
elseif(CMAKE_BUILD_TYPE STREQUAL Debug)
target_compile_definitions(${PROJECT_NAME} PRIVATE "AWS_LAMBDA_LOG=3")
else ()
target_compile_definitions(${PROJECT_NAME} PRIVATE "AWS_LAMBDA_LOG=0")
endif()
if ((BUILD_SHARED_LIBS) AND (LTO_CAPABLE))
target_compile_options(${PROJECT_NAME} PRIVATE "-flto")
target_link_libraries(${PROJECT_NAME} PRIVATE "-flto")
endif()
#tests
if (ENABLE_TESTS)
enable_testing()
add_subdirectory(tests)
endif()
#versioning
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/src/version.cpp.in"
"${CMAKE_CURRENT_BINARY_DIR}/version.cpp"
NEWLINE_STYLE LF)
# installation
install(FILES "include/aws/http/response.h"
DESTINATION "include/aws/http")
install(FILES
"include/aws/lambda-runtime/runtime.h"
"include/aws/lambda-runtime/version.h"
"include/aws/lambda-runtime/outcome.h"
DESTINATION "include/aws/lambda-runtime")
install(FILES "include/aws/logging/logging.h"
DESTINATION "include/aws/logging")
install(TARGETS ${PROJECT_NAME}
EXPORT ${PROJECT_NAME}-targets
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin)
configure_file("${CMAKE_SOURCE_DIR}/cmake/${PROJECT_NAME}-config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake"
@ONLY)
export(EXPORT "${PROJECT_NAME}-targets" NAMESPACE AWS::)
install(EXPORT "${PROJECT_NAME}-targets"
DESTINATION "lib/${PROJECT_NAME}/cmake/"
NAMESPACE AWS::)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake"
DESTINATION "lib/${PROJECT_NAME}/cmake/")
install(PROGRAMS "${CMAKE_SOURCE_DIR}/packaging/packager"
DESTINATION "lib/${PROJECT_NAME}/cmake/")