[Cmake-commits] CMake branch, master, updated. v3.12.2-761-g4e98203

Kitware Robot kwrobot at kitware.com
Fri Sep 28 11:15:05 EDT 2018


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, master has been updated
       via  4e98203c6c318f7c2caf4c31b2c2863772eef57b (commit)
       via  36489b85aa308e3a1b984da0d1e7d3aff4467752 (commit)
       via  22e670a3062869e3014455563d800c72f35d9e4f (commit)
      from  8fea6b0764dbf1b6893e7ca81d93cddca2facfce (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=4e98203c6c318f7c2caf4c31b2c2863772eef57b
commit 4e98203c6c318f7c2caf4c31b2c2863772eef57b
Merge: 8fea6b0 36489b8
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Fri Sep 28 15:13:52 2018 +0000
Commit:     Kitware Robot <kwrobot at kitware.com>
CommitDate: Fri Sep 28 11:13:59 2018 -0400

    Merge topic 'vs-global-props-for-all-targets'
    
    36489b85aa VS: Add test for CMAKE_VS_GLOBALS
    22e670a306 VS: Add option to set VS_GLOBAL_* for all targets
    
    Acked-by: Kitware Robot <kwrobot at kitware.com>
    Merge-request: !2345


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=36489b85aa308e3a1b984da0d1e7d3aff4467752
commit 36489b85aa308e3a1b984da0d1e7d3aff4467752
Author:     Mikhail Korolev <stilriv at gmail.com>
AuthorDate: Thu Sep 27 15:17:19 2018 +0300
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Fri Sep 28 11:13:03 2018 -0400

    VS: Add test for CMAKE_VS_GLOBALS

diff --git a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake
index d50de3d..4bfb2f2 100644
--- a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake
+++ b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake
@@ -13,3 +13,4 @@ run_cmake(VsCSharpCustomTags)
 run_cmake(VsCSharpReferenceProps)
 run_cmake(VsCSharpWithoutSources)
 run_cmake(VsSdkDirectories)
+run_cmake(VsGlobals)
diff --git a/Tests/RunCMake/VS10Project/VsGlobals-check.cmake b/Tests/RunCMake/VS10Project/VsGlobals-check.cmake
new file mode 100644
index 0000000..0e7fd45
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/VsGlobals-check.cmake
@@ -0,0 +1,44 @@
+set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/foo.vcxproj")
+if(NOT EXISTS "${vcProjectFile}")
+  set(RunCMake_TEST_FAILED "Project file ${vcProjectFile} does not exist.")
+  return()
+endif()
+
+set(InsideGlobals FALSE)
+set(DefaultLanguageSet FALSE)
+set(MinimumVisualStudioVersionSet FALSE)
+
+file(STRINGS "${vcProjectFile}" lines)
+foreach(line IN LISTS lines)
+  if(line MATCHES "^ *<PropertyGroup Label=\"Globals\"> *$")
+    set(InsideGlobals TRUE)
+  elseif(line MATCHES "^ *<DefaultLanguage>([a-zA-Z\\-]+)</DefaultLanguage> *$")
+    if("${CMAKE_MATCH_1}" STREQUAL "en-US")
+      if(InsideGlobals)
+        message(STATUS "foo.vcxproj has correct DefaultLanguage global property")
+        set(DefaultLanguageSet TRUE)
+      else()
+        message(STATUS "DefaultLanguage is set but not within \"Globals\" property group")
+      endif()
+    endif()
+  elseif(line MATCHES "^ *<MinimumVisualStudioVersion>([0-9\\.]+)</MinimumVisualStudioVersion> *$")
+    if("${CMAKE_MATCH_1}" STREQUAL "14.0")
+      if(InsideGlobals)
+        message(STATUS "foo.vcxproj has correct MinimumVisualStudioVersion global property")
+        set(MinimumVisualStudioVersionSet TRUE)
+      else()
+        message(STATUS "MinimumVisualStudioVersion is set but not within \"Globals\" property group")
+      endif()
+    endif()
+  endif()
+endforeach()
+
+if(NOT DefaultLanguageSet)
+  set(RunCMake_TEST_FAILED "DefaultLanguageSet not found or not set correctly.")
+  return()
+endif()
+
+if(NOT MinimumVisualStudioVersionSet)
+  set(RunCMake_TEST_FAILED "MinimumVisualStudioVersionSet not found or not set correctly.")
+  return()
+endif()
diff --git a/Tests/RunCMake/VS10Project/VsGlobals.cmake b/Tests/RunCMake/VS10Project/VsGlobals.cmake
new file mode 100644
index 0000000..a3ed5af
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/VsGlobals.cmake
@@ -0,0 +1,8 @@
+enable_language(CXX)
+
+set(CMAKE_VS_GLOBALS
+    "DefaultLanguage=en-US"
+    "MinimumVisualStudioVersion=14.0"
+)
+
+add_library(foo foo.cpp)

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=22e670a3062869e3014455563d800c72f35d9e4f
commit 22e670a3062869e3014455563d800c72f35d9e4f
Author:     Mikhail Korolev <stilriv at gmail.com>
AuthorDate: Fri Sep 21 14:23:22 2018 +0300
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Tue Sep 25 09:20:25 2018 -0400

    VS: Add option to set VS_GLOBAL_* for all targets
    
    Fixes: #18287

diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst
index 6071999..f217f11 100644
--- a/Help/manual/cmake-variables.7.rst
+++ b/Help/manual/cmake-variables.7.rst
@@ -394,6 +394,7 @@ Variables that Control the Build
    /variable/CMAKE_TRY_COMPILE_TARGET_TYPE
    /variable/CMAKE_USE_RELATIVE_PATHS
    /variable/CMAKE_VISIBILITY_INLINES_HIDDEN
+   /variable/CMAKE_VS_GLOBALS
    /variable/CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD
    /variable/CMAKE_VS_INCLUDE_PACKAGE_TO_DEFAULT_BUILD
    /variable/CMAKE_VS_SDK_EXCLUDE_DIRECTORIES
diff --git a/Help/release/dev/vs-global-props-for-all-targets.rst b/Help/release/dev/vs-global-props-for-all-targets.rst
new file mode 100644
index 0000000..647949e
--- /dev/null
+++ b/Help/release/dev/vs-global-props-for-all-targets.rst
@@ -0,0 +1,6 @@
+vs-global-props-for-all-targets
+-------------------------------
+
+* A :variable:`CMAKE_VS_GLOBALS` variable was added to initialize
+  :prop_tgt:`VS_GLOBAL_<variable>` target properties on targets as
+  they are created.
diff --git a/Help/variable/CMAKE_VS_GLOBALS.rst b/Help/variable/CMAKE_VS_GLOBALS.rst
new file mode 100644
index 0000000..83777b6
--- /dev/null
+++ b/Help/variable/CMAKE_VS_GLOBALS.rst
@@ -0,0 +1,21 @@
+CMAKE_VS_GLOBALS
+----------------
+
+List of ``Key=Value`` records to be set per target as target properties
+:prop_tgt:`VS_GLOBAL_<variable>` with ``variable=Key`` and value ``Value``.
+
+For example:
+
+.. code-block:: cmake
+
+  set(CMAKE_VS_GLOBALS
+    "DefaultLanguage=en-US"
+    "MinimumVisualStudioVersion=14.0"
+    )
+
+will set properties ``VS_GLOBAL_DefaultLanguage`` to ``en-US`` and
+``VS_GLOBAL_MinimumVisualStudioVersion`` to ``14.0`` for all targets
+(except for ``INTERFACE`` libraries).
+
+This variable is meant to be set by a
+:variable:`toolchain file <CMAKE_TOOLCHAIN_FILE>`.
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 4e353c7..a338fe3 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -440,6 +440,31 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type,
   if (this->TargetTypeValue <= cmStateEnums::UTILITY) {
     this->SetPropertyDefault("DOTNET_TARGET_FRAMEWORK_VERSION", nullptr);
   }
+
+  if (this->GetType() != cmStateEnums::INTERFACE_LIBRARY &&
+      this->GetType() != cmStateEnums::UTILITY) {
+
+    // check for "CMAKE_VS_GLOBALS" variable and set up target properties
+    // if any
+    const char* globals = mf->GetDefinition("CMAKE_VS_GLOBALS");
+    if (globals) {
+      const std::string genName = mf->GetGlobalGenerator()->GetName();
+      if (cmHasLiteralPrefix(genName, "Visual Studio")) {
+        std::vector<std::string> props;
+        cmSystemTools::ExpandListArgument(globals, props);
+        const std::string vsGlobal = "VS_GLOBAL_";
+        for (const std::string& i : props) {
+          // split NAME=VALUE
+          const std::string::size_type assignment = i.find('=');
+          if (assignment != std::string::npos) {
+            const std::string propName = vsGlobal + i.substr(0, assignment);
+            const std::string propValue = i.substr(assignment + 1);
+            this->SetPropertyDefault(propName, propValue.c_str());
+          }
+        }
+      }
+    }
+  }
 }
 
 cmGlobalGenerator* cmTarget::GetGlobalGenerator() const

-----------------------------------------------------------------------

Summary of changes:
 Help/manual/cmake-variables.7.rst                  |  1 +
 .../dev/vs-global-props-for-all-targets.rst        |  6 +++
 Help/variable/CMAKE_VS_GLOBALS.rst                 | 21 +++++++++++
 Source/cmTarget.cxx                                | 25 ++++++++++++
 Tests/RunCMake/VS10Project/RunCMakeTest.cmake      |  1 +
 Tests/RunCMake/VS10Project/VsGlobals-check.cmake   | 44 ++++++++++++++++++++++
 Tests/RunCMake/VS10Project/VsGlobals.cmake         |  8 ++++
 7 files changed, 106 insertions(+)
 create mode 100644 Help/release/dev/vs-global-props-for-all-targets.rst
 create mode 100644 Help/variable/CMAKE_VS_GLOBALS.rst
 create mode 100644 Tests/RunCMake/VS10Project/VsGlobals-check.cmake
 create mode 100644 Tests/RunCMake/VS10Project/VsGlobals.cmake


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list