[CMake] How to remove _WINDOWS for MSVC preprocessor definitions for library & executable projects?

Erwin Coumans erwin.coumans at gmail.com
Tue Jul 14 16:47:07 EDT 2009


> string (REPLACE "/D_WINDOWS" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})

Great, that did the job.

Thanks!
Erwin


2009/7/14 Tyler Roscoe <tyler at cryptio.net>:
> On Tue, Jul 14, 2009 at 12:07:32PM -0700, Erwin Coumans wrote:
>> By default Cmake seems to add some built-in preprocessor definitions
>> for Visual Studio project files,
>> such as WIN32 and _WINDOWS. WIN32 is ok, but _WINDOWS is not always desired.
>
> Looks like it's set in Modules/Platform/Windows-cl.cmake:
>
> SET (CMAKE_CXX_FLAGS_INIT "/DWIN32 /D_WINDOWS /W3 [...]
>
>> Is there an option to remove _WINDOWS from those definitions, for both
>> library and executable projects?
>
> The values above end up populating CMAKE_CXX_FLAGS. So just remove them
> from there at the top of your project:
>
> string (REPLACE "/D_WINDOWS" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
>
>
> tyler
>


More information about the CMake mailing list