[CMake] Suggestion for CMake platform/compiler detection

Bill Hoffman bill.hoffman at kitware.com
Wed Nov 15 13:10:18 EST 2006


Brandon J. Van Every wrote:
> Alexander Neundorf wrote:
>> CMake has some of that.
>> It has for OS:
>> UNIX
>> APPLE
>> WIN32
>> CYGWIN
>> MINGW
>>   
>
> Cygwin is not an OS, it's a compiler.
>
> The Bash that comes with Cygwin provides a filesystem environment.  
> Oftentimes when people compile on Windows in open source land, what 
> they really want / need to know is the difference between various 
> shells.  Is it Cygwin Bash, MSYS Bash, straight Windows Command 
> Prompt, or something else?
>
>
>>
>> And for the compilers:
>> Not sure it has GCC, but at least it has CMAKE_COMPILER_IS_GNUCXX
>> BORLAND
>> MSVC
>> For the Intel Compiler in KDE we currently check using 
>> if(CMAKE_C_COMPILER MATCHES "icc")
>>
>> So there is room for improvement.   
>
>
> There's coverage, it's just ad hoc, not canonized, and has an 
> inconsistent interface.  At present this doesn't trouble me, personally.
>> I think mainly some of the cmake files in Modules/ and 
>> Modules/Platforms/ would have to be extended. For compatibility 
>> reasons I'm not sure new prefixes like "OS_" and "CC_" would be a 
>> good idea.
>>   
>
> It would also be good to look at other canonical (OS compiler library 
> etc.) specifiers before deciding on such a thing.  Like the Boost 
> conventions, for instance.  I do think any canonization should include 
> space for a shell specifier, and I don't think any extant canonization 
> does that.  Shells are *exceedingly* problematic for builds.  Can't 
> tell you how much time I've lost to backslash, escaped whitespace, and 
> double quoting issues.
The problem with the shell, is that you can run cmake, then run make 
from a different shell....
For the most part that works on unix.   zsh, bash, sh, csh basically 
work the same.   The trouble shows up
on windows.   MSYS uses a version of bash, and MinGW uses the windows 
shell, and cygwin uses bash,
zsh, or some other more like unix.  

-Bill



More information about the CMake mailing list