mirror of
https://github.com/Kitware/CMake.git
synced 2025-12-31 19:00:54 -06:00
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.
This commit is contained in:
committed by
Brad King
parent
a94672b919
commit
d993ebd4ca
@@ -142,7 +142,7 @@ if("x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC"
|
||||
endif()
|
||||
if(DEFINED CMAKE_RC_PREPROCESSOR)
|
||||
set(CMAKE_DEPFILE_FLAGS_RC "-clang:-MD -clang:-MF -clang:<DEPFILE>")
|
||||
set(CMAKE_RC_COMPILE_OBJECT "${CMAKE_COMMAND} -E cmake_llvm_rc <SOURCE> <OBJECT>.pp <${CMAKE_RC_PREPROCESSOR}> <DEFINES> -DRC_INVOKED <INCLUDES> <FLAGS> -E <SOURCE> ++ <CMAKE_RC_COMPILER> <DEFINES> -I <SOURCE_DIR> <INCLUDES> /fo <OBJECT> <OBJECT>.pp")
|
||||
set(CMAKE_RC_COMPILE_OBJECT "${CMAKE_COMMAND} -E cmake_llvm_rc <SOURCE> <OBJECT>.pp <${CMAKE_RC_PREPROCESSOR}> <DEFINES> -DRC_INVOKED <INCLUDES> <FLAGS> -E -- <SOURCE> ++ <CMAKE_RC_COMPILER> <DEFINES> -I <SOURCE_DIR> <INCLUDES> /fo <OBJECT> <OBJECT>.pp")
|
||||
if(CMAKE_GENERATOR STREQUAL "Ninja")
|
||||
set(CMAKE_NINJA_CMCLDEPS_RC 0)
|
||||
set(CMAKE_NINJA_DEP_TYPE_RC gcc)
|
||||
|
||||
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user