diff options
author | Brad King <brad.king@kitware.com> | 2017-07-11 11:37:13 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2017-07-11 11:37:42 (GMT) |
commit | 970569a941a3259f5303a5090ed7bca7bb6e6d7e (patch) | |
tree | 51992b7663d4ba195e80301adb56127b13b61c13 /Source | |
parent | a49b235db9036d5ec8c8535d2074c136eeb13254 (diff) | |
parent | 2644e4c9fcc747d750d6a522d2b4029b172902c3 (diff) | |
download | CMake-970569a941a3259f5303a5090ed7bca7bb6e6d7e.zip CMake-970569a941a3259f5303a5090ed7bca7bb6e6d7e.tar.gz CMake-970569a941a3259f5303a5090ed7bca7bb6e6d7e.tar.bz2 |
Merge topic 'vs-2017-choose-via-environment'
2644e4c9 VS: Choose VS 2017 instance via environment variable
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !1030
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmVSSetupHelper.cxx | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/Source/cmVSSetupHelper.cxx b/Source/cmVSSetupHelper.cxx index c2ff664..7168f26 100644 --- a/Source/cmVSSetupHelper.cxx +++ b/Source/cmVSSetupHelper.cxx @@ -1,6 +1,7 @@ /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmVSSetupHelper.h" +#include "cmSystemTools.h" #ifndef VSSetupConstants #define VSSetupConstants @@ -240,6 +241,22 @@ bool cmVSSetupAPIHelper::EnumerateAndChooseVSInstance() setupHelper == NULL) return false; + std::string envVSCommonToolsDir; + + // FIXME: When we support VS versions beyond 2017, the version + // to choose will be passed in by the caller. We need to map that + // to a per-version name of this environment variable. + if (cmSystemTools::GetEnv("VS150COMNTOOLS", envVSCommonToolsDir)) { + cmSystemTools::ConvertToUnixSlashes(envVSCommonToolsDir); + } + // FIXME: If the environment variable value changes between runs + // of CMake within a given build tree the results are not defined. + // Instead we should save a CMAKE_GENERATOR_INSTANCE value in the cache + // (similar to CMAKE_GENERATOR_TOOLSET) to hold it persistently. + // Unfortunately doing so will require refactoring elsewhere in + // order to make sure the value is available in time to create + // the generator. + std::vector<VSInstanceInfo> vecVSInstances; SmartCOMPtr<IEnumSetupInstances> enumInstances = NULL; if (FAILED( @@ -263,6 +280,17 @@ bool cmVSSetupAPIHelper::EnumerateAndChooseVSInstance() instance = instance2 = NULL; if (isInstalled) { + if (!envVSCommonToolsDir.empty()) { + std::string currentVSLocation(instanceInfo.VSInstallLocation.begin(), + instanceInfo.VSInstallLocation.end()); + cmSystemTools::ConvertToUnixSlashes(currentVSLocation); + currentVSLocation += "/Common7/Tools"; + if (cmSystemTools::ComparePath(currentVSLocation, + envVSCommonToolsDir)) { + chosenInstanceInfo = instanceInfo; + return true; + } + } vecVSInstances.push_back(instanceInfo); } } |