Using CMake instead of clang ++

I am trying to get CMake and Clang to work with my program. I have set environment variables CC

and CXX

as such:

export CC=/usr/bin/clang
export CXX=/usr/bin/clang++

      

But when I run cmake .

and make

, I get a linker error because it is using /usr/bin/clang

and not /usr/bin/clang++

and therefore cannot see the C ++ standard library. After running make VERBOSE=1

this is what I get:

/usr/bin/clang   -std=c++11 -Wall -O3   CMakeFiles/Saruman.dir/Board.cpp.o
CMakeFiles/Saruman.dir/CaptureList.cpp.o CMakeFiles/Saruman.dir/Evaluation.cpp.o
CMakeFiles/Saruman.dir/main.cpp.o CMakeFiles/Saruman.dir/MoveList.cpp.o
CMakeFiles/Saruman.dir/Search.cpp.o CMakeFiles/Saruman.dir/TranspositionTables.cpp.o 
CMakeFiles/Saruman.dir/UCI.cpp.o  -o Saruman -rdynamic -lpthread 

CMakeFiles/Saruman.dir/Board.cpp.o: In function Board::Board(std::string)':
/home/terry/code/chess/engine/Source/Board.cpp:(.text+0x100): undefined reference to
`std::string::compare(char const*) const'

      

And explicitly call /usr/bin/clang

instead /usr/bin/clang++

. When I run manually

clang++ -std=c++11 -Wall -O3 ...

      

it compiles fine.

Any help would be greatly appreciated.

+3


source to share


1 answer


You can tell the cpp compiler directly to cmake



cmake . -DCMAKE_CXX_COMPILER=/usr/bin/clang++

-1


source







All Articles