From a2e6d2482e4eb007c8012f2aee3b2381cc95a001 Mon Sep 17 00:00:00 2001 From: David Cole Date: Fri, 4 Nov 2011 13:07:38 -0400 Subject: [PATCH 1/5] Tests: Fix MFC test to work with VS 10 and later (#11213) The mfc app in the test was generated by the VS 7.1 wizard, and due to changes in VS since then, the values used for WINVER and _WIN32_WINNT caused compile errors when built with VS 10 or later. Change them to values appropriate for targeting Windows XP or later when building with VS 10 or later. See http://msdn.microsoft.com/en-us/library/6sehtctf.aspx for more info. --- Tests/MFC/mfc1/stdafx.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Tests/MFC/mfc1/stdafx.h b/Tests/MFC/mfc1/stdafx.h index fb9dfb33d..35a678dcd 100644 --- a/Tests/MFC/mfc1/stdafx.h +++ b/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 From 011694c269a1193ec8f7fe8dce8d4a86bcafa8e4 Mon Sep 17 00:00:00 2001 From: David Cole Date: Fri, 4 Nov 2011 13:29:41 -0400 Subject: [PATCH 2/5] VS10: Use expected values for UseOfMfc (#11213) Use expected values for the UseOfMfc xml element in VS 10 .vcxproj files. CMAKE_MFC_FLAG=1 maps to "Static" CMAKE_MFC_FLAG=2 maps to "Dynamic" all other values map to "false" Thanks to Randy Schott and McBen for their patches which served as inspiration and motivation for getting this done. See also http://public.kitware.com/Bug/view.php?id=11224 --- Source/cmVisualStudio10TargetGenerator.cxx | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 551b0adef..c51254aa9 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -290,16 +290,24 @@ void cmVisualStudio10TargetGenerator::WriteProjectConfigurationValues() } configType += "\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("true\n", 2); + useOfMfcValue = "Static"; } - else + else if(mfcFlagValue == "2") { - this->WriteString("false\n", 2); + useOfMfcValue = "Dynamic"; } + std::string mfcLine = ""; + mfcLine += useOfMfcValue + "\n"; + this->WriteString(mfcLine.c_str(), 2); + if(this->Target->GetType() <= cmTarget::MODULE_LIBRARY && this->ClOptions[*i]->UsingUnicode()) { From d85ab7a41212c7d42305dd1e33d8f5a0ac9fdf68 Mon Sep 17 00:00:00 2001 From: David Cole Date: Tue, 8 Nov 2011 15:11:31 -0500 Subject: [PATCH 3/5] Tests: Add environment logging to the MFC test (#11213) Simply to ease analyzing still-occurring dashboard failures. --- Tests/MFC/CMakeLists.txt | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Tests/MFC/CMakeLists.txt b/Tests/MFC/CMakeLists.txt index ea5c41d6e..df3149a65 100644 --- a/Tests/MFC/CMakeLists.txt +++ b/Tests/MFC/CMakeLists.txt @@ -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 =====") From 51f442e6034a151e797f678e479073285b433d71 Mon Sep 17 00:00:00 2001 From: David Cole Date: Tue, 8 Nov 2011 15:22:40 -0500 Subject: [PATCH 4/5] VS11: Update InstallRequiredSystemLibraries.cmake for VS11 (#11213) Should fix the newly added MFC test on VS11 dashboards. --- Modules/InstallRequiredSystemLibraries.cmake | 96 ++++++++++++-------- 1 file changed, 58 insertions(+), 38 deletions(-) diff --git a/Modules/InstallRequiredSystemLibraries.cmake b/Modules/InstallRequiredSystemLibraries.cmake index b6735c1a9..65d254a4a 100644 --- a/Modules/InstallRequiredSystemLibraries.cmake +++ b/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 From 537020f9581d36c436d18e30f98d58f0ef5924cc Mon Sep 17 00:00:00 2001 From: David Cole Date: Wed, 9 Nov 2011 13:31:05 -0500 Subject: [PATCH 5/5] Tests: Nudge MFC test to pass on VS 6 dashboards (#11213) InstallRequiredSystemLibraries does not install any dlls when used with VS 6 dashboards. Modify the ValidateBuild script to expect only 1 file when building with VS 6. Using "-DCMAKE_INSTALL_PREFIX=" does not work when evaluates to a long enough string. However, using "-DCMAKE_INSTALL_PREFIX:PATH=" does work, even with the longer strings. So: make sure to include the ":PATH" when using this construct with ExternalProject calls so that they may install to the proper location on VS 6 builds. All existing calls that match "CMAKE_INSTALL_PREFIX.*INSTALL_DIR" include the ":PATH" after this commit. By the way: https://twitter.com/DLRdave/status/134339505397309440 --- Tests/ExternalProject/Example/CMakeLists.txt | 2 +- Tests/MFC/CMakeLists.txt | 4 ++-- Tests/MFC/ValidateBuild.cmake.in | 12 ++++++++++-- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Tests/ExternalProject/Example/CMakeLists.txt b/Tests/ExternalProject/Example/CMakeLists.txt index 2cadd7d22..69ebaaf51 100644 --- a/Tests/ExternalProject/Example/CMakeLists.txt +++ b/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= + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH= BUILD_COMMAND "" ) diff --git a/Tests/MFC/CMakeLists.txt b/Tests/MFC/CMakeLists.txt index df3149a65..62ff749fe 100644 --- a/Tests/MFC/CMakeLists.txt +++ b/Tests/MFC/CMakeLists.txt @@ -17,7 +17,7 @@ ExternalProject_Add(mfcShared PATCH_COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/CMakeLists.SharedMfcDll.txt /CMakeLists.txt - CMAKE_ARGS -DCMAKE_INSTALL_PREFIX= + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH= ) @@ -33,7 +33,7 @@ ExternalProject_Add(mfcStatic PATCH_COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/CMakeLists.StaticMfcLib.txt /CMakeLists.txt - CMAKE_ARGS -DCMAKE_INSTALL_PREFIX= + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH= ) diff --git a/Tests/MFC/ValidateBuild.cmake.in b/Tests/MFC/ValidateBuild.cmake.in index 68de54927..ed923f5e7 100644 --- a/Tests/MFC/ValidateBuild.cmake.in +++ b/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}'")