diff options
author | Thomas Bernard <tbernard@go-engineering.de> | 2020-07-28 20:12:13 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2020-08-07 15:48:48 (GMT) |
commit | d993ebd4ca0fc1044745dd1874bab082090f9801 (patch) | |
tree | 4be36be8c43daee550aeec10f4d11a703d263d72 /Modules/Platform/Windows-MSVC.cmake | |
parent | a94672b919db3ec961e5b4405352fec9ba95ddeb (diff) | |
download | CMake-d993ebd4ca0fc1044745dd1874bab082090f9801.zip CMake-d993ebd4ca0fc1044745dd1874bab082090f9801.tar.gz CMake-d993ebd4ca0fc1044745dd1874bab082090f9801.tar.bz2 |
clang-cl: Add '--' before source file
On Linux and macOS, absolute paths start with `/` which may be
interpreted by clang-cl as an option. To avoid this, we separate the
source file path from preceding options with `--` to tell `clang-cl` it
is not an option.
Diffstat (limited to 'Modules/Platform/Windows-MSVC.cmake')
-rw-r--r-- | Modules/Platform/Windows-MSVC.cmake | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Modules/Platform/Windows-MSVC.cmake b/Modules/Platform/Windows-MSVC.cmake index e272da9..173ef40 100644 --- a/Modules/Platform/Windows-MSVC.cmake +++ b/Modules/Platform/Windows-MSVC.cmake @@ -333,6 +333,14 @@ macro(__windows_compiler_msvc lang) set(CMAKE_LINK_PCH ON) if (CMAKE_${lang}_COMPILER_ID STREQUAL "Clang") set(CMAKE_PCH_PROLOGUE "#pragma clang system_header") + + # 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. + string(REPLACE "-c <SOURCE>" "-c -- <SOURCE>" CMAKE_${lang}_COMPILE_OBJECT "${CMAKE_${lang}_COMPILE_OBJECT}") + string(REPLACE "-c <SOURCE>" "-c -- <SOURCE>" CMAKE_${lang}_CREATE_PREPROCESSED_SOURCE "${CMAKE_${lang}_COMPILE_OBJECT}") + string(REPLACE "-c <SOURCE>" "-c -- <SOURCE>" CMAKE_${lang}_CREATE_ASSEMBLY_SOURCE "${CMAKE_${lang}_COMPILE_OBJECT}") + elseif(MSVC_VERSION GREATER_EQUAL 1913) # At least MSVC toolet 14.13 from VS 2017 15.6 set(CMAKE_PCH_PROLOGUE "#pragma system_header") |