MantisBT - CMake
View Issue Details
0009670CMakeCMakepublic2009-10-06 23:112014-06-02 08:37
Philip Lowman 
Brad King 
normalminoralways
closedfixed 
CMake-2-8 
CMake 2.8.12 
0009670: [PATCH] CMake fails to escape quotes in CMAKE_C_FLAGS during try_compile()
In generating CMakeLists.txt for a try_compile() CMake does not properly
escape quotes present in CMAKE_C_FLAGS. This can lead to CMAKE_C_FLAGS being
outputted as a list, rather than a string, which likely will lead to a
compilation error.

Example:

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /FI\"C:/Temp/TryCompile Escape Bug/force_foo.h\"")
include(TestBigEndian)
TEST_BIG_ENDIAN(AM_BIG_ENDIAN)

Output of CMakeLists.txt:
<snip>
SET(CMAKE_C_FLAGS " /DWIN32 /D_WINDOWS /W3 /Zm1000 /FI"C:/Temp/TryCompile Escape Bug/blah/hi.h" ${COMPILE_DEFINITIONS}")
</snip>

Patch is attached

This problem can be worked around by deferring the manipulation of
CMAKE_{C,CXX}_FLAGS until after all compilation tests have completed.
No tags attached.
patch escape_cmake_c_flags.patch (784) 2009-10-06 23:11
https://public.kitware.com/Bug/file/2535/escape_cmake_c_flags.patch
Issue History
2009-10-06 23:11Philip LowmanNew Issue
2009-10-06 23:11Philip LowmanFile Added: escape_cmake_c_flags.patch
2009-10-21 21:39Bill HoffmanStatusnew => assigned
2009-10-21 21:39Bill HoffmanAssigned To => Brad King
2009-10-22 08:46Brad KingNote Added: 0018172
2012-08-13 10:37Brad KingStatusassigned => backlog
2012-08-13 10:37Brad KingNote Added: 0030532
2013-11-02 11:24Stephen KellyNote Added: 0034333
2013-11-02 11:24Stephen KellyStatusbacklog => resolved
2013-11-02 11:24Stephen KellyFixed in Version => CMake 2.8.12
2013-11-02 11:24Stephen KellyResolutionopen => fixed
2014-06-02 08:37Robert MaynardNote Added: 0035994
2014-06-02 08:37Robert MaynardStatusresolved => closed

Notes
(0018172)
Brad King   
2009-10-22 08:46   
Unfortunately this problem can also be worked around by temporarily adding the escapes to CMAKE_C_FLAGS, and I bet there are projects that do this. If we start escaping automatically those projects will break. Escaping changes need a policy. See CMP0005 for example.
(0030532)
Brad King   
2012-08-13 10:37   
Sending issues I'm not actively working on to the backlog to await someone with time for them.

If an issue you care about is sent to the backlog when you feel it should have been addressed in a different manner, please bring it up on the CMake mailing list for discussion. Sign up for the mailing list here, if you're not already on it:

 http://www.cmake.org/mailman/listinfo/cmake [^]

It's easy to re-activate a bug here if you can find a CMake developer or contributor who has the bandwidth to take it on.
(0034333)
Stephen Kelly   
2013-11-02 11:24   
There are now COMPILE_OPTIONS properties and the target_compile_options and add_compile_options commands to satisfy this.
(0035994)
Robert Maynard   
2014-06-02 08:37   
Closing resolved issues that have not been updated in more than 4 months.