|
| 1 | +# |
| 2 | +# CMakeLists.txt |
| 3 | +# Copyright © 2013 François-Xavier 'Bombela' Bourlet <[email protected]> |
| 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) |
| 24 | +project(backward CXX) |
| 25 | + |
| 26 | +############################################################################### |
| 27 | +# COMPILER FLAGS |
| 28 | +############################################################################### |
| 29 | + |
| 30 | +if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_COMPILER_IS_GNUCXX) |
| 31 | + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra") |
| 32 | + #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") |
| 33 | + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g") |
| 34 | +endif() |
| 35 | + |
| 36 | +include_directories(${CMAKE_SOURCE_DIR}/include) |
| 37 | +enable_testing() |
| 38 | + |
| 39 | +############################################################################### |
| 40 | +# TESTS |
| 41 | +############################################################################### |
| 42 | + |
| 43 | +include_directories(${CMAKE_SOURCE_DIR}) |
| 44 | + |
| 45 | +add_library(test_main SHARED test/_test_main.cpp) |
| 46 | + |
| 47 | +macro(backward_add_test src src_dep definition) |
| 48 | + get_filename_component(name ${src} NAME_WE) |
| 49 | + set(test_name "test_${name}") |
| 50 | + |
| 51 | + add_executable(${test_name} ${src} ${src_dep}) |
| 52 | + |
| 53 | + set(_definition ${definition}) |
| 54 | + if(_definition) |
| 55 | + set_target_properties(${test_name} |
| 56 | + PROPERTIES COMPILE_DEFINITIONS ${definition}) |
| 57 | + endif() |
| 58 | + |
| 59 | + target_link_libraries(${test_name} dw bfd dl test_main) |
| 60 | + add_test(${test_name} ${test_name}) |
| 61 | +endmacro() |
| 62 | + |
| 63 | +set(TESTS |
| 64 | + compile |
| 65 | + minitrace |
| 66 | + smalltrace |
| 67 | + simplerecursive |
| 68 | + fib |
| 69 | + segfault |
| 70 | + invalidread |
| 71 | + suicide |
| 72 | + divbyzero |
| 73 | + ) |
| 74 | + |
| 75 | +foreach(test ${TESTS}) |
| 76 | + backward_add_test(test/${test}.cpp "" "") |
| 77 | +endforeach() |
| 78 | + |
| 79 | +set(TESTS |
| 80 | + invalidread2 |
| 81 | + ) |
| 82 | + |
| 83 | +set(some_definition "BACKWARD_HAS_BFD=1") |
| 84 | +#set(some_definition "BACKWARD_NOTHING") |
| 85 | +foreach(test ${TESTS}) |
| 86 | + backward_add_test(test/${test}.cpp backward.cpp ${some_definition}) |
| 87 | +endforeach() |
0 commit comments