-
Notifications
You must be signed in to change notification settings - Fork 17
/
components.cmake
133 lines (109 loc) · 4.5 KB
/
components.cmake
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License").
# You may not use this file except in compliance with the License.
# A copy of the License is located at
#
# http://aws.amazon.com/apache2.0/
#
# or in the "license" file accompanying this file. This file is distributed
# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
# express or implied. See the License for the specific language governing
# permissions and limitations under the License.
project (apl VERSION 1.0.0 LANGUAGES C CXX)
if (TRACING)
message("Tracing enabled.")
add_definitions(-DENABLE_TRACING)
endif(TRACING)
if (POLICY CMP0048)
cmake_policy(SET CMP0048 NEW)
endif (POLICY CMP0048)
# Required for Xcode builds
if (POLICY CMP0114)
cmake_policy(SET CMP0114 NEW)
endif (POLICY CMP0114)
if (WERROR)
message("Paranoid build (-Werror) enabled.")
add_compile_options(-Wall -Werror -Wendif-labels -Wno-sign-compare -Wno-shadow -Wno-missing-braces )
endif(WERROR)
# Set compilation flags for memory debugging
if (DEBUG_MEMORY_USE)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DDEBUG_MEMORY_USE=1")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DDEBUG_MEMORY_USE=1")
endif (DEBUG_MEMORY_USE)
#Disable RTTI if requested. Will not work for every case.
if (DISABLE_RTTI)
message("RTTI disabled. Static inclusion may not work for clients using dynamic casting.")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-rtti")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
endif()
if(COVERAGE)
# We can't really generate core coverage without tests. Option will be applied in clang.cmake as feature is clang
# specific.
set(BUILD_TESTS ON)
message("Coverage instrumentation enabled.")
endif(COVERAGE)
if(ENABLE_ALEXAEXTENSIONS)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DALEXAEXTENSIONS=1")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DALEXAEXTENSIONS=1")
endif(ENABLE_ALEXAEXTENSIONS)
# Enforce clang linking if it's used. Useful when building on Pi/etc.
if(APPLE)
function(append value)
foreach(variable ${ARGN})
set(${variable} "${${variable}} ${value}" PARENT_SCOPE)
endforeach(variable)
endfunction()
append("-stdlib=libc++" CMAKE_CXX_FLAGS CMAKE_EXE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS CMAKE_MODULE_LINKER_FLAGS)
append("-lc++abi" CMAKE_EXE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS CMAKE_MODULE_LINKER_FLAGS)
endif()
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "(Apple)?[Cc]lang")
message("Using Clang")
include(clang.cmake)
elseif(CMAKE_COMPILER_IS_GNUCXX)
message("Using gcc")
include(gcc.cmake)
elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC")
message("Using msvc")
include(msvc.cmake)
else()
message(FATAL_ERROR "Compiler ${CMAKE_CXX_COMPILER_ID} is not known")
endif()
# Do not move. It requires WASM_FLAGS while defining targets and generates part of environment required by next target.
include(thirdparty/thirdparty.cmake)
if(BUILD_DOC)
include(doxygen.cmake)
endif(BUILD_DOC)
if (BUILD_TESTS)
set(BUILD_UNIT_TESTS ON)
set(BUILD_TEST_PROGRAMS ON)
endif (BUILD_TESTS)
# Build with dependency on the Alexa Extensions library.
if (BUILD_ALEXAEXTENSIONS)
add_subdirectory(extensions)
target_compile_definitions(alexaext PUBLIC ALEXAEXTENSIONS BUILD_UNIT_TESTS=${BUILD_UNIT_TESTS})
endif(BUILD_ALEXAEXTENSIONS)
# The core library
add_subdirectory(aplcore)
# We treat enumgen as an external project because it needs to be built using the host toolchain
include(tools.cmake)
if (BUILD_TEST_PROGRAMS)
add_subdirectory(test)
endif (BUILD_TEST_PROGRAMS)
if (VALIDATE_HEADERS OR VALIDATE_FORBIDDEN_FUNCTIONS)
add_custom_target(validation ALL)
endif ()
if (VALIDATE_HEADERS)
add_custom_command(OUTPUT include_validation
COMMAND bash ${CMAKE_CURRENT_SOURCE_DIR}/bin/apl-header-inclusion-validation.sh
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/)
add_custom_target(target_validate_includes ALL DEPENDS include_validation)
add_dependencies(validation target_validate_includes)
endif (VALIDATE_HEADERS)
if (VALIDATE_FORBIDDEN_FUNCTIONS)
add_custom_command(OUTPUT forbidden_function_validation
COMMAND bash ${CMAKE_CURRENT_SOURCE_DIR}/bin/find-forbidden-functions
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/)
add_custom_target(target_validate_forbidden_functions ALL DEPENDS forbidden_function_validation)
add_dependencies(validation target_validate_forbidden_functions)
endif (VALIDATE_FORBIDDEN_FUNCTIONS)