From 4376ebacaad3d740ad95545b01084ddf545bb5f4 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 d4a8e29..0edf87f 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)