[Cmake-commits] CMake branch, next, updated. v3.8.0-rc1-209-ged67fe7
Brad King
brad.king at kitware.com
Thu Feb 16 13:21:51 EST 2017
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".
The branch, next has been updated
via ed67fe7451a5ebdf179bbfc5c2517f0e19e651d6 (commit)
via 1ba91291e3237e5535a46c6ff1bce6a33d298a76 (commit)
via f7b9bf41c5386dfc38b7a722f75b0e23a02d542b (commit)
via 4bff2d14fd3010ba4aa1bfc3eda2fb2cdcc5da0f (commit)
via 624fb9d7175ee011f8a86c8d7614be4806a53184 (commit)
from 5dc1ca679d48a4ef7ef0cd5c987e077bb75915c2 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ed67fe7451a5ebdf179bbfc5c2517f0e19e651d6
commit ed67fe7451a5ebdf179bbfc5c2517f0e19e651d6
Merge: 5dc1ca6 1ba9129
Author: Brad King <brad.king at kitware.com>
AuthorDate: Thu Feb 16 13:21:49 2017 -0500
Commit: CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Thu Feb 16 13:21:49 2017 -0500
Merge topic 'install_name_policy' into next
1ba91291 Add policy CMP0068 separate install_name and RPATH settings on macOS
f7b9bf41 Apple: Add BUILD_WITH_INSTALL_NAME_DIR target property
4bff2d14 Apple: Refactor support for using INSTALL_NAME_DIR.
624fb9d7 Help: Format BUILD_WITH_INSTALL_RPATH documentation
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1ba91291e3237e5535a46c6ff1bce6a33d298a76
commit 1ba91291e3237e5535a46c6ff1bce6a33d298a76
Author: Clinton Stimpson <clinton at elemtech.com>
AuthorDate: Thu Feb 9 08:12:10 2017 -0700
Commit: Clinton Stimpson <clinton at elemtech.com>
CommitDate: Tue Feb 14 14:28:07 2017 -0700
Add policy CMP0068 separate install_name and RPATH settings on macOS
BUILD_WITH_INSTALL_RPATH, SKIP_BUILD_RPATH, CMAKE_SKIP_RPATH and
CMAKE_SKIP_INSTALL_RPATH no longer any effect on the install name
of a target on macOS.
Fixes: #16589
diff --git a/Help/manual/cmake-policies.7.rst b/Help/manual/cmake-policies.7.rst
index 3266958..0c9ee2d 100644
--- a/Help/manual/cmake-policies.7.rst
+++ b/Help/manual/cmake-policies.7.rst
@@ -51,6 +51,14 @@ The :variable:`CMAKE_MINIMUM_REQUIRED_VERSION` variable may also be used
to determine whether to report an error on use of deprecated macros or
functions.
+Policies Introduced by CMake 3.9
+================================
+
+.. toctree::
+ :maxdepth: 1
+
+ CMP0068: RPATH settings on macOS do not affect install_name. </policy/CMP0068>
+
Policies Introduced by CMake 3.8
================================
diff --git a/Help/policy/CMP0068.rst b/Help/policy/CMP0068.rst
new file mode 100644
index 0000000..978a6e3
--- /dev/null
+++ b/Help/policy/CMP0068.rst
@@ -0,0 +1,35 @@
+CMP0068
+-------
+
+``RPATH`` settings on macOS do not affect ``install_name``.
+
+CMake 3.9 and newer remove any effect the following settings may have on the
+``install_name`` of a target on macOS:
+
+* :prop_tgt:`BUILD_WITH_INSTALL_RPATH` target property
+* :prop_tgt:`SKIP_BUILD_RPATH` target property
+* :variable:`CMAKE_SKIP_RPATH` variable
+* :variable:`CMAKE_SKIP_INSTALL_RPATH` variable
+
+Previously, setting :prop_tgt:`BUILD_WITH_INSTALL_RPATH` had the effect of
+setting both the ``install_name`` of a target to :prop_tgt:`INSTALL_NAME_DIR`
+and the ``RPATH`` to :prop_tgt:`INSTALL_RPATH`. In CMake 3.9, it only affects
+setting of ``RPATH``. However, if one wants :prop_tgt:`INSTALL_NAME_DIR` to
+apply to the target in the build tree, one may set
+:prop_tgt:`BUILD_WITH_INSTALL_NAME_DIR`.
+
+If :prop_tgt:`SKIP_BUILD_RPATH`, :variable:`CMAKE_SKIP_RPATH` or
+:variable:`CMAKE_SKIP_INSTALL_RPATH` were used to strip the directory portion
+of the ``install_name`` of a target, one may set ``INSTALL_NAME_DIR=""``
+instead.
+
+The ``OLD`` behavior of this policy is to use the ``RPATH`` settings for
+``install_name`` on macOS. The ``NEW`` behavior of this policy is to ignore
+the ``RPATH`` settings for ``install_name`` on macOS.
+
+This policy was introduced in CMake version 3.9. 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/BUILD_WITH_INSTALL_NAME_DIR.rst b/Help/prop_tgt/BUILD_WITH_INSTALL_NAME_DIR.rst
index 7e02518..bbb9a24 100644
--- a/Help/prop_tgt/BUILD_WITH_INSTALL_NAME_DIR.rst
+++ b/Help/prop_tgt/BUILD_WITH_INSTALL_NAME_DIR.rst
@@ -9,5 +9,5 @@ This property is initialized by the value of the variable
:variable:`CMAKE_BUILD_WITH_INSTALL_NAME_DIR` if it is set when a target is
created.
-If this property is not set, the value of :prop_tgt:`BUILD_WITH_INSTALL_RPATH`
-is used in its place.
+If this property is not set and policy :policy:`CMP0068` is not ``NEW``, the
+value of :prop_tgt:`BUILD_WITH_INSTALL_RPATH` is used in its place.
diff --git a/Help/prop_tgt/BUILD_WITH_INSTALL_RPATH.rst b/Help/prop_tgt/BUILD_WITH_INSTALL_RPATH.rst
index 97c3736..0244351 100644
--- a/Help/prop_tgt/BUILD_WITH_INSTALL_RPATH.rst
+++ b/Help/prop_tgt/BUILD_WITH_INSTALL_RPATH.rst
@@ -10,6 +10,6 @@ This property is initialized by the value of the
:variable:`CMAKE_BUILD_WITH_INSTALL_RPATH` variable if it is set when a target
is created.
-This property also controls use of :prop_tgt:`INSTALL_NAME_DIR` in the build
-tree on macOS, but defers to the :prop_tgt:`BUILD_WITH_INSTALL_NAME_DIR` target
-property if the latter is set.
+If policy :policy:`CMP0068` is not ``NEW``, this property also controls use of
+:prop_tgt:`INSTALL_NAME_DIR` in the build tree on macOS. Either way, the
+:prop_tgt:`BUILD_WITH_INSTALL_NAME_DIR` target property takes precedence.
diff --git a/Help/release/dev/install_name_policy.rst b/Help/release/dev/install_name_policy.rst
index 71bdf35..7fe9a86 100644
--- a/Help/release/dev/install_name_policy.rst
+++ b/Help/release/dev/install_name_policy.rst
@@ -6,3 +6,6 @@ install_name_policy
control whether to use the :prop_tgt:`INSTALL_NAME_DIR` target property
value for binaries in the build tree. This is for macOS ``install_name``
as :prop_tgt:`BUILD_WITH_INSTALL_RPATH` is for ``RPATH``.
+
+* On macOS, ``RPATH`` settings such as :prop_tgt:`BUILD_WITH_INSTALL_RPATH`
+ no longer affect the ``install_name`` field. See policy :policy:`CMP0068`.
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index d32bcd8..8512b99 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -1402,14 +1402,30 @@ bool cmGeneratorTarget::MacOSXUseInstallNameDir() const
return cmSystemTools::IsOn(build_with_install_name);
}
+ cmPolicies::PolicyStatus cmp0068 = this->GetPolicyStatusCMP0068();
+ if (cmp0068 == cmPolicies::NEW) {
+ return false;
+ }
+
bool use_install_name = this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH");
+ if (use_install_name && cmp0068 == cmPolicies::WARN) {
+ this->LocalGenerator->GetGlobalGenerator()->AddCMP0068WarnTarget(
+ this->GetName());
+ }
+
return use_install_name;
}
bool cmGeneratorTarget::CanGenerateInstallNameDir(
InstallNameType name_type) const
{
+ cmPolicies::PolicyStatus cmp0068 = this->GetPolicyStatusCMP0068();
+
+ if (cmp0068 == cmPolicies::NEW) {
+ return true;
+ }
+
bool skip = this->Makefile->IsOn("CMAKE_SKIP_RPATH");
if (name_type == INSTALL_NAME_FOR_INSTALL) {
skip |= this->Makefile->IsOn("CMAKE_SKIP_INSTALL_RPATH");
@@ -1417,6 +1433,11 @@ bool cmGeneratorTarget::CanGenerateInstallNameDir(
skip |= this->GetPropertyAsBool("SKIP_BUILD_RPATH");
}
+ if (skip && cmp0068 == cmPolicies::WARN) {
+ this->LocalGenerator->GetGlobalGenerator()->AddCMP0068WarnTarget(
+ this->GetName());
+ }
+
return !skip;
}
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index f118250..b6b7d9e 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -1194,6 +1194,11 @@ void cmGlobalGenerator::AddCMP0042WarnTarget(const std::string& target)
this->CMP0042WarnTargets.insert(target);
}
+void cmGlobalGenerator::AddCMP0068WarnTarget(const std::string& target)
+{
+ this->CMP0068WarnTargets.insert(target);
+}
+
bool cmGlobalGenerator::CheckALLOW_DUPLICATE_CUSTOM_TARGETS() const
{
// If the property is not enabled then okay.
@@ -1235,6 +1240,8 @@ bool cmGlobalGenerator::Compute()
// clear targets to issue warning CMP0042 for
this->CMP0042WarnTargets.clear();
+ // clear targets to issue warning CMP0068 for
+ this->CMP0068WarnTargets.clear();
// Check whether this generator is allowed to run.
if (!this->CheckALLOW_DUPLICATE_CUSTOM_TARGETS()) {
@@ -1366,6 +1373,24 @@ void cmGlobalGenerator::Generate()
this->GetCMakeInstance()->IssueMessage(cmake::AUTHOR_WARNING, w.str());
}
+ if (!this->CMP0068WarnTargets.empty()) {
+ std::ostringstream w;
+ /* clang-format off */
+ w <<
+ cmPolicies::GetPolicyWarning(cmPolicies::CMP0068) << "\n"
+ "For compatibility with older versions of CMake, the install_name "
+ "fields for the following targets are still affected by RPATH "
+ "settings:\n"
+ ;
+ /* clang-format on */
+ for (std::set<std::string>::iterator iter =
+ this->CMP0068WarnTargets.begin();
+ iter != this->CMP0068WarnTargets.end(); ++iter) {
+ w << " " << *iter << "\n";
+ }
+ this->GetCMakeInstance()->IssueMessage(cmake::AUTHOR_WARNING, w.str());
+ }
+
this->CMakeInstance->UpdateProgress("Generating done", -1);
}
diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h
index 18e3730..b3cb41f 100644
--- a/Source/cmGlobalGenerator.h
+++ b/Source/cmGlobalGenerator.h
@@ -357,6 +357,7 @@ public:
cmExportBuildFileGenerator* GetExportedTargetsFile(
const std::string& filename) const;
void AddCMP0042WarnTarget(const std::string& target);
+ void AddCMP0068WarnTarget(const std::string& target);
virtual void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const;
@@ -562,6 +563,8 @@ private:
// track targets to issue CMP0042 warning for.
std::set<std::string> CMP0042WarnTargets;
+ // track targets to issue CMP0068 warning for.
+ std::set<std::string> CMP0068WarnTargets;
mutable std::map<cmSourceFile*, std::set<cmGeneratorTarget const*> >
FilenameTargetDepends;
diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h
index 62e67c7..ecf06b3 100644
--- a/Source/cmPolicies.h
+++ b/Source/cmPolicies.h
@@ -200,7 +200,10 @@ class cmMakefile;
7, 0, cmPolicies::WARN) \
SELECT(POLICY, CMP0067, \
"Honor language standard in try_compile() source-file signature.", \
- 3, 8, 0, cmPolicies::WARN)
+ 3, 8, 0, cmPolicies::WARN) \
+ SELECT(POLICY, CMP0068, \
+ "RPATH settings on macOS do not affect install_name.", 3, 9, 0, \
+ cmPolicies::WARN)
#define CM_SELECT_ID(F, A1, A2, A3, A4, A5, A6) F(A1)
#define CM_FOR_EACH_POLICY_ID(POLICY) \
@@ -221,7 +224,8 @@ class cmMakefile;
F(CMP0052) \
F(CMP0060) \
F(CMP0063) \
- F(CMP0065)
+ F(CMP0065) \
+ F(CMP0068)
/** \class cmPolicies
* \brief Handles changes in CMake behavior and policies
diff --git a/Tests/RunCMake/CMP0068/CMP0068-NEW-result.txt b/Tests/RunCMake/CMP0068/CMP0068-NEW-result.txt
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/Tests/RunCMake/CMP0068/CMP0068-NEW-result.txt
@@ -0,0 +1 @@
+0
diff --git a/Tests/RunCMake/CMP0068/CMP0068-NEW.cmake b/Tests/RunCMake/CMP0068/CMP0068-NEW.cmake
new file mode 100644
index 0000000..eb8cfa1
--- /dev/null
+++ b/Tests/RunCMake/CMP0068/CMP0068-NEW.cmake
@@ -0,0 +1,6 @@
+
+cmake_policy(SET CMP0068 NEW)
+cmake_policy(SET CMP0042 NEW)
+
+add_library(foo SHARED empty.cpp)
+set_target_properties(foo PROPERTIES INSTALL_NAME_DIR "@rpath" INSTALL_RPATH "@loader_path/" BUILD_WITH_INSTALL_RPATH 1)
diff --git a/Tests/RunCMake/CMP0068/CMP0068-OLD-result.txt b/Tests/RunCMake/CMP0068/CMP0068-OLD-result.txt
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/Tests/RunCMake/CMP0068/CMP0068-OLD-result.txt
@@ -0,0 +1 @@
+0
diff --git a/Tests/RunCMake/CMP0068/CMP0068-OLD.cmake b/Tests/RunCMake/CMP0068/CMP0068-OLD.cmake
new file mode 100644
index 0000000..cf1040f
--- /dev/null
+++ b/Tests/RunCMake/CMP0068/CMP0068-OLD.cmake
@@ -0,0 +1,6 @@
+
+cmake_policy(SET CMP0068 OLD)
+cmake_policy(SET CMP0042 NEW)
+
+add_library(foo SHARED empty.cpp)
+set_target_properties(foo PROPERTIES INSTALL_NAME_DIR "@rpath" INSTALL_RPATH "@loader_path/" BUILD_WITH_INSTALL_RPATH 1)
diff --git a/Tests/RunCMake/CMP0068/CMP0068-WARN-result.txt b/Tests/RunCMake/CMP0068/CMP0068-WARN-result.txt
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/Tests/RunCMake/CMP0068/CMP0068-WARN-result.txt
@@ -0,0 +1 @@
+0
diff --git a/Tests/RunCMake/CMP0068/CMP0068-WARN-stderr.txt b/Tests/RunCMake/CMP0068/CMP0068-WARN-stderr.txt
new file mode 100644
index 0000000..3cb5854
--- /dev/null
+++ b/Tests/RunCMake/CMP0068/CMP0068-WARN-stderr.txt
@@ -0,0 +1,12 @@
+CMake Warning \(dev\):
+ Policy CMP0068 is not set: RPATH settings on macOS do not affect
+ install_name. Run "cmake --help-policy CMP0068" for policy details. Use
+ the cmake_policy command to set the policy and suppress this warning.
+
+ For compatibility with older versions of CMake, the install_name fields for
+ the following targets are still affected by RPATH settings:
+
+ foo3
+ foo4
+
+This warning is for project developers. Use -Wno-dev to suppress it.
diff --git a/Tests/RunCMake/CMP0068/CMP0068-WARN.cmake b/Tests/RunCMake/CMP0068/CMP0068-WARN.cmake
new file mode 100644
index 0000000..b7ec480
--- /dev/null
+++ b/Tests/RunCMake/CMP0068/CMP0068-WARN.cmake
@@ -0,0 +1,12 @@
+cmake_policy(SET CMP0042 NEW)
+
+add_library(foo SHARED empty.cpp)
+add_library(foo-static STATIC empty.cpp)
+add_library(foo2 SHARED empty.cpp)
+set_target_properties(foo2 PROPERTIES MACOSX_RPATH 1)
+add_library(foo3 SHARED empty.cpp)
+set_target_properties(foo3 PROPERTIES BUILD_WITH_INSTALL_RPATH 1 INSTALL_NAME_DIR "@loader_path")
+add_library(foo4 SHARED empty.cpp)
+set_target_properties(foo4 PROPERTIES BUILD_WITH_INSTALL_RPATH 1 INSTALL_NAME_DIR "@rpath")
+add_library(foo5 SHARED empty.cpp)
+set_target_properties(foo5 PROPERTIES BUILD_WITH_INSTALL_RPATH 1 BUILD_WITH_INSTALL_NAME_DIR 1 INSTALL_NAME_DIR "@rpath")
diff --git a/Tests/RunCMake/CMP0068/CMakeLists.txt b/Tests/RunCMake/CMP0068/CMakeLists.txt
new file mode 100644
index 0000000..375cbdb
--- /dev/null
+++ b/Tests/RunCMake/CMP0068/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.8)
+project(${RunCMake_TEST} CXX)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/CMP0068/RunCMakeTest.cmake b/Tests/RunCMake/CMP0068/RunCMakeTest.cmake
new file mode 100644
index 0000000..88a6225
--- /dev/null
+++ b/Tests/RunCMake/CMP0068/RunCMakeTest.cmake
@@ -0,0 +1,5 @@
+include(RunCMake)
+
+run_cmake(CMP0068-OLD)
+run_cmake(CMP0068-NEW)
+run_cmake(CMP0068-WARN)
diff --git a/Tests/RunCMake/CMP0068/empty.cpp b/Tests/RunCMake/CMP0068/empty.cpp
new file mode 100644
index 0000000..11ec041
--- /dev/null
+++ b/Tests/RunCMake/CMP0068/empty.cpp
@@ -0,0 +1,7 @@
+#ifdef _WIN32
+__declspec(dllexport)
+#endif
+ int empty()
+{
+ return 0;
+}
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index 63016f1..bd92013 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -104,6 +104,9 @@ add_RunCMake_test(CMP0057)
add_RunCMake_test(CMP0059)
add_RunCMake_test(CMP0060)
add_RunCMake_test(CMP0064)
+if(CMAKE_SYSTEM_NAME MATCHES Darwin AND CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG)
+ add_RunCMake_test(CMP0068)
+endif()
# The test for Policy 65 requires the use of the
# CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS variable, which both the VS and Xcode
diff --git a/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt b/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt
index 57047fb..78657ef 100644
--- a/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt
+++ b/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt
@@ -20,6 +20,7 @@
\* CMP0060
\* CMP0063
\* CMP0065
+ \* CMP0068
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/install/EXPORT-OldIFace.cmake b/Tests/RunCMake/install/EXPORT-OldIFace.cmake
index 033f684..ee3fb23 100644
--- a/Tests/RunCMake/install/EXPORT-OldIFace.cmake
+++ b/Tests/RunCMake/install/EXPORT-OldIFace.cmake
@@ -1,5 +1,6 @@
enable_language(C)
set(CMAKE_BUILD_WITH_INSTALL_RPATH 1)
+set(CMAKE_BUILD_WITH_INSTALL_NAME_DIR 1)
add_subdirectory(EXPORT-OldIFace)
add_library(foo SHARED empty.c)
target_link_libraries(foo bar)
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f7b9bf41c5386dfc38b7a722f75b0e23a02d542b
commit f7b9bf41c5386dfc38b7a722f75b0e23a02d542b
Author: Clinton Stimpson <clinton at elemtech.com>
AuthorDate: Thu Feb 9 08:05:10 2017 -0700
Commit: Clinton Stimpson <clinton at elemtech.com>
CommitDate: Tue Feb 14 14:28:07 2017 -0700
Apple: Add BUILD_WITH_INSTALL_NAME_DIR target property
This new property controls whether to apply INSTALL_NAME_DIR to the
build tree. It also overrides BUILD_WITH_INSTALL_RPATH.
diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst
index 38aba81..5fad10c 100644
--- a/Help/manual/cmake-properties.7.rst
+++ b/Help/manual/cmake-properties.7.rst
@@ -123,6 +123,7 @@ Properties on Targets
/prop_tgt/AUTORCC_OPTIONS
/prop_tgt/BINARY_DIR
/prop_tgt/BUILD_RPATH
+ /prop_tgt/BUILD_WITH_INSTALL_NAME_DIR
/prop_tgt/BUILD_WITH_INSTALL_RPATH
/prop_tgt/BUNDLE_EXTENSION
/prop_tgt/BUNDLE
diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst
index 95f780a..2aea851 100644
--- a/Help/manual/cmake-variables.7.rst
+++ b/Help/manual/cmake-variables.7.rst
@@ -263,6 +263,7 @@ Variables that Control the Build
/variable/CMAKE_AUTOUIC
/variable/CMAKE_AUTOUIC_OPTIONS
/variable/CMAKE_BUILD_RPATH
+ /variable/CMAKE_BUILD_WITH_INSTALL_NAME_DIR
/variable/CMAKE_BUILD_WITH_INSTALL_RPATH
/variable/CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY
/variable/CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY_CONFIG
diff --git a/Help/prop_tgt/BUILD_WITH_INSTALL_NAME_DIR.rst b/Help/prop_tgt/BUILD_WITH_INSTALL_NAME_DIR.rst
new file mode 100644
index 0000000..7e02518
--- /dev/null
+++ b/Help/prop_tgt/BUILD_WITH_INSTALL_NAME_DIR.rst
@@ -0,0 +1,13 @@
+BUILD_WITH_INSTALL_NAME_DIR
+---------------------------
+
+``BUILD_WITH_INSTALL_NAME_DIR`` is a boolean specifying whether the macOS
+``install_name`` of a target in the build tree uses the directory given by
+:prop_tgt:`INSTALL_NAME_DIR`. This setting only applies to targets on macOS.
+
+This property is initialized by the value of the variable
+:variable:`CMAKE_BUILD_WITH_INSTALL_NAME_DIR` if it is set when a target is
+created.
+
+If this property is not set, the value of :prop_tgt:`BUILD_WITH_INSTALL_RPATH`
+is used in its place.
diff --git a/Help/prop_tgt/BUILD_WITH_INSTALL_RPATH.rst b/Help/prop_tgt/BUILD_WITH_INSTALL_RPATH.rst
index 35297e9..97c3736 100644
--- a/Help/prop_tgt/BUILD_WITH_INSTALL_RPATH.rst
+++ b/Help/prop_tgt/BUILD_WITH_INSTALL_RPATH.rst
@@ -9,3 +9,7 @@ installation.
This property is initialized by the value of the
:variable:`CMAKE_BUILD_WITH_INSTALL_RPATH` variable if it is set when a target
is created.
+
+This property also controls use of :prop_tgt:`INSTALL_NAME_DIR` in the build
+tree on macOS, but defers to the :prop_tgt:`BUILD_WITH_INSTALL_NAME_DIR` target
+property if the latter is set.
diff --git a/Help/release/dev/install_name_policy.rst b/Help/release/dev/install_name_policy.rst
new file mode 100644
index 0000000..71bdf35
--- /dev/null
+++ b/Help/release/dev/install_name_policy.rst
@@ -0,0 +1,8 @@
+install_name_policy
+-------------------
+
+* A :prop_tgt:`BUILD_WITH_INSTALL_NAME_DIR` target property and corresponding
+ :variable:`CMAKE_BUILD_WITH_INSTALL_NAME_DIR` variable were added to
+ control whether to use the :prop_tgt:`INSTALL_NAME_DIR` target property
+ value for binaries in the build tree. This is for macOS ``install_name``
+ as :prop_tgt:`BUILD_WITH_INSTALL_RPATH` is for ``RPATH``.
diff --git a/Help/variable/CMAKE_BUILD_WITH_INSTALL_NAME_DIR.rst b/Help/variable/CMAKE_BUILD_WITH_INSTALL_NAME_DIR.rst
new file mode 100644
index 0000000..30d5d3b
--- /dev/null
+++ b/Help/variable/CMAKE_BUILD_WITH_INSTALL_NAME_DIR.rst
@@ -0,0 +1,7 @@
+CMAKE_BUILD_WITH_INSTALL_NAME_DIR
+---------------------------------
+
+Whether to use :prop_tgt:`INSTALL_NAME_DIR` on targets in the build tree.
+
+This variable is used to initialize the :prop_tgt:`BUILD_WITH_INSTALL_NAME_DIR`
+property on all targets.
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index 5dd0261..d32bcd8 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -1396,6 +1396,12 @@ bool cmGeneratorTarget::MacOSXRpathInstallNameDirDefault() const
bool cmGeneratorTarget::MacOSXUseInstallNameDir() const
{
+ const char* build_with_install_name =
+ this->GetProperty("BUILD_WITH_INSTALL_NAME_DIR");
+ if (build_with_install_name) {
+ return cmSystemTools::IsOn(build_with_install_name);
+ }
+
bool use_install_name = this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH");
return use_install_name;
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index fe3472d..ad3d604 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -253,6 +253,7 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type,
this->SetPropertyDefault("WIN32_EXECUTABLE", CM_NULLPTR);
this->SetPropertyDefault("MACOSX_BUNDLE", CM_NULLPTR);
this->SetPropertyDefault("MACOSX_RPATH", CM_NULLPTR);
+ this->SetPropertyDefault("BUILD_WITH_INSTALL_NAME_DIR", CM_NULLPTR);
this->SetPropertyDefault("C_CLANG_TIDY", CM_NULLPTR);
this->SetPropertyDefault("C_COMPILER_LAUNCHER", CM_NULLPTR);
this->SetPropertyDefault("C_CPPLINT", CM_NULLPTR);
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4bff2d14fd3010ba4aa1bfc3eda2fb2cdcc5da0f
commit 4bff2d14fd3010ba4aa1bfc3eda2fb2cdcc5da0f
Author: Clinton Stimpson <clinton at elemtech.com>
AuthorDate: Thu Feb 9 07:46:40 2017 -0700
Commit: Clinton Stimpson <clinton at elemtech.com>
CommitDate: Tue Feb 14 14:28:01 2017 -0700
Apple: Refactor support for using INSTALL_NAME_DIR.
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index 6ce8140..5dd0261 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -1321,8 +1321,7 @@ bool cmGeneratorTarget::HasMacOSXRpathInstallNameDir(
return false;
}
const char* install_name = this->GetProperty("INSTALL_NAME_DIR");
- bool use_install_name =
- this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH");
+ bool use_install_name = this->MacOSXUseInstallNameDir();
if (install_name && use_install_name &&
std::string(install_name) == "@rpath") {
install_name_is_rpath = true;
@@ -1395,6 +1394,26 @@ bool cmGeneratorTarget::MacOSXRpathInstallNameDirDefault() const
return cmp0042 == cmPolicies::NEW;
}
+bool cmGeneratorTarget::MacOSXUseInstallNameDir() const
+{
+ bool use_install_name = this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH");
+
+ return use_install_name;
+}
+
+bool cmGeneratorTarget::CanGenerateInstallNameDir(
+ InstallNameType name_type) const
+{
+ bool skip = this->Makefile->IsOn("CMAKE_SKIP_RPATH");
+ if (name_type == INSTALL_NAME_FOR_INSTALL) {
+ skip |= this->Makefile->IsOn("CMAKE_SKIP_INSTALL_RPATH");
+ } else {
+ skip |= this->GetPropertyAsBool("SKIP_BUILD_RPATH");
+ }
+
+ return !skip;
+}
+
std::string cmGeneratorTarget::GetSOName(const std::string& config) const
{
if (this->IsImported()) {
@@ -1503,24 +1522,25 @@ std::string cmGeneratorTarget::GetFullName(const std::string& config,
std::string cmGeneratorTarget::GetInstallNameDirForBuildTree(
const std::string& config) const
{
- // If building directly for installation then the build tree install_name
- // is the same as the install tree.
- if (this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")) {
- return this->GetInstallNameDirForInstallTree();
- }
+ if (this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) {
- // Use the build tree directory for the target.
- if (this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME") &&
- !this->Makefile->IsOn("CMAKE_SKIP_RPATH") &&
- !this->GetPropertyAsBool("SKIP_BUILD_RPATH")) {
- std::string dir;
- if (this->MacOSXRpathInstallNameDirDefault()) {
- dir = "@rpath";
- } else {
- dir = this->GetDirectory(config);
+ // If building directly for installation then the build tree install_name
+ // is the same as the install tree.
+ if (this->MacOSXUseInstallNameDir()) {
+ return this->GetInstallNameDirForInstallTree();
+ }
+
+ // Use the build tree directory for the target.
+ if (this->CanGenerateInstallNameDir(INSTALL_NAME_FOR_BUILD)) {
+ std::string dir;
+ if (this->MacOSXRpathInstallNameDirDefault()) {
+ dir = "@rpath";
+ } else {
+ dir = this->GetDirectory(config);
+ }
+ dir += "/";
+ return dir;
}
- dir += "/";
- return dir;
}
return "";
}
@@ -1531,8 +1551,7 @@ std::string cmGeneratorTarget::GetInstallNameDirForInstallTree() const
std::string dir;
const char* install_name_dir = this->GetProperty("INSTALL_NAME_DIR");
- if (!this->Makefile->IsOn("CMAKE_SKIP_RPATH") &&
- !this->Makefile->IsOn("CMAKE_SKIP_INSTALL_RPATH")) {
+ if (this->CanGenerateInstallNameDir(INSTALL_NAME_FOR_INSTALL)) {
if (install_name_dir && *install_name_dir) {
dir = install_name_dir;
dir += "/";
diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h
index f568699..689fbda 100644
--- a/Source/cmGeneratorTarget.h
+++ b/Source/cmGeneratorTarget.h
@@ -525,6 +525,16 @@ public:
/** Whether this library defaults to \@rpath. */
bool MacOSXRpathInstallNameDirDefault() const;
+ enum InstallNameType
+ {
+ INSTALL_NAME_FOR_BUILD,
+ INSTALL_NAME_FOR_INSTALL
+ };
+ /** Whether to use INSTALL_NAME_DIR. */
+ bool MacOSXUseInstallNameDir() const;
+ /** Whether to generate an install_name. */
+ bool CanGenerateInstallNameDir(InstallNameType t) const;
+
/** Test for special case of a third-party shared library that has
no soname at all. */
bool IsImportedSharedLibWithoutSOName(const std::string& config) const;
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=624fb9d7175ee011f8a86c8d7614be4806a53184
commit 624fb9d7175ee011f8a86c8d7614be4806a53184
Author: Brad King <brad.king at kitware.com>
AuthorDate: Tue Feb 14 08:51:37 2017 -0500
Commit: Brad King <brad.king at kitware.com>
CommitDate: Tue Feb 14 08:52:02 2017 -0500
Help: Format BUILD_WITH_INSTALL_RPATH documentation
diff --git a/Help/prop_tgt/BUILD_WITH_INSTALL_RPATH.rst b/Help/prop_tgt/BUILD_WITH_INSTALL_RPATH.rst
index abcf28f..35297e9 100644
--- a/Help/prop_tgt/BUILD_WITH_INSTALL_RPATH.rst
+++ b/Help/prop_tgt/BUILD_WITH_INSTALL_RPATH.rst
@@ -1,11 +1,11 @@
BUILD_WITH_INSTALL_RPATH
------------------------
-Should build tree targets have install tree rpaths.
+``BUILD_WITH_INSTALL_RPATH`` is a boolean specifying whether to link the target
+in the build tree with the :prop_tgt:`INSTALL_RPATH`. This takes precedence
+over :prop_tgt:`SKIP_BUILD_RPATH` and avoids the need for relinking before
+installation.
-BUILD_WITH_INSTALL_RPATH is a boolean specifying whether to link the
-target in the build tree with the INSTALL_RPATH. This takes
-precedence over SKIP_BUILD_RPATH and avoids the need for relinking
-before installation. This property is initialized by the value of the
-variable CMAKE_BUILD_WITH_INSTALL_RPATH if it is set when a target is
-created.
+This property is initialized by the value of the
+:variable:`CMAKE_BUILD_WITH_INSTALL_RPATH` variable if it is set when a target
+is created.
-----------------------------------------------------------------------
Summary of changes:
Help/manual/cmake-policies.7.rst | 8 ++
Help/manual/cmake-properties.7.rst | 1 +
Help/manual/cmake-variables.7.rst | 1 +
Help/policy/CMP0068.rst | 35 ++++++++
Help/prop_tgt/BUILD_WITH_INSTALL_NAME_DIR.rst | 13 +++
Help/prop_tgt/BUILD_WITH_INSTALL_RPATH.rst | 18 ++--
Help/release/dev/install_name_policy.rst | 11 +++
.../variable/CMAKE_BUILD_WITH_INSTALL_NAME_DIR.rst | 7 ++
Source/cmGeneratorTarget.cxx | 86 +++++++++++++++-----
Source/cmGeneratorTarget.h | 10 +++
Source/cmGlobalGenerator.cxx | 25 ++++++
Source/cmGlobalGenerator.h | 3 +
Source/cmPolicies.h | 8 +-
Source/cmTarget.cxx | 1 +
.../CMP0068-NEW-result.txt} | 0
Tests/RunCMake/CMP0068/CMP0068-NEW.cmake | 6 ++
.../CMP0068-OLD-result.txt} | 0
Tests/RunCMake/CMP0068/CMP0068-OLD.cmake | 6 ++
.../CMP0068-WARN-result.txt} | 0
Tests/RunCMake/CMP0068/CMP0068-WARN-stderr.txt | 12 +++
.../CMP0068-WARN.cmake} | 3 +
Tests/RunCMake/{CMP0051 => CMP0068}/CMakeLists.txt | 2 +-
Tests/RunCMake/CMP0068/RunCMakeTest.cmake | 5 ++
.../Export => RunCMake/CMP0068}/empty.cpp | 0
Tests/RunCMake/CMakeLists.txt | 3 +
.../RunCMake/TargetPolicies/PolicyList-stderr.txt | 1 +
Tests/RunCMake/install/EXPORT-OldIFace.cmake | 1 +
27 files changed, 236 insertions(+), 30 deletions(-)
create mode 100644 Help/policy/CMP0068.rst
create mode 100644 Help/prop_tgt/BUILD_WITH_INSTALL_NAME_DIR.rst
create mode 100644 Help/release/dev/install_name_policy.rst
create mode 100644 Help/variable/CMAKE_BUILD_WITH_INSTALL_NAME_DIR.rst
copy Tests/RunCMake/{CMP0022/CMP0022-WARN-empty-old-result.txt => CMP0068/CMP0068-NEW-result.txt} (100%)
create mode 100644 Tests/RunCMake/CMP0068/CMP0068-NEW.cmake
copy Tests/RunCMake/{CMP0022/CMP0022-WARN-empty-old-result.txt => CMP0068/CMP0068-OLD-result.txt} (100%)
create mode 100644 Tests/RunCMake/CMP0068/CMP0068-OLD.cmake
copy Tests/RunCMake/{CMP0022/CMP0022-WARN-empty-old-result.txt => CMP0068/CMP0068-WARN-result.txt} (100%)
create mode 100644 Tests/RunCMake/CMP0068/CMP0068-WARN-stderr.txt
copy Tests/RunCMake/{CMP0042/CMP0042-WARN.cmake => CMP0068/CMP0068-WARN.cmake} (69%)
copy Tests/RunCMake/{CMP0051 => CMP0068}/CMakeLists.txt (63%)
create mode 100644 Tests/RunCMake/CMP0068/RunCMakeTest.cmake
copy Tests/{ExportImport/Export => RunCMake/CMP0068}/empty.cpp (100%)
hooks/post-receive
--
CMake
More information about the Cmake-commits
mailing list