I have following setting in my Toolchain.cmake
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_VERSION 1)
set(CMAKE_SYSTEM_PROCESSOR x86_64)
set(cross_triple "x86_64-linux-gnu")
set(clang_5.0 "/third_party/llvm-build/Release+Asserts")
set(clang_link_flags "-lstdc++")
set(CMAKE_C_COMPILER ${clang_5.0}/bin/clang)
set(CMAKE_CXX_COMPILER ${clang_5.0}/bin/clang++)
set(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER})
set(CMAKE_CXX_FLAGS "-std=c++11 -stdlib=libc++ -Wno-c++11-narrowing -v")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${clang_link_flags}")
And, my clang compiler folder as belows:
-rwxr-xr-x 1 1024 1024 15774563 May 11 21:06 sancov
-rwxr-xr-x 1 1024 1024 3925178 May 11 21:06 llvm-symbolizer
-rwxr-xr-x 1 1024 1024 16048083 May 11 21:06 llvm-ar
-rwxr-xr-x 1 1024 1024 63993992 May 11 21:06 lld
-rwxr-xr-x 1 1024 1024 82308936 May 11 21:06 clang
lrwxrwxrwx 1 1024 1024 3 May 18 01:11 ld.lld -> lld
lrwxrwxrwx 1 1024 1024 5 May 18 01:11 clang-cl -> clang
lrwxrwxrwx 1 1024 1024 5 May 18 01:11 clang++ -> clang
Everything looks fine for me. But, when I use Cmake then make to compile my project, for all the .cpp .c files, Cmake choose to use clang instead of clang++ to compile the source codes, like:
"/third_party/llvm-build/Release+Asserts/bin/clang" -cc1 -x c++ xxx.cpp -o xxx.cpp.o
For some reason, the "-lstdc++" flags won't take affect in the linker, which cause some issues.
My questions:
why cmake choose to use "clang -x c++", instead of directly using clang++? Anything missing here? How to let cmake choose clang++?
define "-lstdc++" in CMAKE_EXE_LINKER_FLAGS look like does not take affect. Can you tell what can be the reason?
Thanks.