summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2019-04-22 11:38:20 (GMT)
committerKitware Robot <kwrobot@kitware.com>2019-04-22 11:38:33 (GMT)
commitcb23f2ac8b2484c9bf1e0db78831b3ea8d54766c (patch)
tree95826235038775468ac681b1dfef81afb5a9fc1d
parent8c322f9313e60af28d2deee739a88a683885e484 (diff)
parentdb02be85a0bcccb633b31f087cde96d95fd21e8f (diff)
downloadCMake-cb23f2ac8b2484c9bf1e0db78831b3ea8d54766c.zip
CMake-cb23f2ac8b2484c9bf1e0db78831b3ea8d54766c.tar.gz
CMake-cb23f2ac8b2484c9bf1e0db78831b3ea8d54766c.tar.bz2
Merge topic 'vs-default-platform'
db02be85a0 VS: Provide the default platform name to project code Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !3246
-rw-r--r--Help/generator/Visual Studio 16 2019.rst3
-rw-r--r--Help/manual/cmake-variables.7.rst1
-rw-r--r--Help/release/3.14.rst11
-rw-r--r--Help/variable/CMAKE_VS_PLATFORM_NAME.rst4
-rw-r--r--Help/variable/CMAKE_VS_PLATFORM_NAME_DEFAULT.rst9
-rw-r--r--Source/cmGlobalVisualStudio7Generator.cxx2
-rw-r--r--Source/cmGlobalVisualStudioGenerator.cxx8
-rw-r--r--Source/cmGlobalVisualStudioGenerator.h3
-rw-r--r--Tests/RunCMake/GeneratorPlatform/TestPlatform-toolchain.cmake1
-rw-r--r--Tests/RunCMake/GeneratorPlatform/TestPlatformToolchain-stderr.txt1
10 files changed, 40 insertions, 3 deletions
diff --git a/Help/generator/Visual Studio 16 2019.rst b/Help/generator/Visual Studio 16 2019.rst
index b456554..4aec7f7 100644
--- a/Help/generator/Visual Studio 16 2019.rst
+++ b/Help/generator/Visual Studio 16 2019.rst
@@ -28,7 +28,8 @@ by default.
Platform Selection
^^^^^^^^^^^^^^^^^^
-The default target platform name (architecture) is that of the host.
+The default target platform name (architecture) is that of the host
+and is provided in the :variable:`CMAKE_VS_PLATFORM_NAME_DEFAULT` variable.
The :variable:`CMAKE_GENERATOR_PLATFORM` variable may be set, perhaps
via the :manual:`cmake(1)` ``-A`` option, to specify a target platform
diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst
index 22e8add..3e8c884 100644
--- a/Help/manual/cmake-variables.7.rst
+++ b/Help/manual/cmake-variables.7.rst
@@ -105,6 +105,7 @@ Variables that Provide Information
/variable/CMAKE_VS_MSBUILD_COMMAND
/variable/CMAKE_VS_NsightTegra_VERSION
/variable/CMAKE_VS_PLATFORM_NAME
+ /variable/CMAKE_VS_PLATFORM_NAME_DEFAULT
/variable/CMAKE_VS_PLATFORM_TOOLSET
/variable/CMAKE_VS_PLATFORM_TOOLSET_CUDA
/variable/CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE
diff --git a/Help/release/3.14.rst b/Help/release/3.14.rst
index f2a91c6..c208304 100644
--- a/Help/release/3.14.rst
+++ b/Help/release/3.14.rst
@@ -137,6 +137,10 @@ Variables
relocatable and reproducible builds that are invariant of the build
directory.
+* A :variable:`CMAKE_VS_PLATFORM_NAME_DEFAULT` variable was added for
+ :ref:`Visual Studio Generators` to report their default platform used
+ when :variable:`CMAKE_GENERATOR_PLATFORM` is not set explicitly.
+
Properties
----------
@@ -391,3 +395,10 @@ Changes made since CMake 3.14.0 include the following.
our conventions. 3.14.1 revises the module to use ``Fontconfig_*``
variable names. This is incompatible with 3.14.0 but since the
module is new in the 3.14 series usage should not yet be widespread.
+
+3.14.3
+------
+
+* The :variable:`CMAKE_VS_PLATFORM_NAME_DEFAULT` variable was added
+ to help toolchain files work with the :generator:`Visual Studio 16 2019`
+ generator where the default platform now depends on the host platform.
diff --git a/Help/variable/CMAKE_VS_PLATFORM_NAME.rst b/Help/variable/CMAKE_VS_PLATFORM_NAME.rst
index a532743..7a4642a 100644
--- a/Help/variable/CMAKE_VS_PLATFORM_NAME.rst
+++ b/Help/variable/CMAKE_VS_PLATFORM_NAME.rst
@@ -1,8 +1,10 @@
CMAKE_VS_PLATFORM_NAME
----------------------
-Visual Studio target platform name.
+Visual Studio target platform name used by the current generator.
VS 8 and above allow project files to specify a target platform.
CMake provides the name of the chosen platform in this variable.
See the :variable:`CMAKE_GENERATOR_PLATFORM` variable for details.
+
+See also the :variable:`CMAKE_VS_PLATFORM_NAME_DEFAULT` variable.
diff --git a/Help/variable/CMAKE_VS_PLATFORM_NAME_DEFAULT.rst b/Help/variable/CMAKE_VS_PLATFORM_NAME_DEFAULT.rst
new file mode 100644
index 0000000..c18e6fd
--- /dev/null
+++ b/Help/variable/CMAKE_VS_PLATFORM_NAME_DEFAULT.rst
@@ -0,0 +1,9 @@
+CMAKE_VS_PLATFORM_NAME_DEFAULT
+------------------------------
+
+Default for the Visual Studio target platform name for the current generator
+without considering the value of the :variable:`CMAKE_GENERATOR_PLATFORM`
+variable. For :ref:`Visual Studio Generators` for VS 2017 and below this is
+always ``Win32``. For VS 2019 and above this is based on the host platform.
+
+See also the :variable:`CMAKE_VS_PLATFORM_NAME` variable.
diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx
index d7630e4..c31dbf4 100644
--- a/Source/cmGlobalVisualStudio7Generator.cxx
+++ b/Source/cmGlobalVisualStudio7Generator.cxx
@@ -101,7 +101,7 @@ void cmGlobalVisualStudio7Generator::EnableLanguage(
}
// Create list of configurations requested by user's cache, if any.
- this->cmGlobalGenerator::EnableLanguage(lang, mf, optional);
+ this->cmGlobalVisualStudioGenerator::EnableLanguage(lang, mf, optional);
// if this environment variable is set, then copy it to
// a static cache entry. It will be used by
diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx
index 280c986..39c325c 100644
--- a/Source/cmGlobalVisualStudioGenerator.cxx
+++ b/Source/cmGlobalVisualStudioGenerator.cxx
@@ -53,6 +53,14 @@ void cmGlobalVisualStudioGenerator::SetVersion(VSVersion v)
this->Version = v;
}
+void cmGlobalVisualStudioGenerator::EnableLanguage(
+ std::vector<std::string> const& lang, cmMakefile* mf, bool optional)
+{
+ mf->AddDefinition("CMAKE_VS_PLATFORM_NAME_DEFAULT",
+ this->DefaultPlatformName.c_str());
+ this->cmGlobalGenerator::EnableLanguage(lang, mf, optional);
+}
+
bool cmGlobalVisualStudioGenerator::SetGeneratorPlatform(std::string const& p,
cmMakefile* mf)
{
diff --git a/Source/cmGlobalVisualStudioGenerator.h b/Source/cmGlobalVisualStudioGenerator.h
index 039191c..cbab329 100644
--- a/Source/cmGlobalVisualStudioGenerator.h
+++ b/Source/cmGlobalVisualStudioGenerator.h
@@ -50,6 +50,9 @@ public:
/** Is the installed VS an Express edition? */
bool IsExpressEdition() const { return this->ExpressEdition; }
+ void EnableLanguage(std::vector<std::string> const& languages, cmMakefile*,
+ bool optional) override;
+
bool SetGeneratorPlatform(std::string const& p, cmMakefile* mf) override;
/**
diff --git a/Tests/RunCMake/GeneratorPlatform/TestPlatform-toolchain.cmake b/Tests/RunCMake/GeneratorPlatform/TestPlatform-toolchain.cmake
index 763478c..d8138b8 100644
--- a/Tests/RunCMake/GeneratorPlatform/TestPlatform-toolchain.cmake
+++ b/Tests/RunCMake/GeneratorPlatform/TestPlatform-toolchain.cmake
@@ -1 +1,2 @@
+message("CMAKE_VS_PLATFORM_NAME_DEFAULT is \"${CMAKE_VS_PLATFORM_NAME_DEFAULT}\"")
set(CMAKE_GENERATOR_PLATFORM "Test Platform")
diff --git a/Tests/RunCMake/GeneratorPlatform/TestPlatformToolchain-stderr.txt b/Tests/RunCMake/GeneratorPlatform/TestPlatformToolchain-stderr.txt
index b9bb3b2..6867790 100644
--- a/Tests/RunCMake/GeneratorPlatform/TestPlatformToolchain-stderr.txt
+++ b/Tests/RunCMake/GeneratorPlatform/TestPlatformToolchain-stderr.txt
@@ -1,3 +1,4 @@
+CMAKE_VS_PLATFORM_NAME_DEFAULT is "[^"]+"
CMake Error at TestPlatformToolchain.cmake:[0-9]+ \(message\):
CMAKE_GENERATOR_PLATFORM is "Test Platform" as expected.
Call Stack \(most recent call first\):