[CMake] "COMPILE_DEFINITIONS"

Jared Oberhaus oberhaus at pobox.com
Thu Apr 23 16:28:47 EDT 2009


My interpretation of the question was the simplest thing to think of,  
which is just to provide a list of symbols that you want defined in a  
target, as in:

set_target_properties(MyDll PROPERTIES
     COMPILE_DEFINITIONS _USRDLL,UNICODE)

It appears to be as simple as separating the symbols with a comma,  
with no spaces.

As for appending to the existing COMPILE_DEFINITIONS for a target, I  
defer to Alexander Neundorf's answer below.


On Wednesday 11 March 2009, Alexander Neundorf wrote:
> On Wednesday 11 March 2009, Steven Van Ingelgem wrote:
> > Hi all,
> >
> >
> > How can I add multiple "COMPILE_DEFINITIONS" for 1 source file?
> > I tried with a foreach loop, I tried with an array to
> > "COMPILE_DEFINITIONS". In the first case, the latest is retained,  
> in the
> > last case only the first one is set.
>
> I can think of the following ways:
>
> use SET_PROPERTY(SOURCE ... ) with the APPEND argument, or
>
> first use GET_SOURCE_FILE_PROPERTY() to get the current value, then  
> append the
> new value to the variable, and then set the new value using
> SET_SOURCE_FILES_PROPERTIES().
>
> Make sure to use quuotes around the dereferenced variable:
> SET_SOURCE_FILES_PROPERTIES(.... "${my_list_of_stuff}" ).
>
> Please post the code if it doesn't work.
>
> Alex
>


More information about the CMake mailing list