4
0
mirror of https://github.com/QuasarApp/backward-cpp.git synced 2025-05-02 12:59:34 +00:00
backward-cpp/CMakeLists.txt

100 lines
3.2 KiB
CMake
Raw Normal View History

2013-03-14 23:10:06 -07:00
#
# CMakeLists.txt
2013-03-15 13:15:28 -07:00
# Copyright 2013 Google Inc. All Rights Reserved.
2013-03-14 23:10:06 -07:00
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
cmake_minimum_required(VERSION 2.8.12)
2013-03-14 23:10:06 -07:00
project(backward CXX)
2016-11-17 16:56:48 -02:00
find_package(Backward REQUIRED PATHS ${CMAKE_CURRENT_LIST_DIR})
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_CXX_STANDARD 11)
2013-03-14 23:10:06 -07:00
###############################################################################
# COMPILER FLAGS
###############################################################################
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic-errors")
2013-03-14 23:10:06 -07:00
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")
endif()
###############################################################################
# BACKWARD OBJECT
###############################################################################
add_library(backward_object OBJECT backward.cpp)
target_compile_definitions(backward_object PRIVATE ${BACKWARD_DEFINITIONS})
target_include_directories(backward_object PRIVATE ${BACKWARD_INCLUDE_DIRS})
set(BACKWARD_ENABLE $<TARGET_OBJECTS:backward_object> CACHE STRING
"Link with this object to setup backward automatically")
2013-03-14 23:10:06 -07:00
###############################################################################
# TESTS
###############################################################################
2014-10-18 17:27:16 +02:00
if(BACKWARD_TESTS)
enable_testing()
2013-03-14 23:10:06 -07:00
2014-10-18 17:27:16 +02:00
add_library(test_main SHARED test/_test_main.cpp)
2013-03-14 23:10:06 -07:00
macro(backward_add_test src)
2014-10-18 17:27:16 +02:00
get_filename_component(name ${src} NAME_WE)
set(test_name "test_${name}")
2013-03-14 23:10:06 -07:00
add_executable(${test_name} ${src} ${ARGN})
2013-03-14 23:10:06 -07:00
2016-11-17 16:56:48 -02:00
target_link_libraries(${test_name} PRIVATE Backward::Backward test_main)
2014-10-18 17:27:16 +02:00
add_test(NAME ${name} COMMAND ${test_name})
endmacro()
2013-03-14 23:10:06 -07:00
2014-10-18 17:27:16 +02:00
# Tests without backward.cpp
set(TESTS
test
stacktrace
rectrace
select_signals
)
2013-03-14 23:10:06 -07:00
2014-10-18 17:27:16 +02:00
foreach(test ${TESTS})
backward_add_test(test/${test}.cpp)
2014-10-18 17:27:16 +02:00
endforeach()
2013-03-14 23:10:06 -07:00
2014-10-18 17:27:16 +02:00
# Tests with backward.cpp
set(TESTS
suicide
)
2013-03-14 23:10:06 -07:00
2014-10-18 17:27:16 +02:00
foreach(test ${TESTS})
backward_add_test(test/${test}.cpp ${BACKWARD_ENABLE})
2014-10-18 17:27:16 +02:00
endforeach()
endif()
2016-11-17 17:29:27 -02:00
install(
FILES "backward.hpp"
DESTINATION ${CMAKE_INSTALL_PREFIX}/include
)
install(
FILES "BackwardConfig.cmake"
DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/backward
)