Linked Questions
53 questions linked to/from How to specify a compiler in CMake?
1 vote
1 answer
1k views
CMake generator for Clang on Windows [duplicate]
I'm trying to build a simple C++ project on Windows 10 using Clang version 9.0.0. I can run the following command successful. clang++ main.cpp -o learn.exe This produces learn.exe which run ...
0 votes
1 answer
1k views
Infinite loop configuring CMake [duplicate]
I have a tiny library with its own cmake file. I am trying to add this library to the platformio ploject. I create a "CMakeListsUser.txt" and add this line "add_subdirectory(GLibc)"...
0 votes
1 answer
264 views
CMake subproject cant find compiler [duplicate]
I have a project with a structure as follows: project ├── build ├── CMakeLists.txt ├── extern (git submodule) │ └── mylib │ ├── build │ ├── CMakeLists.txt │ └── src └── src └── ...
0 votes
0 answers
79 views
CMake won't select the correct C++ compiler [duplicate]
I am trying to build a CMake C++ Project with C++20 because I want to use the <ranges> library. I have tested my gcc compiler with the -std=c++20 flag and it works. However, when I build a ...
0 votes
0 answers
46 views
CMake automatically adds -MD -MT and -MF options [duplicate]
Starting with cmake 3.20, a series of GNU-specific options are added to the compile lines, and I'm not sure why CMAKE_C_FLAGS does not remove them. Prior to the release of cmake 3.20, those options ...
0 votes
0 answers
42 views
avr-gcc: error: unrecognized command-line option '-arch' [duplicate]
having setup an AVR project in Clion on m1 mac I encountered some problem compiling the project I appreciate any help in advance CMakeLists.txt project(micro_controller C) SET(MCU "atmega328&...
200 votes
23 answers
681k views
CMake error at CMakeLists.txt:30 (project): No CMAKE_C_COMPILER could be found
I'm trying make a Visual Studio solution with CMake to compile the latest version of aseprite and CMake keeps giving me the: No CMAKE_C_COMPILER could be found. No CMAKE_CXX_COMPILER could be found. ...
50 votes
4 answers
140k views
Unable to specify the compiler with CMake
I have a problem with this CMakeLists.txt file: cmake_minimum_required(VERSION 2.6) SET(CMAKE_C_COMPILER C:/MinGW/bin/gcc) SET(CMAKE_CXX_COMPILER C:/MinGW/bin/g++) project(cmake_test) ...
22 votes
2 answers
26k views
What is "XX" in CXX in a cmake CMakeLists.txt file
What is "XX" in CXX in a cmake CMakeLists.txt file. What is its significance. Why is it "XX" not PP against a CPP file ?
31 votes
5 answers
19k views
Using CMake with multiple compilers for the same language
It seems like CMake is fairly entrenched in its view that there should be one, and only one, CMAKE_CXX_COMPILER for all C++ source files. I can't find a way to override this on a per-target basis. ...
41 votes
1 answer
12k views
CMake: In which order are files parsed (cache, toolchain, etc.)?
This seems as a trivial question, since CMake is a script language the general answer is: strictly sequential. But I came across several cases where it was important when or in which order CMake is ...
13 votes
6 answers
8k views
Changing compiler with cmake creates infinite loop
I try to change the compiler with cmake : SET(CMAKE_C_COMPILER "/opt/rh/devtoolset-2/root/usr/bin/gcc") SET(CMAKE_CXX_COMPILER "/opt/rh/devtoolset-2/root/usr/bin/g++") I do that in the begining of ...
3 votes
2 answers
2k views
Is there a cmake compile feature for c++17's charconv?
I have written some code that make use c++17's charconv, that I can compile just fine with g++ 9. Even though I have set the std to c++17 in my CMakeLists.txt, cmake insists on using c++ 7.5, which ...
1 vote
1 answer
3k views
libtorch and CUDA stub library loaded at runtime problem
I am trying to compile a .cpp application which depends on LibTorch, the cpp version of PyTorch (https://pytorch.org/) on a HPC server. I have loaded CUDA 11.8 via a module load. nvcc -V outputs nvcc: ...
1 vote
2 answers
4k views
compile_commands.json file with clangd lsp in neovim. Can't resolve " 'iostream' file not found " error even though .exe can be succesfully built
On Windows 10 in powershell I am using g++ as a compiler with CMake and MinGW Makefiles I am also using neovim (with the kickstarter config) and clangd lsp, installed from Mason Also downloaded LLVM ...