View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0014759CMake(No Category)public2014-02-17 07:552016-06-10 14:31
ReporterMathieu Malaterre 
Assigned ToKitware Robot 
PrioritynormalSeverityminorReproducibilityhave not tried
StatusclosedResolutionmoved 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0014759: add_definitions and -std=c++11
DescriptionI recently discovered a new behavior for add_definitions as explained at:

http://stackoverflow.com/questions/10851247/how-to-activate-c-11-in-cmake#16393486 [^]

For some reason, cmake seems to cope with something like this:

ADD_DEFINITIONS(
    -std=c++11 # Or -std=c++0x
    # Other flags
)

I doubt this is pure luck, so I would suggest that it either be documented as:
1. Undefined behavior
2. Properly defined behavior, in which case `cmake --help-command add_definitions` should be updated.

thanks
TagsNo tags attached.
Attached Files

 Relationships

  Notes
(0035118)
Nils Gladitz (developer)
2014-02-17 08:11

You mean the fact that it is being used for something other than definitions?

The command help currently does state:

"This command can be used to add any flags, but it was originally intended to add preprocessor definitions."

I would vote for having this behaviour deprecated by policy.
Maybe some time after target specific compiler features have been implemented since it would make this specific (and apparently common) "hack" superfluous.
(0035119)
Mathieu Malaterre (developer)
2014-02-17 08:14

Depending on how you read it:

"Adds -D define flags to the compilation of source files."

I thought that flags refered to the defined string, eg FOO or BAR as in the example:

add_definitions(-DFOO -DBAR ...)


However as you pointed out, there is way to read the documentation and understand that flag means -DFOO, in which case indeed this is -sort of- documented.
(0035123)
Brad King (manager)
2014-02-17 09:00

The command has accepted arbitrary flags since day one. That is why the syntax is "-D" for definition flags. Nowadays we parse out the -D flags and treat them like COMPILE_DEFINITIONS and pass through the rest of the flags for compatibility.

Now that we have add_compile_options the value of this old add_definitions behavior is only in compatibility rather than in functionality. We could consider adding a policy to disallow non-definition flags but I'd like to wait until versions of CMake that understand add_compile_options have been out for longer (2.8.12).
(0042489)
Kitware Robot (administrator)
2016-06-10 14:29

Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.

 Issue History
Date Modified Username Field Change
2014-02-17 07:55 Mathieu Malaterre New Issue
2014-02-17 08:11 Nils Gladitz Note Added: 0035118
2014-02-17 08:14 Mathieu Malaterre Note Added: 0035119
2014-02-17 09:00 Brad King Note Added: 0035123
2016-06-10 14:29 Kitware Robot Note Added: 0042489
2016-06-10 14:29 Kitware Robot Status new => resolved
2016-06-10 14:29 Kitware Robot Resolution open => moved
2016-06-10 14:29 Kitware Robot Assigned To => Kitware Robot
2016-06-10 14:31 Kitware Robot Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team