MantisBT - CMake
View Issue Details
0009092CMakeCMakepublic2009-06-02 05:262009-09-14 18:19
Marcel Loose 
Brad King 
normalminoralways
closedno change required 
CMake-2-6 
 
0009092: cmMakefile::ParseDefineFlag() doesn't recognize "-DFOO -DBAR" as definitions, but puts them into flags
I ran into this while trying to compile a few assembly sources (see CMake mailing list thread: Problem with ASM and COMPILE_DEFINITIONS).

Definitions added using add_definitions() with a quoted string
containing more than one argument are NOT discarded by CMake
when /usr/bin/as is called. For example, when using:

  add_defintions("-DMYDEF -DMYOTHERDEF")

these definitions remain as arguments to /usr/bin/as.

However, when supplying only a single argument, quotes don't seem to
matter. Also, when removing the quotes on the multiple arguments above,
CMake properly discards these preprocessor variables when
invoking /usr/bin/as.
I've attached a tar ball with file needed to reproduce this problem.
I borrowed the sources from Torsten Maehne (who pointed me to issue 0008107)
Note: pow2.s was created from pow2.c using the command: gcc -fPIC -S pow2.c
No tags attached.
gz asm_add_definitions_bug.tar.gz (1,646) 2009-06-02 05:26
https://public.kitware.com/Bug/file/2293/asm_add_definitions_bug.tar.gz
Issue History
2009-06-02 05:26Marcel LooseNew Issue
2009-06-02 05:26Marcel LooseFile Added: asm_add_definitions_bug.tar.gz
2009-09-14 12:34Bill HoffmanStatusnew => assigned
2009-09-14 12:34Bill HoffmanAssigned To => Alex Neundorf
2009-09-14 16:11Alex NeundorfNote Added: 0017485
2009-09-14 16:12Alex NeundorfAssigned ToAlex Neundorf => Brad King
2009-09-14 16:12Alex NeundorfSummaryProblem with ASM and COMPILE_DEFINITIONS set through add_definitions() => cmMakefile::ParseDefineFlag() doesn't recognize "-DFOO -DBAR" as definitions, but puts them into flags
2009-09-14 18:18Brad KingNote Added: 0017499
2009-09-14 18:19Brad KingNote Added: 0017500
2009-09-14 18:19Brad KingStatusassigned => closed
2009-09-14 18:19Brad KingResolutionopen => no change required

Notes
(0017485)
Alex Neundorf   
2009-09-14 16:11   
Hmm. If I do
add_definitions("-DFOO -DBAR=bar" -DBLUB=blub)
the -DBLUB=blub is removed, the double quoted part appears through the <FLAGS> variable is CMAKE_ASM${ASM_DIALECT}_COMPILE_OBJECT.
This happens because this regex is used in cmMakefile::ParseDefineFlag() to check whether the argument is a define-flag:
"^[-/]D[A-Za-z_][A-Za-z0-9_]*(=.*)?$"

Two such flags whitespace-separated don't match that expression.

I think Brad is responsible for that parsing...

Alex
(0017499)
Brad King   
2009-09-14 18:18   
The documentation of add_definitions does not say anything about automatically parsing space-separated values from its arguments. CMake thinks you want the actual flag "DFOO -DBAR" with '-' as the leading character.
(0017500)
Brad King   
2009-09-14 18:19   
Use separate_arguments() to parse space-separated arguments before passing to add_definitions.