Merge topic 'pie-link-options'

c4b4d8b3a6 POSITION_INDEPENDENT_CODE: Manage link flags for executables
724a0346f7 POSITION_INDEPENDENT_CODE: Fix erroneous '-fPIE' flag for Sun Studio
023188ffb4 INTERFACE_POSITION_INDEPENDENT_CODE: add generator expressions support

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2465
This commit is contained in:
Craig Scott
2018-11-12 20:42:42 +00:00
committed by Kitware Robot
54 changed files with 768 additions and 30 deletions

View File

@@ -57,6 +57,7 @@ Policies Introduced by CMake 3.14
.. toctree::
:maxdepth: 1
CMP0083: Add PIE options when linking executable. </policy/CMP0083>
CMP0082: Install rules from add_subdirectory() are interleaved with those in caller. </policy/CMP0082>
Policies Introduced by CMake 3.13

24
Help/policy/CMP0083.rst Normal file
View File

@@ -0,0 +1,24 @@
CMP0083
-------
To control generation of Position Independent Executable (``PIE``) or not, some
flags are required at link time.
CMake 3.13 and lower did not add these link flags when
:prop_tgt:`POSITION_INDEPENDENT_CODE` is set.
The ``OLD`` behavior for this policy is to not manage ``PIE`` link flags. The
``NEW`` behavior is to add link flags if :prop_tgt:`POSITION_INDEPENDENT_CODE`
is set:
* Set to ``TRUE``: flags to produce a position independent executable are
passed to the linker step. For example ``-pie`` for ``GCC``.
* Set to ``FALSE``: flags not to produce a position independent executable are
passed to the linker step. For example ``-no-pie`` for ``GCC``.
* Not set: no flags are passed to the linker step.
This policy was introduced in CMake version 3.14. CMake version
|release| warns when the policy is not set and uses ``OLD`` behavior. Use
the :command:`cmake_policy` command to set it to ``OLD`` or ``NEW`` explicitly.
.. include:: DEPRECATED.txt

View File

@@ -14,3 +14,9 @@ undefined, then consumers will determine their
:prop_tgt:`POSITION_INDEPENDENT_CODE` property by other means. Consumers
must ensure that the targets that they link to have a consistent
requirement for their ``INTERFACE_POSITION_INDEPENDENT_CODE`` property.
Contents of ``INTERFACE_POSITION_INDEPENDENT_CODE`` may use
"generator expressions" with the syntax ``$<...>``. See the
:manual:`cmake-generator-expressions(7)` manual for available expressions.
See the :manual:`cmake-buildsystem(7)` manual for more on defining buildsystem
properties.

View File

@@ -0,0 +1,5 @@
INTERFACE_POSITION_INDEPENDENT_CODE
-----------------------------------
* :prop_tgt:`INTERFACE_POSITION_INDEPENDENT_CODE` target property gains the
support of :manual:`generator expressions <cmake-generator-expressions(7)>`.

View File

@@ -0,0 +1,6 @@
link-option-PIE
---------------
* Required link options to manage Position Independent Executable are now
added when :prop_tgt:`POSITION_INDEPENDENT_CODE` is set. These flags are
controlled by policy :policy:`CMP0083`.