[libcxxabi] r305174 - build: use POSITION_INDEPENDENT_CODE CMake property

Saleem Abdulrasool via cfe-commits cfe-commits at lists.llvm.org
Sun Jun 11 16:59:24 PDT 2017


Author: compnerd
Date: Sun Jun 11 18:59:24 2017
New Revision: 305174

URL: http://llvm.org/viewvc/llvm-project?rev=305174&view=rev
Log:
build: use POSITION_INDEPENDENT_CODE CMake property

Use the POSITION_INDEPENDENT_CODE target property to indicate that we
should be building with -fPIC or the equivalent flag based on the
toolchain that we are using.  This makes the check more portable and
simplifies the flags management.  Because we don't want this setting to
propagate in the case of an in-tree build, set the property on the
targets we construct explicitly rather than setting
CMAKE_POSITION_INDEPENDENT_CODE to ON globally.

Modified:
    libcxxabi/trunk/cmake/config-ix.cmake
    libcxxabi/trunk/src/CMakeLists.txt

Modified: libcxxabi/trunk/cmake/config-ix.cmake
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/cmake/config-ix.cmake?rev=305174&r1=305173&r2=305174&view=diff
==============================================================================
--- libcxxabi/trunk/cmake/config-ix.cmake (original)
+++ libcxxabi/trunk/cmake/config-ix.cmake Sun Jun 11 18:59:24 2017
@@ -50,7 +50,6 @@ endif ()
 
 # Check compiler flags
 check_c_compiler_flag(-funwind-tables         LIBCXXABI_HAS_FUNWIND_TABLES)
-check_cxx_compiler_flag(-fPIC                 LIBCXXABI_HAS_FPIC_FLAG)
 check_cxx_compiler_flag(-fno-exceptions       LIBCXXABI_HAS_NO_EXCEPTIONS_FLAG)
 check_cxx_compiler_flag(-fno-rtti             LIBCXXABI_HAS_NO_RTTI_FLAG)
 check_cxx_compiler_flag(-fstrict-aliasing     LIBCXXABI_HAS_FSTRICT_ALIASING_FLAG)

Modified: libcxxabi/trunk/src/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/CMakeLists.txt?rev=305174&r1=305173&r2=305174&view=diff
==============================================================================
--- libcxxabi/trunk/src/CMakeLists.txt (original)
+++ libcxxabi/trunk/src/CMakeLists.txt Sun Jun 11 18:59:24 2017
@@ -77,7 +77,6 @@ if (MINGW)
 endif()
 
 # Setup flags.
-add_compile_flags_if_supported(-fPIC)
 add_link_flags_if_supported(-nodefaultlibs)
 
 set(LIBCXXABI_SHARED_LINK_FLAGS)
@@ -110,11 +109,12 @@ endif()
 
 # Add a object library that contains the compiled source files.
 add_library(cxxabi_objects OBJECT ${LIBCXXABI_SOURCES} ${LIBCXXABI_HEADERS})
-
 set_target_properties(cxxabi_objects
-  PROPERTIES
-    COMPILE_FLAGS "${LIBCXXABI_COMPILE_FLAGS}"
-  )
+                      PROPERTIES
+                        COMPILE_FLAGS
+                          "${LIBCXXABI_COMPILE_FLAGS}"
+                        POSITION_INDEPENDENT_CODE
+                          ON)
 
 set(LIBCXXABI_TARGETS)
 
@@ -123,12 +123,17 @@ if (LIBCXXABI_ENABLE_SHARED)
   add_library(cxxabi_shared SHARED $<TARGET_OBJECTS:cxxabi_objects>)
   target_link_libraries(cxxabi_shared ${LIBCXXABI_LIBRARIES})
   set_target_properties(cxxabi_shared
-    PROPERTIES
-      LINK_FLAGS    "${LIBCXXABI_LINK_FLAGS} ${LIBCXXABI_SHARED_LINK_FLAGS}"
-      OUTPUT_NAME   "c++abi"
-      VERSION       "1.0"
-      SOVERSION     "1"
-    )
+                        PROPERTIES
+                          LINK_FLAGS
+                            "${LIBCXXABI_LINK_FLAGS} ${LIBCXXABI_SHARED_LINK_FLAGS}"
+                          OUTPUT_NAME
+                            "c++abi"
+                          POSITION_INDEPENDENT_CODE
+                            ON
+                          SOVERSION
+                            "1"
+                          VERSION
+                            "1.0")
   list(APPEND LIBCXXABI_TARGETS "cxxabi_shared")
 endif()
 
@@ -137,10 +142,13 @@ if (LIBCXXABI_ENABLE_STATIC)
   add_library(cxxabi_static STATIC $<TARGET_OBJECTS:cxxabi_objects>)
   target_link_libraries(cxxabi_static ${LIBCXXABI_LIBRARIES})
   set_target_properties(cxxabi_static
-    PROPERTIES
-      LINK_FLAGS    "${LIBCXXABI_LINK_FLAGS}"
-      OUTPUT_NAME   "c++abi"
-  )
+                        PROPERTIES
+                          LINK_FLAGS
+                            "${LIBCXXABI_LINK_FLAGS}"
+                          OUTPUT_NAME
+                            "c++abi"
+                          POSITION_INDEPENDENT_CODE
+                            ON)
   list(APPEND LIBCXXABI_TARGETS "cxxabi_static")
 endif()
 




More information about the cfe-commits mailing list