MantisBT - CMake
View Issue Details
0015156CMakeCMakepublic2014-09-14 08:332015-03-02 08:57
Meng-Yuan Huang 
 
normalminoralways
closedfixed 
LinuxCentOS6.5 x64
CMake 2.8.12 
CMake 3.1CMake 3.1 
0015156: Sometime, CMake can't find clang/clang++
I have a CMake C++ project, test. I want to build it by clang/clang++ on CentOS 6.5. I run cmake by this command line:
cmake -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ .

Unfortunately, sometime, cmake said it can't find clang/clang++.
Strangely, if I run the command line again, it becomes to able to find them.
Strangely again, if run the command line again, it becomes to not able to find them.
...

If cmake can find clang/clang++, then running make will invoke clang/clang++.
Otherwise, if cmake can't find clang/clang++, then running make will invoke gcc/g++.

I recorded a video to show the problem:
http://1drv.ms/1uwXVek [^]

Please fix this problem.

CMake 3.0.2 also has a similar but different problem as 2.8.12.
1. Download the attached test project, test.tar.gz and extract it.
2. Run cmake -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ .
for several times and inspect the cmake output messages.
No tags attached.
gz test.tar.gz (26,051) 2014-09-14 08:33
https://public.kitware.com/Bug/file/5256/test.tar.gz
Issue History
2014-09-14 08:33Meng-Yuan HuangNew Issue
2014-09-14 08:33Meng-Yuan HuangFile Added: test.tar.gz
2014-09-15 09:47Brad KingNote Added: 0036793
2014-09-15 09:54Meng-Yuan HuangNote Added: 0036794
2014-09-15 10:09Brad KingNote Added: 0036796
2014-09-15 10:11Brad KingNote Added: 0036798
2014-09-15 20:09Meng-Yuan HuangNote Added: 0036811
2014-09-16 08:37Brad KingNote Added: 0036814
2014-09-16 08:37Brad KingStatusnew => resolved
2014-09-16 08:37Brad KingResolutionopen => fixed
2014-09-16 08:37Brad KingFixed in Version => CMake 3.1
2014-09-16 08:37Brad KingTarget Version => CMake 3.1
2015-03-02 08:57Robert MaynardNote Added: 0038124
2015-03-02 08:57Robert MaynardStatusresolved => closed

Notes
(0036793)
Brad King   
2014-09-15 09:47   
Please try either:

 cmake -DCMAKE_C_COMPILER=/full/path/to/bin/clang -DCMAKE_CXX_COMPILER=/full/path/to/bin/clang++ .

or

 CC=clang CXX=clang++ cmake .

in a fresh tree.
(0036794)
Meng-Yuan Huang   
2014-09-15 09:54   
Hi Brad King,

Thanks. I know using absolute paths to clang and clang++ can work around the problem. However, I want to know whether this problem be fixed.
(0036796)
Brad King   
2014-09-15 10:09   
I think this may have been fixed since 3.0. Please try a version from the Git 'master' branch or a nightly binary:

 http://www.cmake.org/files/dev/?C=M;O=D [^]
(0036798)
Brad King   
2014-09-15 10:11   
Re 0015156:0036796: IIRC, the fix was here:

 cmGlobalGenerator: Do not re-add CMAKE_<LANG>_COMPILER
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=731427a6 [^]
(0036811)
Meng-Yuan Huang   
2014-09-15 20:09   
Hi Brad King,

Thanks.
I confirmed ver. 3.0.20140911-g5cbab solves this problem.
However, ver. 3.0.2 surely has a similar but different problem.
(0036814)
Brad King   
2014-09-16 08:37   
Re 0015156:0036811: Thanks for testing. The fix will be in the 3.1 release. For older versions please use one of the methods suggested in 0015156:0036793.
(0038124)
Robert Maynard   
2015-03-02 08:57   
Closing resolved issues that have not been updated in more than 4 months.