Selaa lähdekoodia

Merge topic 'vs-ConfigurationType-genex'

8909a450a6 VS: Add support for generator expressions to VS_CONFIGURATION_TYPE

Acked-by: Kitware Robot <[email protected]>
Merge-request: !3746
Brad King 6 vuotta sitten
vanhempi
sitoutus
3e93b2fa66

+ 2 - 0
Help/prop_tgt/VS_CONFIGURATION_TYPE.rst

@@ -4,6 +4,8 @@ VS_CONFIGURATION_TYPE
 Visual Studio project configuration type.
 Visual Studio project configuration type.
 
 
 Sets the ``ConfigurationType`` attribute for a generated Visual Studio project.
 Sets the ``ConfigurationType`` attribute for a generated Visual Studio project.
+The property value may use
+:manual:`generator expressions <cmake-generator-expressions(7)>`.
 If this property is set, it overrides the default setting that is based on the
 If this property is set, it overrides the default setting that is based on the
 target type (e.g. ``StaticLibrary``, ``Application``, ...).
 target type (e.g. ``StaticLibrary``, ``Application``, ...).
 
 

+ 5 - 0
Help/release/dev/vs-configuration-type-genex.rst

@@ -0,0 +1,5 @@
+vs-configuration-type-genex
+---------------------------
+
+* :prop_tgt:`VS_CONFIGURATION_TYPE` now supports
+  :manual:`generator expressions <cmake-generator-expressions(7)>`.

+ 4 - 1
Source/cmVisualStudio10TargetGenerator.cxx

@@ -1115,7 +1115,10 @@ void cmVisualStudio10TargetGenerator::WriteProjectConfigurationValues(Elem& e0)
       std::string configType;
       std::string configType;
       if (const char* vsConfigurationType =
       if (const char* vsConfigurationType =
             this->GeneratorTarget->GetProperty("VS_CONFIGURATION_TYPE")) {
             this->GeneratorTarget->GetProperty("VS_CONFIGURATION_TYPE")) {
-        configType = vsConfigurationType;
+        cmGeneratorExpression ge;
+        std::unique_ptr<cmCompiledGeneratorExpression> cge =
+          ge.Parse(vsConfigurationType);
+        configType = cge->Evaluate(this->LocalGenerator, c);
       } else {
       } else {
         switch (this->GeneratorTarget->GetType()) {
         switch (this->GeneratorTarget->GetType()) {
           case cmStateEnums::SHARED_LIBRARY:
           case cmStateEnums::SHARED_LIBRARY:

+ 1 - 1
Tests/RunCMake/VS10Project/VsConfigurationType-check.cmake

@@ -9,7 +9,7 @@ file(STRINGS "${vcProjectFile}" lines)
 foreach(line IN LISTS lines)
 foreach(line IN LISTS lines)
   if(line MATCHES "^ *<ConfigurationType>(.*)</ConfigurationType>$")
   if(line MATCHES "^ *<ConfigurationType>(.*)</ConfigurationType>$")
     set(propertyFound TRUE)
     set(propertyFound TRUE)
-    set(expectedValue "MyValue")
+    set(expectedValue "MyValue foo")
     set(actualValue ${CMAKE_MATCH_1})
     set(actualValue ${CMAKE_MATCH_1})
     if(NOT (${actualValue} STREQUAL ${expectedValue}))
     if(NOT (${actualValue} STREQUAL ${expectedValue}))
       set(RunCMake_TEST_FAILED "ConfigurationType \"${actualValue}\" differs from expected value \"${expectedValue}\".")
       set(RunCMake_TEST_FAILED "ConfigurationType \"${actualValue}\" differs from expected value \"${expectedValue}\".")

+ 1 - 1
Tests/RunCMake/VS10Project/VsConfigurationType.cmake

@@ -1,3 +1,3 @@
 enable_language(CXX)
 enable_language(CXX)
 add_library(foo foo.cpp)
 add_library(foo foo.cpp)
-set_target_properties(foo PROPERTIES VS_CONFIGURATION_TYPE "MyValue")
+set_target_properties(foo PROPERTIES VS_CONFIGURATION_TYPE "MyValue $<TARGET_PROPERTY:foo,NAME>")