View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0015826CMakeCMakepublic2015-11-02 10:412016-06-10 14:31
ReporterEdward Rudd 
Assigned ToKitware Robot 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionmoved 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0015826: target_compile_options de-duplicates flags but some repeats matter
DescriptionSo, I'm trying to build up a project via CMake that targets emscripten/asm.js Generally everything works great except for ONE thing that I'm trying to do. Pass custom emcc specific compile options. Emcc has compile options in the form of "-s USE_BLAH=2" . Generally these are used only as link options which doing this

target_link_libraries(MyTarget "-s USE_ZLIB=1" "-s USE_SDL=2" "-s ASSERTIONS=2") works fine. and the produced options has the options unquoted.

  em++ -s USE_ZLIB=1 -s USE_SDL=2 -s ASSERTIONS=2 -g -o MyTarget.js @CMakeFiles/MyTarget.dir/linklibs.rsp

However when applying them to compile options it breaks apart. e.g.

target_compile_options(MyTarget PRIVATE "-s USE_ZLIB=1" "-s USE_SDL=2")

CXX_FLAGS = "-s USE_ZLIB=1" "-s USE_SDL=2" -g @CMakeFiles/MyTarget.dir/includes_CXX.rsp

which emcc/em++ do not see the quoted argument as the option correctly and things do not work.

If I don't quote them then the produced output is further incorrect

target_compile_options(MyTarget PRIVATE -s USE_ZLIB=1 -s USE_SDL=2)

CXX_FLAGS = -s USE_ZLIB=1 USE_SDL=2 -g @CMakeFiles/MyTarget.dir/includes_CXX.rsp

Only one "-s" is produced!
TagsNo tags attached.
Attached Files

 Relationships

  Notes
(0040255)
Anil Altinay (reporter)
2016-01-19 01:19
edited on: 2016-01-19 16:29

target_compile_options(..) get rid of same flags. In my case

target_compile_options(schedRandomizePercentage PRIVATE -mllvm -sched-randomize -mllvm -sched-randomize-percentage=100)

It tries to execute second flag without -mllvm but that is not what I want. I have tried following tricks to go around the problem but none of them worked.

______________TRICKS______________
1. Using PUBLIC instead of PRIVATE
2. Using semicolon instead of space between flags
3. Separating same flags into different commands like the following.

target_compile_options(schedRandomizePercentage PRIVATE -mllvm -sched-randomize)

target_compile_options(schedRandomizePercentage PRIVATE -mllvm -sched-randomize-percentage=100)

(0040260)
Brad King (manager)
2016-01-19 10:28

Re 0015826:0040255: I think that is the underlying problem and so I've updated the summary accordingly. The latter approach in the description is the intended interface.
(0040261)
Brad King (manager)
2016-01-19 10:33

It appears that the implementation intentionally removes duplicate options. See the "uniqueOptions" set here:

 https://cmake.org/gitweb?p=cmake.git;a=blob;f=Source/cmGeneratorTarget.cxx;hb=v3.4.1#l2346 [^]

Steve, was your intention here to avoid duplicates caused by collection of options repeated in multiple dependencies? That seems tricky to reconcile with these paired options.
(0040276)
Stephen Kelly (developer)
2016-01-20 15:33

Yes, I think that was my intention there. It seems to have been that way since it was introduced. I think the de-duplication was just intended to follow the pattern which include directories and compile definitions follow, but that doesn't may not make sense for compile options indeed.
(0040277)
Brad King (manager)
2016-01-20 16:05

Re 0015826:0040276: Thanks. The de-duplication is nice when flags are repeated only because they come from different targets that happen to provide the same flags in their INTERFACE_COMPILE_OPTIONS. However:

- Options specified within a single target's property should not be de-duplicated because repeats may be intentional
- Grouped options must be retained or de-dupliated together

We have at least these cases:

  "-option" "-unrelated-option"
  "-option" "value-to-option" [maybe-more-values]
  "-option with space"

Right now we have no way to tell the first two cases apart. We offer no way to encode the grouping information because we treat options with spaces as single options that happen to have spaces.
(0042876)
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
2015-11-02 10:41 Edward Rudd New Issue
2016-01-19 01:19 Anil Altinay Note Added: 0040255
2016-01-19 10:28 Brad King Note Added: 0040260
2016-01-19 10:28 Brad King Summary handling quoting for compile options. => target_compile_options de-duplicates flags but some repeats matter
2016-01-19 10:33 Brad King Note Added: 0040261
2016-01-19 16:29 Anil Altinay Note Edited: 0040255
2016-01-20 15:33 Stephen Kelly Note Added: 0040276
2016-01-20 16:05 Brad King Note Added: 0040277
2016-06-10 14:29 Kitware Robot Note Added: 0042876
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