[CMake] Suggestion for CMake platform/compiler detection

Tanguy Krotoff tanguy.krotoff at wengo.fr
Mon Nov 13 11:30:43 EST 2006


Hi

Cmake supports several boolean for platform/compiler detection:
UNIX
APPLE
WIN32
CYGWIN
MINGW
BORLAND

I think this approach is too simple and not very easy for the developer.

What about code that I want to compile under Windows using Borland, 
Intel, MinGW and MSVC?
What about code compiled under Cygwin? IF (UNIX) is true or not?
What about Intel compiler under UNIX?

A good and simple approach is to totally separate platform OS detection 
from compiler detection.

I see something like this:

Operating systems:
- OS_WINDOWS
   - OS_WIN32
   - OS_WIN64
   - OS_WINCE_POCKETPC (Windows CE for PocketPC)
   - OS_WINCE_SMARTPHONE (Windows CE for smartphone)
- OS_POSIX
   - OS_MACOSX
   - OS_CYGWIN
   - OS_LINUX
   - OS_HURD
   - OS_BSD
     - OS_FREEBSD
     - OS_NETBSD
     - OS_OPENBSD

Compilers:
- CC_MSVC (Microsoft Visual C++)
   - CC_MSVC6 (Visual C++ 6)
   - CC_MSVC7 (Visual C++ .NET)
   - CC_MSVC71 (Visual C++ 2003)
   - CC_MSVC8 (Visual C++ 2005)
- CC_GCC
   - CC_MINGW (Native GCC under Windows)
   - CC_GCC3 (GNU GCC 3.x)
   - CC_GCC4 (GNU GCC 4.x)
- CC_INTEL (Intel C++)
- CC_BORLAND (Borland C++)

Qt as the same approach and I think Qt is a good example of a massively 
multiplatform tool.

See qglobal.h at:
http://doc.trolltech.com/3.3/qglobal-h.html

It would be good for CMake to have the same separation between OS and 
compiler detection, what do you think?

Regards,

-- 
Tanguy Krotoff <tanguy.krotoff at wengo.fr>
http://openwengo.org


More information about the CMake mailing list