From 490fd39de3a74e5505e687517b07996c2e0f9580 Mon Sep 17 00:00:00 2001 From: Dan Shechter Date: Wed, 11 Jan 2023 16:08:19 +0200 Subject: [PATCH] cmake: allow for inclusion with CPM Allow using backwards-cpp through CPM (Cmake Package Manager)/FetchContent without using the ${BACKWARD_ENABLE} target CPM (https://github.com/cpm-cmake/CPM.cmake) can now be used like so: In a main/top-level CMakeLists.txt: ```cmake include(cmake/CPM.cmake) CPMAddPackage("gh:bombela/backward-cpp#1.7") ``` And in a project (or the same CMakeLists.txt): ```cmake cmake_minimum_required(VERSION 3.9) project (example VERSION 0.1) add_executable(example main.cpp ) target_link_libraries(example Backward::Backward ) ``` --- CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 97327cc..e195dd4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -86,6 +86,11 @@ endif() add_library(backward ${libtype} backward.cpp) target_compile_definitions(backward PUBLIC ${BACKWARD_DEFINITIONS}) target_include_directories(backward PUBLIC ${BACKWARD_INCLUDE_DIRS}) +if(BACKWARD_HAS_EXTERNAL_LIBRARIES) + set_target_properties(backward PROPERTIES + INTERFACE_LINK_LIBRARIES "${BACKWARD_LIBRARIES}") +endif() +add_library(Backward::Backward ALIAS backward) ############################################################################### # TESTS