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

Erwin Coumans erwin.coumans at gmail.com
Tue Jul 14 17:23:25 EDT 2009


remove_definitions(-D_WINDOWS ) didn't work, possibly because it
wasn't added using add_definitions (but a built-in).

I'm happy with string (REPLACE "/D_WINDOWS" "" CMAKE_CXX_FLAGS
${CMAKE_CXX_FLAGS})



2009/7/14 Eric Noulard <eric.noulard at gmail.com>:
> 2009/7/14 Erwin Coumans <erwin.coumans at gmail.com>:
>>> string (REPLACE "/D_WINDOWS" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
>>
>> Great, that did the job.
>>
>
> Don't know if it can work for your case but you have the
> 'remove_definitions' command too:
>
>  remove_definitions
>       Removes -D define flags added by add_definitions.
>
>         remove_definitions(-DFOO -DBAR ...)
>
>       Removes flags (added by add_definitions) from the compiler command
>       line for sources in the current directory and below.
>
>
> --
> Erk
> Membre de l'April - « promouvoir et défendre le logiciel libre » -
> http://www.april.org
>


More information about the CMake mailing list