From 65624c39e3f435a601760bfcb01d9cafbbfb56c1 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 24 Jun 2014 15:39:11 -0400 Subject: [PATCH] VS14: Add Visual Studio 14 generator (#14982) Call the generator "Visual Studio 14" without any year because this version of VS does not provide a year in the product name. Copy cmGlobalVisualStudio12Generator to cmGlobalVisualStudio14Generator and update version numbers accordingly. Add the VS14 enumeration value. Teach the platform module Windows-MSVC to set MSVC14 and document the variable. Teach module InstallRequiredSystemLibraries to look for the VS 14 runtime libraries. Teach tests CheckCompilerRelatedVariables, VSExternalInclude, and RunCMake.GeneratorToolset to treat VS 14 as they do VS 10, 11, and 12. Co-Author: Pawel Stopinski --- Help/generator/Visual Studio 14.rst | 9 ++ Help/manual/cmake-generators.7.rst | 1 + Help/manual/cmake-variables.7.rst | 1 + Help/variable/MSVC14.rst | 6 + Help/variable/MSVC_VERSION.rst | 5 +- Modules/InstallRequiredSystemLibraries.cmake | 8 ++ Modules/Platform/Windows-MSVC.cmake | 5 +- Source/CMakeLists.txt | 2 + Source/cmGlobalVisualStudio14Generator.cxx | 116 ++++++++++++++++++ Source/cmGlobalVisualStudio14Generator.h | 44 +++++++ Source/cmLocalVisualStudioGenerator.h | 4 +- Source/cmVisualStudioGeneratorOptions.cxx | 1 + Source/cmake.cxx | 4 + .../CMakeLists.txt | 4 + .../GeneratorToolset/RunCMakeTest.cmake | 4 +- Tests/VSExternalInclude/CMakeLists.txt | 4 +- 16 files changed, 209 insertions(+), 9 deletions(-) create mode 100644 Help/generator/Visual Studio 14.rst create mode 100644 Help/variable/MSVC14.rst create mode 100644 Source/cmGlobalVisualStudio14Generator.cxx create mode 100644 Source/cmGlobalVisualStudio14Generator.h diff --git a/Help/generator/Visual Studio 14.rst b/Help/generator/Visual Studio 14.rst new file mode 100644 index 000000000..7f4fdc3ae --- /dev/null +++ b/Help/generator/Visual Studio 14.rst @@ -0,0 +1,9 @@ +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. diff --git a/Help/manual/cmake-generators.7.rst b/Help/manual/cmake-generators.7.rst index 8d0c70418..7f5093f0c 100644 --- a/Help/manual/cmake-generators.7.rst +++ b/Help/manual/cmake-generators.7.rst @@ -64,6 +64,7 @@ one may launch CMake from any environment. /generator/Visual Studio 10 2010 /generator/Visual Studio 11 2012 /generator/Visual Studio 12 2013 + /generator/Visual Studio 14 /generator/Xcode Extra Generators diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index df434c541..d0d01a92e 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst @@ -178,6 +178,7 @@ Variables that Describe the System /variable/MSVC10 /variable/MSVC11 /variable/MSVC12 + /variable/MSVC14 /variable/MSVC60 /variable/MSVC70 /variable/MSVC71 diff --git a/Help/variable/MSVC14.rst b/Help/variable/MSVC14.rst new file mode 100644 index 000000000..33c782b74 --- /dev/null +++ b/Help/variable/MSVC14.rst @@ -0,0 +1,6 @@ +MSVC14 +------ + +True when using Microsoft Visual C 14.0 + +Set to true when the compiler is version 14.0 of Microsoft Visual C. diff --git a/Help/variable/MSVC_VERSION.rst b/Help/variable/MSVC_VERSION.rst index d74114ea5..ef3b0b558 100644 --- a/Help/variable/MSVC_VERSION.rst +++ b/Help/variable/MSVC_VERSION.rst @@ -3,9 +3,7 @@ MSVC_VERSION The version of Microsoft Visual C/C++ being used if any. -Known version numbers are: - -:: +Known version numbers are:: 1200 = VS 6.0 1300 = VS 7.0 @@ -15,3 +13,4 @@ Known version numbers are: 1600 = VS 10.0 1700 = VS 11.0 1800 = VS 12.0 + 1900 = VS 14.0 diff --git a/Modules/InstallRequiredSystemLibraries.cmake b/Modules/InstallRequiredSystemLibraries.cmake index 2fc8c04e7..349cbf512 100644 --- a/Modules/InstallRequiredSystemLibraries.cmake +++ b/Modules/InstallRequiredSystemLibraries.cmake @@ -198,6 +198,10 @@ if(MSVC) MSVCRT_FILES_FOR_VERSION(12) endif() + if(MSVC14) + MSVCRT_FILES_FOR_VERSION(14) + endif() + if(CMAKE_INSTALL_MFC_LIBRARIES) if(MSVC70) set(__install__libs ${__install__libs} @@ -367,6 +371,10 @@ if(MSVC) if(MSVC12) MFC_FILES_FOR_VERSION(12) endif() + + if(MSVC14) + MFC_FILES_FOR_VERSION(14) + endif() endif() foreach(lib diff --git a/Modules/Platform/Windows-MSVC.cmake b/Modules/Platform/Windows-MSVC.cmake index 5732170fc..bb6d991b9 100644 --- a/Modules/Platform/Windows-MSVC.cmake +++ b/Modules/Platform/Windows-MSVC.cmake @@ -85,6 +85,7 @@ if(NOT MSVC_VERSION) set(MSVC10) set(MSVC11) set(MSVC12) + set(MSVC14) set(MSVC60) set(MSVC70) set(MSVC71) @@ -92,7 +93,9 @@ if(NOT MSVC_VERSION) set(MSVC90) set(CMAKE_COMPILER_2005) set(CMAKE_COMPILER_SUPPORTS_PDBTYPE) - if(NOT "${_compiler_version}" VERSION_LESS 18) + if(NOT "${_compiler_version}" VERSION_LESS 19) + set(MSVC14 1) + elseif(NOT "${_compiler_version}" VERSION_LESS 18) set(MSVC12 1) elseif(NOT "${_compiler_version}" VERSION_LESS 17) set(MSVC11 1) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index c3c24feef..3838cb02a 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -426,6 +426,8 @@ if (WIN32) cmGlobalVisualStudio11Generator.cxx cmGlobalVisualStudio12Generator.h cmGlobalVisualStudio12Generator.cxx + cmGlobalVisualStudio14Generator.h + cmGlobalVisualStudio14Generator.cxx cmGlobalVisualStudioGenerator.cxx cmGlobalVisualStudioGenerator.h cmIDEFlagTable.h diff --git a/Source/cmGlobalVisualStudio14Generator.cxx b/Source/cmGlobalVisualStudio14Generator.cxx new file mode 100644 index 000000000..9bde0ade9 --- /dev/null +++ b/Source/cmGlobalVisualStudio14Generator.cxx @@ -0,0 +1,116 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2014 Kitware, Inc., Insight Software Consortium + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#include "cmGlobalVisualStudio14Generator.h" +#include "cmLocalVisualStudio10Generator.h" +#include "cmMakefile.h" + +static const char vs14generatorName[] = "Visual Studio 14"; + +class cmGlobalVisualStudio14Generator::Factory + : public cmGlobalGeneratorFactory +{ +public: + virtual cmGlobalGenerator* CreateGlobalGenerator( + const std::string& genName) const + { + if(strncmp(genName.c_str(), vs14generatorName, + sizeof(vs14generatorName) - 1) != 0) + { + return 0; + } + const char* p = genName.c_str() + sizeof(vs14generatorName) - 1; + if(!*p) + { + return new cmGlobalVisualStudio14Generator( + genName, "", ""); + } + if(*p++ != ' ') + { return 0; } + if(strcmp(p, "Win64") == 0) + { + return new cmGlobalVisualStudio14Generator( + genName, "x64", "CMAKE_FORCE_WIN64"); + } + if(strcmp(p, "ARM") == 0) + { + return new cmGlobalVisualStudio14Generator( + genName, "ARM", ""); + } + return 0; + } + + virtual void GetDocumentation(cmDocumentationEntry& entry) const + { + entry.Name = vs14generatorName; + entry.Brief = "Generates Visual Studio 14 project files."; + } + + virtual void GetGenerators(std::vector& names) const + { + names.push_back(vs14generatorName); + names.push_back(vs14generatorName + std::string(" ARM")); + names.push_back(vs14generatorName + std::string(" Win64")); + } +}; + +//---------------------------------------------------------------------------- +cmGlobalGeneratorFactory* cmGlobalVisualStudio14Generator::NewFactory() +{ + return new Factory; +} + +//---------------------------------------------------------------------------- +cmGlobalVisualStudio14Generator::cmGlobalVisualStudio14Generator( + const std::string& name, const std::string& platformName, + const std::string& additionalPlatformDefinition) + : cmGlobalVisualStudio12Generator(name, platformName, + additionalPlatformDefinition) +{ + std::string vc14Express; + this->ExpressEdition = cmSystemTools::ReadRegistryValue( + "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VCExpress\\14.0\\Setup\\VC;" + "ProductDir", vc14Express, cmSystemTools::KeyWOW64_32); + this->DefaultPlatformToolset = "v140"; +} + +//---------------------------------------------------------------------------- +bool +cmGlobalVisualStudio14Generator::MatchesGeneratorName( + const std::string& name) const +{ + return name == this->GetName(); +} + +//---------------------------------------------------------------------------- +void cmGlobalVisualStudio14Generator::WriteSLNHeader(std::ostream& fout) +{ + // Visual Studio 14 writes .sln format 12.00 + fout << "Microsoft Visual Studio Solution File, Format Version 12.00\n"; + if (this->ExpressEdition) + { + fout << "# Visual Studio Express 14 for Windows Desktop\n"; + } + else + { + fout << "# Visual Studio 14\n"; + } +} + +//---------------------------------------------------------------------------- +cmLocalGenerator *cmGlobalVisualStudio14Generator::CreateLocalGenerator() +{ + cmLocalVisualStudio10Generator* lg = + new cmLocalVisualStudio10Generator(cmLocalVisualStudioGenerator::VS14); + lg->SetPlatformName(this->GetPlatformName()); + lg->SetGlobalGenerator(this); + return lg; +} diff --git a/Source/cmGlobalVisualStudio14Generator.h b/Source/cmGlobalVisualStudio14Generator.h new file mode 100644 index 000000000..707411901 --- /dev/null +++ b/Source/cmGlobalVisualStudio14Generator.h @@ -0,0 +1,44 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2014 Kitware, Inc., Insight Software Consortium + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#ifndef cmGlobalVisualStudio14Generator_h +#define cmGlobalVisualStudio14Generator_h + +#include "cmGlobalVisualStudio12Generator.h" + + +/** \class cmGlobalVisualStudio14Generator */ +class cmGlobalVisualStudio14Generator: + public cmGlobalVisualStudio12Generator +{ +public: + cmGlobalVisualStudio14Generator(const std::string& name, + const std::string& platformName, + const std::string& additionalPlatformDefinition); + static cmGlobalGeneratorFactory* NewFactory(); + + virtual bool MatchesGeneratorName(const std::string& name) const; + + virtual void WriteSLNHeader(std::ostream& fout); + + ///! create the correct local generator + virtual cmLocalGenerator *CreateLocalGenerator(); + + /** TODO: VS 14 user macro support. */ + virtual std::string GetUserMacrosDirectory() { return ""; } + + virtual const char* GetToolsVersion() { return "14.0"; } +protected: + virtual const char* GetIDEVersion() { return "14.0"; } +private: + class Factory; +}; +#endif diff --git a/Source/cmLocalVisualStudioGenerator.h b/Source/cmLocalVisualStudioGenerator.h index 3bf4f4339..d26c2eaf0 100644 --- a/Source/cmLocalVisualStudioGenerator.h +++ b/Source/cmLocalVisualStudioGenerator.h @@ -40,7 +40,9 @@ public: VS9 = 90, VS10 = 100, VS11 = 110, - VS12 = 120 + VS12 = 120, + /* VS13 = 130 was skipped */ + VS14 = 140 }; cmLocalVisualStudioGenerator(VSVersion v); diff --git a/Source/cmVisualStudioGeneratorOptions.cxx b/Source/cmVisualStudioGeneratorOptions.cxx index 81adb56c6..2cbf5db7b 100644 --- a/Source/cmVisualStudioGeneratorOptions.cxx +++ b/Source/cmVisualStudioGeneratorOptions.cxx @@ -68,6 +68,7 @@ void cmVisualStudioGeneratorOptions::FixExceptionHandlingDefault() case cmLocalVisualStudioGenerator::VS10: case cmLocalVisualStudioGenerator::VS11: case cmLocalVisualStudioGenerator::VS12: + case cmLocalVisualStudioGenerator::VS14: // by default VS puts empty // for a project, to make our projects look the same put a new line // and space over for the closing as the default diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 86d3766de..a051c8760 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -58,6 +58,7 @@ # include "cmGlobalVisualStudio10Generator.h" # include "cmGlobalVisualStudio11Generator.h" # include "cmGlobalVisualStudio12Generator.h" +# include "cmGlobalVisualStudio14Generator.h" # include "cmGlobalBorlandMakefileGenerator.h" # include "cmGlobalNMakeMakefileGenerator.h" # include "cmGlobalJOMMakefileGenerator.h" @@ -1380,6 +1381,7 @@ int cmake::ActualConfigure() {"10.0", "Visual Studio 10 2010"}, {"11.0", "Visual Studio 11 2012"}, {"12.0", "Visual Studio 12 2013"}, + {"14.0", "Visual Studio 14"}, {0, 0}}; for(int i=0; version[i].MSVersion != 0; i++) { @@ -1778,6 +1780,8 @@ void cmake::AddDefaultGenerators() cmGlobalVisualStudio11Generator::NewFactory()); this->Generators.push_back( cmGlobalVisualStudio12Generator::NewFactory()); + this->Generators.push_back( + cmGlobalVisualStudio14Generator::NewFactory()); this->Generators.push_back( cmGlobalVisualStudio71Generator::NewFactory()); this->Generators.push_back( diff --git a/Tests/CheckCompilerRelatedVariables/CMakeLists.txt b/Tests/CheckCompilerRelatedVariables/CMakeLists.txt index 69cfdb8e3..87b7f1acd 100644 --- a/Tests/CheckCompilerRelatedVariables/CMakeLists.txt +++ b/Tests/CheckCompilerRelatedVariables/CMakeLists.txt @@ -40,6 +40,9 @@ endif() if(DEFINED MSVC12) math(EXPR msvc_total "${msvc_total} + 1") endif() +if(DEFINED MSVC14) + math(EXPR msvc_total "${msvc_total} + 1") +endif() echo_var(MSVC) echo_var(MSVC60) @@ -50,6 +53,7 @@ echo_var(MSVC90) echo_var(MSVC10) echo_var(MSVC11) echo_var(MSVC12) +echo_var(MSVC14) echo_var(MSVC_IDE) if(MSVC) diff --git a/Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake b/Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake index d39f33f0a..62206575c 100644 --- a/Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake +++ b/Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake @@ -3,7 +3,7 @@ include(RunCMake) set(RunCMake_GENERATOR_TOOLSET "") run_cmake(NoToolset) -if("${RunCMake_GENERATOR}" MATCHES "Visual Studio 1[012]|Xcode" AND NOT XCODE_BELOW_3) +if("${RunCMake_GENERATOR}" MATCHES "Visual Studio 1[0124]|Xcode" AND NOT XCODE_BELOW_3) set(RunCMake_GENERATOR_TOOLSET "Test Toolset") run_cmake(TestToolset) else() @@ -17,7 +17,7 @@ set(RunCMake_TEST_OPTIONS -T "Extra Toolset") run_cmake(TwoToolsets) unset(RunCMake_TEST_OPTIONS) -if("${RunCMake_GENERATOR}" MATCHES "Visual Studio 1[012]|Xcode" AND NOT XCODE_BELOW_3) +if("${RunCMake_GENERATOR}" MATCHES "Visual Studio 1[0124]|Xcode" AND NOT XCODE_BELOW_3) set(RunCMake_TEST_OPTIONS -DCMAKE_TOOLCHAIN_FILE=${RunCMake_SOURCE_DIR}/TestToolset-toolchain.cmake) run_cmake(TestToolsetToolchain) unset(RunCMake_TEST_OPTIONS) diff --git a/Tests/VSExternalInclude/CMakeLists.txt b/Tests/VSExternalInclude/CMakeLists.txt index 8fc287145..cfcccecf6 100644 --- a/Tests/VSExternalInclude/CMakeLists.txt +++ b/Tests/VSExternalInclude/CMakeLists.txt @@ -6,7 +6,7 @@ if(${CMAKE_GENERATOR} MATCHES "Visual Studio 6") else() set(PROJECT_EXT vcproj) endif() -if(${CMAKE_GENERATOR} MATCHES "Visual Studio 1[012]") +if(${CMAKE_GENERATOR} MATCHES "Visual Studio 1[0124]") set(PROJECT_EXT vcxproj) endif() @@ -54,7 +54,7 @@ add_dependencies(VSExternalInclude lib2) # and the sln file can no longer be the only source # of that depend. So, for VS 10 make the executable # depend on lib1 and lib2 -if(${CMAKE_GENERATOR} MATCHES "Visual Studio 1[012]") +if(${CMAKE_GENERATOR} MATCHES "Visual Studio 1[0124]") add_dependencies(VSExternalInclude lib1) endif()