Bladeren bron

VS: Import default C++ props file before toolset-specific props file

This avoids overwriting toolset-specific settings like `VCRedistDir`
with default settings.

Fixes: #22420
Matthew Voss 2 jaren geleden
bovenliggende
commit
d3c4c6d630
2 gewijzigde bestanden met toevoegingen van 4 en 1 verwijderingen
  1. 3 0
      Modules/CMakeDetermineCompilerId.cmake
  2. 1 1
      Source/cmVisualStudio10TargetGenerator.cxx

+ 3 - 0
Modules/CMakeDetermineCompilerId.cmake

@@ -401,6 +401,9 @@ Id flags: ${testflags} ${CMAKE_${lang}_COMPILER_ID_FLAGS_ALWAYS}
             endif()
           endif()
           set(id_toolset_version_props "<Import Project=\"${CMAKE_GENERATOR_INSTANCE}\\VC\\Auxiliary\\Build${id_sep}${CMAKE_VS_PLATFORM_TOOLSET_VERSION}\\Microsoft.VCToolsVersion.${CMAKE_VS_PLATFORM_TOOLSET_VERSION}.props\" />")
+          if(lang STREQUAL CXX OR lang STREQUAL C)
+            set(id_toolset_version_props "<Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />${id_toolset_version_props}")
+          endif()
           unset(id_sep)
         endif()
       endif()

+ 1 - 1
Source/cmVisualStudio10TargetGenerator.cxx

@@ -693,12 +693,12 @@ void cmVisualStudio10TargetGenerator::WriteClassicMsBuildProjectFile(
 
     switch (this->ProjectType) {
       case VsProjectType::vcxproj: {
+        Elem(e0, "Import").Attribute("Project", VS10_CXX_DEFAULT_PROPS);
         std::string const& props =
           this->GlobalGenerator->GetPlatformToolsetVersionProps();
         if (!props.empty()) {
           Elem(e0, "Import").Attribute("Project", props);
         }
-        Elem(e0, "Import").Attribute("Project", VS10_CXX_DEFAULT_PROPS);
       } break;
       case VsProjectType::csproj:
         Elem(e0, "Import")