MantisBT - CMake
View Issue Details
0013561CMakeCMakepublic2012-09-28 02:172016-06-10 14:31
icando 
Bill Hoffman 
highmajoralways
closedmoved 
Visual Studio 2012WindowsAny
CMake 2.8.9 
 
0013561: CHECK_CXX_COMPILER_FLAGS is totally broken under newer version of Visual Studio
On Windows platform, by default, CMake will add /INCREMENTAL:YES to the linker flag. This will trigger warning messages by the linker of MSVC, and CHECK_CXX_COMPILER_FLAGS will think the compiler doesn't accept the flag. So basically, CHECK_CXX_COMPILER_FLAGS will just return FAlSE for any flag, valid or invalid. Any scripts that relies on this check will just broken.
Just use any valid flag in CHECK_CXX_COMPILER_FLAGS on Windows platform and Visual Studio 2012. Earlier versions might also be broken because when I was searching in Google, I just found some people complaining about it for Visual Studio 2010 as well.
No tags attached.
txt CMakeLists.txt (222) 2012-10-26 00:59
https://public.kitware.com/Bug/file/4543/*
log CMakeError.log (1,167) 2012-10-26 00:59
https://public.kitware.com/Bug/file/4544/*
txt CMakeLists2.txt (238) 2012-10-26 01:36
https://public.kitware.com/Bug/file/4545/*
log CMakeError2.log (1,210) 2012-10-26 01:36
https://public.kitware.com/Bug/file/4546/*
log output.log (1,017) 2012-10-26 01:38
https://public.kitware.com/Bug/file/4547/*
Issue History
2012-09-28 02:17icandoNew Issue
2012-09-28 08:25Brad KingAssigned To => Bill Hoffman
2012-09-28 08:25Brad KingStatusnew => assigned
2012-09-29 12:19icandoNote Added: 0031114
2012-10-19 12:02icandoNote Added: 0031283
2012-10-22 10:01Bill HoffmanNote Added: 0031288
2012-10-26 00:59icandoFile Added: CMakeLists.txt
2012-10-26 00:59icandoFile Added: CMakeError.log
2012-10-26 01:36icandoFile Added: CMakeLists2.txt
2012-10-26 01:36icandoFile Added: CMakeError2.log
2012-10-26 01:38icandoFile Added: output.log
2012-10-26 01:48icandoNote Added: 0031339
2012-10-26 16:37Bill HoffmanNote Added: 0031345
2012-10-30 04:27icandoNote Added: 0031349
2013-10-22 05:08icandoNote Added: 0034212
2016-06-10 14:28Kitware RobotNote Added: 0042125
2016-06-10 14:28Kitware RobotStatusassigned => resolved
2016-06-10 14:28Kitware RobotResolutionopen => moved
2016-06-10 14:31Kitware RobotStatusresolved => closed

Notes
(0031114)
icando   
2012-09-29 12:19   
Is this problem easy to fix? I just wonder if I could expect this being fixed soon (e.g. next version of CMake).
(0031283)
icando   
2012-10-19 12:02   
Brad King, is it possible to assign to someone else who are more active? I found all recent tasks assigned to Bill Hoffman are not responsive.
(0031288)
Bill Hoffman   
2012-10-22 10:01   
Can you attache a CMakeError.log with this problem?
(0031339)
icando   
2012-10-26 01:48   
Hi Bill Hoffman,

Thanks for your response. I found I make some mistake claiming the things are broken under MSVC. Actually they are not. They are just broken under Intel compiler. Here is the full story:

I tried to test if cmake can detect that the flags /Qstd=c++11 is supported by Intel compiler:

E:\xx>set CC=icl

E:\xx>set CXX=icl

E:\xx>cmake . > output.log 2>&1

I've attached CMakeLists2.txt, CMakeError2.log and output.log.


By looking at the error log I found /INCREMENTAL:YES breaks the flag detection so I randomly test some flag (unfortunately I picked /O1, which failed for totally different reasons) under MSVC. It was also broken, without looking into the error log this time, I mistakenly came to the conclusion that flag detection is also broken under MSVC.

So my question is, is it sufficient to just set CXX and CC if I want to work under Intel compiler? So am I missing something, or the flag detection is not working under Intel compiler?

Thanks.
(0031345)
Bill Hoffman   
2012-10-26 16:37   
So, yes setting CXX and CC is what you need to do, and in fact that seems to be working given your output.log.
-- Check for working C compiler: D:/Program Files (x86)/Develop_Utilities/Intel/Composer XE 2013/bin/intel64/icl.exe

-- Check for working C compiler: D:/Program Files (x86)/Develop_Utilities/Intel/Composer XE 2013/bin/intel64/icl.exe -- works
-- Check for working CXX compiler: D:/Program Files (x86)/Develop_Utilities/Intel/Composer XE 2013/bin/intel64/icl.exe -- works

And yes, the flag detection is broken with the intel compiler and /INCREMENTAL:YES.

This looks like it is fixed already in Modules/Platform/Windows-cl.cmake, but not in Modules/Platform/Windows-Intel.cmake. See MSVC_INCREMENTAL_DEFAULT in the -cl.cmake file. Try to copy that stuff into your Windows-Intel.cmake file and see if that works for you. If it works, we can push it upstream.
(0031349)
icando   
2012-10-30 04:27   
Hi Bill Hoffman,

It works! There is only one place in Windows-Intel.cmake that involves /incremental:yes flag, and it works once I remove the ":yes" part.

As for pushing a patch to upstream, can I leave the work to you? In Windows-cl.cmake it contains a bunch of logic of handling older/newer MSVC, and handling different build types. So it involves some work to clone the logic
(0034212)
icando   
2013-10-22 05:08   
Fixed in master.
(0042125)
Kitware Robot   
2016-06-10 14:28   
Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.