[PATCH] D53073: With CMake 3.8+ force Visual Studio generator builds to use the x64 host toolchain if the user is on a 64-bit system

Greg Bedwell via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 10 04:55:58 PDT 2018


gbedwell updated this revision to Diff 168985.

https://reviews.llvm.org/D53073

Files:
  CMakeLists.txt


Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -26,10 +26,21 @@
 endif()
 
 if ((CMAKE_GENERATOR MATCHES "Visual Studio") AND (CMAKE_GENERATOR_TOOLSET STREQUAL ""))
-  message(WARNING "Visual Studio generators use the x86 host compiler by "
-                  "default, even for 64-bit targets. This can result in linker "
-                  "instability and out of memory errors. To use the 64-bit "
-                  "host compiler, pass -Thost=x64 on the CMake command line.")
+
+  if ((CMAKE_VERSION VERSION_LESS 3.8) OR (NOT "$ENV{PROCESSOR_ARCHITECTURE}" STREQUAL "AMD64"))
+    message(WARNING "Visual Studio generators use the x86 host compiler by "
+                    "default, even for 64-bit targets. This can result in "
+                    "linker instability and out of memory errors. To use the "
+                    "64-bit host compiler, pass -Thost=x64 on the CMake "
+                    "command line or update to a newer version of CMake "
+                    "(3.8+) where this will be set automatically on 64-bit "
+                    "systems.")
+  else()
+    # CMake 3.8 introduces the following variable to allow us to select the
+    # 64-bit host Visual Studio toolchain.
+    set(CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE "x64")
+  endif()
+
 endif()
 
 project(LLVM


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D53073.168985.patch
Type: text/x-patch
Size: 1390 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181010/69c9cc5b/attachment.bin>


More information about the llvm-commits mailing list