[CMake] Building with CMake on MinGW/MSYS

Hendrik Sattler post at hendrik-sattler.de
Fri Feb 19 06:09:54 EST 2010


Zitat von Florent Teichteil <florent.teichteil at gmail.com>:
> I am trying to build the OpenJPEG library, that uses CMake to generate
> Makefiles, on MSYS with MinGW's gcc compiler.
>
> Some files of the library include system-dependent headers depending on
> the host system:
>
> #ifdef WIN32
> #include <windows.h>
> #else
> #include <sys/time.h>
> #include <sys/resource.h>
> #include <sys/times.h>
> #endif /* WIN32 */
>
> However, the compilation of these files fails because the variable
> "WIN32" is (very strangely) not defined, so that gcc goes inside the
> "#else" statement and does not find the headers under the "sys"
> directory (which do not exist on windows). As I am compiling on a
> windows platform on MSYS, shouldn't I expect the variable "WIN32" to be
> defined? I tried the "MSYS" and "Unix" makefile generators, but none of
> them works.

The pre-processor symbol is called _WIN32, not WIN32 (not the leading  
underscore):
http://predef.sourceforge.net/preos.html#sec24

HS




More information about the CMake mailing list