# \#comp:clang

**URL:** https://discourse.cmake.org/tag/comp-clang/5.md?match_all_tags=true&page=1&tags%5B%5D=comp%3Aclang

[Latest](https://discourse.cmake.org/latest.md) · [Categories](https://discourse.cmake.org/categories.md) · [Tags](https://discourse.cmake.org/tags.md)

**Page:** 2

---

## [InstallRequiredSystemLibraries fails to detect clang on Windows](https://discourse.cmake.org/t/installrequiredsystemlibraries-fails-to-detect-clang-on-windows/8447)

<div class="topic-metadata">

**Author:** [@andreasxp](https://discourse.cmake.org/u/andreasxp)\
**Replies:** 0\
**Last updated:** [July 2, 2023, 2:21pm UTC](https://discourse.cmake.org/t/installrequiredsystemlibraries-fails-to-detect-clang-on-windows/8447 "2023-07-02T14:21:36Z")

</div>

Clang on Windows (not clang on MinGW) uses the same MSVC libraries as MSVC itself. However, when I included InstallRequiredSystemLibraries, the necessary msvc DLLs were not properly installed. Looking into InstallRequir…

---

## [Handling gcc/g++ '--param' flag](https://discourse.cmake.org/t/handling-gcc-g-param-flag/8408)

<div class="topic-metadata">

**Author:** [@ct\_clmsn](https://discourse.cmake.org/u/ct_clmsn)\
**Replies:** 4\
**Last updated:** [July 1, 2023, 9:49pm UTC](https://discourse.cmake.org/t/handling-gcc-g-param-flag/8408 "2023-07-01T21:49:48Z")

</div>

A project I’m currently working on requires a dependency that has pkg-config support. Cmake currently does everything right with one exception, several of the cxx-flags have a ‘–param’ prefix to indicate specific constr…

---

## [CMake precompile header issue](https://discourse.cmake.org/t/cmake-precompile-header-issue/8243)

<div class="topic-metadata">

**Author:** [@magisu](https://discourse.cmake.org/u/magisu)\
**Replies:** 4\
**Last updated:** [June 7, 2023, 8:40pm UTC](https://discourse.cmake.org/t/cmake-precompile-header-issue/8243 "2023-06-07T20:40:12Z")

</div>

I have the following header files h1.h #ifndef \_\_HEADER1\_\_ #define \_\_HEADER1\_\_ #include \<iostream\> #include \<string\> class Coupler { private: const std::string file; const int line; public: Coupler(const std::stri…

---

## [How to tell CMake on windows to use the compiler to call the linker](https://discourse.cmake.org/t/how-to-tell-cmake-on-windows-to-use-the-compiler-to-call-the-linker/8086)

<div class="topic-metadata">

**Author:** [@Febbe](https://discourse.cmake.org/u/Febbe)\
**Replies:** 2\
**Last updated:** [May 10, 2023, 3:39pm UTC](https://discourse.cmake.org/t/how-to-tell-cmake-on-windows-to-use-the-compiler-to-call-the-linker/8086 "2023-05-10T15:39:51Z")

</div>

I have a Toolchain file, which sets my preferred compiler to clang-cl and the linker to lld-link But, when I want to use -fsanitize=address, lld-link does not know the correct location of the sanitzer runtime library. c…

---

## [Passing \`-fsanitize=fuzzer\` via the command line or from a \`CMakePresets\` file](https://discourse.cmake.org/t/passing-fsanitize-fuzzer-via-the-command-line-or-from-a-cmakepresets-file/7902)

<div class="topic-metadata">

**Author:** [@cristi](https://discourse.cmake.org/u/cristi)\
**Replies:** 4\
**Last updated:** [April 15, 2023, 8:20am UTC](https://discourse.cmake.org/t/passing-fsanitize-fuzzer-via-the-command-line-or-from-a-cmakepresets-file/7902 "2023-04-15T08:20:43Z")

</div>

When using clang as a compiler and trying to set CMAKE\_C\_FLAGS to include -fsanitize=fuzzer, generation fails with: $ cmake .. -DCMAKE\_C\_COMPILER=clang -DCMAKE\_C\_FLAGS="-fsanitize=fuzzer" -- The C compiler identificatio…

---

## [RPATH incorrect when clang links a library compiled with gfortran](https://discourse.cmake.org/t/rpath-incorrect-when-clang-links-a-library-compiled-with-gfortran/6720)

<div class="topic-metadata">

**Author:** [@cianciosa](https://discourse.cmake.org/u/cianciosa)\
**Replies:** 1\
**Last updated:** [October 25, 2022, 9:54pm UTC](https://discourse.cmake.org/t/rpath-incorrect-when-clang-links-a-library-compiled-with-gfortran/6720 "2022-10-25T21:54:35Z")

</div>

I’m running into a runtime problem that I have never had before. I have a bunch of projects spread out across multiple GitHub repositories. A parent repository collects coordinates all this using a bunch of FetchContent …

---

## [Failed to configure preset with Clang/LLVM compilers when using CMake Tools.](https://discourse.cmake.org/t/failed-to-configure-preset-with-clang-llvm-compilers-when-using-cmake-tools/6637)

<div class="topic-metadata">

**Author:** [@hwhsu1231](https://discourse.cmake.org/u/hwhsu1231)\
**Replies:** 8\
**Last updated:** [October 12, 2022, 2:33pm UTC](https://discourse.cmake.org/t/failed-to-configure-preset-with-clang-llvm-compilers-when-using-cmake-tools/6637 "2022-10-12T14:33:05Z")

</div>

Problem Description First of all, I already installed Clang/LLVM by running the following winget command: winget install LLVM.LLVM And I tried with the following example of CMakePresets.json: ▶ Click to expand The stran…

---

## [How to specify GNU-like Clang for \`Visual Studio 16 2019\` generator?](https://discourse.cmake.org/t/how-to-specify-gnu-like-clang-for-visual-studio-16-2019-generator/6639)

<div class="topic-metadata">

**Author:** [@hwhsu1231](https://discourse.cmake.org/u/hwhsu1231)\
**Replies:** 1\
**Last updated:** [October 11, 2022, 4:49pm UTC](https://discourse.cmake.org/t/how-to-specify-gnu-like-clang-for-visual-studio-16-2019-generator/6639 "2022-10-11T16:49:06Z")

</div>

Problem Descriptions There are two types of Clang compilers after I install Clang/LLVM: clang.exe/clang++.exe: GNU-like Clang compiler clang-cl.exe: MSVC-like Clang compiler According to this issue, we can specify …

---

## [CMAKE\_\<LANG\>\_COMPILER\_EXTERNAL\_TOOLCHAIN adds -gcc-toolchain not ---gcc-toolchain](https://discourse.cmake.org/t/cmake-lang-compiler-external-toolchain-adds-gcc-toolchain-not-gcc-toolchain/5748)

<div class="topic-metadata">

**Author:** [@samolisov](https://discourse.cmake.org/u/samolisov)\
**Replies:** 4\
**Last updated:** [June 1, 2022, 10:01am UTC](https://discourse.cmake.org/t/cmake-lang-compiler-external-toolchain-adds-gcc-toolchain-not-gcc-toolchain/5748 "2022-06-01T10:01:10Z")

</div>

Hello, I’m trying to cross-compile a project using clang as a compiler and pass the --gcc-toolchain command line argument to the compiler. As I get, the preferable way for this is to use the CMAKE\_\<LANG\>\_COMPILER\_EXTERN…

---

## [Auto-detect "bad" compiler flags](https://discourse.cmake.org/t/auto-detect-bad-compiler-flags/5738)

<div class="topic-metadata">

**Author:** [@tom](https://discourse.cmake.org/u/tom)\
**Replies:** 3\
**Last updated:** [May 26, 2022, 6:50pm UTC](https://discourse.cmake.org/t/auto-detect-bad-compiler-flags/5738 "2022-05-26T18:50:29Z")

</div>

Hi all, I’ve got an old project that uses the clang /Ox flag for certain configurations on Windows. According to the online clang documentation (Clang Compiler User’s Manual — Clang 11 documentation), this flag is dep…

---

## [Debugging an errant -isystem](https://discourse.cmake.org/t/debugging-an-errant-isystem/5250)

<div class="topic-metadata">

**Author:** [@dcblack](https://discourse.cmake.org/u/dcblack)\
**Replies:** 2\
**Last updated:** [March 21, 2022, 11:07am UTC](https://discourse.cmake.org/t/debugging-an-errant-isystem/5250 "2022-03-21T11:07:30Z")

</div>

I have a project that keeps insisting on putting in a -isystem DIRECTORY, where the directory is completely inappropriate (it points to a directory is not relevant that is from another project elsewhere on my machine) an…

---

## [Apply clang-tidy on objective-c++ file using cmake ?](https://discourse.cmake.org/t/apply-clang-tidy-on-objective-c-file-using-cmake/4860)

<div class="topic-metadata">

**Author:** [@zohar81](https://discourse.cmake.org/u/zohar81)\
**Replies:** 1\
**Last updated:** [January 16, 2022, 6:15pm UTC](https://discourse.cmake.org/t/apply-clang-tidy-on-objective-c-file-using-cmake/4860 "2022-01-16T18:15:22Z")

</div>

Hi, I’m applying my clang-tidy rules on macOS cmake project using the following command : set\_target\_properties(${target\_name} PROPERTIES CXX\_CLANG\_TIDY ${clang\_tidy\_cmd}) Recently I’ve added a file that is written in …

---

## [Setting linker in Clang builds on Windows](https://discourse.cmake.org/t/setting-linker-in-clang-builds-on-windows/4407)

<div class="topic-metadata">

**Author:** [@benavidz](https://discourse.cmake.org/u/benavidz)\
**Replies:** 3\
**Last updated:** [November 3, 2021, 4:02pm UTC](https://discourse.cmake.org/t/setting-linker-in-clang-builds-on-windows/4407 "2021-11-03T16:02:07Z")

</div>

Hello, I have a C++ project which I would like to build with Clang, and link with MSVC link.exe. The only way I was able to figure out how to make this happen was to modify the Windows-Clang.cmake file included with my …

---

## [Support for CUDA & ClangCL on Windows](https://discourse.cmake.org/t/support-for-cuda-clangcl-on-windows/1437)

<div class="topic-metadata">

**Author:** [@mojca](https://discourse.cmake.org/u/mojca)\
**Replies:** 2\
**Last updated:** [June 25, 2020, 7:42am UTC](https://discourse.cmake.org/t/support-for-cuda-clangcl-on-windows/1437 "2020-06-25T07:42:50Z")

</div>

When trying to build a simple CUDA project on Windows and optimistically specifying -T ClangCL, CMake complains about unknown CUDA compiler Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.19041. The CX…

---

## [cmake when generate Xcode project, clang-tidy command is missing](https://discourse.cmake.org/t/cmake-when-generate-xcode-project-clang-tidy-command-is-missing/4115)

<div class="topic-metadata">

**Author:** [@zohar81](https://discourse.cmake.org/u/zohar81)\
**Replies:** 3\
**Last updated:** [September 21, 2021, 5:37am UTC](https://discourse.cmake.org/t/cmake-when-generate-xcode-project-clang-tidy-command-is-missing/4115 "2021-09-21T05:37:52Z")

</div>

Hi, I’ve added clang-tidy capability to my command line that will be set upon activation. before running it, I’ve made sure that my setup has clang-tidy installed. here’s the CMake code option(ENABLE\_CLANG\_TIDY "defa…

---

## [Cmake generates invalid linker tasks with clang on arm64](https://discourse.cmake.org/t/cmake-generates-invalid-linker-tasks-with-clang-on-arm64/4019)

<div class="topic-metadata">

**Author:** [@Pierre\_Joye](https://discourse.cmake.org/u/Pierre_Joye)\
**Replies:** 2\
**Last updated:** [September 3, 2021, 2:28am UTC](https://discourse.cmake.org/t/cmake-generates-invalid-linker-tasks-with-clang-on-arm64/4019 "2021-09-03T02:28:32Z")

</div>

Hello, I initially thought it was a bug but apparently not https://gitlab.kitware.com/cmake/cmake/-/issues/22589 It works on other platform but somehow on arm64, cmake generates something different and the linker fail…

---

## [How to specify system include directories as \`-isystem\` in CMake](https://discourse.cmake.org/t/how-to-specify-system-include-directories-as-isystem-in-cmake/4011)

<div class="topic-metadata">

**Author:** [@alvaropalmaaste](https://discourse.cmake.org/u/alvaropalmaaste)\
**Replies:** 2\
**Last updated:** [September 1, 2021, 10:57pm UTC](https://discourse.cmake.org/t/how-to-specify-system-include-directories-as-isystem-in-cmake/4011 "2021-09-01T22:57:33Z")

</div>

In CMake, I know I can do target\_include\_directories(my\_target SYSTEM PRIVATE ${SOME\_THIRD\_PARTY\_LIBRARY\_INCLUDES}) to avoid catching warnings coming from that library that could stop my compilation if I have those war…

---

## [Idiomatic way to deal with huge number of include directories](https://discourse.cmake.org/t/idiomatic-way-to-deal-with-huge-number-of-include-directories/3947)

<div class="topic-metadata">

**Author:** [@tom](https://discourse.cmake.org/u/tom)\
**Replies:** 3\
**Last updated:** [August 17, 2021, 9:19pm UTC](https://discourse.cmake.org/t/idiomatic-way-to-deal-with-huge-number-of-include-directories/3947 "2021-08-17T21:19:18Z")

</div>

Hi, I’m writing a CMake build system for a very large, very elderly code base. It contains tens of thousands of source code files, most of which live in a complex nested directory structure. Each target is likely to h…

---

## [How to configure cmake on Windows to use clang-cl with ninja multi config for intel 32 bits, intel 64 bits and arm64 coming from Visual Studio](https://discourse.cmake.org/t/how-to-configure-cmake-on-windows-to-use-clang-cl-with-ninja-multi-config-for-intel-32-bits-intel-64-bits-and-arm64-coming-from-visual-studio/3430)

<div class="topic-metadata">

**Author:** [@abique](https://discourse.cmake.org/u/abique)\
**Replies:** 10\
**Last updated:** [May 29, 2021, 5:20pm UTC](https://discourse.cmake.org/t/how-to-configure-cmake-on-windows-to-use-clang-cl-with-ninja-multi-config-for-intel-32-bits-intel-64-bits-and-arm64-coming-from-visual-studio/3430 "2021-05-29T17:20:54Z")

</div>

Hi, How to configure cmake on Windows to use clang-cl with ninja multi config for intel 32 bits, intel 64 bits and arm64 bundled with Visual Studio? Thank you very much!

---

## [clang-format integration](https://discourse.cmake.org/t/clang-format-integration/3358)

<div class="topic-metadata">

**Author:** [@cmak](https://discourse.cmake.org/u/cmak)\
**Replies:** 8\
**Last updated:** [May 25, 2021, 7:41pm UTC](https://discourse.cmake.org/t/clang-format-integration/3358 "2021-05-25T19:41:48Z")

</div>

Is there any plans for a clang-format integration in cmake? cmake does provide a clean clang-tidy integration, but couldn’t find clang-format.

---

## [Create relative paths for compiler\_commands.json](https://discourse.cmake.org/t/create-relative-paths-for-compiler-commands-json/1762)

<div class="topic-metadata">

**Author:** [@leeruns](https://discourse.cmake.org/u/leeruns)\
**Replies:** 8\
**Last updated:** [February 6, 2021, 5:06pm UTC](https://discourse.cmake.org/t/create-relative-paths-for-compiler-commands-json/1762 "2021-02-06T17:06:26Z")

</div>

I am working on a project where the code is currently compiled inside a linux container. When I instruct cmake to write the file it uses absolute paths. cmake -S /app/opt/myApp -B /app/opt/myApp -DCMAKE\_EXPORT\_COMPILE\_…

---

## [Can't cross-compile for Windows since CMake \> 3.17.2](https://discourse.cmake.org/t/cant-cross-compile-for-windows-since-cmake-3-17-2/2247)

<div class="topic-metadata">

**Author:** [@Horyu](https://discourse.cmake.org/u/Horyu)\
**Replies:** 3\
**Last updated:** [December 1, 2020, 12:59pm UTC](https://discourse.cmake.org/t/cant-cross-compile-for-windows-since-cmake-3-17-2/2247 "2020-12-01T12:59:41Z")

</div>

Hi, I’m using vcpkg to cross-compile libraries for Windows, I use the llvm 9 + clang-cl 9 toolchains and since the new update of vcpkg that brought cmake to 3.18.4 I can’t cross-compile anymore, it seems the linker sear…

---

## [Cross compilation help](https://discourse.cmake.org/t/cross-compilation-help/1486)

<div class="topic-metadata">

**Author:** [@Arcnor](https://discourse.cmake.org/u/Arcnor)\
**Replies:** 1\
**Last updated:** [November 11, 2020, 3:02pm UTC](https://discourse.cmake.org/t/cross-compilation-help/1486 "2020-11-11T15:02:30Z")

</div>

Hi, I’m trying to use CMake to generate a project for cross compiling for another system (gaming console). The SDK uses MSVC with a property sheet for settings and clang as its compiler. I’ve hacked around to make CMake…

---

## [Potential Bug in 'cmake/Modules/Compiler/clang.cmake' (CMAKE\_C(XX)\_COMPILE\_OPTIONS\_PIC)](https://discourse.cmake.org/t/potential-bug-in-cmake-modules-compiler-clang-cmake-cmake-c-xx-compile-options-pic/1933)

<div class="topic-metadata">

**Author:** [@marchani](https://discourse.cmake.org/u/marchani)\
**Replies:** 6\
**Last updated:** [September 30, 2020, 1:32pm UTC](https://discourse.cmake.org/t/potential-bug-in-cmake-modules-compiler-clang-cmake-cmake-c-xx-compile-options-pic/1933 "2020-09-30T13:32:31Z")

</div>

I was attempting to cross-compile gRPC (https://github.com/grpc/grpc) from Windows to Linux as a third-party dependency using CMake and the Clang compiler; however, I encountered what I believe may be incorrect behavior …

---

## [Clang-tidy passing incorrect arguments on windows?](https://discourse.cmake.org/t/clang-tidy-passing-incorrect-arguments-on-windows/1123)

<div class="topic-metadata">

**Author:** [@anon45792294](https://discourse.cmake.org/u/anon45792294)\
**Replies:** 3\
**Last updated:** [May 23, 2020, 8:40pm UTC](https://discourse.cmake.org/t/clang-tidy-passing-incorrect-arguments-on-windows/1123 "2020-05-23T20:40:12Z")

</div>

I’m trying to use clang-tidy on windows using clang-cl. But I’m getting this error while trying to run clang-tidy: \>------ Build All started: Project: PitoEngine, Configuration: Debug\_x64 ------ \[1/14\] Building CXX o…

---

## [CMAKE\_RANLIB vs CMAKE\_CXX\_COMPILER\_RANLIB](https://discourse.cmake.org/t/cmake-ranlib-vs-cmake-cxx-compiler-ranlib/1017)

<div class="topic-metadata">

**Author:** [@rnyberg](https://discourse.cmake.org/u/rnyberg)\
**Replies:** 1\
**Last updated:** [April 14, 2020, 2:03pm UTC](https://discourse.cmake.org/t/cmake-ranlib-vs-cmake-cxx-compiler-ranlib/1017 "2020-04-14T14:03:02Z")

</div>

Hi! I’m not certain how these variables are to be used. In my case building with clang 7 and -flto I need to run the cxx compiler specific ranlib but CMAKE\_RANLIB is the one actually run. Am I supposed to to something l…

---

## [Overwriting option flags CMAKE\_RUNTIME\_OUTPUT\_DIRECTORY, CMAKE\_LIBRARY\_OUTPUT\_DIRECTORY and CMAKE\_ARCHIVE\_OUTPUT\_DIRECTORY](https://discourse.cmake.org/t/overwriting-option-flags-cmake-runtime-output-directory-cmake-library-output-directory-and-cmake-archive-output-directory/194)

<div class="topic-metadata">

**Author:** [@danbr](https://discourse.cmake.org/u/danbr)\
**Replies:** 2\
**Last updated:** [November 13, 2019, 3:33pm UTC](https://discourse.cmake.org/t/overwriting-option-flags-cmake-runtime-output-directory-cmake-library-output-directory-and-cmake-archive-output-directory/194 "2019-11-13T15:33:47Z")

</div>

Hello! I have the following use case: Lets say the project’s top-level CMakeLists.txt file contains the following lines: set(CMAKE\_RUNTIME\_OUTPUT\_DIRECTORY, \[some-path\]) set(CMAKE\_RUNTIME\_LIBRARY\_DIRECTORY, \[some-pat…

[Previous page](https://discourse.cmake.org/tag/comp-clang/5.md?match_all_tags=true&tags%5B%5D=comp%3Aclang)
