From a9c0ea0e07329520f62141f74021d74684d0c6d0 Mon Sep 17 00:00:00 2001
From: Přemysl Janouch
Date: Sat, 14 Feb 2015 22:47:20 +0100
Subject: Fix static linking into a shared library
---
CMakeLists.txt | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7bac446..f89bab6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -74,6 +74,14 @@ set_target_properties (termo-static PROPERTIES
VERSION ${project_VERSION}
SOVERSION ${project_API_VERSION})
+# A fix for: relocation R_X86_64_32 against `a local symbol' can not be
+# used when making a shared object; recompile with -fPIC
+# See http://www.cmake.org/pipermail/cmake/2007-May/014350.html
+# This should enable linking the static library into a shared one.
+if (CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
+ set_target_properties (termo-static PROPERTIES COMPILE_FLAGS "-fPIC")
+endif (CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
+
# Demos
add_executable (demo-async EXCLUDE_FROM_ALL demo-async.c)
target_link_libraries (demo-async termo-static ${lib_libraries})
--
cgit v1.2.3-70-g09d2