diff options
author | Sergey Larin <cerg2010cerg2010@mail.ru> | 2020-02-12 14:17:33 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2020-02-24 15:53:39 (GMT) |
commit | 5c6d6ec27c5e4d466d7ba7b291ded39c76fb8169 (patch) | |
tree | 7525ba62d3837a6c74b13a4ba2cd8fd383baf1c9 /Modules/Platform/Windows-Clang.cmake | |
parent | 125f0451a9061c60036c5f92d104ee9fb3111a98 (diff) | |
download | CMake-5c6d6ec27c5e4d466d7ba7b291ded39c76fb8169.zip CMake-5c6d6ec27c5e4d466d7ba7b291ded39c76fb8169.tar.gz CMake-5c6d6ec27c5e4d466d7ba7b291ded39c76fb8169.tar.bz2 |
PCH: Clang: Update PCH usage flags to include original header
Add an additional include flag to PCH usage command line to fix programs
that rely on `compile_commands.json` file. Pass it to the preprocessor
directly to avoid compiler driver to change it to '-include-pch'.
When preprocessor is requested to preprocess a file, it tries to get
the original filename from '.pch' and uses that file for preprocessing.
CMake generates a '.pch' file from the '.hxx' file by passing an empty
'.cxx' source file to the compiler as a compilation unit and the header
file with the '-include' flag. After that, compiler puts compilation
unit filename in the '.pch' as the original filename.
However, CMake build system uses empty file as the source file and
passes the header file using '-include-pch' flag. As a result, Clang
uses the wrong file for preprocessing and produces the corrupted
preprocessed file.
Fixes: #20355
Signed-off-by: Sergey Larin <cerg2010cerg2010@mail.ru>
Diffstat (limited to 'Modules/Platform/Windows-Clang.cmake')
-rw-r--r-- | Modules/Platform/Windows-Clang.cmake | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/Modules/Platform/Windows-Clang.cmake b/Modules/Platform/Windows-Clang.cmake index 7fd5e49..dc8dd6f 100644 --- a/Modules/Platform/Windows-Clang.cmake +++ b/Modules/Platform/Windows-Clang.cmake @@ -86,7 +86,7 @@ macro(__windows_compiler_clang_gnu lang) set(CMAKE_PCH_EXTENSION .pch) set(CMAKE_PCH_PROLOGUE "#pragma clang system_header") - set(CMAKE_${lang}_COMPILE_OPTIONS_USE_PCH -Xclang -include-pch -Xclang <PCH_FILE>) + set(CMAKE_${lang}_COMPILE_OPTIONS_USE_PCH -Xclang -include-pch -Xclang <PCH_FILE> -Xclang -include -Xclang <PCH_HEADER>) set(CMAKE_${lang}_COMPILE_OPTIONS_CREATE_PCH -Xclang -emit-pch -Xclang -include -Xclang <PCH_HEADER>) unset(__ADDED_FLAGS) |