# \#comp:gcc

**URL:** https://discourse.cmake.org/tag/comp-gcc/4.md

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

---

## [Configure clang-tidy when using an arm-none-eabi-gcc/g++ toolchain](https://discourse.cmake.org/t/configure-clang-tidy-when-using-an-arm-none-eabi-gcc-g-toolchain/10862)

<div class="topic-metadata">

**Author:** [@itavero](https://discourse.cmake.org/u/itavero)\
**Replies:** 5\
**Last updated:** [December 5, 2025, 11:27am UTC](https://discourse.cmake.org/t/configure-clang-tidy-when-using-an-arm-none-eabi-gcc-g-toolchain/10862 "2025-12-05T11:27:51Z")

</div>

We are developing embedded firmware for ARM Cortex-M, Xtensa and RISC-V microcontrollers. All come with a GCC based toolchain, for instance arm-none-eabi-gcc (arm-none-eabi-g++). We are using CMake 3.28.1 (or slightly …

---

## [target\_precompile\_headers(PRIVATE) in library project does not work when using library functions in an executable project..](https://discourse.cmake.org/t/target-precompile-headers-private-in-library-project-does-not-work-when-using-library-functions-in-an-executable-project/15313)

<div class="topic-metadata">

**Author:** [@AlephVoid](https://discourse.cmake.org/u/AlephVoid)\
**Replies:** 1\
**Last updated:** [November 17, 2025, 6:55pm UTC](https://discourse.cmake.org/t/target-precompile-headers-private-in-library-project-does-not-work-when-using-library-functions-in-an-executable-project/15313 "2025-11-17T18:55:40Z")

</div>

Related question: Question. There is another problem which seems to stump me, that is it seems that target\_precompile\_headers with PRIVATE keyword(Which is a good practice) does not seem to work in my executable project…

---

## [Cannot include header files inside the header files in library project (With executable project for testing)](https://discourse.cmake.org/t/cannot-include-header-files-inside-the-header-files-in-library-project-with-executable-project-for-testing/15311)

<div class="topic-metadata">

**Author:** [@AlephVoid](https://discourse.cmake.org/u/AlephVoid)\
**Replies:** 2\
**Last updated:** [November 16, 2025, 1:52pm UTC](https://discourse.cmake.org/t/cannot-include-header-files-inside-the-header-files-in-library-project-with-executable-project-for-testing/15311 "2025-11-16T13:52:47Z")

</div>

I have the problem which stumped me for 3 days. I am creating an C++ library which inside the library codebase includes are more freely defined than on an executable. For example: #include "base\_task.h" Inside library…

---

## [Import std in clang with custom stdlibc++](https://discourse.cmake.org/t/import-std-in-clang-with-custom-stdlibc/14042)

<div class="topic-metadata">

**Author:** [@krzysztofkortas](https://discourse.cmake.org/u/krzysztofkortas)\
**Replies:** 3\
**Last updated:** [June 5, 2025, 7:28pm UTC](https://discourse.cmake.org/t/import-std-in-clang-with-custom-stdlibc/14042 "2025-06-05T19:28:42Z")

</div>

Merge request 10727 added support for import std using clang and stdlibc++. I use clang with a custom gcc installation passed through a flag --gcc-install-dir via CMAKE\_CXX\_FLAGS. In the Clang-CXX-CXXImportStd.cmake fil…

---

## [cmake-gui blocks presets that are usable through command line cmake](https://discourse.cmake.org/t/cmake-gui-blocks-presets-that-are-usable-through-command-line-cmake/9459)

<div class="topic-metadata">

**Author:** [@AngelDev06](https://discourse.cmake.org/u/AngelDev06)\
**Replies:** 2\
**Last updated:** [March 12, 2025, 2:38pm UTC](https://discourse.cmake.org/t/cmake-gui-blocks-presets-that-are-usable-through-command-line-cmake/9459 "2025-03-12T14:38:48Z")

</div>

I have an issue specifically with cmake-gui. I have written a CMakePresets.json file to build my project on linux however as stated in the title even though running cmake --list-presets on command line displays all prese…

---

## [Multiple compiler link problems](https://discourse.cmake.org/t/multiple-compiler-link-problems/13346)

<div class="topic-metadata">

**Author:** [@ramcdona](https://discourse.cmake.org/u/ramcdona)\
**Replies:** 1\
**Last updated:** [January 11, 2025, 6:57pm UTC](https://discourse.cmake.org/t/multiple-compiler-link-problems/13346 "2025-01-11T18:57:01Z")

</div>

For $reasons$, I need to build my project as libraries using different compilers and then link them together. I am on MacOS and am trying to blend XCode and GCC. I’ve set up a MWE on GitHub here with a longer explanati…

---

## [Generated Makefile build command gives errors as it has quotes in the build command](https://discourse.cmake.org/t/generated-makefile-build-command-gives-errors-as-it-has-quotes-in-the-build-command/13331)

<div class="topic-metadata">

**Author:** [@pj0585](https://discourse.cmake.org/u/pj0585)\
**Replies:** 9\
**Last updated:** [January 6, 2025, 8:50pm UTC](https://discourse.cmake.org/t/generated-makefile-build-command-gives-errors-as-it-has-quotes-in-the-build-command/13331 "2025-01-06T20:50:40Z")

</div>

Hi, I have created a CMakeLists.txt for cross compiling my C project. I have enabled many warning options and need many -D options as well. While adding these to target\_compile\_options() I have added quotes to make it l…

---

## [cmake with arm-none-eabi-gcc doesn't include/link default headers and libraries](https://discourse.cmake.org/t/cmake-with-arm-none-eabi-gcc-doesnt-include-link-default-headers-and-libraries/13254)

<div class="topic-metadata">

**Author:** [@b.e.nazarenko](https://discourse.cmake.org/u/b.e.nazarenko)\
**Replies:** 2\
**Last updated:** [December 24, 2024, 6:38am UTC](https://discourse.cmake.org/t/cmake-with-arm-none-eabi-gcc-doesnt-include-link-default-headers-and-libraries/13254 "2024-12-24T06:38:45Z")

</div>

Moving my project from eclipse to cmake. Made a simple arm-none-eabi toolchain file (got it from STM32 CubeMX), and it works fine. But when I tried to use anything from root includes (math.h for example), it didn’t work.…

---

## [custom linker tool using 3.29 LINKER\_TYPE](https://discourse.cmake.org/t/custom-linker-tool-using-3-29-linker-type/13075)

<div class="topic-metadata">

**Author:** [@FloneStar](https://discourse.cmake.org/u/FloneStar)\
**Replies:** 5\
**Last updated:** [November 27, 2024, 2:04pm UTC](https://discourse.cmake.org/t/custom-linker-tool-using-3-29-linker-type/13075 "2024-11-27T14:04:25Z")

</div>

in our project we have the need to run a custom linker tool. This custom linker tool is supposed to be used for only some targets (some shared libs will be linked the normal way), not all. I have successfully registered …

---

## [\-std=c++11 not being used/set properly with GCC 4.8.5](https://discourse.cmake.org/t/std-c-11-not-being-used-set-properly-with-gcc-4-8-5/10767)

<div class="topic-metadata">

**Author:** [@bp7878](https://discourse.cmake.org/u/bp7878)\
**Replies:** 0\
**Last updated:** [April 30, 2024, 6:11pm UTC](https://discourse.cmake.org/t/std-c-11-not-being-used-set-properly-with-gcc-4-8-5/10767 "2024-04-30T18:11:14Z")

</div>

I’m working on an older project under RHEL 7 with GCC 4.8.5. I have cmake3 3.17.5 installed. I’m building a shared library that is complaining about a for loop error: error: ‘for’ loop initial declarations are only a…

---

## [PACKAGE\_INIT generates PACKAGE\_PREFIX\_DIR with the wrong directory](https://discourse.cmake.org/t/package-init-generates-package-prefix-dir-with-the-wrong-directory/10453)

<div class="topic-metadata">

**Author:** [@josiest](https://discourse.cmake.org/u/josiest)\
**Replies:** 17\
**Last updated:** [April 15, 2024, 11:21am UTC](https://discourse.cmake.org/t/package-init-generates-package-prefix-dir-with-the-wrong-directory/10453 "2024-04-15T11:21:38Z")

</div>

I have a very small library called pi-events, and I’m trying to install it locally to another project I have called sdl-sandbox, which lives in D:/projects/sdl-sandbox My pi-events-config.cmake.in file looks like this: …

---

## [cmake 3.28 and importing C++ headers in gcc](https://discourse.cmake.org/t/cmake-3-28-and-importing-c-headers-in-gcc/9311)

<div class="topic-metadata">

**Author:** [@John\_Fourkiotis](https://discourse.cmake.org/u/John_Fourkiotis)\
**Replies:** 5\
**Last updated:** [October 30, 2023, 5:18pm UTC](https://discourse.cmake.org/t/cmake-3-28-and-importing-c-headers-in-gcc/9311 "2023-10-30T17:18:18Z")

</div>

Hi, I’m trying to create a CMakeLists.txt that more or less will do what the following Makefile does: CXX=a path to gcc14 built from master MODULE\_FLAGS = -fmodules-ts -flang-info-module-cmi make\_module\_of\_vector: …

---

## [CMake goes into an infinite loop when there are two stand-alone subprojects with two different compilers within the same build](https://discourse.cmake.org/t/cmake-goes-into-an-infinite-loop-when-there-are-two-stand-alone-subprojects-with-two-different-compilers-within-the-same-build/8833)

<div class="topic-metadata">

**Author:** [@chudur-budur](https://discourse.cmake.org/u/chudur-budur)\
**Replies:** 1\
**Last updated:** [August 29, 2023, 1:54am UTC](https://discourse.cmake.org/t/cmake-goes-into-an-infinite-loop-when-there-are-two-stand-alone-subprojects-with-two-different-compilers-within-the-same-build/8833 "2023-08-29T01:54:32Z")

</div>

I am new to CMake. What I want to have is two different stand-alone subprojects within one “root” project such that those two subprojects could be built independently. Given that those two subprojects use two different t…

---

## [How to use relative paths when generating code coverage info](https://discourse.cmake.org/t/how-to-use-relative-paths-when-generating-code-coverage-info/8572)

<div class="topic-metadata">

**Author:** [@amlamarra](https://discourse.cmake.org/u/amlamarra)\
**Replies:** 1\
**Last updated:** [July 24, 2023, 9:49am UTC](https://discourse.cmake.org/t/how-to-use-relative-paths-when-generating-code-coverage-info/8572 "2023-07-24T09:49:11Z")

</div>

When I manually compile code to generate coverage info with g++ --coverage ..., it will generate gcno files using relative paths. If I wanted them to be absolute paths, I would add -fprofile-abs-path. However, when using…

---

## [How to enable color output with Ninja](https://discourse.cmake.org/t/how-to-enable-color-output-with-ninja/8544)

<div class="topic-metadata">

**Author:** [@murtiko](https://discourse.cmake.org/u/murtiko)\
**Replies:** 3\
**Last updated:** [July 19, 2023, 11:33pm UTC](https://discourse.cmake.org/t/how-to-enable-color-output-with-ninja/8544 "2023-07-19T23:33:25Z")

</div>

Hi, How can I enable color output when using the Ninja generator? I have set CMAKE\_COLOR\_DIAGNOSTICS to ON and also tried adding the -fdiagnostics-color=always compiler option, but still, no color is displayed. The co…

---

## [Generate two binaries that share CMakeFile but different linker script](https://discourse.cmake.org/t/generate-two-binaries-that-share-cmakefile-but-different-linker-script/8531)

<div class="topic-metadata">

**Author:** [@symon97x](https://discourse.cmake.org/u/symon97x)\
**Replies:** 3\
**Last updated:** [July 19, 2023, 8:32pm UTC](https://discourse.cmake.org/t/generate-two-binaries-that-share-cmakefile-but-different-linker-script/8531 "2023-07-19T20:32:45Z")

</div>

In my embedded project I have a use case in which the CMakelist.txt needs to generate two “quasi identical” binaries that share the same build process, same sources, headers and dependencies, but different linker scripts…

---

## [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…

---

## [Per-file #define pattern in CMake (log-level/file-hash,etc)](https://discourse.cmake.org/t/per-file-define-pattern-in-cmake-log-level-file-hash-etc/8281)

<div class="topic-metadata">

**Author:** [@sam](https://discourse.cmake.org/u/sam)\
**Replies:** 1\
**Last updated:** [June 8, 2023, 4:15am UTC](https://discourse.cmake.org/t/per-file-define-pattern-in-cmake-log-level-file-hash-etc/8281 "2023-06-08T04:15:39Z")

</div>

Hi everyone, I lead a team of embedded C software engineers and we’re seeking a more suitable build system than what we have had grow organically over the years. I’ve been reading lots of CMake documentation, and testin…

---

## [Linking cufft\_static with a CXX target](https://discourse.cmake.org/t/linking-cufft-static-with-a-cxx-target/7946)

<div class="topic-metadata">

**Author:** [@pauleonix](https://discourse.cmake.org/u/pauleonix)\
**Replies:** 5\
**Last updated:** [April 24, 2023, 5:40pm UTC](https://discourse.cmake.org/t/linking-cufft-static-with-a-cxx-target/7946 "2023-04-24T17:40:50Z")

</div>

The cuFFT/1d\_c2c sample by Nvidia provides a CMakeLists.txt which links CUDA::cufft. Modifying it to link against CUDA::cufft\_static causes a lot of linking issues. The cuFFT docs provide some guidance here, so I modifie…

---

## [Incremental build with generated headers must run twice](https://discourse.cmake.org/t/incremental-build-with-generated-headers-must-run-twice/7449)

<div class="topic-metadata">

**Author:** [@ConcernedPanda](https://discourse.cmake.org/u/ConcernedPanda)\
**Replies:** 8\
**Last updated:** [February 26, 2023, 11:33pm UTC](https://discourse.cmake.org/t/incremental-build-with-generated-headers-must-run-twice/7449 "2023-02-26T23:33:09Z")

</div>

I’m in the process of transitioning a legacy project into cmake, and I’ve hit a snag using a custom\_command to generate header files. On a clean build, everything works perfectly, the headers are generated and the code …

---

## [link option wrong with -latomic](https://discourse.cmake.org/t/link-option-wrong-with-latomic/7173)

<div class="topic-metadata">

**Author:** [@dglz.hyj](https://discourse.cmake.org/u/dglz.hyj)\
**Replies:** 2\
**Last updated:** [January 4, 2023, 11:38am UTC](https://discourse.cmake.org/t/link-option-wrong-with-latomic/7173 "2023-01-04T11:38:54Z")

</div>

\#include "thread" #include "iostream" #include "atomic" using namespace std; struct A { int a\[100\]; }; struct B { int x, y; }; int main() { std::atomic\<A\> Ap ; std::atomic\<B\> Bp ; std::cout \<\< std::boolalp…

---

## [CMake does not set the compiler option -std to gnu17 or c++17 although I set the target\_compile\_features to cxx\_std\_17](https://discourse.cmake.org/t/cmake-does-not-set-the-compiler-option-std-to-gnu17-or-c-17-although-i-set-the-target-compile-features-to-cxx-std-17/3299)

<div class="topic-metadata">

**Author:** [@the\_shmoo](https://discourse.cmake.org/u/the_shmoo)\
**Replies:** 18\
**Last updated:** [December 7, 2022, 3:43pm UTC](https://discourse.cmake.org/t/cmake-does-not-set-the-compiler-option-std-to-gnu17-or-c-17-although-i-set-the-target-compile-features-to-cxx-std-17/3299 "2022-12-07T15:43:03Z")

</div>

I updated the versions of GCC and CMake. After the update CMake no longer sets the right command line option for the c++ standard. Here is how I set it: add\_library(project\_options INTERFACE) target\_compile\_features(pr…

---

## [How to check that the current compiler is GCC/MSYS when using Ninja generator?](https://discourse.cmake.org/t/how-to-check-that-the-current-compiler-is-gcc-msys-when-using-ninja-generator/6698)

<div class="topic-metadata">

**Author:** [@hwhsu1231](https://discourse.cmake.org/u/hwhsu1231)\
**Replies:** 7\
**Last updated:** [November 6, 2022, 8:25am UTC](https://discourse.cmake.org/t/how-to-check-that-the-current-compiler-is-gcc-msys-when-using-ninja-generator/6698 "2022-11-06T08:25:04Z")

</div>

Problem Descriptions There is a variable called MSYS, which is set True when we’re using MSYS Makefiles generator. However, it will be EMPTY if we’re using Ninja or Ninja Multi-Config generator. I’m wondering that is th…

---

## [Combining two projects](https://discourse.cmake.org/t/combining-two-projects/5988)

<div class="topic-metadata">

**Author:** [@alexanderzhirov](https://discourse.cmake.org/u/alexanderzhirov)\
**Replies:** 1\
**Last updated:** [July 9, 2022, 1:10pm UTC](https://discourse.cmake.org/t/combining-two-projects/5988 "2022-07-09T13:10:37Z")

</div>

There are two projects: FreeRDP and cFLTK (a C wrapper for the FLTK library). I am writing a GUI for FreeRDP and I want to combine my work with the FreeRDP source code project. My attempt at unification: I have separa…

---

## [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…

---

## [Cmake doesn't pickup where the required executable is (FLEX)](https://discourse.cmake.org/t/cmake-doesnt-pickup-where-the-required-executable-is-flex/5588)

<div class="topic-metadata">

**Author:** [@Rellotscrewdriver](https://discourse.cmake.org/u/Rellotscrewdriver)\
**Replies:** 2\
**Last updated:** [May 3, 2022, 11:18am UTC](https://discourse.cmake.org/t/cmake-doesnt-pickup-where-the-required-executable-is-flex/5588 "2022-05-03T11:18:52Z")

</div>

Hi, I’m trying to conifigure a third-party project using cmake 3.23 which requires FLEX, and I have both of them on my machine and for some reason it doesn’t pick up where they are, telling me that it couldn’t find f…

---

## [compile C++20 modules with cmake](https://discourse.cmake.org/t/compile-c-20-modules-with-cmake/5116)

<div class="topic-metadata">

**Author:** [@raj](https://discourse.cmake.org/u/raj)\
**Replies:** 1\
**Last updated:** [February 25, 2022, 5:49pm UTC](https://discourse.cmake.org/t/compile-c-20-modules-with-cmake/5116 "2022-02-25T17:49:59Z")

</div>

Hi I have two files main.cpp and module1.cpp (simple hello\_world example) I want to build them with cmake. following is cmake code (not working) cmake\_minimum\_required(VERSION 3.21) project(cpp\_concurrency\_mastercla…

---

## [ld unable to find iostreams functions under MSYS2](https://discourse.cmake.org/t/ld-unable-to-find-iostreams-functions-under-msys2/2330)

<div class="topic-metadata">

**Author:** [@R030t1](https://discourse.cmake.org/u/R030t1)\
**Replies:** 13\
**Last updated:** [February 20, 2022, 1:42pm UTC](https://discourse.cmake.org/t/ld-unable-to-find-iostreams-functions-under-msys2/2330 "2022-02-20T13:42:10Z")

</div>

If I include iostreams I receive linking errors running under MSYS2 targeting x86\_64: cmake . -GNinja ninja ... undefined reference to std::ios\_base::Init, etc. If I try to use cout it fails to find those methods as w…

---

## [CMake - search in list - "Unknown arguments specified"](https://discourse.cmake.org/t/cmake-search-in-list-unknown-arguments-specified/4471)

<div class="topic-metadata">

**Author:** [@LynarStudios](https://discourse.cmake.org/u/LynarStudios)\
**Replies:** 2\
**Last updated:** [November 12, 2021, 9:19am UTC](https://discourse.cmake.org/t/cmake-search-in-list-unknown-arguments-specified/4471 "2021-11-12T09:19:19Z")

</div>

Hello community :slight\_smile: I’m currently facing a cmake code issue, which I’m trying to understand and might need some support here. So I hope this is the right place to address this. The following code should dete…

[Next page](https://discourse.cmake.org/tag/comp-gcc/4.md?match_all_tags=true&page=1&tags%5B%5D=comp%3Agcc)
