summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Help/command/if.rst9
-rw-r--r--Help/envvar/ASM_DIALECT.rst2
-rw-r--r--Help/envvar/ASM_DIALECTFLAGS.rst2
-rw-r--r--Help/envvar/CC.rst2
-rw-r--r--Help/envvar/CFLAGS.rst2
-rw-r--r--Help/envvar/CMAKE_BUILD_PARALLEL_LEVEL.rst2
-rw-r--r--Help/envvar/CMAKE_CONFIG_TYPE.rst2
-rw-r--r--Help/envvar/CMAKE_MSVCIDE_RUN_PATH.rst2
-rw-r--r--Help/envvar/CMAKE_OSX_ARCHITECTURES.rst2
-rw-r--r--Help/envvar/CSFLAGS.rst2
-rw-r--r--Help/envvar/CTEST_INTERACTIVE_DEBUG_MODE.rst2
-rw-r--r--Help/envvar/CTEST_OUTPUT_ON_FAILURE.rst2
-rw-r--r--Help/envvar/CTEST_PARALLEL_LEVEL.rst2
-rw-r--r--Help/envvar/CTEST_PROGRESS_OUTPUT.rst2
-rw-r--r--Help/envvar/CTEST_USE_LAUNCHERS_DEFAULT.rst2
-rw-r--r--Help/envvar/CUDACXX.rst2
-rw-r--r--Help/envvar/CUDAFLAGS.rst2
-rw-r--r--Help/envvar/CUDAHOSTCXX.rst2
-rw-r--r--Help/envvar/CXX.rst2
-rw-r--r--Help/envvar/CXXFLAGS.rst2
-rw-r--r--Help/envvar/DASHBOARD_TEST_FROM_CTEST.rst2
-rw-r--r--Help/envvar/DESTDIR.rst2
-rw-r--r--Help/envvar/ENV_VAR.txt3
-rw-r--r--Help/envvar/FC.rst2
-rw-r--r--Help/envvar/FFLAGS.rst2
-rw-r--r--Help/envvar/LDFLAGS.rst2
-rw-r--r--Help/envvar/MACOSX_DEPLOYMENT_TARGET.rst2
-rw-r--r--Help/envvar/PackageName_ROOT.rst2
-rw-r--r--Help/envvar/RC.rst2
-rw-r--r--Help/envvar/RCFLAGS.rst2
-rw-r--r--Help/manual/cmake-modules.7.rst2
-rw-r--r--Help/manual/cmake-policies.7.rst1
-rw-r--r--Help/policy/CMP0083.rst24
-rw-r--r--Help/prop_tgt/INTERFACE_POSITION_INDEPENDENT_CODE.rst6
-rw-r--r--Help/release/dev/INTERFACE_POSITION_INDEPENDENT_CODE.rst5
-rw-r--r--Help/release/dev/if-supports-cache-defined.rst5
-rw-r--r--Help/release/dev/link-option-PIE.rst6
-rw-r--r--Modules/BundleUtilities.cmake32
-rw-r--r--Modules/CMakeAddFortranSubdirectory.cmake12
-rw-r--r--Modules/CMakeCXXInformation.cmake7
-rw-r--r--Modules/CMakeFortranInformation.cmake6
-rw-r--r--Modules/CMakePrintHelpers.cmake21
-rw-r--r--Modules/CPack.cmake10
-rw-r--r--Modules/CheckPrototypeDefinition.cmake4
-rw-r--r--Modules/Compiler/AppleClang-C.cmake3
-rw-r--r--Modules/Compiler/AppleClang-CXX.cmake3
-rw-r--r--Modules/Compiler/Clang.cmake20
-rw-r--r--Modules/Compiler/GNU.cmake16
-rw-r--r--Modules/Compiler/SunPro-C.cmake3
-rw-r--r--Modules/Compiler/SunPro-CXX.cmake3
-rw-r--r--Modules/Compiler/SunPro-Fortran.cmake3
-rw-r--r--Modules/DeployQt4.cmake12
-rw-r--r--Modules/Documentation.cmake4
-rw-r--r--Modules/FindBoost.cmake6
-rw-r--r--Modules/FindPackageMessage.cmake18
-rw-r--r--Modules/Internal/CMakeCheckCompilerFlag.cmake146
-rw-r--r--Modules/Platform/Android/abi-common.cmake4
-rw-r--r--Modules/Platform/CYGWIN-GNU.cmake2
-rw-r--r--Modules/Platform/FreeBSD.cmake1
-rw-r--r--Modules/Platform/Fuchsia.cmake2
-rw-r--r--Modules/Platform/Linux-Intel.cmake4
-rw-r--r--Modules/Platform/Linux-PGI.cmake2
-rw-r--r--Modules/Platform/NetBSD.cmake1
-rw-r--r--Modules/Platform/SINIX.cmake2
-rw-r--r--Modules/Platform/UNIX_SV.cmake2
-rw-r--r--Modules/Platform/UnixWare.cmake2
-rw-r--r--Modules/Platform/Windows-GNU.cmake2
-rw-r--r--Modules/WriteCompilerDetectionHeader.cmake9
-rw-r--r--Source/CMakeVersion.cmake2
-rw-r--r--Source/CTest/cmCTestTestHandler.cxx39
-rw-r--r--Source/CTest/cmCTestTestHandler.h2
-rw-r--r--Source/cmCTest.cxx43
-rw-r--r--Source/cmCTest.h24
-rw-r--r--Source/cmConditionEvaluator.cxx6
-rw-r--r--Source/cmGeneratorExpressionDAGChecker.cxx12
-rw-r--r--Source/cmGeneratorExpressionDAGChecker.h1
-rw-r--r--Source/cmGeneratorExpressionNode.cxx3
-rw-r--r--Source/cmGeneratorTarget.cxx171
-rw-r--r--Source/cmGeneratorTarget.h5
-rw-r--r--Source/cmGlobalXCodeGenerator.cxx23
-rw-r--r--Source/cmGlobalXCodeGenerator.h3
-rw-r--r--Source/cmLocalGenerator.cxx32
-rw-r--r--Source/cmLocalGenerator.h4
-rw-r--r--Source/cmMakefileTargetGenerator.cxx3
-rw-r--r--Source/cmPolicies.h7
-rw-r--r--Source/cmVS141CLFlagTable.h2
-rw-r--r--Tests/RunCMake/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/PositionIndependentCode/CMP0083-cmp0083_new-check.cmake22
-rw-r--r--Tests/RunCMake/PositionIndependentCode/CMP0083-cmp0083_old-check.cmake20
-rw-r--r--Tests/RunCMake/PositionIndependentCode/CMP0083.cmake45
-rw-r--r--Tests/RunCMake/PositionIndependentCode/CheckPIESupported.cmake12
-rw-r--r--Tests/RunCMake/PositionIndependentCode/Genex1-result.txt1
-rw-r--r--Tests/RunCMake/PositionIndependentCode/Genex1-stderr.txt3
-rw-r--r--Tests/RunCMake/PositionIndependentCode/Genex1.cmake9
-rw-r--r--Tests/RunCMake/PositionIndependentCode/Genex2-result.txt1
-rw-r--r--Tests/RunCMake/PositionIndependentCode/Genex2-stderr.txt3
-rw-r--r--Tests/RunCMake/PositionIndependentCode/Genex2.cmake9
-rw-r--r--Tests/RunCMake/PositionIndependentCode/PIE-pie_off-check.cmake7
-rw-r--r--Tests/RunCMake/PositionIndependentCode/PIE-pie_on-check.cmake7
-rw-r--r--Tests/RunCMake/PositionIndependentCode/PIE.cmake19
-rw-r--r--Tests/RunCMake/PositionIndependentCode/PIE_validator.cmake32
-rw-r--r--Tests/RunCMake/PositionIndependentCode/RunCMakeTest.cmake64
-rw-r--r--Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt1
-rw-r--r--Tests/Unset/CMakeLists.txt9
-rw-r--r--Utilities/Scripts/BoostScanDeps.cmake4
105 files changed, 1015 insertions, 117 deletions
diff --git a/Help/command/if.rst b/Help/command/if.rst
index 1cd9965..a682c83 100644
--- a/Help/command/if.rst
+++ b/Help/command/if.rst
@@ -187,11 +187,10 @@ Possible conditions are:
``if(<variable|string> IN_LIST <variable>)``
True if the given element is contained in the named list variable.
-``if(DEFINED <name>|ENV{<name>})``
- True if a variable or environment variable
- with given ``<name>`` is defined.
- The value of the variable does not matter.
- Note that macro arguments are not variables.
+``if(DEFINED <name>|CACHE{<name>}|ENV{<name>})``
+ True if a variable, cache variable or environment variable
+ with given ``<name>`` is defined. The value of the variable
+ does not matter. Note that macro arguments are not variables.
``if((condition) AND (condition OR (condition)))``
The conditions inside the parenthesis are evaluated first and then
diff --git a/Help/envvar/ASM_DIALECT.rst b/Help/envvar/ASM_DIALECT.rst
index ec48f71..cabb959 100644
--- a/Help/envvar/ASM_DIALECT.rst
+++ b/Help/envvar/ASM_DIALECT.rst
@@ -1,6 +1,8 @@
ASM<DIALECT>
------------
+.. include:: ENV_VAR.txt
+
Preferred executable for compiling a specific dialect of assembly language
files. ``ASM<DIALECT>`` can be ``ASM``, ``ASM_NASM``, ``ASM_MASM`` or
``ASM-ATT``. Will only be used by CMake on the first configuration to determine
diff --git a/Help/envvar/ASM_DIALECTFLAGS.rst b/Help/envvar/ASM_DIALECTFLAGS.rst
index 4ed02fe..90cbbdb 100644
--- a/Help/envvar/ASM_DIALECTFLAGS.rst
+++ b/Help/envvar/ASM_DIALECTFLAGS.rst
@@ -1,6 +1,8 @@
ASM<DIALECT>FLAGS
-----------------
+.. include:: ENV_VAR.txt
+
Default compilation flags to be used when compiling a specific dialect of an
assembly language. ``ASM<DIALECT>FLAGS`` can be ``ASMFLAGS``, ``ASM_NASMFLAGS``,
``ASM_MASMFLAGS`` or ``ASM-ATTFLAGS``. Will only be used by CMake on the
diff --git a/Help/envvar/CC.rst b/Help/envvar/CC.rst
index 7e68110..ef12059 100644
--- a/Help/envvar/CC.rst
+++ b/Help/envvar/CC.rst
@@ -1,6 +1,8 @@
CC
--
+.. include:: ENV_VAR.txt
+
Preferred executable for compiling ``C`` language files. Will only be used by
CMake on the first configuration to determine ``C`` compiler, after which the
value for ``CC`` is stored in the cache as
diff --git a/Help/envvar/CFLAGS.rst b/Help/envvar/CFLAGS.rst
index 60b2cd3..fda9ccc 100644
--- a/Help/envvar/CFLAGS.rst
+++ b/Help/envvar/CFLAGS.rst
@@ -1,6 +1,8 @@
CFLAGS
------
+.. include:: ENV_VAR.txt
+
Default compilation flags to be used when compiling ``C`` files. Will only be
used by CMake on the first configuration to determine ``CC`` default compilation
flags, after which the value for ``CFLAGS`` is stored in the cache
diff --git a/Help/envvar/CMAKE_BUILD_PARALLEL_LEVEL.rst b/Help/envvar/CMAKE_BUILD_PARALLEL_LEVEL.rst
index 198dc51..199ca3e 100644
--- a/Help/envvar/CMAKE_BUILD_PARALLEL_LEVEL.rst
+++ b/Help/envvar/CMAKE_BUILD_PARALLEL_LEVEL.rst
@@ -1,6 +1,8 @@
CMAKE_BUILD_PARALLEL_LEVEL
--------------------------
+.. include:: ENV_VAR.txt
+
Specifies the maximum number of concurrent processes to use when building
using the ``cmake --build`` command line
:ref:`Build Tool Mode <Build Tool Mode>`.
diff --git a/Help/envvar/CMAKE_CONFIG_TYPE.rst b/Help/envvar/CMAKE_CONFIG_TYPE.rst
index 1306b47..168593d 100644
--- a/Help/envvar/CMAKE_CONFIG_TYPE.rst
+++ b/Help/envvar/CMAKE_CONFIG_TYPE.rst
@@ -1,5 +1,7 @@
CMAKE_CONFIG_TYPE
-----------------
+.. include:: ENV_VAR.txt
+
The default build configuration for :ref:`Build Tool Mode` and
``ctest`` build handler when there is no explicit configuration given.
diff --git a/Help/envvar/CMAKE_MSVCIDE_RUN_PATH.rst b/Help/envvar/CMAKE_MSVCIDE_RUN_PATH.rst
index 54d5f9e..77ead4d 100644
--- a/Help/envvar/CMAKE_MSVCIDE_RUN_PATH.rst
+++ b/Help/envvar/CMAKE_MSVCIDE_RUN_PATH.rst
@@ -1,6 +1,8 @@
CMAKE_MSVCIDE_RUN_PATH
----------------------
+.. include:: ENV_VAR.txt
+
Extra PATH locations for custom commands when using
:generator:`Visual Studio 9 2008` (or above) generators.
diff --git a/Help/envvar/CMAKE_OSX_ARCHITECTURES.rst b/Help/envvar/CMAKE_OSX_ARCHITECTURES.rst
index 5fd6e52..ef7d547 100644
--- a/Help/envvar/CMAKE_OSX_ARCHITECTURES.rst
+++ b/Help/envvar/CMAKE_OSX_ARCHITECTURES.rst
@@ -1,6 +1,8 @@
CMAKE_OSX_ARCHITECTURES
-----------------------
+.. include:: ENV_VAR.txt
+
Target specific architectures for macOS.
The ``CMAKE_OSX_ARCHITECTURES`` environment variable sets the default value for
diff --git a/Help/envvar/CSFLAGS.rst b/Help/envvar/CSFLAGS.rst
index 251ddc5..404bb59 100644
--- a/Help/envvar/CSFLAGS.rst
+++ b/Help/envvar/CSFLAGS.rst
@@ -1,6 +1,8 @@
CSFLAGS
-------
+.. include:: ENV_VAR.txt
+
Preferred executable for compiling ``CSharp`` language files. Will only be
used by CMake on the first configuration to determine ``CSharp`` default
compilation flags, after which the value for ``CSFLAGS`` is stored in the cache
diff --git a/Help/envvar/CTEST_INTERACTIVE_DEBUG_MODE.rst b/Help/envvar/CTEST_INTERACTIVE_DEBUG_MODE.rst
index 25ed14f..b769d51 100644
--- a/Help/envvar/CTEST_INTERACTIVE_DEBUG_MODE.rst
+++ b/Help/envvar/CTEST_INTERACTIVE_DEBUG_MODE.rst
@@ -1,5 +1,7 @@
CTEST_INTERACTIVE_DEBUG_MODE
----------------------------
+.. include:: ENV_VAR.txt
+
Environment variable that will exist and be set to ``1`` when a test executed
by CTest is run in interactive mode.
diff --git a/Help/envvar/CTEST_OUTPUT_ON_FAILURE.rst b/Help/envvar/CTEST_OUTPUT_ON_FAILURE.rst
index 1fcf42b..bf860cb 100644
--- a/Help/envvar/CTEST_OUTPUT_ON_FAILURE.rst
+++ b/Help/envvar/CTEST_OUTPUT_ON_FAILURE.rst
@@ -1,6 +1,8 @@
CTEST_OUTPUT_ON_FAILURE
-----------------------
+.. include:: ENV_VAR.txt
+
Boolean environment variable that controls if the output should be logged for
failed tests. Set the value to 1, True, or ON to enable output on failure.
See :manual:`ctest(1)` for more information on controlling output of failed
diff --git a/Help/envvar/CTEST_PARALLEL_LEVEL.rst b/Help/envvar/CTEST_PARALLEL_LEVEL.rst
index c767a01..fd4936e 100644
--- a/Help/envvar/CTEST_PARALLEL_LEVEL.rst
+++ b/Help/envvar/CTEST_PARALLEL_LEVEL.rst
@@ -1,5 +1,7 @@
CTEST_PARALLEL_LEVEL
--------------------
+.. include:: ENV_VAR.txt
+
Specify the number of tests for CTest to run in parallel. See :manual:`ctest(1)`
for more information on parallel test execution.
diff --git a/Help/envvar/CTEST_PROGRESS_OUTPUT.rst b/Help/envvar/CTEST_PROGRESS_OUTPUT.rst
index a8e15bc..de23e11 100644
--- a/Help/envvar/CTEST_PROGRESS_OUTPUT.rst
+++ b/Help/envvar/CTEST_PROGRESS_OUTPUT.rst
@@ -1,6 +1,8 @@
CTEST_PROGRESS_OUTPUT
---------------------
+.. include:: ENV_VAR.txt
+
Boolean environment variable that affects how :manual:`ctest <ctest(1)>`
command output reports overall progress. When set to 1, TRUE, ON or anything
else that evaluates to boolean true, progress is reported by repeatedly
diff --git a/Help/envvar/CTEST_USE_LAUNCHERS_DEFAULT.rst b/Help/envvar/CTEST_USE_LAUNCHERS_DEFAULT.rst
index 8d8eea5..79dbb79 100644
--- a/Help/envvar/CTEST_USE_LAUNCHERS_DEFAULT.rst
+++ b/Help/envvar/CTEST_USE_LAUNCHERS_DEFAULT.rst
@@ -1,4 +1,6 @@
CTEST_USE_LAUNCHERS_DEFAULT
---------------------------
+.. include:: ENV_VAR.txt
+
Initializes the :variable:`CTEST_USE_LAUNCHERS` variable if not already defined.
diff --git a/Help/envvar/CUDACXX.rst b/Help/envvar/CUDACXX.rst
index 8a5fd4b..10c0f9d 100644
--- a/Help/envvar/CUDACXX.rst
+++ b/Help/envvar/CUDACXX.rst
@@ -1,6 +1,8 @@
CUDACXX
-------
+.. include:: ENV_VAR.txt
+
Preferred executable for compiling ``CUDA`` language files. Will only be used by
CMake on the first configuration to determine ``CUDA`` compiler, after which the
value for ``CUDA`` is stored in the cache as
diff --git a/Help/envvar/CUDAFLAGS.rst b/Help/envvar/CUDAFLAGS.rst
index 3dff49f..4456d6b 100644
--- a/Help/envvar/CUDAFLAGS.rst
+++ b/Help/envvar/CUDAFLAGS.rst
@@ -1,6 +1,8 @@
CUDAFLAGS
---------
+.. include:: ENV_VAR.txt
+
Default compilation flags to be used when compiling ``CUDA`` files. Will only be
used by CMake on the first configuration to determine ``CUDA`` default
compilation flags, after which the value for ``CUDAFLAGS`` is stored in the
diff --git a/Help/envvar/CUDAHOSTCXX.rst b/Help/envvar/CUDAHOSTCXX.rst
index bb786ca..b9f65bd 100644
--- a/Help/envvar/CUDAHOSTCXX.rst
+++ b/Help/envvar/CUDAHOSTCXX.rst
@@ -1,6 +1,8 @@
CUDAHOSTCXX
-----------
+.. include:: ENV_VAR.txt
+
Preferred executable for compiling host code when compiling ``CUDA``
language files. Will only be used by CMake on the first configuration to
determine ``CUDA`` host compiler, after which the value for ``CUDAHOSTCXX`` is
diff --git a/Help/envvar/CXX.rst b/Help/envvar/CXX.rst
index 3b1e445..d655350 100644
--- a/Help/envvar/CXX.rst
+++ b/Help/envvar/CXX.rst
@@ -1,6 +1,8 @@
CXX
---
+.. include:: ENV_VAR.txt
+
Preferred executable for compiling ``CXX`` language files. Will only be used by
CMake on the first configuration to determine ``CXX`` compiler, after which the
value for ``CXX`` is stored in the cache as
diff --git a/Help/envvar/CXXFLAGS.rst b/Help/envvar/CXXFLAGS.rst
index 8b58abd..d7296dc 100644
--- a/Help/envvar/CXXFLAGS.rst
+++ b/Help/envvar/CXXFLAGS.rst
@@ -1,6 +1,8 @@
CXXFLAGS
--------
+.. include:: ENV_VAR.txt
+
Default compilation flags to be used when compiling ``CXX`` (C++) files. Will
only be used by CMake on the first configuration to determine ``CXX`` default
compilation flags, after which the value for ``CXXFLAGS`` is stored in the cache
diff --git a/Help/envvar/DASHBOARD_TEST_FROM_CTEST.rst b/Help/envvar/DASHBOARD_TEST_FROM_CTEST.rst
index fab1c0c..2b303a4 100644
--- a/Help/envvar/DASHBOARD_TEST_FROM_CTEST.rst
+++ b/Help/envvar/DASHBOARD_TEST_FROM_CTEST.rst
@@ -1,5 +1,7 @@
DASHBOARD_TEST_FROM_CTEST
-------------------------
+.. include:: ENV_VAR.txt
+
Environment variable that will exist when a test executed by CTest is run
in non-interactive mode. The value will be equal to :variable:`CMAKE_VERSION`.
diff --git a/Help/envvar/DESTDIR.rst b/Help/envvar/DESTDIR.rst
index 87f1115..d2144ae 100644
--- a/Help/envvar/DESTDIR.rst
+++ b/Help/envvar/DESTDIR.rst
@@ -1,6 +1,8 @@
DESTDIR
-------
+.. include:: ENV_VAR.txt
+
On UNIX one can use the ``DESTDIR`` mechanism in order to relocate the
whole installation. ``DESTDIR`` means DESTination DIRectory. It is
commonly used by makefile users in order to install software at
diff --git a/Help/envvar/ENV_VAR.txt b/Help/envvar/ENV_VAR.txt
new file mode 100644
index 0000000..e1e70cd
--- /dev/null
+++ b/Help/envvar/ENV_VAR.txt
@@ -0,0 +1,3 @@
+This is a CMake :ref:`Environment Variable <CMake Language
+Environment Variables>`. Its initial value is taken from
+the calling process environment.
diff --git a/Help/envvar/FC.rst b/Help/envvar/FC.rst
index 7d293fd..d6cabbc 100644
--- a/Help/envvar/FC.rst
+++ b/Help/envvar/FC.rst
@@ -1,6 +1,8 @@
FC
--
+.. include:: ENV_VAR.txt
+
Preferred executable for compiling ``Fortran`` language files. Will only be used
by CMake on the first configuration to determine ``Fortran`` compiler, after
which the value for ``Fortran`` is stored in the cache as
diff --git a/Help/envvar/FFLAGS.rst b/Help/envvar/FFLAGS.rst
index 19d6169..02d3c34 100644
--- a/Help/envvar/FFLAGS.rst
+++ b/Help/envvar/FFLAGS.rst
@@ -1,6 +1,8 @@
FFLAGS
------
+.. include:: ENV_VAR.txt
+
Default compilation flags to be used when compiling ``Fortran`` files. Will only
be used by CMake on the first configuration to determine ``Fortran`` default
compilation flags, after which the value for ``FFLAGS`` is stored in the cache
diff --git a/Help/envvar/LDFLAGS.rst b/Help/envvar/LDFLAGS.rst
index 52da99c..816d6ef 100644
--- a/Help/envvar/LDFLAGS.rst
+++ b/Help/envvar/LDFLAGS.rst
@@ -1,6 +1,8 @@
LDFLAGS
-------
+.. include:: ENV_VAR.txt
+
Will only be used by CMake on the first configuration to determine the default
linker flags, after which the value for ``LDFLAGS`` is stored in the cache
as :variable:`CMAKE_EXE_LINKER_FLAGS_INIT`,
diff --git a/Help/envvar/MACOSX_DEPLOYMENT_TARGET.rst b/Help/envvar/MACOSX_DEPLOYMENT_TARGET.rst
index 9dafa32..662bd03 100644
--- a/Help/envvar/MACOSX_DEPLOYMENT_TARGET.rst
+++ b/Help/envvar/MACOSX_DEPLOYMENT_TARGET.rst
@@ -1,6 +1,8 @@
MACOSX_DEPLOYMENT_TARGET
------------------------
+.. include:: ENV_VAR.txt
+
Specify the minimum version of macOS on which the target binaries are
to be deployed.
diff --git a/Help/envvar/PackageName_ROOT.rst b/Help/envvar/PackageName_ROOT.rst
index e01009b..ecec63b 100644
--- a/Help/envvar/PackageName_ROOT.rst
+++ b/Help/envvar/PackageName_ROOT.rst
@@ -1,6 +1,8 @@
<PackageName>_ROOT
------------------
+.. include:: ENV_VAR.txt
+
Calls to :command:`find_package(<PackageName>)` will search in prefixes
specified by the ``<PackageName>_ROOT`` environment variable, where
``<PackageName>`` is the name given to the ``find_package`` call
diff --git a/Help/envvar/RC.rst b/Help/envvar/RC.rst
index 6c2db19..557520e 100644
--- a/Help/envvar/RC.rst
+++ b/Help/envvar/RC.rst
@@ -1,6 +1,8 @@
RC
--
+.. include:: ENV_VAR.txt
+
Preferred executable for compiling ``resource`` files. Will only be used by CMake
on the first configuration to determine ``resource`` compiler, after which the
value for ``RC`` is stored in the cache as
diff --git a/Help/envvar/RCFLAGS.rst b/Help/envvar/RCFLAGS.rst
index 4f2f31c..45419fe 100644
--- a/Help/envvar/RCFLAGS.rst
+++ b/Help/envvar/RCFLAGS.rst
@@ -1,6 +1,8 @@
RCFLAGS
-------
+.. include:: ENV_VAR.txt
+
Default compilation flags to be used when compiling ``resource`` files. Will
only be used by CMake on the first configuration to determine ``resource``
default compilation flags, after which the value for ``RCFLAGS`` is stored in
diff --git a/Help/manual/cmake-modules.7.rst b/Help/manual/cmake-modules.7.rst
index 95744df..266c7a1 100644
--- a/Help/manual/cmake-modules.7.rst
+++ b/Help/manual/cmake-modules.7.rst
@@ -48,7 +48,6 @@ These modules are loaded using the :command:`include` command.
/module/CMakeFindPackageMode
/module/CMakeGraphVizOptions
/module/CMakePackageConfigHelpers
- /module/CMakeParseArguments
/module/CMakePrintHelpers
/module/CMakePrintSystemInformation
/module/CMakePushCheckState
@@ -270,6 +269,7 @@ Deprecated Utility Modules
/module/CMakeDetermineVSServicePack
/module/CMakeExpandImportedTargets
/module/CMakeForceCompiler
+ /module/CMakeParseArguments
/module/TestCXXAcceptsFlag
/module/Use_wxWindows
/module/WriteBasicConfigVersionFile
diff --git a/Help/manual/cmake-policies.7.rst b/Help/manual/cmake-policies.7.rst
index 0587429..98279ef 100644
--- a/Help/manual/cmake-policies.7.rst
+++ b/Help/manual/cmake-policies.7.rst
@@ -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
diff --git a/Help/policy/CMP0083.rst b/Help/policy/CMP0083.rst
new file mode 100644
index 0000000..7b467b0
--- /dev/null
+++ b/Help/policy/CMP0083.rst
@@ -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
diff --git a/Help/prop_tgt/INTERFACE_POSITION_INDEPENDENT_CODE.rst b/Help/prop_tgt/INTERFACE_POSITION_INDEPENDENT_CODE.rst
index ea700df..4336d71 100644
--- a/Help/prop_tgt/INTERFACE_POSITION_INDEPENDENT_CODE.rst
+++ b/Help/prop_tgt/INTERFACE_POSITION_INDEPENDENT_CODE.rst
@@ -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.
diff --git a/Help/release/dev/INTERFACE_POSITION_INDEPENDENT_CODE.rst b/Help/release/dev/INTERFACE_POSITION_INDEPENDENT_CODE.rst
new file mode 100644
index 0000000..7732ff6
--- /dev/null
+++ b/Help/release/dev/INTERFACE_POSITION_INDEPENDENT_CODE.rst
@@ -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)>`.
diff --git a/Help/release/dev/if-supports-cache-defined.rst b/Help/release/dev/if-supports-cache-defined.rst
new file mode 100644
index 0000000..1e700c0
--- /dev/null
+++ b/Help/release/dev/if-supports-cache-defined.rst
@@ -0,0 +1,5 @@
+if-supports-cache-defined
+-------------------------
+
+* The :command:`if` command gained support for checking if cache variables
+ are defined with the ``DEFINED CACHE{VAR}`` syntax.
diff --git a/Help/release/dev/link-option-PIE.rst b/Help/release/dev/link-option-PIE.rst
new file mode 100644
index 0000000..824ab2c
--- /dev/null
+++ b/Help/release/dev/link-option-PIE.rst
@@ -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`.
diff --git a/Modules/BundleUtilities.cmake b/Modules/BundleUtilities.cmake
index 4a3f476..10e5510 100644
--- a/Modules/BundleUtilities.cmake
+++ b/Modules/BundleUtilities.cmake
@@ -41,7 +41,7 @@ Instead, invoke them from an :command:`install(CODE)` or
.. code-block:: cmake
- FIXUP_BUNDLE(<app> <libs> <dirs>)
+ fixup_bundle(<app> <libs> <dirs>)
Fix up a bundle in-place and make it standalone, such that it can be
drag-n-drop copied to another machine and run on that machine as long
@@ -64,14 +64,14 @@ which are then ignored (e.g. IGNORE_ITEM "vcredist_x86.exe;vcredist_x64.exe")
.. code-block:: cmake
- COPY_AND_FIXUP_BUNDLE(<src> <dst> <libs> <dirs>)
+ copy_and_fixup_bundle(<src> <dst> <libs> <dirs>)
Makes a copy of the bundle <src> at location <dst> and then fixes up
the new copied bundle in-place at <dst>...
.. code-block:: cmake
- VERIFY_APP(<app>)
+ verify_app(<app>)
Verifies that an application <app> appears valid based on running
analysis tools on it. Calls "message(FATAL_ERROR" if the application
@@ -82,14 +82,14 @@ which are then ignored (e.g. IGNORE_ITEM "vcredist_x86.exe;vcredist_x64.exe")
.. code-block:: cmake
- GET_BUNDLE_MAIN_EXECUTABLE(<bundle> <result_var>)
+ get_bundle_main_executable(<bundle> <result_var>)
The result will be the full path name of the bundle's main executable
file or an "error:" prefixed string if it could not be determined.
.. code-block:: cmake
- GET_DOTAPP_DIR(<exe> <dotapp_dir_var>)
+ get_dotapp_dir(<exe> <dotapp_dir_var>)
Returns the nearest parent dir whose name ends with ".app" given the
full path to an executable. If there is no such parent dir, then
@@ -99,7 +99,7 @@ The returned directory may or may not exist.
.. code-block:: cmake
- GET_BUNDLE_AND_EXECUTABLE(<app> <bundle_var> <executable_var> <valid_var>)
+ get_bundle_and_executable(<app> <bundle_var> <executable_var> <valid_var>)
Takes either a ".app" directory name or the name of an executable
nested inside a ".app" directory and returns the path to the ".app"
@@ -108,14 +108,14 @@ directory in <bundle_var> and the path to its main executable in
.. code-block:: cmake
- GET_BUNDLE_ALL_EXECUTABLES(<bundle> <exes_var>)
+ get_bundle_all_executables(<bundle> <exes_var>)
Scans the given bundle recursively for all executable files and
accumulates them into a variable.
.. code-block:: cmake
- GET_ITEM_KEY(<item> <key_var>)
+ get_item_key(<item> <key_var>)
Given a file (item) name, generate a key that should be unique
considering the set of libraries that need copying or fixing up to
@@ -127,7 +127,7 @@ associate a set of variables with a given item based on its key.
.. code-block:: cmake
- CLEAR_BUNDLE_KEYS(<keys_var>)
+ clear_bundle_keys(<keys_var>)
Loop over the list of keys, clearing all the variables associated with
each key. After the loop, clear the list of keys itself.
@@ -137,7 +137,7 @@ list of keys.
.. code-block:: cmake
- SET_BUNDLE_KEY_VALUES(<keys_var> <context> <item> <exepath> <dirs>
+ set_bundle_key_values(<keys_var> <context> <item> <exepath> <dirs>
<copyflag> [<rpaths>])
Add a key to the list (if necessary) for the given item. If added,
@@ -145,7 +145,7 @@ also set all the variables associated with that key.
.. code-block:: cmake
- GET_BUNDLE_KEYS(<app> <libs> <dirs> <keys_var>)
+ get_bundle_keys(<app> <libs> <dirs> <keys_var>)
Loop over all the executable and library files within the bundle (and
given as extra <libs>) and accumulate a list of keys representing
@@ -158,7 +158,7 @@ which are then ignored (e.g. IGNORE_ITEM "vcredist_x86.exe;vcredist_x64.exe")
.. code-block:: cmake
- COPY_RESOLVED_ITEM_INTO_BUNDLE(<resolved_item> <resolved_embedded_item>)
+ copy_resolved_item_into_bundle(<resolved_item> <resolved_embedded_item>)
Copy a resolved item into the bundle if necessary. Copy is not
necessary if the resolved_item is "the same as" the
@@ -166,7 +166,7 @@ resolved_embedded_item.
.. code-block:: cmake
- COPY_RESOLVED_FRAMEWORK_INTO_BUNDLE(<resolved_item> <resolved_embedded_item>)
+ copy_resolved_framework_into_bundle(<resolved_item> <resolved_embedded_item>)
Copy a resolved framework into the bundle if necessary. Copy is not
necessary if the resolved_item is "the same as" the
@@ -180,7 +180,7 @@ dylib itself plus the framework Resources directory.
.. code-block:: cmake
- FIXUP_BUNDLE_ITEM(<resolved_embedded_item> <exepath> <dirs>)
+ fixup_bundle_item(<resolved_embedded_item> <exepath> <dirs>)
Get the direct/non-system prerequisites of the resolved embedded item.
For each prerequisite, change the way it is referenced to the value of
@@ -206,7 +206,7 @@ marked writable before install_name_tool tries to change them.
.. code-block:: cmake
- VERIFY_BUNDLE_PREREQUISITES(<bundle> <result_var> <info_var>)
+ verify_bundle_prerequisites(<bundle> <result_var> <info_var>)
Verifies that the sum of all prerequisites of all files inside the
bundle are contained within the bundle or are "system" libraries,
@@ -217,7 +217,7 @@ which are then ignored (e.g. IGNORE_ITEM "vcredist_x86.exe;vcredist_x64.exe")
.. code-block:: cmake
- VERIFY_BUNDLE_SYMLINKS(<bundle> <result_var> <info_var>)
+ verify_bundle_symlinks(<bundle> <result_var> <info_var>)
Verifies that any symlinks found in the bundle point to other files
that are already also in the bundle... Anything that points to an
diff --git a/Modules/CMakeAddFortranSubdirectory.cmake b/Modules/CMakeAddFortranSubdirectory.cmake
index 2bb3128..50b2807 100644
--- a/Modules/CMakeAddFortranSubdirectory.cmake
+++ b/Modules/CMakeAddFortranSubdirectory.cmake
@@ -5,18 +5,18 @@
CMakeAddFortranSubdirectory
---------------------------
-Use MinGW gfortran from VS if a fortran compiler is not found.
+Add a fortran-only subdirectory, find a fortran compiler, and build.
-The 'add_fortran_subdirectory' function adds a subdirectory to a
-project that contains a fortran only sub-project. The module will
+The ``cmake_add_fortran_subdirectory`` function adds a subdirectory
+to a project that contains a fortran-only subproject. The module will
check the current compiler and see if it can support fortran. If no
fortran compiler is found and the compiler is MSVC, then this module
will find the MinGW gfortran. It will then use an external project to
build with the MinGW tools. It will also create imported targets for
the libraries created. This will only work if the fortran code is
-built into a dll, so BUILD_SHARED_LIBS is turned on in the project.
-In addition the CMAKE_GNUtoMS option is set to on, so that the MS .lib
-files are created. Usage is as follows:
+built into a dll, so :variable:`BUILD_SHARED_LIBS` is turned on in
+the project. In addition the :variable:`CMAKE_GNUtoMS` option is set
+to on, so that Microsoft .lib files are created. Usage is as follows:
::
diff --git a/Modules/CMakeCXXInformation.cmake b/Modules/CMakeCXXInformation.cmake
index 2975874..a896b99 100644
--- a/Modules/CMakeCXXInformation.cmake
+++ b/Modules/CMakeCXXInformation.cmake
@@ -105,6 +105,12 @@ endif()
if(NOT CMAKE_CXX_COMPILE_OPTIONS_PIE)
set(CMAKE_CXX_COMPILE_OPTIONS_PIE ${CMAKE_C_COMPILE_OPTIONS_PIE})
endif()
+if(NOT CMAKE_CXX_LINK_OPTIONS_PIE)
+ set(CMAKE_CXX_LINK_OPTIONS_PIE ${CMAKE_C_LINK_OPTIONS_PIE})
+endif()
+if(NOT CMAKE_CXX_LINK_OPTIONS_NO_PIE)
+ set(CMAKE_CXX_LINK_OPTIONS_NO_PIE ${CMAKE_C_LINK_OPTIONS_NO_PIE})
+endif()
if(NOT CMAKE_CXX_COMPILE_OPTIONS_DLL)
set(CMAKE_CXX_COMPILE_OPTIONS_DLL ${CMAKE_C_COMPILE_OPTIONS_DLL})
@@ -269,4 +275,3 @@ CMAKE_VERBOSE_MAKEFILE
)
set(CMAKE_CXX_INFORMATION_LOADED 1)
-
diff --git a/Modules/CMakeFortranInformation.cmake b/Modules/CMakeFortranInformation.cmake
index cceac83..ffa6a24 100644
--- a/Modules/CMakeFortranInformation.cmake
+++ b/Modules/CMakeFortranInformation.cmake
@@ -74,6 +74,12 @@ endif()
if(NOT CMAKE_Fortran_COMPILE_OPTIONS_PIE)
set(CMAKE_Fortran_COMPILE_OPTIONS_PIE ${CMAKE_C_COMPILE_OPTIONS_PIE})
endif()
+if(NOT CMAKE_Fortran_LINK_OPTIONS_PIE)
+ set(CMAKE_Fortran_LINK_OPTIONS_PIE ${CMAKE_C_LINK_OPTIONS_PIE})
+endif()
+if(NOT CMAKE_Fortran_LINK_OPTIONS_NO_PIE)
+ set(CMAKE_Fortran_LINK_OPTIONS_NO_PIE ${CMAKE_C_LINK_OPTIONS_NO_PIE})
+endif()
if(NOT CMAKE_Fortran_COMPILE_OPTIONS_DLL)
set(CMAKE_Fortran_COMPILE_OPTIONS_DLL ${CMAKE_C_COMPILE_OPTIONS_DLL})
diff --git a/Modules/CMakePrintHelpers.cmake b/Modules/CMakePrintHelpers.cmake
index d5bbb4f..1af0bb7 100644
--- a/Modules/CMakePrintHelpers.cmake
+++ b/Modules/CMakePrintHelpers.cmake
@@ -5,32 +5,33 @@
CMakePrintHelpers
-----------------
-Convenience macros for printing properties and variables, useful e.g. for debugging.
+Convenience functions for printing properties and variables, useful
+e.g. for debugging.
::
- CMAKE_PRINT_PROPERTIES([TARGETS target1 .. targetN]
+ cmake_print_properties([TARGETS target1 .. targetN]
[SOURCES source1 .. sourceN]
[DIRECTORIES dir1 .. dirN]
[TESTS test1 .. testN]
[CACHE_ENTRIES entry1 .. entryN]
PROPERTIES prop1 .. propN )
-This macro prints the values of the properties of the given targets,
+This function prints the values of the properties of the given targets,
source files, directories, tests or cache entries. Exactly one of the
scope keywords must be used. Example::
- cmake_print_properties(TARGETS foo bar PROPERTIES
- LOCATION INTERFACE_INCLUDE_DIRS)
+ cmake_print_properties(TARGETS foo bar PROPERTIES
+ LOCATION INTERFACE_INCLUDE_DIRS)
This will print the LOCATION and INTERFACE_INCLUDE_DIRS properties for
both targets foo and bar.
+::
+ cmake_print_variables(var1 var2 .. varN)
-CMAKE_PRINT_VARIABLES(var1 var2 .. varN)
-
-This macro will print the name of each variable followed by its value.
+This function will print the name of each variable followed by its value.
Example::
cmake_print_variables(CMAKE_C_COMPILER CMAKE_MAJOR_VERSION DOES_NOT_EXIST)
@@ -40,7 +41,7 @@ Gives::
-- CMAKE_C_COMPILER="/usr/bin/gcc" ; CMAKE_MAJOR_VERSION="2" ; DOES_NOT_EXIST=""
#]=======================================================================]
-function(CMAKE_PRINT_VARIABLES)
+function(cmake_print_variables)
set(msg "")
foreach(var ${ARGN})
if(msg)
@@ -52,7 +53,7 @@ function(CMAKE_PRINT_VARIABLES)
endfunction()
-function(CMAKE_PRINT_PROPERTIES )
+function(cmake_print_properties)
set(options )
set(oneValueArgs )
set(multiValueArgs TARGETS SOURCES TESTS DIRECTORIES CACHE_ENTRIES PROPERTIES )
diff --git a/Modules/CPack.cmake b/Modules/CPack.cmake
index f3e3423..ebce851 100644
--- a/Modules/CPack.cmake
+++ b/Modules/CPack.cmake
@@ -7,8 +7,8 @@ CPack
Build binary and source package installers.
-Variables common to all CPack generators
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+Introduction
+^^^^^^^^^^^^
The CPack module generates binary and source installers in a variety of
formats using the cpack program. Inclusion of the CPack module adds
@@ -23,6 +23,9 @@ installers on macOS and Windows), CPack generates installers that
allow users to select individual application components to install.
See :module:`CPackComponent` module for further details.
+CPack generators
+^^^^^^^^^^^^^^^^
+
The :variable:`CPACK_GENERATOR` variable has different meanings in different
contexts. In a ``CMakeLists.txt`` file, :variable:`CPACK_GENERATOR` is a
*list of generators*: and when :manual:`cpack <cpack(1)>` is run with no other
@@ -57,6 +60,9 @@ This is the key: For each generator listed in :variable:`CPACK_GENERATOR` in
internally to *the one currently being used* and then include the
:variable:`CPACK_PROJECT_CONFIG_FILE`.
+Variables common to all CPack generators
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
Before including this CPack module in your ``CMakeLists.txt`` file, there
are a variety of variables that can be set to customize the resulting
installers. The most commonly-used variables are:
diff --git a/Modules/CheckPrototypeDefinition.cmake b/Modules/CheckPrototypeDefinition.cmake
index b379ec4..c90b766 100644
--- a/Modules/CheckPrototypeDefinition.cmake
+++ b/Modules/CheckPrototypeDefinition.cmake
@@ -28,7 +28,7 @@ Example:
"unistd.h;pwd.h"
SOLARIS_GETPWENT_R)
-The following variables may be set before calling this macro to modify
+The following variables may be set before calling this function to modify
the way the check is run:
::
@@ -46,7 +46,7 @@ get_filename_component(__check_proto_def_dir "${CMAKE_CURRENT_LIST_FILE}" PATH)
include_guard(GLOBAL)
-function(CHECK_PROTOTYPE_DEFINITION _FUNCTION _PROTOTYPE _RETURN _HEADER _VARIABLE)
+function(check_prototype_definition _FUNCTION _PROTOTYPE _RETURN _HEADER _VARIABLE)
if (NOT DEFINED ${_VARIABLE})
set(CHECK_PROTOTYPE_DEFINITION_CONTENT "/* */\n")
diff --git a/Modules/Compiler/AppleClang-C.cmake b/Modules/Compiler/AppleClang-C.cmake
index a48adec..8754951 100644
--- a/Modules/Compiler/AppleClang-C.cmake
+++ b/Modules/Compiler/AppleClang-C.cmake
@@ -1,6 +1,9 @@
include(Compiler/Clang)
__compiler_clang(C)
+set(CMAKE_C_LINK_OPTIONS_PIE ${CMAKE_C_COMPILE_OPTIONS_PIE} -Xlinker -pie)
+set(CMAKE_C_LINK_OPTIONS_NO_PIE -Xlinker -no_pie)
+
if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.0)
set(CMAKE_C90_STANDARD_COMPILE_OPTION "-std=c90")
set(CMAKE_C90_EXTENSION_COMPILE_OPTION "-std=gnu90")
diff --git a/Modules/Compiler/AppleClang-CXX.cmake b/Modules/Compiler/AppleClang-CXX.cmake
index e5fd647..54c1388 100644
--- a/Modules/Compiler/AppleClang-CXX.cmake
+++ b/Modules/Compiler/AppleClang-CXX.cmake
@@ -1,6 +1,9 @@
include(Compiler/Clang)
__compiler_clang(CXX)
+set(CMAKE_CXX_LINK_OPTIONS_PIE ${CMAKE_CXX_COMPILE_OPTIONS_PIE} -Xlinker -pie)
+set(CMAKE_CXX_LINK_OPTIONS_NO_PIE -Xlinker -no_pie)
+
if(NOT "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC")
set(CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN "-fvisibility-inlines-hidden")
endif()
diff --git a/Modules/Compiler/Clang.cmake b/Modules/Compiler/Clang.cmake
index e23470b..7cee9c7 100644
--- a/Modules/Compiler/Clang.cmake
+++ b/Modules/Compiler/Clang.cmake
@@ -21,6 +21,26 @@ else()
macro(__compiler_clang lang)
__compiler_gnu(${lang})
set(CMAKE_${lang}_COMPILE_OPTIONS_PIE "-fPIE")
+ # Link options for PIE are already set in 'Compiler/GNU.cmake'
+ # but clang may require alternate syntax on some platforms
+ if (NOT CMAKE_${lang}_FLAG_PIE)
+ cmake_check_compiler_flag(${lang} "${CMAKE_${lang}_COMPILE_OPTIONS_PIE};-Xlinker;-pie"
+ CMAKE_${lang}_FLAG_XLINKER_PIE)
+ if (CMAKE_${lang}_FLAG_XLINKER_PIE)
+ set(CMAKE_${lang}_LINK_OPTIONS_PIE ${CMAKE_${lang}_COMPILE_OPTIONS_PIE} "-Xlinker" "-pie")
+ else()
+ set(CMAKE_${lang}_LINK_OPTIONS_PIE "")
+ endif()
+ endif()
+ if (NOT CMAKE_${lang}_FLAG_NO_PIE)
+ cmake_check_compiler_flag(${lang} "-Xlinker;-no_pie"
+ CMAKE_${lang}_FLAG_XLINKER_NO_PIE)
+ if (CMAKE_${lang}_FLAG_XLINKER_NO_PIE)
+ set(CMAKE_${lang}_LINK_OPTIONS_NO_PIE "-Xlinker" "-no_pie")
+ else()
+ set(CMAKE_${lang}_LINK_OPTIONS_NO_PIE "")
+ endif()
+ endif()
set(CMAKE_INCLUDE_SYSTEM_FLAG_${lang} "-isystem ")
set(CMAKE_${lang}_COMPILE_OPTIONS_VISIBILITY "-fvisibility=")
if(CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 3.4.0)
diff --git a/Modules/Compiler/GNU.cmake b/Modules/Compiler/GNU.cmake
index 4491d4b..688a1b5 100644
--- a/Modules/Compiler/GNU.cmake
+++ b/Modules/Compiler/GNU.cmake
@@ -9,6 +9,7 @@ endif()
set(__COMPILER_GNU 1)
include(Compiler/CMakeCommonCompilerMacros)
+include(Internal/CMakeCheckCompilerFlag)
macro(__compiler_gnu lang)
# Feature flags.
@@ -16,6 +17,21 @@ macro(__compiler_gnu lang)
set(CMAKE_${lang}_COMPILE_OPTIONS_PIC "-fPIC")
if(NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 3.4)
set(CMAKE_${lang}_COMPILE_OPTIONS_PIE "-fPIE")
+ # Support of PIE at link stage depends on various elements : platform, compiler, linker
+ # so the easiest way is to check if compiler supports these flags
+ cmake_check_compiler_flag(${lang} "${CMAKE_${lang}_COMPILE_OPTIONS_PIE};-pie"
+ CMAKE_${lang}_FLAG_PIE)
+ if (CMAKE_${lang}_FLAG_PIE)
+ set(CMAKE_${lang}_LINK_OPTIONS_PIE ${CMAKE_${lang}_COMPILE_OPTIONS_PIE} "-pie")
+ else()
+ set(CMAKE_${lang}_LINK_OPTIONS_PIE "")
+ endif()
+ cmake_check_compiler_flag(${lang} "-no-pie" CMAKE_${lang}_FLAG_NO_PIE)
+ if (CMAKE_${lang}_FLAG_NO_PIE)
+ set(CMAKE_${lang}_LINK_OPTIONS_NO_PIE "-no-pie")
+ else()
+ set(CMAKE_${lang}_LINK_OPTIONS_NO_PIE "")
+ endif()
endif()
if(NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 4.0)
set(CMAKE_${lang}_COMPILE_OPTIONS_VISIBILITY "-fvisibility=")
diff --git a/Modules/Compiler/SunPro-C.cmake b/Modules/Compiler/SunPro-C.cmake
index 047de43..75b8fe6 100644
--- a/Modules/Compiler/SunPro-C.cmake
+++ b/Modules/Compiler/SunPro-C.cmake
@@ -6,6 +6,9 @@ include(Compiler/SunPro)
set(CMAKE_C_VERBOSE_FLAG "-#")
set(CMAKE_C_COMPILE_OPTIONS_PIC -KPIC)
+set(CMAKE_C_COMPILE_OPTIONS_PIE "")
+set(CMAKE_C_LINK_OPTIONS_PIE "")
+set(CMAKE_C_LINK_OPTIONS_NO_PIE "")
set(CMAKE_SHARED_LIBRARY_C_FLAGS "-KPIC")
set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-G")
set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-R")
diff --git a/Modules/Compiler/SunPro-CXX.cmake b/Modules/Compiler/SunPro-CXX.cmake
index 4c1ac5b..662ac30 100644
--- a/Modules/Compiler/SunPro-CXX.cmake
+++ b/Modules/Compiler/SunPro-CXX.cmake
@@ -6,6 +6,9 @@ include(Compiler/SunPro)
set(CMAKE_CXX_VERBOSE_FLAG "-v")
set(CMAKE_CXX_COMPILE_OPTIONS_PIC -KPIC)
+set(CMAKE_CXX_COMPILE_OPTIONS_PIE "")
+set(CMAKE_CXX_LINK_OPTIONS_PIE "")
+set(CMAKE_CXX_LINK_OPTIONS_NO_PIE "")
set(CMAKE_SHARED_LIBRARY_CXX_FLAGS "-KPIC")
set(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "-G")
set(CMAKE_SHARED_LIBRARY_RUNTIME_CXX_FLAG "-R")
diff --git a/Modules/Compiler/SunPro-Fortran.cmake b/Modules/Compiler/SunPro-Fortran.cmake
index 2247dd0..e110253 100644
--- a/Modules/Compiler/SunPro-Fortran.cmake
+++ b/Modules/Compiler/SunPro-Fortran.cmake
@@ -3,6 +3,9 @@ set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-fixed")
set(CMAKE_Fortran_FORMAT_FREE_FLAG "-free")
set(CMAKE_Fortran_COMPILE_OPTIONS_PIC "-KPIC")
+set(CMAKE_Fortran_COMPILE_OPTIONS_PIE "")
+set(CMAKE_Fortran_LINK_OPTIONS_PIE "")
+set(CMAKE_Fortran_LINK_OPTIONS_NO_PIE "")
set(CMAKE_SHARED_LIBRARY_Fortran_FLAGS "-KPIC")
set(CMAKE_SHARED_LIBRARY_CREATE_Fortran_FLAGS "-G")
set(CMAKE_SHARED_LIBRARY_RUNTIME_Fortran_FLAG "-R")
diff --git a/Modules/DeployQt4.cmake b/Modules/DeployQt4.cmake
index c69cd38..4a18927 100644
--- a/Modules/DeployQt4.cmake
+++ b/Modules/DeployQt4.cmake
@@ -26,13 +26,13 @@ PARENT_SCOPE. Also depends on BundleUtilities.cmake.
::
- WRITE_QT4_CONF(<qt_conf_dir> <qt_conf_contents>)
+ write_qt4_conf(<qt_conf_dir> <qt_conf_contents>)
Writes a qt.conf file with the <qt_conf_contents> into <qt_conf_dir>.
::
- RESOLVE_QT4_PATHS(<paths_var> [<executable_path>])
+ resolve_qt4_paths(<paths_var> [<executable_path>])
Loop through <paths_var> list and if any don't exist resolve them
relative to the <executable_path> (if supplied) or the
@@ -40,7 +40,7 @@ CMAKE_INSTALL_PREFIX.
::
- FIXUP_QT4_EXECUTABLE(<executable>
+ fixup_qt4_executable(<executable>
[<qtplugins> <libs> <dirs> <plugins_dir> <request_qt_conf>])
Copies Qt plugins, writes a Qt configuration file (if needed) and
@@ -67,7 +67,7 @@ needed.
::
- INSTALL_QT4_PLUGIN_PATH(plugin executable copy installed_plugin_path_var
+ install_qt4_plugin_path(plugin executable copy installed_plugin_path_var
<plugins_dir> <component> <configurations>)
Install (or copy) a resolved <plugin> to the default plugins directory
@@ -82,7 +82,7 @@ If <component> is set then anything installed will use this COMPONENT.
::
- INSTALL_QT4_PLUGIN(plugin executable copy installed_plugin_path_var
+ install_qt4_plugin(plugin executable copy installed_plugin_path_var
<plugins_dir> <component>)
Install (or copy) an unresolved <plugin> to the default plugins
@@ -92,7 +92,7 @@ INSTALL_QT4_PLUGIN_PATH.
::
- INSTALL_QT4_EXECUTABLE(<executable>
+ install_qt4_executable(<executable>
[<qtplugins> <libs> <dirs> <plugins_dir> <request_qt_conf> <component>])
Installs Qt plugins, writes a Qt configuration file (if needed) and
diff --git a/Modules/Documentation.cmake b/Modules/Documentation.cmake
index 229b8ab..aaf24f6 100644
--- a/Modules/Documentation.cmake
+++ b/Modules/Documentation.cmake
@@ -5,9 +5,7 @@
Documentation
-------------
-DocumentationVTK.cmake
-
-This file provides support for the VTK documentation framework. It
+This module provides support for the VTK documentation framework. It
relies on several tools (Doxygen, Perl, etc).
#]=======================================================================]
diff --git a/Modules/FindBoost.cmake b/Modules/FindBoost.cmake
index 7abddbd..ccd245b 100644
--- a/Modules/FindBoost.cmake
+++ b/Modules/FindBoost.cmake
@@ -873,9 +873,8 @@ function(_Boost_COMPONENT_DEPENDENCIES component _ret)
set(_Boost_LOG_DEPENDENCIES date_time log_setup filesystem thread regex chrono atomic)
set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l atomic)
set(_Boost_MPI_DEPENDENCIES serialization)
- set(_Boost_MPI_PYTHON_DEPENDENCIES python mpi serialization)
- set(_Boost_NUMPY_DEPENDENCIES python)
- set(_Boost_SYNC_DEPENDENCIES chrono atomic)
+ set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization)
+ set(_Boost_NUMPY_DEPENDENCIES python${component_python_version})
set(_Boost_THREAD_DEPENDENCIES chrono date_time atomic)
set(_Boost_TIMER_DEPENDENCIES chrono system)
set(_Boost_WAVE_DEPENDENCIES filesystem serialization thread chrono date_time atomic)
@@ -1129,6 +1128,7 @@ else()
# _Boost_COMPONENT_HEADERS. See the instructions at the top of
# _Boost_COMPONENT_DEPENDENCIES.
set(_Boost_KNOWN_VERSIONS ${Boost_ADDITIONAL_VERSIONS}
+ "1.69.0" "1.69"
"1.68.0" "1.68" "1.67.0" "1.67" "1.66.0" "1.66" "1.65.1" "1.65.0" "1.65"
"1.64.0" "1.64" "1.63.0" "1.63" "1.62.0" "1.62" "1.61.0" "1.61" "1.60.0" "1.60"
"1.59.0" "1.59" "1.58.0" "1.58" "1.57.0" "1.57" "1.56.0" "1.56" "1.55.0" "1.55"
diff --git a/Modules/FindPackageMessage.cmake b/Modules/FindPackageMessage.cmake
index 1cdfde8..0628b98 100644
--- a/Modules/FindPackageMessage.cmake
+++ b/Modules/FindPackageMessage.cmake
@@ -5,14 +5,14 @@
FindPackageMessage
------------------
+.. code-block:: cmake
+ find_package_message(<name> "message for user" "find result details")
-FIND_PACKAGE_MESSAGE(<name> "message for user" "find result details")
-
-This macro is intended to be used in FindXXX.cmake modules files. It
-will print a message once for each unique find result. This is useful
-for telling the user where a package was found. The first argument
-specifies the name (XXX) of the package. The second argument
+This function is intended to be used in FindXXX.cmake modules files.
+It will print a message once for each unique find result. This is
+useful for telling the user where a package was found. The first
+argument specifies the name (XXX) of the package. The second argument
specifies the message to display. The third argument lists details
about the find result so that if they change the message will be
displayed again. The macro also obeys the QUIET argument to the
@@ -20,17 +20,17 @@ find_package command.
Example:
-::
+.. code-block:: cmake
if(X11_FOUND)
- FIND_PACKAGE_MESSAGE(X11 "Found X11: ${X11_X11_LIB}"
+ find_package_message(X11 "Found X11: ${X11_X11_LIB}"
"[${X11_X11_LIB}][${X11_INCLUDE_DIR}]")
else()
...
endif()
#]=======================================================================]
-function(FIND_PACKAGE_MESSAGE pkg msg details)
+function(find_package_message pkg msg details)
# Avoid printing a message repeatedly for the same find result.
if(NOT ${pkg}_FIND_QUIETLY)
string(REPLACE "\n" "" details "${details}")
diff --git a/Modules/Internal/CMakeCheckCompilerFlag.cmake b/Modules/Internal/CMakeCheckCompilerFlag.cmake
new file mode 100644
index 0000000..ca9b356
--- /dev/null
+++ b/Modules/Internal/CMakeCheckCompilerFlag.cmake
@@ -0,0 +1,146 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+#[=[
+
+NOTE: This function is used internally by CMake. Projects should not include
+ this file directly.
+
+The cmake_check_compiler_flag() function can be used to compile and link a
+source file to check whether a specific compiler or linker flag is supported.
+The function does not use the try_compile() command so as to avoid infinite
+recursion. It may not work for all platforms or toolchains, the caller is
+responsible for ensuring it is only called in valid situations.
+
+Parameters:
+ lang - Language to check.
+ flag - The flag to add to the compile/link command line.
+ result - Boolean output variable. It will be stored in the cache as an
+ internal variable and if true, will cause future tests that assign
+ to that variable to be bypassed.
+
+Optional parameters:
+ SRC_EXT - Overrides the extension of the source file used for the
+ check. Defaults are 'c' (C), 'cxx' (CXX), 'F' (Fortran).
+ COMMAND_PATTERN - Pattern to be used for the command line. The default is
+ '<FLAG> -o <OUTPUT> <SOURCE>'
+ FAIL_REGEX - List of additional regular expressions that, if matched by
+ the output, give a failed result for the check. A common
+ set of regular expressions will be included in addition to
+ those given by FAIL_REGEX.
+
+#]=]
+
+include_guard(GLOBAL)
+include(CMakeCheckCompilerFlagCommonPatterns)
+
+function(CMAKE_CHECK_COMPILER_FLAG lang flag result)
+ # Cache results between runs similar to check_<lang>_source_compiles()
+ if(DEFINED ${result})
+ return()
+ endif()
+
+ set(comment "Is the '${flag}' option(s) supported")
+ string(REPLACE ";" " " comment "${comment}")
+
+ if (NOT lang MATCHES "^(C|CXX|Fortran|ASM)$")
+ # other possible languages are not supported
+ # log message to keep trace of this problem...
+ file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
+ "Function 'CMAKE_CHECK_COMPILER_FLAG' called with unsupported language: ${lang}\n")
+ set(${result} FALSE CACHE INTERNAL ${comment})
+ return()
+ endif()
+ if (lang STREQUAL "ASM")
+ # assume ASM compiler is a multi-language compiler, so supports C language as well
+ set(check_lang C)
+ else()
+ set(check_lang ${lang})
+ endif()
+
+ cmake_parse_arguments(CCCF "" "SRC_EXT;COMMAND_PATTERN" "FAIL_REGEX" ${ARGN})
+
+ if (NOT CCCF_COMMAND_PATTERN)
+ set (CCCF_COMMAND_PATTERN "<FLAG> -o <OUTPUT> <SOURCE>")
+ endif()
+
+ list (APPEND CCCF_FAIL_REGEX "argument unused during compilation") # clang
+ if (check_lang STREQUAL "C")
+ list(APPEND CCCF_FAIL_REGEX
+ "command line option .* is valid for .* but not for C") # GNU
+ elseif(check_lang STREQUAL "CXX")
+ list(APPEND CCCF_FAIL_REGEX
+ "command line option .* is valid for .* but not for C\\+\\+") # GNU
+ elseif(check_lang STREQUAL "Fortran")
+ list(APPEND CCCF_FAIL_REGEX
+ "command line option .* is valid for .* but not for Fortran") # GNU
+ endif()
+
+ # Add patterns for common errors
+ check_compiler_flag_common_patterns(COMPILER_FLAG_COMMON_PATTERNS)
+ foreach(arg IN LISTS COMPILER_FLAG_COMMON_PATTERNS)
+ if(arg MATCHES "^FAIL_REGEX$")
+ continue()
+ endif()
+ list(APPEND CCCF_FAIL_REGEX "${arg}")
+ endforeach()
+
+ if(NOT CCCF_SRC_EXT)
+ if (check_lang STREQUAL "C")
+ set(CCCF_SRC_EXT c)
+ elseif(check_lang STREQUAL "CXX")
+ set(CCCF_SRC_EXT cxx)
+ elseif(check_lang STREQUAL "Fortran")
+ set(CCCF_SRC_EXT F)
+ endif()
+ endif()
+
+ # Compute the directory in which to run the test.
+ set(COMPILER_FLAG_DIR "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp")
+ # Compute source and output files.
+ set(COMPILER_FLAG_SRC
+ "${COMPILER_FLAG_DIR}/CompilerFlag${lang}.${CCCF_SRC_EXT}")
+ if(check_lang STREQUAL "Fortran")
+ file(WRITE "${COMPILER_FLAG_SRC}"
+ " program simple\n end program simple\n")
+ else()
+ file(WRITE "${COMPILER_FLAG_SRC}" "int main (void)\n{ return 0; }\n")
+ endif()
+ get_filename_component(COMPILER_FLAG_EXE "${COMPILER_FLAG_SRC}" NAME_WE)
+ string(APPEND COMPILER_FLAG_EXE "${CMAKE_EXECUTABLE_SUFFIX}")
+
+ # Build command line
+ separate_arguments(CCCF_COMMAND_PATTERN UNIX_COMMAND
+ "${CCCF_COMMAND_PATTERN}")
+ list(TRANSFORM CCCF_COMMAND_PATTERN REPLACE "<SOURCE>" "${COMPILER_FLAG_SRC}")
+ list(TRANSFORM CCCF_COMMAND_PATTERN REPLACE "<OUTPUT>" "${COMPILER_FLAG_EXE}")
+ list(TRANSFORM CCCF_COMMAND_PATTERN REPLACE "<FLAG>" "${flag}")
+
+ execute_process(
+ COMMAND "${CMAKE_COMMAND}" -E env LC_ALL=C LC_MESSAGES=C LANG=C
+ "${CMAKE_${lang}_COMPILER}" ${CCCF_COMMAND_PATTERN}
+ WORKING_DIRECTORY "${COMPILER_FLAG_DIR}"
+ OUTPUT_VARIABLE COMPILER_FLAG_OUTPUT
+ ERROR_VARIABLE COMPILER_FLAG_OUTPUT
+ RESULT_VARIABLE COMPILER_FLAG_RESULT)
+
+ # Record result in the cache so we can avoid re-testing every CMake run
+ if (COMPILER_FLAG_RESULT)
+ set(${result} FALSE CACHE INTERNAL ${comment})
+ else()
+ foreach(regex IN LISTS CCCF_FAIL_REGEX)
+ if(COMPILER_FLAG_OUTPUT MATCHES "${regex}")
+ set(${result} FALSE CACHE INTERNAL ${comment})
+ endif()
+ endforeach()
+ endif()
+ if (DEFINED ${result})
+ file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
+ "Determining if the ${flag} option "
+ "is supported for ${lang} language failed with the following output:\n"
+ "${COMPILER_FLAG_OUTPUT}\n")
+ return()
+ endif()
+
+ set(${result} TRUE CACHE INTERNAL ${comment})
+endfunction()
diff --git a/Modules/Platform/Android/abi-common.cmake b/Modules/Platform/Android/abi-common.cmake
index 10fb897..a0b47f4 100644
--- a/Modules/Platform/Android/abi-common.cmake
+++ b/Modules/Platform/Android/abi-common.cmake
@@ -12,10 +12,6 @@ if(NOT DEFINED CMAKE_POSITION_INDEPENDENT_CODE
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif()
-if(CMAKE_POSITION_INDEPENDENT_CODE)
- string(APPEND _ANDROID_ABI_INIT_EXE_LDFLAGS " -fPIE -pie")
-endif()
-
string(APPEND _ANDROID_ABI_INIT_EXE_LDFLAGS " -Wl,--gc-sections")
if(NOT _ANDROID_ABI_INIT_EXE_LDFLAGS_NO_nocopyreloc)
diff --git a/Modules/Platform/CYGWIN-GNU.cmake b/Modules/Platform/CYGWIN-GNU.cmake
index 784c8c6..f55b80d 100644
--- a/Modules/Platform/CYGWIN-GNU.cmake
+++ b/Modules/Platform/CYGWIN-GNU.cmake
@@ -27,6 +27,8 @@ macro(__cygwin_compiler_gnu lang)
# No -fPIC on cygwin
set(CMAKE_${lang}_COMPILE_OPTIONS_PIC "")
set(CMAKE_${lang}_COMPILE_OPTIONS_PIE "")
+ set(CMAKE_${lang}_LINK_OPTIONS_PIE "")
+ set(CMAKE_${lang}_LINK_OPTIONS_NO_PIE "")
set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "")
# Initialize C link type selection flags. These flags are used when
diff --git a/Modules/Platform/FreeBSD.cmake b/Modules/Platform/FreeBSD.cmake
index 082e9f6..4a4c00d 100644
--- a/Modules/Platform/FreeBSD.cmake
+++ b/Modules/Platform/FreeBSD.cmake
@@ -1,6 +1,7 @@
set(CMAKE_DL_LIBS "")
set(CMAKE_C_COMPILE_OPTIONS_PIC "-fPIC")
set(CMAKE_C_COMPILE_OPTIONS_PIE "-fPIE")
+# PIE link options are managed in Compiler/<compiler>.cmake file
set(CMAKE_SHARED_LIBRARY_C_FLAGS "-fPIC") # -pic
set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared") # -shared
set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") # +s, flag for exe link to use shared lib
diff --git a/Modules/Platform/Fuchsia.cmake b/Modules/Platform/Fuchsia.cmake
index 896da7b..7b33434 100644
--- a/Modules/Platform/Fuchsia.cmake
+++ b/Modules/Platform/Fuchsia.cmake
@@ -3,6 +3,8 @@ set(FUCHSIA 1)
set(CMAKE_DL_LIBS "")
set(CMAKE_C_COMPILE_OPTIONS_PIC "-fPIC")
set(CMAKE_C_COMPILE_OPTIONS_PIE "-fPIE")
+set(CMAKE_C_LINK_OPTIONS_PIE ${CMAKE_C_COMPILE_OPTIONS_PIE} "-pie")
+set(CMAKE_C_LINK_OPTIONS_NO_PIE "-no-pie")
set(CMAKE_SHARED_LIBRARY_C_FLAGS "-fPIC")
set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared")
set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,")
diff --git a/Modules/Platform/Linux-Intel.cmake b/Modules/Platform/Linux-Intel.cmake
index f712e2b..ab22b1d 100644
--- a/Modules/Platform/Linux-Intel.cmake
+++ b/Modules/Platform/Linux-Intel.cmake
@@ -23,6 +23,10 @@ endif()
macro(__linux_compiler_intel lang)
set(CMAKE_${lang}_COMPILE_OPTIONS_PIC "-fPIC")
set(CMAKE_${lang}_COMPILE_OPTIONS_PIE "-fPIE")
+ if (NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 13.0)
+ set(CMAKE_${lang}_LINK_OPTIONS_PIE ${CMAKE_${lang}_COMPILE_OPTIONS_PIE} "-pie")
+ set(CMAKE_${lang}_LINK_OPTIONS_NO_PIE "-no-pie")
+ endif()
set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "-fPIC")
set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-shared")
diff --git a/Modules/Platform/Linux-PGI.cmake b/Modules/Platform/Linux-PGI.cmake
index db032c2..3e7e391 100644
--- a/Modules/Platform/Linux-PGI.cmake
+++ b/Modules/Platform/Linux-PGI.cmake
@@ -12,6 +12,8 @@ macro(__linux_compiler_pgi lang)
# Shared library compile and link flags.
set(CMAKE_${lang}_COMPILE_OPTIONS_PIC "-fPIC")
set(CMAKE_${lang}_COMPILE_OPTIONS_PIE "")
+ set(CMAKE_${lang}_LINK_OPTIONS_PIE "")
+ set(CMAKE_${lang}_LINK_OPTIONS_NO_PIE "")
set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "-fPIC")
set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-shared")
set(CMAKE_SHARED_LIBRARY_LINK_${lang}_FLAGS " ")
diff --git a/Modules/Platform/NetBSD.cmake b/Modules/Platform/NetBSD.cmake
index a8f4cc8..d99cb4a 100644
--- a/Modules/Platform/NetBSD.cmake
+++ b/Modules/Platform/NetBSD.cmake
@@ -1,6 +1,7 @@
set(CMAKE_DL_LIBS "")
set(CMAKE_C_COMPILE_OPTIONS_PIC "-fPIC")
set(CMAKE_C_COMPILE_OPTIONS_PIE "-fPIE")
+# PIE link options are managed in Compiler/<compiler>.cmake file
set(CMAKE_SHARED_LIBRARY_C_FLAGS "-fPIC") # -pic
set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared") # -shared
set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") # +s, flag for exe link to use shared lib
diff --git a/Modules/Platform/SINIX.cmake b/Modules/Platform/SINIX.cmake
index c37a113..e44ceef 100644
--- a/Modules/Platform/SINIX.cmake
+++ b/Modules/Platform/SINIX.cmake
@@ -1,4 +1,6 @@
set(CMAKE_C_COMPILE_OPTIONS_PIC -K PIC)
set(CMAKE_C_COMPILE_OPTIONS_PIE "")
+set(CMAKE_C_LINK_OPTIONS_PIE "")
+set(CMAKE_C_LINK_OPTIONS_NO_PIE "")
set(CMAKE_SHARED_LIBRARY_C_FLAGS "-K PIC")
include(Platform/UnixPaths)
diff --git a/Modules/Platform/UNIX_SV.cmake b/Modules/Platform/UNIX_SV.cmake
index 1ec96ae..433daf3 100644
--- a/Modules/Platform/UNIX_SV.cmake
+++ b/Modules/Platform/UNIX_SV.cmake
@@ -1,5 +1,7 @@
set(CMAKE_C_COMPILE_OPTIONS_PIC -K PIC)
set(CMAKE_C_COMPILE_OPTIONS_PIE "")
+set(CMAKE_C_LINK_OPTIONS_PIE "")
+set(CMAKE_C_LINK_OPTIONS_NO_PIE "")
set(CMAKE_SHARED_LIBRARY_C_FLAGS "-K PIC")
set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "-Wl,-Bexport")
include(Platform/UnixPaths)
diff --git a/Modules/Platform/UnixWare.cmake b/Modules/Platform/UnixWare.cmake
index e649bd2..8c9d430 100644
--- a/Modules/Platform/UnixWare.cmake
+++ b/Modules/Platform/UnixWare.cmake
@@ -1,5 +1,7 @@
set(CMAKE_C_COMPILE_OPTIONS_PIC -K PIC)
set(CMAKE_C_COMPILE_OPTIONS_PIE "")
+set(CMAKE_C_LINK_OPTIONS_PIE "")
+set(CMAKE_C_LINK_OPTIONS_NO_PIE "")
set(CMAKE_SHARED_LIBRARY_C_FLAGS "-K PIC")
set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-Wl,-Bexport")
include(Platform/UnixPaths)
diff --git a/Modules/Platform/Windows-GNU.cmake b/Modules/Platform/Windows-GNU.cmake
index cfb325b..2e854e5 100644
--- a/Modules/Platform/Windows-GNU.cmake
+++ b/Modules/Platform/Windows-GNU.cmake
@@ -72,6 +72,8 @@ macro(__windows_compiler_gnu lang)
# No -fPIC on Windows
set(CMAKE_${lang}_COMPILE_OPTIONS_PIC "")
set(CMAKE_${lang}_COMPILE_OPTIONS_PIE "")
+ set(CMAKE_${lang}_LINK_OPTIONS_PIE "")
+ set(CMAKE_${lang}_LINK_OPTIONS_NO_PIE "")
set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "")
set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_OBJECTS ${__WINDOWS_GNU_LD_RESPONSE})
diff --git a/Modules/WriteCompilerDetectionHeader.cmake b/Modules/WriteCompilerDetectionHeader.cmake
index a556567..21ccd7c 100644
--- a/Modules/WriteCompilerDetectionHeader.cmake
+++ b/Modules/WriteCompilerDetectionHeader.cmake
@@ -7,9 +7,8 @@ WriteCompilerDetectionHeader
This module provides the function write_compiler_detection_header().
-The ``WRITE_COMPILER_DETECTION_HEADER`` function can be used to generate
-a file suitable for preprocessor inclusion which contains macros to be
-used in source code::
+This function can be used to generate a file suitable for preprocessor
+inclusion which contains macros to be used in source code::
write_compiler_detection_header(
FILE <file>
@@ -25,8 +24,8 @@ used in source code::
[ALLOW_UNKNOWN_COMPILER_VERSIONS]
)
-The ``write_compiler_detection_header`` function generates the
-file ``<file>`` with macros which all have the prefix ``<prefix>``.
+This generates the file ``<file>`` with macros which all have the prefix
+``<prefix>``.
By default, all content is written directly to the ``<file>``. The
``OUTPUT_FILES_VAR`` may be specified to cause the compiler-specific
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake
index 0d78906..19e2da7 100644
--- a/Source/CMakeVersion.cmake
+++ b/Source/CMakeVersion.cmake
@@ -1,5 +1,5 @@
# CMake version number components.
set(CMake_VERSION_MAJOR 3)
set(CMake_VERSION_MINOR 13)
-set(CMake_VERSION_PATCH 20181112)
+set(CMake_VERSION_PATCH 20181113)
#set(CMake_VERSION_RC 1)
diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx
index c936910..1d938e6 100644
--- a/Source/CTest/cmCTestTestHandler.cxx
+++ b/Source/CTest/cmCTestTestHandler.cxx
@@ -535,11 +535,21 @@ int cmCTestTestHandler::ProcessHandler()
percent = 99;
}
+ std::string passColorCode;
+ std::string failedColorCode;
+ if (failed.empty()) {
+ passColorCode = this->CTest->GetColorCode(cmCTest::Color::GREEN);
+ } else {
+ failedColorCode = this->CTest->GetColorCode(cmCTest::Color::RED);
+ }
cmCTestLog(this->CTest, HANDLER_OUTPUT,
std::endl
- << static_cast<int>(percent + .5f) << "% tests passed, "
- << failed.size() << " tests failed out of " << total
- << std::endl);
+ << passColorCode << static_cast<int>(percent + .5f)
+ << "% tests passed"
+ << this->CTest->GetColorCode(cmCTest::Color::CLEAR_COLOR)
+ << ", " << failedColorCode << failed.size() << " tests failed"
+ << this->CTest->GetColorCode(cmCTest::Color::CLEAR_COLOR)
+ << " out of " << total << std::endl);
if ((!this->CTest->GetLabelsForSubprojects().empty() &&
this->CTest->GetSubprojectSummary())) {
this->PrintLabelOrSubprojectSummary(true);
@@ -562,6 +572,8 @@ int cmCTestTestHandler::ProcessHandler()
this->StartLogFile("TestsDisabled", ofs);
const char* disabled_reason;
+ cmCTestLog(this->CTest, HANDLER_OUTPUT,
+ this->CTest->GetColorCode(cmCTest::Color::BLUE));
for (cmCTestTestResult const& dt : disabledTests) {
ofs << dt.TestCount << ":" << dt.Name << std::endl;
if (dt.CompletionStatus == "Disabled") {
@@ -573,6 +585,8 @@ int cmCTestTestHandler::ProcessHandler()
"\t" << std::setw(3) << dt.TestCount << " - " << dt.Name
<< " (" << disabled_reason << ")" << std::endl);
}
+ cmCTestLog(this->CTest, HANDLER_OUTPUT,
+ this->CTest->GetColorCode(cmCTest::Color::CLEAR_COLOR));
}
if (!failed.empty()) {
@@ -587,10 +601,17 @@ int cmCTestTestHandler::ProcessHandler()
!cmHasLiteralPrefix(ft.CompletionStatus, "SKIP_RETURN_CODE=") &&
ft.CompletionStatus != "Disabled") {
ofs << ft.TestCount << ":" << ft.Name << std::endl;
- cmCTestLog(this->CTest, HANDLER_OUTPUT,
- "\t" << std::setw(3) << ft.TestCount << " - " << ft.Name
- << " (" << this->GetTestStatus(ft) << ")"
- << std::endl);
+ auto testColor = cmCTest::Color::RED;
+ if (this->GetTestStatus(ft) == "Not Run") {
+ testColor = cmCTest::Color::YELLOW;
+ }
+ cmCTestLog(
+ this->CTest, HANDLER_OUTPUT,
+ "\t" << this->CTest->GetColorCode(testColor) << std::setw(3)
+ << ft.TestCount << " - " << ft.Name << " ("
+ << this->GetTestStatus(ft) << ")"
+ << this->CTest->GetColorCode(cmCTest::Color::CLEAR_COLOR)
+ << std::endl);
}
}
}
@@ -1725,7 +1746,7 @@ void cmCTestTestHandler::UseExcludeRegExp()
this->UseExcludeRegExpFirst = !this->UseIncludeRegExpFlag;
}
-const char* cmCTestTestHandler::GetTestStatus(cmCTestTestResult const& result)
+std::string cmCTestTestHandler::GetTestStatus(cmCTestTestResult const& result)
{
static const char* statuses[] = { "Not Run", "Timeout", "SEGFAULT",
"ILLEGAL", "INTERRUPT", "NUMERICAL",
@@ -1737,7 +1758,7 @@ const char* cmCTestTestHandler::GetTestStatus(cmCTestTestResult const& result)
return "No Status";
}
if (status == cmCTestTestHandler::OTHER_FAULT) {
- return result.ExceptionStatus.c_str();
+ return result.ExceptionStatus;
}
return statuses[status];
}
diff --git a/Source/CTest/cmCTestTestHandler.h b/Source/CTest/cmCTestTestHandler.h
index d2694a1..bcacf23 100644
--- a/Source/CTest/cmCTestTestHandler.h
+++ b/Source/CTest/cmCTestTestHandler.h
@@ -274,7 +274,7 @@ private:
*/
std::string FindTheExecutable(const char* exe);
- const char* GetTestStatus(cmCTestTestResult const&);
+ std::string GetTestStatus(cmCTestTestResult const&);
void ExpandTestsToRunInformation(size_t numPossibleTests);
void ExpandTestsToRunInformationForRerunFailed();
diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx
index 9a046db..c2b6575 100644
--- a/Source/cmCTest.cxx
+++ b/Source/cmCTest.cxx
@@ -296,6 +296,7 @@ cmCTest::cmCTest()
this->DropSiteCDash = false;
this->BuildID = "";
this->OutputTestOutputOnTestFailure = false;
+ this->OutputColorCode = this->ColoredOutputSupportedByConsole();
this->RepeatTests = 1; // default to run each test once
this->RepeatUntilFail = false;
@@ -2075,7 +2076,18 @@ bool cmCTest::HandleCommandLineArguments(size_t& i,
return true;
}
-bool cmCTest::ProgressOutputSupportedByConsole() const
+#if !defined(_WIN32)
+bool cmCTest::ConsoleIsNotDumb()
+{
+ std::string term_env_variable;
+ if (cmSystemTools::GetEnv("TERM", term_env_variable)) {
+ return isatty(1) && term_env_variable != "dumb";
+ }
+ return false;
+}
+#endif
+
+bool cmCTest::ProgressOutputSupportedByConsole()
{
#if defined(_WIN32)
// On Windows we need a console buffer.
@@ -2084,12 +2096,19 @@ bool cmCTest::ProgressOutputSupportedByConsole() const
return GetConsoleScreenBufferInfo(console, &csbi);
#else
// On UNIX we need a non-dumb tty.
- std::string term_env_variable;
- if (cmSystemTools::GetEnv("TERM", term_env_variable)) {
- return isatty(1) && term_env_variable != "dumb";
- }
+ return ConsoleIsNotDumb();
#endif
+}
+
+bool cmCTest::ColoredOutputSupportedByConsole()
+{
+#if defined(_WIN32)
+ // Not supported on Windows
return false;
+#else
+ // On UNIX we need a non-dumb tty.
+ return ConsoleIsNotDumb();
+#endif
}
// handle the -S -SR and -SP arguments
@@ -2958,6 +2977,20 @@ void cmCTest::Log(int logType, const char* file, int line, const char* msg,
}
}
+std::string cmCTest::GetColorCode(Color color) const
+{
+ if (this->OutputColorCode) {
+#if defined(_WIN32)
+ // Not supported on Windows
+ static_cast<void>(color);
+#else
+ return "\033[0;" + std::to_string(static_cast<int>(color)) + "m";
+#endif
+ }
+
+ return "";
+}
+
cmDuration cmCTest::GetRemainingTimeAllowed()
{
if (!this->GetHandler("script")) {
diff --git a/Source/cmCTest.h b/Source/cmCTest.h
index 1ee002a..427049d 100644
--- a/Source/cmCTest.h
+++ b/Source/cmCTest.h
@@ -405,6 +405,19 @@ public:
void Log(int logType, const char* file, int line, const char* msg,
bool suppress = false);
+ /** Color values */
+ enum class Color
+ {
+ CLEAR_COLOR = 0,
+ RED = 31,
+ GREEN = 32,
+ YELLOW = 33,
+ BLUE = 34
+ };
+
+ /** Get color code characters for a specific color */
+ std::string GetColorCode(Color color) const;
+
/** Get the version of dart server */
int GetDartVersion() { return this->DartVersion; }
int GetDropSiteCDash() { return this->DropSiteCDash; }
@@ -575,8 +588,16 @@ private:
bool HandleCommandLineArguments(size_t& i, std::vector<std::string>& args,
std::string& errormsg);
+#if !defined(_WIN32)
/** returns true iff the console supports progress output */
- bool ProgressOutputSupportedByConsole() const;
+ static bool ConsoleIsNotDumb();
+#endif
+
+ /** returns true iff the console supports progress output */
+ static bool ProgressOutputSupportedByConsole();
+
+ /** returns true iff the console supports colored output */
+ static bool ColoredOutputSupportedByConsole();
/** handle the -S -SP and -SR arguments */
void HandleScriptArguments(size_t& i, std::vector<std::string>& args,
@@ -625,6 +646,7 @@ private:
int OutputLogFileLastTag;
bool OutputTestOutputOnTestFailure;
+ bool OutputColorCode;
std::map<std::string, std::string> Definitions;
};
diff --git a/Source/cmConditionEvaluator.cxx b/Source/cmConditionEvaluator.cxx
index 172ef92..3b4206f 100644
--- a/Source/cmConditionEvaluator.cxx
+++ b/Source/cmConditionEvaluator.cxx
@@ -495,6 +495,12 @@ bool cmConditionEvaluator::HandleLevel1(cmArgumentList& newArgs, std::string&,
argP1->GetValue().operator[](argP1len - 1) == '}') {
std::string env = argP1->GetValue().substr(4, argP1len - 5);
bdef = cmSystemTools::HasEnv(env);
+ } else if (argP1len > 6 &&
+ argP1->GetValue().substr(0, 6) == "CACHE{" &&
+ argP1->GetValue().operator[](argP1len - 1) == '}') {
+ std::string cache = argP1->GetValue().substr(6, argP1len - 7);
+ bdef =
+ this->Makefile.GetState()->GetCacheEntryValue(cache) != nullptr;
} else {
bdef = this->Makefile.IsDefinitionSet(argP1->GetValue());
}
diff --git a/Source/cmGeneratorExpressionDAGChecker.cxx b/Source/cmGeneratorExpressionDAGChecker.cxx
index 8d57441..56eb2bf 100644
--- a/Source/cmGeneratorExpressionDAGChecker.cxx
+++ b/Source/cmGeneratorExpressionDAGChecker.cxx
@@ -166,6 +166,18 @@ bool cmGeneratorExpressionDAGChecker::EvaluatingGenexExpression()
return top->Property == "TARGET_GENEX_EVAL" || top->Property == "GENEX_EVAL";
}
+bool cmGeneratorExpressionDAGChecker::EvaluatingPICExpression()
+{
+ const cmGeneratorExpressionDAGChecker* top = this;
+ const cmGeneratorExpressionDAGChecker* parent = this->Parent;
+ while (parent) {
+ top = parent;
+ parent = parent->Parent;
+ }
+
+ return top->Property == "INTERFACE_POSITION_INDEPENDENT_CODE";
+}
+
bool cmGeneratorExpressionDAGChecker::EvaluatingLinkLibraries(
cmGeneratorTarget const* tgt)
{
diff --git a/Source/cmGeneratorExpressionDAGChecker.h b/Source/cmGeneratorExpressionDAGChecker.h
index a5134c3..1525c39 100644
--- a/Source/cmGeneratorExpressionDAGChecker.h
+++ b/Source/cmGeneratorExpressionDAGChecker.h
@@ -66,6 +66,7 @@ struct cmGeneratorExpressionDAGChecker
const std::string& expr);
bool EvaluatingGenexExpression();
+ bool EvaluatingPICExpression();
bool EvaluatingLinkLibraries(cmGeneratorTarget const* tgt = nullptr);
#define DECLARE_TRANSITIVE_PROPERTY_METHOD(METHOD) bool METHOD() const;
diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx
index f901215..49b97fb 100644
--- a/Source/cmGeneratorExpressionNode.cxx
+++ b/Source/cmGeneratorExpressionNode.cxx
@@ -1225,7 +1225,8 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
const char* prop = target->GetProperty(propertyName);
if (dagCheckerParent) {
- if (dagCheckerParent->EvaluatingGenexExpression()) {
+ if (dagCheckerParent->EvaluatingGenexExpression() ||
+ dagCheckerParent->EvaluatingPICExpression()) {
// No check required.
} else if (dagCheckerParent->EvaluatingLinkLibraries()) {
#define TRANSITIVE_PROPERTY_COMPARE(PROPERTY) \
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index 1663400..0b28d1e 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -495,6 +495,36 @@ const char* cmGeneratorTarget::GetFeature(const std::string& feature,
return this->LocalGenerator->GetFeature(feature, config);
}
+const char* cmGeneratorTarget::GetLinkPIEProperty(
+ const std::string& config) const
+{
+ static std::string PICValue;
+
+ PICValue = this->GetLinkInterfaceDependentStringAsBoolProperty(
+ "POSITION_INDEPENDENT_CODE", config);
+
+ if (PICValue == "(unset)") {
+ // POSITION_INDEPENDENT_CODE is not set
+ return nullptr;
+ }
+
+ switch (this->GetPolicyStatusCMP0083()) {
+ case cmPolicies::WARN: {
+ std::ostringstream e;
+ e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0083);
+ this->LocalGenerator->IssueMessage(cmake::AUTHOR_WARNING, e.str());
+ CM_FALLTHROUGH;
+ }
+ case cmPolicies::OLD:
+ return nullptr;
+ default:
+ // nothing to do
+ break;
+ }
+
+ return PICValue.c_str();
+}
+
bool cmGeneratorTarget::IsIPOEnabled(std::string const& lang,
std::string const& config) const
{
@@ -4237,6 +4267,29 @@ void cmGeneratorTarget::CheckPropertyCompatibility(
}
}
+template <typename PropertyType>
+std::string valueAsString(PropertyType);
+template <>
+std::string valueAsString<bool>(bool value)
+{
+ return value ? "TRUE" : "FALSE";
+}
+template <>
+std::string valueAsString<const char*>(const char* value)
+{
+ return value ? value : "(unset)";
+}
+template <>
+std::string valueAsString<std::string>(std::string value)
+{
+ return value;
+}
+template <>
+std::string valueAsString<std::nullptr_t>(std::nullptr_t /*unused*/)
+{
+ return "(unset)";
+}
+
std::string compatibilityType(CompatibleType t)
{
switch (t) {
@@ -4268,34 +4321,49 @@ std::string compatibilityAgree(CompatibleType t, bool dominant)
}
template <typename PropertyType>
-PropertyType getTypedProperty(cmGeneratorTarget const* tgt,
- const std::string& prop);
+PropertyType getTypedProperty(
+ cmGeneratorTarget const* tgt, const std::string& prop,
+ cmGeneratorExpressionInterpreter* genexInterpreter = nullptr);
template <>
bool getTypedProperty<bool>(cmGeneratorTarget const* tgt,
- const std::string& prop)
+ const std::string& prop,
+ cmGeneratorExpressionInterpreter* genexInterpreter)
{
- return tgt->GetPropertyAsBool(prop);
-}
+ if (genexInterpreter == nullptr) {
+ return tgt->GetPropertyAsBool(prop);
+ }
-template <>
-const char* getTypedProperty<const char*>(cmGeneratorTarget const* tgt,
- const std::string& prop)
-{
- return tgt->GetProperty(prop);
+ const char* value = tgt->GetProperty(prop);
+ return cmSystemTools::IsOn(genexInterpreter->Evaluate(value, prop));
}
-template <typename PropertyType>
-std::string valueAsString(PropertyType);
template <>
-std::string valueAsString<bool>(bool value)
+const char* getTypedProperty<const char*>(
+ cmGeneratorTarget const* tgt, const std::string& prop,
+ cmGeneratorExpressionInterpreter* genexInterpreter)
{
- return value ? "TRUE" : "FALSE";
+ const char* value = tgt->GetProperty(prop);
+
+ if (genexInterpreter == nullptr) {
+ return value;
+ }
+
+ return genexInterpreter->Evaluate(value, prop).c_str();
}
+
template <>
-std::string valueAsString<const char*>(const char* value)
+std::string getTypedProperty<std::string>(
+ cmGeneratorTarget const* tgt, const std::string& prop,
+ cmGeneratorExpressionInterpreter* genexInterpreter)
{
- return value ? value : "(unset)";
+ const char* value = tgt->GetProperty(prop);
+
+ if (genexInterpreter == nullptr) {
+ return valueAsString(value);
+ }
+
+ return genexInterpreter->Evaluate(value, prop);
}
template <typename PropertyType>
@@ -4310,6 +4378,12 @@ const char* impliedValue<const char*>(const char* /*unused*/)
{
return "";
}
+template <>
+std::string impliedValue<std::string>(
+ std::string /*unused*/) // NOLINT(clang-tidy)
+{
+ return std::string();
+}
template <typename PropertyType>
std::pair<bool, PropertyType> consistentProperty(PropertyType lhs,
@@ -4330,6 +4404,13 @@ std::pair<bool, const char*> consistentStringProperty(const char* lhs,
return std::make_pair(b, b ? lhs : nullptr);
}
+std::pair<bool, std::string> consistentStringProperty(const std::string& lhs,
+ const std::string& rhs)
+{
+ const bool b = lhs == rhs;
+ return std::make_pair(b, b ? lhs : valueAsString(nullptr));
+}
+
std::pair<bool, const char*> consistentNumberProperty(const char* lhs,
const char* rhs,
CompatibleType t)
@@ -4372,9 +4453,10 @@ std::pair<bool, const char*> consistentProperty(const char* lhs,
const char* const null_ptr = nullptr;
switch (t) {
- case BoolType:
- assert(false && "consistentProperty for strings called with BoolType");
- return std::pair<bool, const char*>(false, null_ptr);
+ case BoolType: {
+ bool same = cmSystemTools::IsOn(lhs) == cmSystemTools::IsOn(rhs);
+ return std::make_pair(same, same ? lhs : nullptr);
+ }
case StringType:
return consistentStringProperty(lhs, rhs);
case NumberMinType:
@@ -4385,6 +4467,40 @@ std::pair<bool, const char*> consistentProperty(const char* lhs,
return std::pair<bool, const char*>(false, null_ptr);
}
+std::pair<bool, std::string> consistentProperty(const std::string& lhs,
+ const std::string& rhs,
+ CompatibleType t)
+{
+ const std::string null_ptr = valueAsString(nullptr);
+
+ if (lhs == null_ptr && rhs == null_ptr) {
+ return std::make_pair(true, lhs);
+ }
+ if (lhs == null_ptr) {
+ return std::make_pair(true, rhs);
+ }
+ if (rhs == null_ptr) {
+ return std::make_pair(true, lhs);
+ }
+
+ switch (t) {
+ case BoolType: {
+ bool same = cmSystemTools::IsOn(lhs) == cmSystemTools::IsOn(rhs);
+ return std::make_pair(same, same ? lhs : null_ptr);
+ }
+ case StringType:
+ return consistentStringProperty(lhs, rhs);
+ case NumberMinType:
+ case NumberMaxType: {
+ auto value = consistentNumberProperty(lhs.c_str(), rhs.c_str(), t);
+ return std::make_pair(
+ value.first, value.first ? std::string(value.second) : null_ptr);
+ }
+ }
+ assert(false && "Unreachable!");
+ return std::pair<bool, std::string>(false, null_ptr);
+}
+
template <typename PropertyType>
PropertyType checkInterfacePropertyCompatibility(cmGeneratorTarget const* tgt,
const std::string& p,
@@ -4394,6 +4510,7 @@ PropertyType checkInterfacePropertyCompatibility(cmGeneratorTarget const* tgt,
PropertyType* /*unused*/)
{
PropertyType propContent = getTypedProperty<PropertyType>(tgt, p);
+
std::vector<std::string> headPropKeys = tgt->GetPropertyKeys();
const bool explicitlySet =
std::find(headPropKeys.begin(), headPropKeys.end(), p) !=
@@ -4423,6 +4540,11 @@ PropertyType checkInterfacePropertyCompatibility(cmGeneratorTarget const* tgt,
}
std::string interfaceProperty = "INTERFACE_" + p;
+ std::unique_ptr<cmGeneratorExpressionInterpreter> genexInterpreter(
+ p == "POSITION_INDEPENDENT_CODE" ? new cmGeneratorExpressionInterpreter(
+ tgt->GetLocalGenerator(), config, tgt)
+ : nullptr);
+
for (cmGeneratorTarget const* theTarget : deps) {
// An error should be reported if one dependency
// has INTERFACE_POSITION_INDEPENDENT_CODE ON and the other
@@ -4434,8 +4556,8 @@ PropertyType checkInterfacePropertyCompatibility(cmGeneratorTarget const* tgt,
const bool ifaceIsSet = std::find(propKeys.begin(), propKeys.end(),
interfaceProperty) != propKeys.end();
- PropertyType ifacePropContent =
- getTypedProperty<PropertyType>(theTarget, interfaceProperty);
+ PropertyType ifacePropContent = getTypedProperty<PropertyType>(
+ theTarget, interfaceProperty, genexInterpreter.get());
std::string reportEntry;
if (ifaceIsSet) {
@@ -4533,6 +4655,13 @@ bool cmGeneratorTarget::GetLinkInterfaceDependentBoolProperty(
BoolType, nullptr);
}
+std::string cmGeneratorTarget::GetLinkInterfaceDependentStringAsBoolProperty(
+ const std::string& p, const std::string& config) const
+{
+ return checkInterfacePropertyCompatibility<std::string>(
+ this, p, config, "FALSE", BoolType, nullptr);
+}
+
const char* cmGeneratorTarget::GetLinkInterfaceDependentStringProperty(
const std::string& p, const std::string& config) const
{
diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h
index 5e7cf12..52defee 100644
--- a/Source/cmGeneratorTarget.h
+++ b/Source/cmGeneratorTarget.h
@@ -173,6 +173,8 @@ public:
const char* GetFeature(const std::string& feature,
const std::string& config) const;
+ const char* GetLinkPIEProperty(const std::string& config) const;
+
bool IsIPOEnabled(std::string const& lang, std::string const& config) const;
bool IsLinkInterfaceDependentBoolProperty(const std::string& p,
@@ -789,6 +791,9 @@ private:
cmHeadToLinkInterfaceMap& GetHeadToLinkInterfaceUsageRequirementsMap(
std::string const& config) const;
+ std::string GetLinkInterfaceDependentStringAsBoolProperty(
+ const std::string& p, const std::string& config) const;
+
// Cache import information from properties for each configuration.
struct ImportInfo
{
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index b7a361e..8a38f9b 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -1755,6 +1755,26 @@ void cmGlobalXCodeGenerator::CreateCustomRulesMakefile(
}
}
+void cmGlobalXCodeGenerator::AddPositionIndependentLinkAttribute(
+ cmGeneratorTarget* target, cmXCodeObject* buildSettings,
+ const std::string& configName)
+{
+ // For now, only EXECUTABLE is concerned
+ if (target->GetType() != cmStateEnums::EXECUTABLE) {
+ return;
+ }
+
+ const char* PICValue = target->GetLinkPIEProperty(configName);
+ if (PICValue == nullptr) {
+ // POSITION_INDEPENDENT_CODE is not set
+ return;
+ }
+
+ buildSettings->AddAttribute(
+ "LD_NO_PIE",
+ this->CreateString(cmSystemTools::IsOn(PICValue) ? "NO" : "YES"));
+}
+
void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
cmXCodeObject* buildSettings,
const std::string& configName)
@@ -1806,6 +1826,9 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
buildSettings->AddAttribute("LLVM_LTO", this->CreateString(ltoValue));
}
+ // Handle PIE linker configuration
+ this->AddPositionIndependentLinkAttribute(gtgt, buildSettings, configName);
+
// Add define flags
this->CurrentLocalGenerator->AppendFlags(
defFlags, this->CurrentMakefile->GetDefineFlags());
diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h
index 62f7030..9b0d4fe 100644
--- a/Source/cmGlobalXCodeGenerator.h
+++ b/Source/cmGlobalXCodeGenerator.h
@@ -171,6 +171,9 @@ private:
const std::string& configName);
cmXCodeObject* CreateUtilityTarget(cmGeneratorTarget* gtgt);
void AddDependAndLinkInformation(cmXCodeObject* target);
+ void AddPositionIndependentLinkAttribute(cmGeneratorTarget* target,
+ cmXCodeObject* buildSettings,
+ const std::string& configName);
void CreateBuildSettings(cmGeneratorTarget* gtgt,
cmXCodeObject* buildSettings,
const std::string& buildType);
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index a703f4d..da48950 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -1201,6 +1201,8 @@ void cmLocalGenerator::GetTargetFlags(
break;
}
+ this->AppendPositionIndependentLinkerFlags(linkFlags, target, config,
+ linkLanguage);
this->AppendIPOLinkerFlags(linkFlags, target, config, linkLanguage);
}
@@ -2027,6 +2029,36 @@ void cmLocalGenerator::AppendIPOLinkerFlags(std::string& flags,
}
}
+void cmLocalGenerator::AppendPositionIndependentLinkerFlags(
+ std::string& flags, cmGeneratorTarget* target, const std::string& config,
+ const std::string& lang)
+{
+ // For now, only EXECUTABLE is concerned
+ if (target->GetType() != cmStateEnums::EXECUTABLE) {
+ return;
+ }
+
+ const char* PICValue = target->GetLinkPIEProperty(config);
+ if (PICValue == nullptr) {
+ // POSITION_INDEPENDENT_CODE is not set
+ return;
+ }
+
+ std::string name = "CMAKE_" + lang + "_LINK_OPTIONS_";
+ name += cmSystemTools::IsOn(PICValue) ? "PIE" : "NO_PIE";
+
+ auto pieFlags = this->Makefile->GetSafeDefinition(name);
+ if (pieFlags.empty()) {
+ return;
+ }
+
+ std::vector<std::string> flagsList;
+ cmSystemTools::ExpandListArgument(pieFlags, flagsList);
+ for (const auto& flag : flagsList) {
+ this->AppendFlagEscape(flags, flag);
+ }
+}
+
void cmLocalGenerator::AppendCompileOptions(std::string& options,
const char* options_list,
const char* regex) const
diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h
index 3dd6929..2fa0070 100644
--- a/Source/cmLocalGenerator.h
+++ b/Source/cmLocalGenerator.h
@@ -126,6 +126,10 @@ public:
void AppendIPOLinkerFlags(std::string& flags, cmGeneratorTarget* target,
const std::string& config,
const std::string& lang);
+ void AppendPositionIndependentLinkerFlags(std::string& flags,
+ cmGeneratorTarget* target,
+ const std::string& config,
+ const std::string& lang);
///! Get the include flags for the current makefile and language
std::string GetIncludeFlags(const std::vector<std::string>& includes,
cmGeneratorTarget* target,
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index 3c46784..9acae49 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -97,6 +97,9 @@ void cmMakefileTargetGenerator::GetTargetLinkFlags(
this->GeneratorTarget->GetLinkOptions(opts, this->ConfigName, linkLanguage);
// LINK_OPTIONS are escaped.
this->LocalGenerator->AppendCompileOptions(flags, opts);
+
+ this->LocalGenerator->AppendPositionIndependentLinkerFlags(
+ flags, this->GeneratorTarget, this->ConfigName, linkLanguage);
}
void cmMakefileTargetGenerator::CreateRuleFile()
diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h
index 5c27124..52ef470 100644
--- a/Source/cmPolicies.h
+++ b/Source/cmPolicies.h
@@ -244,7 +244,9 @@ class cmMakefile;
SELECT(POLICY, CMP0082, \
"Install rules from add_subdirectory() are interleaved with those " \
"in caller.", \
- 3, 14, 0, cmPolicies::WARN)
+ 3, 14, 0, cmPolicies::WARN) \
+ SELECT(POLICY, CMP0083, "Add PIE options when linking executable.", 3, 14, \
+ 0, cmPolicies::WARN)
#define CM_SELECT_ID(F, A1, A2, A3, A4, A5, A6) F(A1)
#define CM_FOR_EACH_POLICY_ID(POLICY) \
@@ -271,7 +273,8 @@ class cmMakefile;
F(CMP0069) \
F(CMP0073) \
F(CMP0076) \
- F(CMP0081)
+ F(CMP0081) \
+ F(CMP0083)
/** \class cmPolicies
* \brief Handles changes in CMake behavior and policies
diff --git a/Source/cmVS141CLFlagTable.h b/Source/cmVS141CLFlagTable.h
index 2a9944a..7d219be 100644
--- a/Source/cmVS141CLFlagTable.h
+++ b/Source/cmVS141CLFlagTable.h
@@ -194,6 +194,8 @@ static cmVS7FlagTable cmVS141CLFlagTable[] = {
{ "EnablePREfast", "analyze", "", "true", 0 },
{ "UseFullPaths", "FC", "", "true", 0 },
{ "OmitDefaultLibName", "Zl", "", "true", 0 },
+ { "SupportJustMyCode", "JMC-", "", "false", 0 },
+ { "SupportJustMyCode", "JMC", "", "true", 0 },
// Bool Properties With Argument
{ "MultiProcessorCompilation", "MP", "", "true",
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index e23926f..b6b6519 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -190,7 +190,8 @@ add_RunCMake_test(PolicyScope)
add_RunCMake_test(WriteCompilerDetectionHeader)
add_RunCMake_test(SourceProperties)
if(NOT WIN32)
- add_RunCMake_test(PositionIndependentCode)
+ add_RunCMake_test(PositionIndependentCode -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}
+ -DCMAKE_CXX_COMPILER_ID=${CMAKE_CXX_COMPILER_ID})
endif()
if(NOT CMAKE_GENERATOR MATCHES "Visual Studio")
add_RunCMake_test(VisibilityPreset)
diff --git a/Tests/RunCMake/PositionIndependentCode/CMP0083-cmp0083_new-check.cmake b/Tests/RunCMake/PositionIndependentCode/CMP0083-cmp0083_new-check.cmake
new file mode 100644
index 0000000..255e63d
--- /dev/null
+++ b/Tests/RunCMake/PositionIndependentCode/CMP0083-cmp0083_new-check.cmake
@@ -0,0 +1,22 @@
+
+include ("${RunCMake_TEST_BINARY_DIR}/${RunCMake_TEST_CONFIG}/CMP0083_config.cmake")
+
+
+# retrieve default type of executable
+check_executable ("${cmp0083_ref}" ref)
+
+if (ref STREQUAL "PIE")
+ # check no_pie executable is really no position independent
+ check_executable ("${cmp0083_new_no_pie}" new_no_pie)
+ if (NOT new_no_pie STREQUAL "NO_PIE")
+ set (RunCMake_TEST_FAILED "CMP0083(NEW) do not produce expected executable.")
+ endif()
+elseif (ref STREQUAL "NO_PIE")
+ # check pie executable is really position independent
+ check_executable ("${cmp0083_new_pie}" new_pie)
+ if (NOT new_pie MATCHES "PIE")
+ set (RunCMake_TEST_FAILED "CMP0083(NEW) do not produce expected executable.")
+ endif()
+else()
+ set (RunCMake_TEST_FAILED "CMP0083(NEW) unexpected result.")
+endif()
diff --git a/Tests/RunCMake/PositionIndependentCode/CMP0083-cmp0083_old-check.cmake b/Tests/RunCMake/PositionIndependentCode/CMP0083-cmp0083_old-check.cmake
new file mode 100644
index 0000000..b66b672
--- /dev/null
+++ b/Tests/RunCMake/PositionIndependentCode/CMP0083-cmp0083_old-check.cmake
@@ -0,0 +1,20 @@
+
+include ("${RunCMake_TEST_BINARY_DIR}/${RunCMake_TEST_CONFIG}/CMP0083_config.cmake")
+
+
+# retrieve default type of executable
+check_executable ("${cmp0083_ref}" ref)
+
+# POSITION_INDEPENDENT_CODE must not have influence on executable
+# pie and no_pie executable must have same type as reference
+check_executable ("${cmp0083_old_pie}" old_pie)
+if (NOT old_pie STREQUAL ref)
+ set (RunCMake_TEST_FAILED "CMP0083(OLD) do not produce expected executable.")
+ return()
+endif()
+
+check_executable ("${cmp0083_old_no_pie}" old_no_pie)
+if (NOT old_no_pie STREQUAL ref)
+ set (RunCMake_TEST_FAILED "CMP0083(OLD) do not produce expected executable.")
+ return()
+endif()
diff --git a/Tests/RunCMake/PositionIndependentCode/CMP0083.cmake b/Tests/RunCMake/PositionIndependentCode/CMP0083.cmake
new file mode 100644
index 0000000..9713ea4
--- /dev/null
+++ b/Tests/RunCMake/PositionIndependentCode/CMP0083.cmake
@@ -0,0 +1,45 @@
+
+# create reference to detect default : PIE or not
+add_executable (cmp0083_ref main.cpp)
+
+
+set (CMAKE_POSITION_INDEPENDENT_CODE ON)
+
+cmake_policy(SET CMP0083 NEW)
+add_executable (cmp0083_new_pie main.cpp)
+
+
+cmake_policy(SET CMP0083 OLD)
+add_executable (cmp0083_old_pie main.cpp)
+
+
+set (CMAKE_POSITION_INDEPENDENT_CODE OFF)
+
+cmake_policy(SET CMP0083 NEW)
+add_executable (cmp0083_new_no_pie main.cpp)
+
+
+cmake_policy(SET CMP0083 OLD)
+add_executable (cmp0083_old_no_pie main.cpp)
+
+# high-level targets
+add_custom_target(cmp0083_new)
+add_dependencies(cmp0083_new cmp0083_ref cmp0083_new_pie cmp0083_new_no_pie)
+
+# high-level targets
+add_custom_target(cmp0083_old)
+add_dependencies(cmp0083_old cmp0083_ref cmp0083_old_pie cmp0083_old_no_pie)
+
+
+# generate file holding paths to executables
+file (GENERATE OUTPUT "${CMAKE_BINARY_DIR}/$<CONFIG>/CMP0083_config.cmake"
+ CONTENT
+[==[
+include ("${RunCMake_TEST_SOURCE_DIR}/PIE_validator.cmake")
+
+set (cmp0083_ref "$<TARGET_FILE:cmp0083_ref>")
+set (cmp0083_new_pie "$<TARGET_FILE:cmp0083_new_pie>")
+set (cmp0083_old_pie "$<TARGET_FILE:cmp0083_old_pie>")
+set (cmp0083_new_no_pie "$<TARGET_FILE:cmp0083_new_no_pie>")
+set (cmp0083_old_no_pie "$<TARGET_FILE:cmp0083_old_no_pie>")
+]==])
diff --git a/Tests/RunCMake/PositionIndependentCode/CheckPIESupported.cmake b/Tests/RunCMake/PositionIndependentCode/CheckPIESupported.cmake
new file mode 100644
index 0000000..1e0a2c9
--- /dev/null
+++ b/Tests/RunCMake/PositionIndependentCode/CheckPIESupported.cmake
@@ -0,0 +1,12 @@
+
+if (CMAKE_CXX_LINK_OPTIONS_PIE)
+ file(WRITE "${PIE_SUPPORTED}" "\nset(PIE_SUPPORTED TRUE)\n")
+else()
+ file(WRITE "${PIE_SUPPORTED}" "\nset(PIE_SUPPORTED FALSE)\n")
+endif()
+
+if (CMAKE_CXX_LINK_OPTIONS_NO_PIE)
+ file(APPEND "${PIE_SUPPORTED}" "\nset(NO_PIE_SUPPORTED TRUE)\n")
+else()
+ file(APPEND "${PIE_SUPPORTED}" "\nset(NO_PIE_SUPPORTED FALSE)\n")
+endif()
diff --git a/Tests/RunCMake/PositionIndependentCode/Genex1-result.txt b/Tests/RunCMake/PositionIndependentCode/Genex1-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/PositionIndependentCode/Genex1-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/PositionIndependentCode/Genex1-stderr.txt b/Tests/RunCMake/PositionIndependentCode/Genex1-stderr.txt
new file mode 100644
index 0000000..c242a05
--- /dev/null
+++ b/Tests/RunCMake/PositionIndependentCode/Genex1-stderr.txt
@@ -0,0 +1,3 @@
+CMake Error: Property POSITION_INDEPENDENT_CODE on target "conflict1" does
+not match the INTERFACE_POSITION_INDEPENDENT_CODE property requirement
+of dependency "genex_pic".
diff --git a/Tests/RunCMake/PositionIndependentCode/Genex1.cmake b/Tests/RunCMake/PositionIndependentCode/Genex1.cmake
new file mode 100644
index 0000000..a91be3e
--- /dev/null
+++ b/Tests/RunCMake/PositionIndependentCode/Genex1.cmake
@@ -0,0 +1,9 @@
+
+add_library(genex_pic UNKNOWN IMPORTED)
+# PIC is ON if sibling target is a library, OFF if it is an executable
+set_property(TARGET genex_pic PROPERTY INTERFACE_POSITION_INDEPENDENT_CODE $<NOT:$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>>)
+
+
+add_library(conflict1 STATIC main.cpp)
+set_property(TARGET conflict1 PROPERTY POSITION_INDEPENDENT_CODE OFF)
+target_link_libraries(conflict1 PRIVATE genex_pic)
diff --git a/Tests/RunCMake/PositionIndependentCode/Genex2-result.txt b/Tests/RunCMake/PositionIndependentCode/Genex2-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/PositionIndependentCode/Genex2-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/PositionIndependentCode/Genex2-stderr.txt b/Tests/RunCMake/PositionIndependentCode/Genex2-stderr.txt
new file mode 100644
index 0000000..735a926
--- /dev/null
+++ b/Tests/RunCMake/PositionIndependentCode/Genex2-stderr.txt
@@ -0,0 +1,3 @@
+CMake Error: Property POSITION_INDEPENDENT_CODE on target "conflict2" does
+not match the INTERFACE_POSITION_INDEPENDENT_CODE property requirement
+of dependency "genex_pic".
diff --git a/Tests/RunCMake/PositionIndependentCode/Genex2.cmake b/Tests/RunCMake/PositionIndependentCode/Genex2.cmake
new file mode 100644
index 0000000..fb0a5db
--- /dev/null
+++ b/Tests/RunCMake/PositionIndependentCode/Genex2.cmake
@@ -0,0 +1,9 @@
+
+add_library(genex_pic UNKNOWN IMPORTED)
+# PIC is ON if sibling target is a library, OFF if it is an executable
+set_property(TARGET genex_pic PROPERTY INTERFACE_POSITION_INDEPENDENT_CODE $<NOT:$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>>)
+
+
+add_executable(conflict2 main.cpp)
+set_property(TARGET conflict2 PROPERTY POSITION_INDEPENDENT_CODE ON)
+target_link_libraries(conflict2 PRIVATE genex_pic)
diff --git a/Tests/RunCMake/PositionIndependentCode/PIE-pie_off-check.cmake b/Tests/RunCMake/PositionIndependentCode/PIE-pie_off-check.cmake
new file mode 100644
index 0000000..096395c
--- /dev/null
+++ b/Tests/RunCMake/PositionIndependentCode/PIE-pie_off-check.cmake
@@ -0,0 +1,7 @@
+
+include ("${RunCMake_TEST_BINARY_DIR}/${RunCMake_TEST_CONFIG}/PIE_config.cmake")
+
+check_executable ("${pie_off}" status)
+if (NOT status STREQUAL "NO_PIE")
+ set (RunCMake_TEST_FAILED "Executable is NOT 'no PIE' (${status}).")
+endif()
diff --git a/Tests/RunCMake/PositionIndependentCode/PIE-pie_on-check.cmake b/Tests/RunCMake/PositionIndependentCode/PIE-pie_on-check.cmake
new file mode 100644
index 0000000..bf3d018
--- /dev/null
+++ b/Tests/RunCMake/PositionIndependentCode/PIE-pie_on-check.cmake
@@ -0,0 +1,7 @@
+
+include ("${RunCMake_TEST_BINARY_DIR}/${RunCMake_TEST_CONFIG}/PIE_config.cmake")
+
+check_executable ("${pie_on}" status)
+if (NOT status STREQUAL "PIE")
+ set (RunCMake_TEST_FAILED "Executable is NOT 'PIE' (${status}).")
+endif()
diff --git a/Tests/RunCMake/PositionIndependentCode/PIE.cmake b/Tests/RunCMake/PositionIndependentCode/PIE.cmake
new file mode 100644
index 0000000..a9d579d
--- /dev/null
+++ b/Tests/RunCMake/PositionIndependentCode/PIE.cmake
@@ -0,0 +1,19 @@
+
+cmake_policy(SET CMP0083 NEW)
+
+add_executable (pie_on main.cpp)
+set_property(TARGET pie_on PROPERTY POSITION_INDEPENDENT_CODE ON)
+
+add_executable (pie_off main.cpp)
+set_property(TARGET pie_off PROPERTY POSITION_INDEPENDENT_CODE OFF)
+
+
+# generate file holding paths to executables
+file (GENERATE OUTPUT "${CMAKE_BINARY_DIR}/$<CONFIG>/PIE_config.cmake"
+ CONTENT
+[==[
+include ("${RunCMake_TEST_SOURCE_DIR}/PIE_validator.cmake")
+
+set (pie_on "$<TARGET_FILE:pie_on>")
+set (pie_off "$<TARGET_FILE:pie_off>")
+]==])
diff --git a/Tests/RunCMake/PositionIndependentCode/PIE_validator.cmake b/Tests/RunCMake/PositionIndependentCode/PIE_validator.cmake
new file mode 100644
index 0000000..7be35db
--- /dev/null
+++ b/Tests/RunCMake/PositionIndependentCode/PIE_validator.cmake
@@ -0,0 +1,32 @@
+
+include_guard(GLOBAL)
+
+function (CHECK_EXECUTABLE executable result)
+ set (${result} "UNKNOWN" PARENT_SCOPE)
+
+ if (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
+ set (tool otool -hv)
+ else()
+ set (tool "${CMAKE_COMMAND}" -E env LANG=C LC_ALL=C readelf -lW)
+ endif()
+
+ execute_process(COMMAND ${tool} "${executable}"
+ OUTPUT_VARIABLE output
+ ERROR_VARIABLE output)
+
+ if (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
+ if (output MATCHES "( |\t)PIE( |\n|$)")
+ set (${result} "PIE" PARENT_SCOPE)
+ else()
+ set (${result} "NO_PIE" PARENT_SCOPE)
+ endif()
+ else()
+ if (output MATCHES "Elf file type is DYN")
+ set (${result} "PIE" PARENT_SCOPE)
+ elseif (output MATCHES "Elf file type is EXEC")
+ set (${result} "NO_PIE" PARENT_SCOPE)
+ else()
+ message(SEND_ERROR "Did not find a known file type")
+ endif()
+ endif()
+endfunction()
diff --git a/Tests/RunCMake/PositionIndependentCode/RunCMakeTest.cmake b/Tests/RunCMake/PositionIndependentCode/RunCMakeTest.cmake
index 6a67e3c..6efa0d4 100644
--- a/Tests/RunCMake/PositionIndependentCode/RunCMakeTest.cmake
+++ b/Tests/RunCMake/PositionIndependentCode/RunCMakeTest.cmake
@@ -7,3 +7,67 @@ run_cmake(Conflict4)
run_cmake(Conflict5)
run_cmake(Conflict6)
run_cmake(Debug)
+run_cmake(Genex1)
+run_cmake(Genex2)
+
+set(RunCMake_TEST_OPTIONS "-DPIE_SUPPORTED=${RunCMake_BINARY_DIR}/PIESupported.cmake")
+run_cmake(CheckPIESupported)
+include ("${RunCMake_BINARY_DIR}/PIESupported.cmake" OPTIONAL)
+
+if (PIE_SUPPORTED OR NO_PIE_SUPPORTED)
+ if (CMAKE_SYSTEM_NAME MATCHES "^(Linux|(Free|Net|Open)BSD)$")
+ # try to locate readelf needed for validation
+ find_program (READELF NAMES readelf)
+ endif()
+ if (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
+ # try to locate otool needed for validation
+ find_program (OTOOL NAMES otool)
+ endif()
+
+ if ((READELF OR OTOOL) AND
+ (CMAKE_CXX_COMPILER_ID STREQUAL "GNU"
+ OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang"
+ OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang"))
+ macro(run_cmake_target test subtest)
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${test}-build)
+ set(RunCMake_TEST_NO_CLEAN 1)
+ set(RunCMake_TEST_CONFIG Release)
+ run_cmake_command(${test}-${subtest} ${CMAKE_COMMAND} --build . --config Release --target ${subtest} ${ARGN})
+
+ unset(RunCMake_TEST_BINARY_DIR)
+ unset(RunCMake_TEST_NO_CLEAN)
+ endmacro()
+
+ set(RunCMake_TEST_SOURCE_DIR "${RunCMake_SOURCE_DIR}")
+ set(RunCMake_TEST_OUTPUT_MERGE TRUE)
+ if (NOT RunCMake_GENERATOR_IS_MULTI_CONFIG)
+ set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Release)
+ endif()
+
+ run_cmake(PIE)
+ if (PIE_SUPPORTED)
+ run_cmake_target(PIE pie_on)
+ endif()
+ if (NO_PIE_SUPPORTED)
+ run_cmake_target(PIE pie_off)
+ endif()
+
+ run_cmake(CMP0083)
+ run_cmake_target(CMP0083 cmp0083_ref)
+
+ # retrieve default mode
+ include("${RunCMake_SOURCE_DIR}/PIE_validator.cmake")
+ include("${RunCMake_BINARY_DIR}/CMP0083-build/Release/CMP0083_config.cmake")
+ check_executable("${cmp0083_ref}" cmp0083_ref_mode)
+
+ if ((cmp0083_ref_mode STREQUAL "PIE" AND NO_PIE_SUPPORTED)
+ OR (cmp0083_ref_mode STREQUAL "NO_PIE" AND PIE_SUPPORTED))
+ run_cmake_target(CMP0083 cmp0083_new)
+ endif()
+ run_cmake_target(CMP0083 cmp0083_old)
+
+ unset(RunCMake_TEST_SOURCE_DIR)
+ unset(RunCMake_TEST_OPTIONS)
+ unset(RunCMake_TEST_OUTPUT_MERGE)
+ endif()
+endif()
diff --git a/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt b/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt
index 2441a9c..0bcf886 100644
--- a/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt
+++ b/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt
@@ -26,6 +26,7 @@
\* CMP0073
\* CMP0076
\* CMP0081
+ \* CMP0083
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
diff --git a/Tests/Unset/CMakeLists.txt b/Tests/Unset/CMakeLists.txt
index 07aa68e..a40367b 100644
--- a/Tests/Unset/CMakeLists.txt
+++ b/Tests/Unset/CMakeLists.txt
@@ -21,17 +21,26 @@ set(x 43)
if(NOT x EQUAL 43)
message(FATAL_ERROR "x!=43")
endif()
+if(DEFINED CACHE{x})
+ message(FATAL_ERROR "x shouldn't be found in the cache")
+endif()
+
set(x)
if(DEFINED x)
message(FATAL_ERROR "x should be undefined now!")
endif()
+
# Cache variable
set(BAR "test" CACHE STRING "documentation")
if(NOT DEFINED BAR)
message(FATAL_ERROR "BAR not defined")
endif()
+if(NOT DEFINED CACHE{BAR})
+ message(FATAL_ERROR "BAR could not be found by CACHE{BAR}")
+endif()
+
# Test interaction of cache entries with variables.
set(BAR "test-var")
if(NOT "$CACHE{BAR}" STREQUAL "test")
diff --git a/Utilities/Scripts/BoostScanDeps.cmake b/Utilities/Scripts/BoostScanDeps.cmake
index bd2e6a8..28a94ce 100644
--- a/Utilities/Scripts/BoostScanDeps.cmake
+++ b/Utilities/Scripts/BoostScanDeps.cmake
@@ -51,12 +51,12 @@ function(_Boost_FIND_COMPONENT_DEPENDENCIES component includedir _ret_libs)
# Special-case since it is part of mpi; look only in boost/mpi/python*
if(component STREQUAL "mpi_python")
- set(_boost_DEPS "python")
+ set(_boost_DEPS "python\${component_python_version}")
set(library_component TRUE)
set(_boost_unprocessed_headers ${_boost_mpi_python_headers})
# Special-case since it is part of python; look only in boost/python/numpy*
elseif(component STREQUAL "numpy")
- set(_boost_DEPS "python")
+ set(_boost_DEPS "python\${component_python_version}")
set(library_component TRUE)
set(_boost_unprocessed_headers ${_boost_python_numpy_headers})
# Special-case since it is a serialization variant; look in boost/serialization