[cmake-developers] [CMake 0015826]: handling quoting for compile options.

Mantis Bug Tracker mantis at public.kitware.com
Mon Nov 2 10:41:41 EST 2015


The following issue has been SUBMITTED. 
====================================================================== 
https://public.kitware.com/Bug/view.php?id=15826 
====================================================================== 
Reported By:                Edward Rudd
Assigned To:                
====================================================================== 
Project:                    CMake
Issue ID:                   15826
Category:                   CMake
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     new
====================================================================== 
Date Submitted:             2015-11-02 17:41 WAST
Last Modified:              2015-11-02 17:41 WAST
====================================================================== 
Summary:                    handling quoting for compile options.
Description: 
So, 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!
====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2015-11-02 17:41 Edward Rudd    New Issue                                    
======================================================================



More information about the cmake-developers mailing list