Ver código fonte

Merge topic 'fix-11213-vs10-mfc-support'

537020f Tests: Nudge MFC test to pass on VS 6 dashboards (#11213)
51f442e VS11: Update InstallRequiredSystemLibraries.cmake for VS11 (#11213)
d85ab7a Tests: Add environment logging to the MFC test (#11213)
011694c VS10: Use expected values for UseOfMfc (#11213)
a2e6d24 Tests: Fix MFC test to work with VS 10 and later (#11213)
David Cole 14 anos atrás
pai
commit
f1197ff0da

+ 58 - 38
Modules/InstallRequiredSystemLibraries.cmake

@@ -141,36 +141,46 @@ IF(MSVC)
     ENDIF(CMAKE_INSTALL_DEBUG_LIBRARIES)
   ENDIF(MSVC90)
 
-  IF(MSVC10)
+  MACRO(MSVCRT_FILES_FOR_VERSION version)
+    SET(v "${version}")
+
     # Find the runtime library redistribution directory.
     GET_FILENAME_COMPONENT(msvc_install_dir
-      "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\10.0;InstallDir]" ABSOLUTE)
-    FIND_PATH(MSVC10_REDIST_DIR NAMES ${CMAKE_MSVC_ARCH}/Microsoft.VC100.CRT
+      "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\${v}.0;InstallDir]" ABSOLUTE)
+    FIND_PATH(MSVC${v}_REDIST_DIR NAMES ${CMAKE_MSVC_ARCH}/Microsoft.VC${v}0.CRT
       PATHS
         "${msvc_install_dir}/../../VC/redist"
         "${base_dir}/VC/redist"
-        "$ENV{ProgramFiles}/Microsoft Visual Studio 10.0/VC/redist"
-        "$ENV{ProgramFiles(x86)}/Microsoft Visual Studio 10.0/VC/redist"
+        "$ENV{ProgramFiles}/Microsoft Visual Studio ${v}.0/VC/redist"
+        "$ENV{ProgramFiles(x86)}/Microsoft Visual Studio ${v}.0/VC/redist"
       )
-    MARK_AS_ADVANCED(MSVC10_REDIST_DIR)
-    SET(MSVC10_CRT_DIR "${MSVC10_REDIST_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.VC100.CRT")
+    MARK_AS_ADVANCED(MSVC${v}_REDIST_DIR)
+    SET(MSVC${v}_CRT_DIR "${MSVC${v}_REDIST_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.VC${v}0.CRT")
 
     IF(NOT CMAKE_INSTALL_DEBUG_LIBRARIES_ONLY)
       SET(__install__libs
-        "${MSVC10_CRT_DIR}/msvcp100.dll"
-        "${MSVC10_CRT_DIR}/msvcr100.dll"
+        "${MSVC${v}_CRT_DIR}/msvcp${v}0.dll"
+        "${MSVC${v}_CRT_DIR}/msvcr${v}0.dll"
         )
     ENDIF(NOT CMAKE_INSTALL_DEBUG_LIBRARIES_ONLY)
 
     IF(CMAKE_INSTALL_DEBUG_LIBRARIES)
-      SET(MSVC10_CRT_DIR
-        "${MSVC10_REDIST_DIR}/Debug_NonRedist/${CMAKE_MSVC_ARCH}/Microsoft.VC100.DebugCRT")
+      SET(MSVC${v}_CRT_DIR
+        "${MSVC${v}_REDIST_DIR}/Debug_NonRedist/${CMAKE_MSVC_ARCH}/Microsoft.VC${v}0.DebugCRT")
       SET(__install__libs ${__install__libs}
-        "${MSVC10_CRT_DIR}/msvcp100d.dll"
-        "${MSVC10_CRT_DIR}/msvcr100d.dll"
+        "${MSVC${v}_CRT_DIR}/msvcp${v}0d.dll"
+        "${MSVC${v}_CRT_DIR}/msvcr${v}0d.dll"
         )
     ENDIF(CMAKE_INSTALL_DEBUG_LIBRARIES)
-  ENDIF(MSVC10)
+  ENDMACRO()
+
+  IF(MSVC10)
+    MSVCRT_FILES_FOR_VERSION(10)
+  ENDIF()
+
+  IF(MSVC11)
+    MSVCRT_FILES_FOR_VERSION(11)
+  ENDIF()
 
   IF(CMAKE_INSTALL_MFC_LIBRARIES)
     IF(MSVC70)
@@ -273,42 +283,52 @@ IF(MSVC)
         )
     ENDIF(MSVC90)
 
-    IF(MSVC10)
+    MACRO(MFC_FILES_FOR_VERSION version)
+      SET(v "${version}")
+
       IF(CMAKE_INSTALL_DEBUG_LIBRARIES)
-        SET(MSVC10_MFC_DIR
-          "${MSVC10_REDIST_DIR}/Debug_NonRedist/${CMAKE_MSVC_ARCH}/Microsoft.VC100.DebugMFC")
+        SET(MSVC${v}_MFC_DIR
+          "${MSVC${v}_REDIST_DIR}/Debug_NonRedist/${CMAKE_MSVC_ARCH}/Microsoft.VC${v}0.DebugMFC")
         SET(__install__libs ${__install__libs}
-          "${MSVC10_MFC_DIR}/mfc100d.dll"
-          "${MSVC10_MFC_DIR}/mfc100ud.dll"
-          "${MSVC10_MFC_DIR}/mfcm100d.dll"
-          "${MSVC10_MFC_DIR}/mfcm100ud.dll"
+          "${MSVC${v}_MFC_DIR}/mfc${v}0d.dll"
+          "${MSVC${v}_MFC_DIR}/mfc${v}0ud.dll"
+          "${MSVC${v}_MFC_DIR}/mfcm${v}0d.dll"
+          "${MSVC${v}_MFC_DIR}/mfcm${v}0ud.dll"
           )
       ENDIF(CMAKE_INSTALL_DEBUG_LIBRARIES)
 
-      SET(MSVC10_MFC_DIR "${MSVC10_REDIST_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.VC100.MFC")
+      SET(MSVC${v}_MFC_DIR "${MSVC${v}_REDIST_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.VC${v}0.MFC")
       IF(NOT CMAKE_INSTALL_DEBUG_LIBRARIES_ONLY)
         SET(__install__libs ${__install__libs}
-          "${MSVC10_MFC_DIR}/mfc100.dll"
-          "${MSVC10_MFC_DIR}/mfc100u.dll"
-          "${MSVC10_MFC_DIR}/mfcm100.dll"
-          "${MSVC10_MFC_DIR}/mfcm100u.dll"
+          "${MSVC${v}_MFC_DIR}/mfc${v}0.dll"
+          "${MSVC${v}_MFC_DIR}/mfc${v}0u.dll"
+          "${MSVC${v}_MFC_DIR}/mfcm${v}0.dll"
+          "${MSVC${v}_MFC_DIR}/mfcm${v}0u.dll"
           )
       ENDIF(NOT CMAKE_INSTALL_DEBUG_LIBRARIES_ONLY)
 
-      # include the language dll's for vs10 as well as the actuall dll's
-      SET(MSVC10_MFCLOC_DIR "${MSVC10_REDIST_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.VC100.MFCLOC")
+      # include the language dll's as well as the actuall dll's
+      SET(MSVC${v}_MFCLOC_DIR "${MSVC${v}_REDIST_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.VC${v}0.MFCLOC")
       SET(__install__libs ${__install__libs}
-        "${MSVC10_MFCLOC_DIR}/mfc100chs.dll"
-        "${MSVC10_MFCLOC_DIR}/mfc100cht.dll"
-        "${MSVC10_MFCLOC_DIR}/mfc100enu.dll"
-        "${MSVC10_MFCLOC_DIR}/mfc100esp.dll"
-        "${MSVC10_MFCLOC_DIR}/mfc100deu.dll"
-        "${MSVC10_MFCLOC_DIR}/mfc100fra.dll"
-        "${MSVC10_MFCLOC_DIR}/mfc100ita.dll"
-        "${MSVC10_MFCLOC_DIR}/mfc100jpn.dll"
-        "${MSVC10_MFCLOC_DIR}/mfc100kor.dll"
+        "${MSVC${v}_MFCLOC_DIR}/mfc${v}0chs.dll"
+        "${MSVC${v}_MFCLOC_DIR}/mfc${v}0cht.dll"
+        "${MSVC${v}_MFCLOC_DIR}/mfc${v}0enu.dll"
+        "${MSVC${v}_MFCLOC_DIR}/mfc${v}0esp.dll"
+        "${MSVC${v}_MFCLOC_DIR}/mfc${v}0deu.dll"
+        "${MSVC${v}_MFCLOC_DIR}/mfc${v}0fra.dll"
+        "${MSVC${v}_MFCLOC_DIR}/mfc${v}0ita.dll"
+        "${MSVC${v}_MFCLOC_DIR}/mfc${v}0jpn.dll"
+        "${MSVC${v}_MFCLOC_DIR}/mfc${v}0kor.dll"
         )
-    ENDIF(MSVC10)
+    ENDMACRO()
+
+    IF(MSVC10)
+      MFC_FILES_FOR_VERSION(10)
+    ENDIF()
+
+    IF(MSVC11)
+      MFC_FILES_FOR_VERSION(11)
+    ENDIF()
   ENDIF(CMAKE_INSTALL_MFC_LIBRARIES)
 
   FOREACH(lib

+ 12 - 4
Source/cmVisualStudio10TargetGenerator.cxx

@@ -298,16 +298,24 @@ void cmVisualStudio10TargetGenerator::WriteProjectConfigurationValues()
       }
     configType += "</ConfigurationType>\n";
     this->WriteString(configType.c_str(), 2); 
+
     const char* mfcFlag = 
       this->Target->GetMakefile()->GetDefinition("CMAKE_MFC_FLAG");
-    if(mfcFlag)
+    std::string mfcFlagValue = mfcFlag ? mfcFlag : "0";
+
+    std::string useOfMfcValue = "false";
+    if(mfcFlagValue == "1")
       {
-      this->WriteString("<UseOfMfc>true</UseOfMfc>\n", 2);
+      useOfMfcValue = "Static";
       }
-    else
+    else if(mfcFlagValue == "2")
       {
-      this->WriteString("<UseOfMfc>false</UseOfMfc>\n", 2);
+      useOfMfcValue = "Dynamic";
       }
+    std::string mfcLine = "<UseOfMfc>";
+    mfcLine += useOfMfcValue + "</UseOfMfc>\n";
+    this->WriteString(mfcLine.c_str(), 2);
+
     if(this->Target->GetType() <= cmTarget::MODULE_LIBRARY &&
        this->ClOptions[*i]->UsingUnicode())
       {

+ 1 - 1
Tests/ExternalProject/Example/CMakeLists.txt

@@ -6,6 +6,6 @@ include(ExternalProject)
 ExternalProject_Add(
   cmake281
   URL http://www.cmake.org/files/v2.8/cmake-2.8.1.tar.gz
-  CMAKE_ARGS -D CMAKE_INSTALL_PREFIX=<INSTALL_DIR>
+  CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
   BUILD_COMMAND ""
 )

+ 13 - 2
Tests/MFC/CMakeLists.txt

@@ -17,7 +17,7 @@ ExternalProject_Add(mfcShared
   PATCH_COMMAND ${CMAKE_COMMAND} -E copy
     ${CMAKE_CURRENT_BINARY_DIR}/CMakeLists.SharedMfcDll.txt
     <SOURCE_DIR>/CMakeLists.txt
-  CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
+  CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
   )
 
 
@@ -33,7 +33,7 @@ ExternalProject_Add(mfcStatic
   PATCH_COMMAND ${CMAKE_COMMAND} -E copy
     ${CMAKE_CURRENT_BINARY_DIR}/CMakeLists.StaticMfcLib.txt
     <SOURCE_DIR>/CMakeLists.txt
-  CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
+  CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
   )
 
 
@@ -48,3 +48,14 @@ add_test(
   COMMAND ${CMAKE_COMMAND}
     -P "${CMAKE_CURRENT_BINARY_DIR}/ValidateBuild.cmake"
   )
+
+
+add_test(
+  NAME environment
+  COMMAND ${CMAKE_COMMAND} -E environment
+  )
+
+
+message(STATUS "===== environment =====")
+execute_process(COMMAND ${CMAKE_COMMAND} -E environment)
+message(STATUS "===== /environment =====")

+ 10 - 2
Tests/MFC/ValidateBuild.cmake.in

@@ -31,9 +31,17 @@ message(STATUS "===== mfcShared install tree =====")
 file(GLOB_RECURSE files "${binary_dir}/mfcShared-prefix/bin/*.*")
 message(STATUS "mfcShared files='${files}'")
 list(LENGTH files len)
-if(len LESS 3)
+
+set(msvc6 "@MSVC60@")
+if("${msvc6}" STREQUAL "1")
+  set(expected_minimum_file_count 1)
+else()
+  set(expected_minimum_file_count 3)
+endif()
+
+if(len LESS ${expected_minimum_file_count})
   message(FATAL_ERROR
-    "len='${len}' is less than '3' (count of shared 'bin' files)")
+    "len='${len}' is less than '${expected_minimum_file_count}' (count of shared 'bin' files)")
 endif()
 foreach(f ${files})
   message(STATUS "file '${f}'")

+ 15 - 0
Tests/MFC/mfc1/stdafx.h

@@ -8,23 +8,38 @@
 #define VC_EXTRALEAN		// Exclude rarely-used stuff from Windows headers
 #endif
 
+// See http://msdn.microsoft.com/en-us/library/6sehtctf.aspx for more info
+// on WINVER and _WIN32_WINNT
+
 // Modify the following defines if you have to target a platform prior to the ones specified below.
 // Refer to MSDN for the latest info on corresponding values for different platforms.
 #ifndef WINVER				// Allow use of features specific to Windows 95 and Windows NT 4 or later.
+#if _MSC_VER < 1600
 #define WINVER 0x0400		// Change this to the appropriate value to target Windows 98 and Windows 2000 or later.
+#else
+#define WINVER 0x0501		// Target Windows XP and later with VS 10 and later
+#endif
 #endif
 
 #ifndef _WIN32_WINNT		// Allow use of features specific to Windows NT 4 or later.
+#if _MSC_VER < 1600
 #define _WIN32_WINNT 0x0400		// Change this to the appropriate value to target Windows 98 and Windows 2000 or later.
+#else
+#define _WIN32_WINNT 0x0501		// Target Windows XP and later with VS 10 and later
+#endif
 #endif
 
 #ifndef _WIN32_WINDOWS		// Allow use of features specific to Windows 98 or later.
+#if _MSC_VER < 1600
 #define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later.
 #endif
+#endif
 
 #ifndef _WIN32_IE			// Allow use of features specific to IE 4.0 or later.
+#if _MSC_VER < 1600
 #define _WIN32_IE 0x0400	// Change this to the appropriate value to target IE 5.0 or later.
 #endif
+#endif
 
 #define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS	// some CString constructors will be explicit