From a507ecd1bb21594779cfa4438c2137c47e3e4b98 Mon Sep 17 00:00:00 2001 From: Jiri Hoogland Date: Thu, 10 Dec 2015 10:33:00 -0500 Subject: [PATCH] Add PIC compile flag for GNU/CLang. - ensures shared library code is position-independent. --- CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1897775..64346a2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -171,6 +171,10 @@ if("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU" OR # set(GCC_EXTRA_OPTIONS "") # + if(BUILD_SHARED_LIBS) + set(GCC_EXTRA_OPTIONS "${GCC_EXTRA_OPTIONS} -fPIC") + endif() + # set(FLAG_TESTED "-Wextra") check_cxx_compiler_flag(${FLAG_TESTED} FLAG_WEXTRA) if(FLAG_WEXTRA)