View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0009092CMakeCMakepublic2009-06-02 05:262009-09-14 18:19
ReporterMarcel Loose 
Assigned ToBrad King 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionno change required 
PlatformOSOS Version
Product VersionCMake-2-6 
Target VersionFixed in Version 
Summary0009092: cmMakefile::ParseDefineFlag() doesn't recognize "-DFOO -DBAR" as definitions, but puts them into flags
DescriptionI 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.
Additional InformationI'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
TagsNo tags attached.
Attached Filesgz file icon asm_add_definitions_bug.tar.gz [^] (1,646 bytes) 2009-06-02 05:26

 Relationships

  Notes
(0017485)
Alex Neundorf (developer)
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 (manager)
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 (manager)
2009-09-14 18:19

Use separate_arguments() to parse space-separated arguments before passing to add_definitions.

 Issue History
Date Modified Username Field Change
2009-06-02 05:26 Marcel Loose New Issue
2009-06-02 05:26 Marcel Loose File Added: asm_add_definitions_bug.tar.gz
2009-09-14 12:34 Bill Hoffman Status new => assigned
2009-09-14 12:34 Bill Hoffman Assigned To => Alex Neundorf
2009-09-14 16:11 Alex Neundorf Note Added: 0017485
2009-09-14 16:12 Alex Neundorf Assigned To Alex Neundorf => Brad King
2009-09-14 16:12 Alex Neundorf Summary Problem 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:18 Brad King Note Added: 0017499
2009-09-14 18:19 Brad King Note Added: 0017500
2009-09-14 18:19 Brad King Status assigned => closed
2009-09-14 18:19 Brad King Resolution open => no change required


Copyright © 2000 - 2018 MantisBT Team