-
Notifications
You must be signed in to change notification settings - Fork 50
/
CMakeLists.txt
86 lines (72 loc) · 2.74 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
# Copyright (C) 2018 Intel Corporation
#
#
# SPDX-License-Identifier: Apache-2.0
#
cmake_minimum_required(VERSION 3.5)
project(ade)
if(POLICY CMP0063)
cmake_policy(SET CMP0063 NEW)
endif()
option(ENABLE_ADE_TESTING "Build tests, require google test" OFF)
option(BUILD_ADE_TUTORIAL "Build tutorial samples" OFF)
option(FORCE_ADE_ASSERTS "Always enable ADE_ASSERT" OFF)
option(BUILD_ADE_DOCUMENTATION "Build doxygen documentation" OFF)
option(BUILD_WITH_STATIC_CRT "Build with static multi-threaded C Runtime (MS Windows/Visual Studio only)" OFF)
if(NOT DEFINED CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
endif()
# TODO: this is horrible hack, we must follow cmake
# build/install policy
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
function(add_security_flags target)
if(UNIX)
target_compile_definitions( ${target} PRIVATE _FORTIFY_SOURCE=2 )
if( ${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9)
target_compile_options( ${target} PRIVATE -fstack-protector)
else()
target_compile_options( ${target} PRIVATE -fstack-protector-strong)
endif()
elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL "Intel")
target_compile_options( ${target} PRIVATE -fstack-protector-strong)
endif()
elseif(WIN32)
if( ${CMAKE_CXX_COMPILER_ID} STREQUAL "MSVC")
target_compile_options( ${target} PRIVATE /GS /DynamicBase)
if(BUILD_WITH_STATIC_CRT)
target_compile_options( ${target} PRIVATE "/MT")
endif()
if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "4")
# These options for 32 bit builds only
target_compile_options( ${target} PRIVATE /SAFESEH /NXCOMPAT )
endif()
elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
target_compile_definitions( ${target} PRIVATE _FORTIFY_SOURCE=2 )
target_compile_options( ${target} PRIVATE -fstack-protector-strong )
endif()
endif()
endfunction()
if (MSVC)
add_definitions(-D_SCL_SECURE_NO_WARNINGS)
endif(MSVC)
add_subdirectory(sources/ade/)
if(ENABLE_ADE_TESTING)
enable_testing()
add_subdirectory(sources/tests)
endif()
if(BUILD_ADE_TUTORIAL)
add_subdirectory(tutorial)
endif()
# cpack
if(CMAKE_BUILD_TYPE STREQUAL "Release")
set(CPACK_STRIP_FILES ON)
endif()
set(CPACK_PACKAGE_VERSION ${THE_PROJECT_VERSION})
set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY OFF)
set(CPACK_ARCHIVE_COMPONENT_INSTALL ON)
set(CPACK_GENERATOR "ZIP")
include(CPack)