TYPE3
[iec.git] / src / type3_AndroidCloud / anbox-master / external / backward-cpp / CMakeLists.txt
1 #
2 # CMakeLists.txt
3 # Copyright 2013 Google Inc. All Rights Reserved.
4 #
5 # Permission is hereby granted, free of charge, to any person obtaining a copy
6 # of this software and associated documentation files (the "Software"), to deal
7 # in the Software without restriction, including without limitation the rights
8 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 # copies of the Software, and to permit persons to whom the Software is
10 # furnished to do so, subject to the following conditions:
11 #
12 # The above copyright notice and this permission notice shall be included in
13 # all copies or substantial portions of the Software.
14 #
15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 # SOFTWARE.
22
23 cmake_minimum_required(VERSION 2.8.12)
24 project(backward CXX)
25
26 include(BackwardConfig.cmake)
27
28 # check if compiler is nvcc or nvcc_wrapper
29 set(COMPILER_IS_NVCC false)
30 get_filename_component(COMPILER_NAME ${CMAKE_CXX_COMPILER} NAME)
31 if (COMPILER_NAME MATCHES "^nvcc")
32   set(COMPILER_IS_NVCC true)
33 endif()
34
35 # set CXX standard
36 set(CMAKE_CXX_STANDARD_REQUIRED True)
37 set(CMAKE_CXX_STANDARD 11)
38 if (${COMPILER_IS_NVCC})
39   # GNU CXX extensions are not supported by nvcc
40   set(CMAKE_CXX_EXTENSIONS OFF)
41 endif()
42
43 ###############################################################################
44 # COMPILER FLAGS
45 ###############################################################################
46
47 if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_COMPILER_IS_GNUCXX)
48         set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
49         if (NOT ${COMPILER_IS_NVCC})
50           set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic-errors")
51         endif()
52         set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")
53 endif()
54
55 # Anbox: allow old-style cast, unknown pragmas
56 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=old-style-cast -Wno-error=unknown-pragmas -Wno-error=switch-default")
57
58 ###############################################################################
59 # BACKWARD OBJECT
60 ###############################################################################
61
62 add_library(backward_object OBJECT backward.cpp)
63 target_compile_definitions(backward_object PRIVATE ${BACKWARD_DEFINITIONS})
64 target_include_directories(backward_object PRIVATE ${BACKWARD_INCLUDE_DIRS})
65 set(BACKWARD_ENABLE $<TARGET_OBJECTS:backward_object> CACHE STRING
66         "Link with this object to setup backward automatically")
67
68
69 ###############################################################################
70 # BACKWARD LIBRARY (Includes backward.cpp)
71 ###############################################################################
72 option(BACKWARD_SHARED "Build dynamic backward-cpp shared lib" OFF)
73
74 if(BACKWARD_SHARED)
75     set(libtype SHARED)
76 endif()
77 add_library(backward ${libtype} backward.cpp)
78 target_compile_definitions(backward PUBLIC ${BACKWARD_DEFINITIONS})
79 target_include_directories(backward PUBLIC ${BACKWARD_INCLUDE_DIRS})
80
81 ###############################################################################
82 # TESTS
83 ###############################################################################
84
85 if(BACKWARD_TESTS)
86         enable_testing()
87
88         add_library(test_main SHARED test/_test_main.cpp)
89
90         macro(backward_add_test src)
91                 get_filename_component(name ${src} NAME_WE)
92                 set(test_name "test_${name}")
93
94                 add_executable(${test_name} ${src} ${ARGN})
95
96                 target_link_libraries(${test_name} PRIVATE Backward::Backward test_main)
97
98                 add_test(NAME ${name} COMMAND ${test_name})
99         endmacro()
100
101         # Tests without backward.cpp
102         set(TESTS
103                 test
104                 stacktrace
105                 rectrace
106                 select_signals
107                 )
108
109         foreach(test ${TESTS})
110                 backward_add_test(test/${test}.cpp)
111         endforeach()
112
113         # Tests with backward.cpp
114         set(TESTS
115                 suicide
116                 )
117
118         foreach(test ${TESTS})
119                 backward_add_test(test/${test}.cpp ${BACKWARD_ENABLE})
120         endforeach()
121 endif()
122
123 install(
124     FILES "backward.hpp"
125     DESTINATION ${CMAKE_INSTALL_PREFIX}/include
126 )
127 install(
128     FILES "BackwardConfig.cmake"
129     DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/backward
130 )