diff --git a/Help/generator/Visual Studio 10 2010.rst b/Help/generator/Visual Studio 10 2010.rst index 000677a945..77ea9df02b 100644 --- a/Help/generator/Visual Studio 10 2010.rst +++ b/Help/generator/Visual Studio 10 2010.rst @@ -3,10 +3,17 @@ Visual Studio 10 2010 Generates Visual Studio 10 (VS 2010) project files. -It is possible to append a space followed by the platform name to -create project files for a specific target platform. E.g. -"Visual Studio 10 2010 Win64" will create project files for the -x64 processor; "Visual Studio 10 2010 IA64" for Itanium. +The :variable:`CMAKE_GENERATOR_PLATFORM` variable may be set +to specify a target platform name. + +For compatibility with CMake versions prior to 3.1, one may specify +a target platform name optionally at the end of this generator name: + +``Visual Studio 10 2010 Win64`` + Specify target platform ``x64``. + +``Visual Studio 10 2010 IA64`` + Specify target platform ``Itanium``. For compatibility with CMake versions prior to 3.0, one may specify this -generator using the name "Visual Studio 10" without the year component. +generator using the name ``Visual Studio 10`` without the year component. diff --git a/Help/generator/Visual Studio 11 2012.rst b/Help/generator/Visual Studio 11 2012.rst index 42f6f91608..5fa7f2c76b 100644 --- a/Help/generator/Visual Studio 11 2012.rst +++ b/Help/generator/Visual Studio 11 2012.rst @@ -3,10 +3,20 @@ Visual Studio 11 2012 Generates Visual Studio 11 (VS 2012) project files. -It is possible to append a space followed by the platform name to -create project files for a specific target platform. E.g. -"Visual Studio 11 2012 Win64" will create project files for the -x64 processor; "Visual Studio 11 2012 ARM" for ARM. +The :variable:`CMAKE_GENERATOR_PLATFORM` variable may be set +to specify a target platform name. + +For compatibility with CMake versions prior to 3.1, one may specify +a target platform name optionally at the end of this generator name: + +``Visual Studio 11 2012 Win64`` + Specify target platform ``x64``. + +``Visual Studio 11 2012 ARM`` + Specify target platform ``ARM``. + +``Visual Studio 11 2012 `` + Specify target platform matching a Windows CE SDK name. For compatibility with CMake versions prior to 3.0, one may specify this generator using the name "Visual Studio 11" without the year component. diff --git a/Help/generator/Visual Studio 12 2013.rst b/Help/generator/Visual Studio 12 2013.rst index d2f4912025..2c3b119a4c 100644 --- a/Help/generator/Visual Studio 12 2013.rst +++ b/Help/generator/Visual Studio 12 2013.rst @@ -3,10 +3,17 @@ Visual Studio 12 2013 Generates Visual Studio 12 (VS 2013) project files. -It is possible to append a space followed by the platform name to -create project files for a specific target platform. E.g. -"Visual Studio 12 2013 Win64" will create project files for the -x64 processor; "Visual Studio 12 2013 ARM" for ARM. +The :variable:`CMAKE_GENERATOR_PLATFORM` variable may be set +to specify a target platform name. + +For compatibility with CMake versions prior to 3.1, one may specify +a target platform name optionally at the end of this generator name: + +``Visual Studio 12 2013 Win64`` + Specify target platform ``x64``. + +``Visual Studio 12 2013 ARM`` + Specify target platform ``ARM``. For compatibility with CMake versions prior to 3.0, one may specify this generator using the name "Visual Studio 12" without the year component. diff --git a/Help/generator/Visual Studio 14.rst b/Help/generator/Visual Studio 14.rst index 7f4fdc3ae1..d621b7e5ba 100644 --- a/Help/generator/Visual Studio 14.rst +++ b/Help/generator/Visual Studio 14.rst @@ -3,7 +3,14 @@ Visual Studio 14 Generates Visual Studio 14 project files. -It is possible to append a space followed by the platform name to -create project files for a specific target platform. E.g. -"Visual Studio 14 Win64" will create project files for the -x64 processor; "Visual Studio 14 ARM" for ARM. +The :variable:`CMAKE_GENERATOR_PLATFORM` variable may be set +to specify a target platform name. + +For compatibility with CMake versions prior to 3.1, one may specify +a target platform name optionally at the end of this generator name: + +``Visual Studio 14 Win64`` + Specify target platform ``x64``. + +``Visual Studio 14 ARM`` + Specify target platform ``ARM``. diff --git a/Help/generator/Visual Studio 8 2005.rst b/Help/generator/Visual Studio 8 2005.rst index d7b6de25f3..29012c3715 100644 --- a/Help/generator/Visual Studio 8 2005.rst +++ b/Help/generator/Visual Studio 8 2005.rst @@ -3,6 +3,14 @@ Visual Studio 8 2005 Generates Visual Studio 8 2005 project files. -It is possible to append a space followed by the platform name to -create project files for a specific target platform. E.g. "Visual -Studio 8 2005 Win64" will create project files for the x64 processor. +The :variable:`CMAKE_GENERATOR_PLATFORM` variable may be set +to specify a target platform name. + +For compatibility with CMake versions prior to 3.1, one may specify +a target platform name optionally at the end of this generator name: + +``Visual Studio 8 2005 Win64`` + Specify target platform ``x64``. + +``Visual Studio 8 2005 `` + Specify target platform matching a Windows CE SDK name. diff --git a/Help/generator/Visual Studio 9 2008.rst b/Help/generator/Visual Studio 9 2008.rst index ade9fd5de0..40471b92e6 100644 --- a/Help/generator/Visual Studio 9 2008.rst +++ b/Help/generator/Visual Studio 9 2008.rst @@ -3,7 +3,17 @@ Visual Studio 9 2008 Generates Visual Studio 9 2008 project files. -It is possible to append a space followed by the platform name to -create project files for a specific target platform. E.g. "Visual -Studio 9 2008 Win64" will create project files for the x64 processor; -"Visual Studio 9 2008 IA64" for Itanium. +The :variable:`CMAKE_GENERATOR_PLATFORM` variable may be set +to specify a target platform name. + +For compatibility with CMake versions prior to 3.1, one may specify +a target platform name optionally at the end of this generator name: + +``Visual Studio 9 2008 Win64`` + Specify target platform ``x64``. + +``Visual Studio 9 2008 IA64`` + Specify target platform ``Itanium``. + +``Visual Studio 9 2008 `` + Specify target platform matching a Windows CE SDK name. diff --git a/Help/release/dev/vs-generator-platform.rst b/Help/release/dev/vs-generator-platform.rst new file mode 100644 index 0000000000..df90e19460 --- /dev/null +++ b/Help/release/dev/vs-generator-platform.rst @@ -0,0 +1,7 @@ +vs-generator-platform +--------------------- + +* The Visual Studio generators for versions 8 (2005) and above + learned to read the target platform name from a new + :variable:`CMAKE_GENERATOR_PLATFORM` variable when it is + not specified as part of the generator name. diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index e753c3c266..e2d4645fa5 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -125,6 +125,18 @@ bool cmGlobalVisualStudio10Generator::SetSystemName(std::string const& s, { return false; } + return this->cmGlobalVisualStudio8Generator::SetSystemName(s, mf); +} + +//---------------------------------------------------------------------------- +bool +cmGlobalVisualStudio10Generator::SetGeneratorPlatform(std::string const& p, + cmMakefile* mf) +{ + if(!this->cmGlobalVisualStudio8Generator::SetGeneratorPlatform(p, mf)) + { + return false; + } if(this->GetPlatformName() == "Itanium" || this->GetPlatformName() == "x64") { if(this->IsExpressEdition() && !this->Find64BitTools(mf)) @@ -132,7 +144,7 @@ bool cmGlobalVisualStudio10Generator::SetSystemName(std::string const& s, return false; } } - return this->cmGlobalVisualStudio8Generator::SetSystemName(s, mf); + return true; } //---------------------------------------------------------------------------- diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h index 1155508f42..f1ff9a462c 100644 --- a/Source/cmGlobalVisualStudio10Generator.h +++ b/Source/cmGlobalVisualStudio10Generator.h @@ -31,6 +31,7 @@ public: virtual bool MatchesGeneratorName(const std::string& name) const; virtual bool SetSystemName(std::string const& s, cmMakefile* mf); + virtual bool SetGeneratorPlatform(std::string const& p, cmMakefile* mf); virtual bool SetGeneratorToolset(std::string const& ts, cmMakefile* mf); virtual void GenerateBuildCommand( diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index cb82e54f87..401e4758d1 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -262,12 +262,25 @@ cmLocalGenerator *cmGlobalVisualStudio7Generator::CreateLocalGenerator() //---------------------------------------------------------------------------- std::string const& cmGlobalVisualStudio7Generator::GetPlatformName() const { + if(!this->GeneratorPlatform.empty()) + { + return this->GeneratorPlatform; + } return this->DefaultPlatformName; } //---------------------------------------------------------------------------- bool cmGlobalVisualStudio7Generator::SetSystemName(std::string const& s, cmMakefile* mf) +{ + mf->AddDefinition("CMAKE_VS_INTEL_Fortran_PROJECT_VERSION", + this->GetIntelProjectVersion()); + return this->cmGlobalVisualStudioGenerator::SetSystemName(s, mf); +} + +//---------------------------------------------------------------------------- +bool cmGlobalVisualStudio7Generator::SetGeneratorPlatform(std::string const& p, + cmMakefile* mf) { if(this->GetPlatformName() == "x64") { @@ -278,9 +291,7 @@ bool cmGlobalVisualStudio7Generator::SetSystemName(std::string const& s, mf->AddDefinition("CMAKE_FORCE_IA64", "TRUE"); } mf->AddDefinition("CMAKE_VS_PLATFORM_NAME", this->GetPlatformName().c_str()); - mf->AddDefinition("CMAKE_VS_INTEL_Fortran_PROJECT_VERSION", - this->GetIntelProjectVersion()); - return this->cmGlobalVisualStudioGenerator::SetSystemName(s, mf); + return this->cmGlobalVisualStudioGenerator::SetGeneratorPlatform(p, mf); } void cmGlobalVisualStudio7Generator::GenerateConfigurations(cmMakefile* mf) diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h index dc8b9157e6..04a74dbd58 100644 --- a/Source/cmGlobalVisualStudio7Generator.h +++ b/Source/cmGlobalVisualStudio7Generator.h @@ -46,6 +46,8 @@ public: virtual bool SetSystemName(std::string const& s, cmMakefile* mf); + virtual bool SetGeneratorPlatform(std::string const& p, cmMakefile* mf); + /** Get the documentation entry for this generator. */ static void GetDocumentation(cmDocumentationEntry& entry); @@ -175,6 +177,7 @@ protected: // Set during OutputSLNFile with the name of the current project. // There is one SLN file per project. std::string CurrentProject; + std::string GeneratorPlatform; std::string DefaultPlatformName; bool MasmEnabled; diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index c91730f217..745515bcf1 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -158,6 +158,21 @@ void cmGlobalVisualStudio8Generator::AddPlatformDefinitions(cmMakefile* mf) } } +//---------------------------------------------------------------------------- +bool cmGlobalVisualStudio8Generator::SetGeneratorPlatform(std::string const& p, + cmMakefile* mf) +{ + if(this->DefaultPlatformName == "Win32") + { + this->GeneratorPlatform = p; + return this->cmGlobalVisualStudio7Generator::SetGeneratorPlatform("", mf); + } + else + { + return this->cmGlobalVisualStudio7Generator::SetGeneratorPlatform(p, mf); + } +} + //---------------------------------------------------------------------------- // ouput standard header for dsw file void cmGlobalVisualStudio8Generator::WriteSLNHeader(std::ostream& fout) diff --git a/Source/cmGlobalVisualStudio8Generator.h b/Source/cmGlobalVisualStudio8Generator.h index cb6d3d9f19..4b41ed7d66 100644 --- a/Source/cmGlobalVisualStudio8Generator.h +++ b/Source/cmGlobalVisualStudio8Generator.h @@ -40,6 +40,8 @@ public: cmMakefile *, bool optional); virtual void AddPlatformDefinitions(cmMakefile* mf); + virtual bool SetGeneratorPlatform(std::string const& p, cmMakefile* mf); + /** * Override Configure and Generate to add the build-system check * target. diff --git a/Tests/RunCMake/GeneratorPlatform/RunCMakeTest.cmake b/Tests/RunCMake/GeneratorPlatform/RunCMakeTest.cmake index 60217bcaf4..442eb9f9a1 100644 --- a/Tests/RunCMake/GeneratorPlatform/RunCMakeTest.cmake +++ b/Tests/RunCMake/GeneratorPlatform/RunCMakeTest.cmake @@ -2,6 +2,12 @@ include(RunCMake) run_cmake(NoPlatform) -set(RunCMake_TEST_OPTIONS "-DCMAKE_GENERATOR_PLATFORM=Bad Platform") -run_cmake(BadPlatform) -unset(RunCMake_TEST_OPTIONS) +if("${RunCMake_GENERATOR}" MATCHES "^Visual Studio ([89]|1[0124])( 20[0-9][0-9])?$") + set(RunCMake_TEST_OPTIONS "-DCMAKE_GENERATOR_PLATFORM=x64") + run_cmake(x64Platform) + unset(RunCMake_TEST_OPTIONS) +else() + set(RunCMake_TEST_OPTIONS "-DCMAKE_GENERATOR_PLATFORM=Bad Platform") + run_cmake(BadPlatform) + unset(RunCMake_TEST_OPTIONS) +endif() diff --git a/Tests/RunCMake/GeneratorPlatform/x64Platform-stdout.txt b/Tests/RunCMake/GeneratorPlatform/x64Platform-stdout.txt new file mode 100644 index 0000000000..05a83ff7cf --- /dev/null +++ b/Tests/RunCMake/GeneratorPlatform/x64Platform-stdout.txt @@ -0,0 +1,2 @@ +-- CMAKE_GENERATOR_PLATFORM is 'x64' as expected. +-- CMAKE_VS_PLATFORM_NAME is 'x64' as expected. diff --git a/Tests/RunCMake/GeneratorPlatform/x64Platform.cmake b/Tests/RunCMake/GeneratorPlatform/x64Platform.cmake new file mode 100644 index 0000000000..a23bdc74b7 --- /dev/null +++ b/Tests/RunCMake/GeneratorPlatform/x64Platform.cmake @@ -0,0 +1,7 @@ +foreach(v CMAKE_GENERATOR_PLATFORM CMAKE_VS_PLATFORM_NAME) + if("x${${v}}" STREQUAL "xx64") + message(STATUS "${v} is 'x64' as expected.") + else() + message(FATAL_ERROR "${v} is '${${v}}' but should be 'x64'!") + endif() +endforeach()