Pārlūkot izejas kodu

Merge topic 'genexpr-for-mfc-flag'

c1f1eaf7a4 VS: Teach CMAKE_MFC_FLAG to support generator expressions

Acked-by: Kitware Robot <[email protected]>
Merge-request: !5283
Brad King 5 gadi atpakaļ
vecāks
revīzija
436b57ccb2

+ 4 - 0
Help/release/dev/genexpr-for-mfc-flag.rst

@@ -0,0 +1,4 @@
+genexpr-for-mfc-flag
+--------------------
+
+* The :variable:`CMAKE_MFC_FLAG` variable now supports generator expressions.

+ 3 - 0
Help/variable/CMAKE_MFC_FLAG.rst

@@ -15,3 +15,6 @@ Usage example:
   add_definitions(-D_AFXDLL)
   set(CMAKE_MFC_FLAG 2)
   add_executable(CMakeSetup WIN32 ${SRCS})
+
+Contents of ``CMAKE_MFC_FLAG`` may use
+:manual:`generator expressions <cmake-generator-expressions(7)>`.

+ 1 - 1
Source/cmLocalVisualStudio7Generator.cxx

@@ -583,7 +583,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(
 {
   std::string mfcFlag;
   if (cmProp p = this->Makefile->GetDefinition("CMAKE_MFC_FLAG")) {
-    mfcFlag = *p;
+    mfcFlag = cmGeneratorExpression::Evaluate(*p, this, configName);
   } else {
     mfcFlag = "0";
   }

+ 2 - 1
Source/cmVisualStudio10TargetGenerator.cxx

@@ -1224,7 +1224,8 @@ void cmVisualStudio10TargetGenerator::WriteMSToolConfigurationValues(
   cmGlobalVisualStudio10Generator* gg = this->GlobalGenerator;
   cmProp mfcFlag = this->Makefile->GetDefinition("CMAKE_MFC_FLAG");
   if (mfcFlag) {
-    std::string const mfcFlagValue = *mfcFlag;
+    std::string const mfcFlagValue =
+      cmGeneratorExpression::Evaluate(*mfcFlag, this->LocalGenerator, config);
 
     std::string useOfMfcValue = "false";
     if (this->GeneratorTarget->GetType() <= cmStateEnums::OBJECT_LIBRARY) {

+ 3 - 0
Tests/MFC/CMakeLists.txt.in

@@ -65,3 +65,6 @@ if("${CMAKE_MFC_FLAG}" STREQUAL "2")
   set(CMAKE_INSTALL_MFC_LIBRARIES ON)
   include(InstallRequiredSystemLibraries)
 endif()
+
+# Encode the value inside a generator expression to test evaluation.
+set(CMAKE_MFC_FLAG "$<1:${CMAKE_MFC_FLAG}>")