[CMake] ADD_DEFINITIONS and COMPILE_DEFINITIONS

Ryan Pavlik rpavlik at iastate.edu
Thu Feb 11 12:55:39 EST 2010


No, you need to pass the definition with /D or -D: CMake internally 
removes that prefix before adding it to your target properties (see the 
property COMPILE_DEFINITIONS), and generates the build command 
appropriately for the platform, with either /D or -D as the platform 
requires.  You can use either /D or -D in your CMakeLists.txt calls to 
add_definitions, and it will work cross-platform.

You might also run into issues with space vs. semicolon-delimited lists 
- I know compile flags are space-delimited in some places.

Basically - don't over think it, it will work fine just the way it is.

Ryan

On 02/11/2010 11:42 AM, paul.chavent at fnac.net wrote:
> Hi.
>
> As cmake should abstract us from the platforms, the compilo, etc. I wonder why so much project returns XXX_DEFINITIONS including "-D".
>
> So when we make ADD_DEFINITIONS(XXX_DEFINITIONS) everything work.
> But when we do SET_PROPERTY( [...] COMPILE_DEFINITIONS [...] ) it doesn't work anymore.
>
> So i think it is a bug to provide the "-D", and that we shouldn't use ADD_DEFINITION for adding definitions.
>
> So in my project i will do a STRING(REPLACE "-D" "" XXX_DEFINITIONS ${XXX_DEFINITIONS}) before doing SET_PROPERTY( [...] COMPILE_DEFINITIONS [...] ${XXX_DEFINITIONS})
>
>
> Am I on the wright way ?
>
> Thank you for your reading/comments.
>
> Paul.
>
> PS : there was a thread about this topic (msg21797), but no answer on the good practice.
>
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
>    

-- 
Ryan Pavlik
HCI Graduate Student
Virtual Reality Applications Center
Iowa State University

rpavlik at iastate.edu
http://academic.cleardefinition.com
Internal VRAC/HCI Site: http://tinyurl.com/rpavlik



More information about the CMake mailing list