]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cmake: use CMAKE_POSITION_INDEPENDENT_CODE property instead of -fPIC
authorKefu Chai <kchai@redhat.com>
Wed, 29 Jun 2016 07:49:26 +0000 (15:49 +0800)
committerKefu Chai <kchai@redhat.com>
Wed, 29 Jun 2016 14:26:25 +0000 (22:26 +0800)
use the global setting of CMAKE_POSITION_INDEPENDENT_CODE instead of
hardwiring the CMAKE_C_FLAGS with -fPIC. this helps to reduce the
overhead of symbol resolution when user is using static libraries.
see
https://cmake.org/cmake/help/v2.8.11/cmake.html#variable:CMAKE_POSITION_INDEPENDENT_CODE

Signed-off-by: Kefu Chai <kchai@redhat.com>
CMakeLists.txt
src/CMakeLists.txt

index a3a76666b4904009d9a0f146196c1df79f9d494f..e66e7bce082e887ce37e020004a67c95d99b0fb0 100644 (file)
@@ -156,6 +156,7 @@ if(ENABLE_SHARED)
 else(ENABLE_SHARED)
   set(CEPH_SHARED STATIC)
 endif(ENABLE_SHARED)
+set(CMAKE_POSITION_INDEPENDENT_CODE ${ENABLE_SHARED})
 
 find_package(execinfo)
 
index a5519fe4b64a70a4f5f6589ac13ea1c8a275d638..0b3880a2a9795061280f18ad2701ac292ff6a222 100644 (file)
@@ -19,7 +19,7 @@ add_definitions("-DHAVE_CONFIG_H -D__CEPH__ -D_FILE_OFFSET_BITS=64 -D_REENTRANT
 
 set(CMAKE_ASM_COMPILER  ${PROJECT_SOURCE_DIR}/src/yasm-wrapper)
 set(CMAKE_ASM_FLAGS "-f elf64")
-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -rdynamic -Wall -Wtype-limits -Wignored-qualifiers -Winit-self -Wpointer-arith -Werror=format-security -fno-strict-aliasing -fsigned-char -fPIC")
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -rdynamic -Wall -Wtype-limits -Wignored-qualifiers -Winit-self -Wpointer-arith -Werror=format-security -fno-strict-aliasing -fsigned-char")
 
 if(NOT CMAKE_BUILD_TYPE)
   set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Default BUILD_TYPE is RelWithDebInfo, other options are: Debug, Release, and MinSizeRel." FORCE)