[PATCH] D41219: [cmake] Fix clang-cl cross-compilation on macOS

Shoaib Meenai via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 14 17:06:34 PST 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL320785: [cmake] Fix clang-cl cross-compilation on macOS (authored by smeenai, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D41219?vs=126886&id=127051#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D41219

Files:
  llvm/trunk/cmake/platforms/ClangClCMakeCompileRules.cmake
  llvm/trunk/cmake/platforms/WinMsvc.cmake


Index: llvm/trunk/cmake/platforms/ClangClCMakeCompileRules.cmake
===================================================================
--- llvm/trunk/cmake/platforms/ClangClCMakeCompileRules.cmake
+++ llvm/trunk/cmake/platforms/ClangClCMakeCompileRules.cmake
@@ -0,0 +1,9 @@
+# macOS paths usually start with /Users/*. Unfortunately, clang-cl interprets
+# paths starting with /U as macro undefines, so we need to put a -- before the
+# input file path to force it to be treated as a path. CMake's compilation rules
+# should be tweaked accordingly, but until that's done, and to support older
+# CMake versions, overriding compilation rules works well enough. This file will
+# be included by cmake after the default compilation rules have already been set
+# up, so we can just modify them instead of duplicating them entirely.
+string(REPLACE "-c <SOURCE>" "-c -- <SOURCE>" CMAKE_C_COMPILE_OBJECT "${CMAKE_C_COMPILE_OBJECT}")
+string(REPLACE "-c <SOURCE>" "-c -- <SOURCE>" CMAKE_CXX_COMPILE_OBJECT "${CMAKE_CXX_COMPILE_OBJECT}")
Index: llvm/trunk/cmake/platforms/WinMsvc.cmake
===================================================================
--- llvm/trunk/cmake/platforms/WinMsvc.cmake
+++ llvm/trunk/cmake/platforms/WinMsvc.cmake
@@ -299,3 +299,6 @@
 # control which libraries they require.
 set(CMAKE_C_STANDARD_LIBRARIES "" CACHE STRING "" FORCE)
 set(CMAKE_CXX_STANDARD_LIBRARIES "" CACHE STRING "" FORCE)
+
+# Allow clang-cl to work with macOS paths.
+set(CMAKE_USER_MAKE_RULES_OVERRIDE "${CMAKE_CURRENT_LIST_DIR}/ClangClCMakeCompileRules.cmake")


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D41219.127051.patch
Type: text/x-patch
Size: 1557 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171215/5c3db4ad/attachment.bin>


More information about the llvm-commits mailing list