From bbcd8db054c979361272243a404a3726a7f1303e Mon Sep 17 00:00:00 2001 From: Jeremy <51220084+jeremy-rifkin@users.noreply.github.com> Date: Wed, 4 Oct 2023 10:27:03 -0400 Subject: [PATCH] Better handle PIC / static linking --- CMakeLists.txt | 3 +-- bundled/libdwarf/CMakeLists.txt | 6 ++---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ea088e9..8828ad2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -202,8 +202,6 @@ endif() set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) -set(CMAKE_POSITION_INDEPENDENT_CODE ON) - set( sources src/cpptrace.cpp @@ -228,6 +226,7 @@ if(CPPTRACE_STATIC) add_library(cpptrace STATIC ${sources} include/cpptrace/cpptrace.hpp) else() add_library(cpptrace SHARED ${sources} include/cpptrace/cpptrace.hpp) + set_property(TARGET cpptrace PROPERTY POSITION_INDEPENDENT_CODE ON) endif() target_include_directories( diff --git a/bundled/libdwarf/CMakeLists.txt b/bundled/libdwarf/CMakeLists.txt index bc30c88..b272e94 100644 --- a/bundled/libdwarf/CMakeLists.txt +++ b/bundled/libdwarf/CMakeLists.txt @@ -421,12 +421,10 @@ set( set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) -### libassert uses relocs, -fpic has to be used to allow shared libs to link libassert as a static library. -##set(CMAKE_POSITION_INDEPENDENT_CODE ON) - include(GNUInstallDirs) -add_library(dwarf STATIC ${libdwarf_sources} ${libdwarf_headers}) +add_library(dwarf OBJECT ${libdwarf_sources} ${libdwarf_headers}) +set_property(TARGET dwarf PROPERTY POSITION_INDEPENDENT_CODE ON) target_compile_definitions(dwarf PUBLIC LIBDWARF_BUILD)