llvm.org GIT mirror llvm / 9d3546d
[cmake] Fix clang-cl cross-compilation on macOS macOS paths usually start with /Users, which clang-cl interprets as a macro undefine, leading to pretty much everything failing to compile. CMake should be taught to put a -- in its compilation rules for clang-cl (and I've been meaning to submit that upstream for a while). In the meantime, however, and to support older CMake versions, we can just create a custom make rules override to fix the compilation rules. Differential Revision: https://reviews.llvm.org/D41219 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@320785 91177308-0d34-0410-b5e6-96231b3b80d8 Shoaib Meenai 1 year, 10 months ago
2 changed file(s) with 12 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 # macOS paths usually start with /Users/*. Unfortunately, clang-cl interprets
1 # paths starting with /U as macro undefines, so we need to put a -- before the
2 # input file path to force it to be treated as a path. CMake's compilation rules
3 # should be tweaked accordingly, but until that's done, and to support older
4 # CMake versions, overriding compilation rules works well enough. This file will
5 # be included by cmake after the default compilation rules have already been set
6 # up, so we can just modify them instead of duplicating them entirely.
7 string(REPLACE "-c " "-c -- " CMAKE_C_COMPILE_OBJECT "${CMAKE_C_COMPILE_OBJECT}")
8 string(REPLACE "-c " "-c -- " CMAKE_CXX_COMPILE_OBJECT "${CMAKE_CXX_COMPILE_OBJECT}")
298298 # control which libraries they require.
299299 set(CMAKE_C_STANDARD_LIBRARIES "" CACHE STRING "" FORCE)
300300 set(CMAKE_CXX_STANDARD_LIBRARIES "" CACHE STRING "" FORCE)
301
302 # Allow clang-cl to work with macOS paths.
303 set(CMAKE_USER_MAKE_RULES_OVERRIDE "${CMAKE_CURRENT_LIST_DIR}/ClangClCMakeCompileRules.cmake")