Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cmake error setting compiler

Tags:

linux

cmake

For some reason, CMake's C and C++ compilers are set by default to /usr/bin/qcc. I've followed this post and tried the command

cmake -D CMAKE_C_COMPILER=/usr/bin/gcc -D CMAKE_CXX_COMPILER=/usr/bin/g++

but I get the error

CMake Error: The source directory [current directory]/CMAKE_CXX_COMPILER=/usr/bin/g++" does not exist.

Why is CMake interpreting my commands as a directory, and what is the correct way to set CMake's compilers?

like image 293
1'' Avatar asked Dec 12 '22 15:12

1''


2 Answers

You've got the right idea, however the command line you want is:

cmake -DCMAKE_C_COMPILER=/usr/bin/gcc -DCMAKE_CXX_COMPILER=/usr/bin/g++ <path_to_source>

The differences are subtle. There should be no space between the -D and the variable being set, which is why CMake is interpreting your variable assignment as a directory. Also CMake uses CXX for C++ specific variables, which keeps it consistent with Make.

like image 78
j3lamp Avatar answered Dec 14 '22 03:12

j3lamp


It's CMAKE_CXX_COMPILER, not C++.

like image 45
John Zwinck Avatar answered Dec 14 '22 05:12

John Zwinck