From: Kefu Chai Date: Wed, 29 Jun 2016 07:49:26 +0000 (+0800) Subject: cmake: use CMAKE_POSITION_INDEPENDENT_CODE property instead of -fPIC X-Git-Tag: ses5-milestone5~570^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=6b12a395eb6ba293d13d62dcf690272ab5605e8e;p=ceph.git cmake: use CMAKE_POSITION_INDEPENDENT_CODE property instead of -fPIC 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 --- diff --git a/CMakeLists.txt b/CMakeLists.txt index a3a76666b49..e66e7bce082 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a5519fe4b64..0b3880a2a97 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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)