Avoid adding -pie on older cmake versions
authorPeter Wu <peter@lekensteyn.nl>
Wed, 21 Oct 2015 14:52:47 +0000 (16:52 +0200)
committerMichal Labedzki <michal.labedzki@tieto.com>
Thu, 22 Oct 2015 06:16:24 +0000 (06:16 +0000)
Fixes building on Ubuntu 12.04 x86_64 which has cmake 2.8.7.

Bug: 11617
Change-Id: I253e9fda698d4b963d50516e483d8243231f056b
Reviewed-on: https://code.wireshark.org/review/11193
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michal Labedzki <michal.labedzki@tieto.com>
Tested-by: Michal Labedzki <michal.labedzki@tieto.com>
CMakeLists.txt

index d9ba012e0faf3d5cd3e2ac58db013bbbc5f5684b..140f8eb7dad9264eb596139398cc48fc1657adea 100644 (file)
@@ -230,6 +230,10 @@ if( NOT CMAKE_SYSTEM_NAME STREQUAL "Linux" AND
 endif()
 
 # Always enable -fPIE (or -fPIC). -pie is added below for non-MSVC.
+# Needed when either:
+# - Qt5_POSITION_INDEPENDENT_CODE is set and CMake < 2.8.11
+# - PIE is wanted (-pie) and you want to add -fPIC/-fPIE automatically.
+# This option only has an effect on CMake >= 2.8.9
 set(CMAKE_POSITION_INDEPENDENT_CODE ON)
 
 if( CMAKE_C_COMPILER_ID MATCHES "MSVC")
@@ -592,11 +596,17 @@ endif()
 if(NOT CMAKE_C_COMPILER_ID MATCHES "MSVC")
        set(WIRESHARK_LD_FLAGS
                -Wl,--as-needed
-               -pie
                # -flto
                # -fwhopr
                # -fwhole-program
        )
+       # CMAKE_POSITION_INDEPENDENT_CODE is only supported starting with CMake
+       # 2.8.9. Do not add -pie automatically for older versions.
+       if(NOT CMAKE_VERSION VERSION_LESS "2.8.9")
+               set(WIRESHARK_LD_FLAGS ${WIRESHARK_LD_FLAGS}
+                       -pie
+               )
+       endif()
 endif()
 
 include(CheckCLinkerFlag)