MantisBT - CMake
View Issue Details
0016032CMakeCMakepublic2016-03-22 15:062016-06-10 14:21
Braden McDaniel 
 
normalminoralways
closedno change required 
AppleMac OS X10.11.3
CMake 3.5 
 
0016032: CMake doesn't escape # properly in add_compile_options with Makefile generator
This appears to have regressed in 3.5. If I do:

  add_compile_options(-Wno-#pragma-messages)

I get

  -Wno-

...on the command line.
makefile
Issue History
2016-03-22 15:06Braden McDanielNew Issue
2016-03-22 15:08Braden McDanielTag Attached: makefile
2016-03-22 15:24Brad KingNote Added: 0040752
2016-03-22 15:25Brad KingNote Added: 0040753
2016-03-23 14:20Braden McDanielNote Added: 0040756
2016-03-23 14:21Brad KingStatusnew => resolved
2016-03-23 14:21Brad KingResolutionopen => no change required
2016-06-10 14:21Kitware RobotNote Added: 0041214
2016-06-10 14:21Kitware RobotStatusresolved => closed

Notes
(0040752)
Brad King   
2016-03-22 15:24   
$ cat ../CMakeLists.txt
cmake_minimum_required(VERSION 3.4)
project(Issue16032 C)
add_compile_options("-Wno-#pragma-messages")
add_executable(foo foo.c)

$ cmake --version
cmake version 3.5.0

$ cmake ..
-- The C compiler identification is GNU 5.3.1
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /.../b
$ make VERBOSE=1 | grep pragma
/usr/bin/cc "-Wno-#pragma-messages" -o CMakeFiles/foo.dir/foo.c.o -c "/.../foo.c"
(0040753)
Brad King   
2016-03-22 15:25   
> add_compile_options(-Wno-#pragma-messages)

The "#" character on the line shown in the description will be parsed as the beginning of a line comment since it is not in a quoted argument. CMake reports an error on that line for me so please post a more complete example.
(0040756)
Braden McDaniel   
2016-03-23 14:20   
Alright... Apparently I misunderstood some previous comments regarding how this is intended to operate.

As to why I didn't observe an error: in my actual code, the closing parenthesis was on a separate line.

This can be closed.
(0041214)
Kitware Robot   
2016-06-10 14:21   
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.