From 94cac7a0149a8c1c48f33b0a8140edec5581ce64 Mon Sep 17 00:00:00 2001 From: robotanarchy Date: Mon, 21 Dec 2015 19:01:17 +0100 Subject: use CMake's FindBacktrace for backtrace feature detection --- CMakeLists.txt | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt index 5cd9c67b..cabdc468 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -58,6 +58,14 @@ find_package(Pango) find_package(GdkPixbuf) find_package(PAM) +find_package(Backtrace) +if(Backtrace_FOUND) + include_directories(${Backtrace_INCLUDE_DIRS}) + target_link_libraries(${Backtrace_LIBRARIES}) + add_definitions(-DSWAY_Backtrace_FOUND=1) + set(SWAY_Backtrace_HEADER "${Backtrace_HEADER}") +endif() + include(FeatureSummary) include(Manpage) -- cgit v1.2.3-70-g09d2 From 03c041dd30315125b72699a90085718ebdc13248 Mon Sep 17 00:00:00 2001 From: robotanarchy Date: Mon, 21 Dec 2015 19:09:39 +0100 Subject: add -fPIC flag (position independent code) like in wlc Linking fails otherwise: Linking C executable ../bin/sway /usr/bin/ld: CMakeFiles/sway.dir/commands.c.o: relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a shared object; recompile with -fPIC CMakeFiles/sway.dir/commands.c.o: error adding symbols: Bad value collect2: error: ld returned 1 exit status sway/CMakeFiles/sway.dir/build.make:442: recipe for target 'bin/sway' failed --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) (limited to 'CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt index cabdc468..bb13ef96 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,6 +9,7 @@ add_definitions(-DFALLBACK_CONFIG_DIR=\"${FALLBACK_CONFIG_DIR}\") set(CMAKE_C_FLAGS "-g") set(CMAKE_C_STANDARD 99) set(CMAKE_C_EXTENSIONS OFF) +set(CMAKE_POSITION_INDEPENDENT_CODE ON) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin) add_definitions( -D_GNU_SOURCE -- cgit v1.2.3-70-g09d2 From 470e59b291b7c5e416f5c43bf14dedb8c379b25e Mon Sep 17 00:00:00 2001 From: robotanarchy Date: Tue, 22 Dec 2015 00:32:41 +0100 Subject: fix backtrace detection in CMake works on arch (glibc) and void linux (tested with musl libc) now --- CMakeLists.txt | 4 ++-- common/CMakeLists.txt | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt index bb13ef96..4c349865 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -61,9 +61,9 @@ find_package(PAM) find_package(Backtrace) if(Backtrace_FOUND) - include_directories(${Backtrace_INCLUDE_DIRS}) - target_link_libraries(${Backtrace_LIBRARIES}) + include_directories("${Backtrace_INCLUDE_DIRS}") add_definitions(-DSWAY_Backtrace_FOUND=1) + set(LINK_LIBRARIES, "${LINK_LIBRARIES} ${Backtrace_LIBRARIES}") set(SWAY_Backtrace_HEADER "${Backtrace_HEADER}") endif() diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 95617e15..38767249 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -1,5 +1,4 @@ add_library(sway-common - ${SWAY_Backtrace_HEADER} ipc-client.c list.c log.c @@ -7,3 +6,10 @@ add_library(sway-common readline.c stringop.c ) + +if(Backtrace_FOUND) + set_target_properties(sway-common + PROPERTIES + COMPILE_FLAGS "-include ${Backtrace_HEADER}" + ) +endif() -- cgit v1.2.3-70-g09d2