View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0014983CMakeCMakepublic2014-06-20 07:192016-06-10 14:31
ReporterLudwig Nussel 
Assigned ToKitware Robot 
PrioritynormalSeverityminorReproducibilityhave not tried
StatusclosedResolutionmoved 
PlatformLinuxOSopenSUSEOS VersionFactory
Product VersionCMake 3.0 
Target VersionFixed in Version 
Summary0014983: POSITION_INDEPENDENT_CODE does not add -pie
DescriptionI tried to make wodim a position independent executable to comply with distro policies. I did that by adding this to CMakeLists.txt:
SET_TARGET_PROPERTIES(wodim PROPERTIES POSITION_INDEPENDENT_CODE TRUE)

That however does not set -pie for the linker flags so no actual pie binary is
created. An extra "LINK_FLAGS -pie" is necessary. I guess that's not the
intention of the abstraction.
Steps To ReproduceSET_TARGET_PROPERTIES(wodim PROPERTIES POSITION_INDEPENDENT_CODE TRUE)

should result in

$ readelf -h wodim|grep Type:
  Type: DYN (Shared object file)
TagsNo tags attached.
Attached Files

 Relationships

  Notes
(0036237)
Stephen Kelly (developer)
2014-06-24 04:55

http://lfs.osuosl.org/hlfs/view/unstable/glibc/chapter02/pie.html [^]
(0036239)
Stephen Kelly (developer)
2014-06-24 09:39

This feature was added for the needs of Qt-based executables, as qglobal.h gained a snippet similar to

 #if !defined(__PIC__)
 # error Must compile with -fPIC or -fPIE
 #endif

I followed the lead of qmake, which did not add -pie. I am trying to find out why:

 https://codereview.qt-project.org/88178 [^]
(0036242)
Stephen Kelly (developer)
2014-06-24 11:32

I don't think I know enough about the issues surrounding this. Changing the behavior of POSITION_INDEPENDENT_CODE affects all users of Qt 4 and 5 imported targets.

The 'safest' way forward is a POSITION_INDEPENDENT_EXECUTABLE property which implies POSITION_INDEPENDENT_CODE.
(0042569)
Kitware Robot (administrator)
2016-06-10 14:29

Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.

 Issue History
Date Modified Username Field Change
2014-06-20 07:19 Ludwig Nussel New Issue
2014-06-23 10:40 Brad King Assigned To => Stephen Kelly
2014-06-23 10:40 Brad King Status new => assigned
2014-06-24 04:55 Stephen Kelly Note Added: 0036237
2014-06-24 09:39 Stephen Kelly Note Added: 0036239
2014-06-24 11:32 Stephen Kelly Note Added: 0036242
2014-06-24 11:32 Stephen Kelly Assigned To Stephen Kelly =>
2014-06-24 11:32 Stephen Kelly Status assigned => backlog
2016-06-10 14:29 Kitware Robot Note Added: 0042569
2016-06-10 14:29 Kitware Robot Status backlog => resolved
2016-06-10 14:29 Kitware Robot Resolution open => moved
2016-06-10 14:29 Kitware Robot Assigned To => Kitware Robot
2016-06-10 14:31 Kitware Robot Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team