[CMake] set_target_properties not setting COMPILE_DEFINITIONS?

David Doria daviddoria at gmail.com
Mon Mar 28 14:43:01 EDT 2011


On Mon, Mar 28, 2011 at 2:31 PM, David Doria <daviddoria at gmail.com> wrote:
> On Mon, Mar 28, 2011 at 2:28 PM, Yuri Timenkov <yuri at timenkov.ru> wrote:
>> Try prefixing definitions with -D
>
> I changed to:
> SET(MAIN_BUILD_DEFINITIONS "${MAIN_BUILD_DEFINITIONS} -DUNIX;")
> SET(MAIN_BUILD_DEFINITIONS "${MAIN_BUILD_DEFINITIONS} -DPIXEL_DIMENSION=3;")
>
> and I get:
>
> <command-line>: error: macro names must be identifiers
>
> I think you don't have to add -D when you set COMPILE_DEFINITIONS, but
> you do if you set COMPILE_FLAGS.
>
> David
>

Hm, I noticed that if I do this:

set(my_definitions "UNIX;USE_ITK;USE_FLOAT_PIXELS;")
message("my definitions: " ${my_definitions})

the output is:

UNIXUSE_ITKUSE_FLOAT_PIXELS

but If I put spaces after the semicolons:

set(my_definitions "UNIX; USE_ITK; USE_FLOAT_PIXELS;")

the output is:

UNIX USE_ITK USE_FLOAT_PIXELS

In neither case are the semicolons preserved, which seems bad because
the set_target_properties call expects a semicolon separated list of
preprocessor definitions. Why are these semicolons being removed? They
are in a string (" "), right?

David


More information about the CMake mailing list