MantisBT - CMake
View Issue Details
0013140CMakeCMakepublic2012-04-17 16:342014-06-02 08:37
Erik Jensen 
Stephen Kelly 
normalminoralways
closedfixed 
Windows 7 x64
CMake 2.8.7 
CMake 3.0 
0013140: CMake does not reject unsupported logical target names
I am migrating a project from Visual Studio to CMake that contains several executables with spaces in their names. While the project builds fine when generating Visual Studio project files, it fails to build when using NMake due to invalid makefiles.
1. Create a project with an executable target containing a space.
2. Use CMake to create NMake files for the build.
3. Attempt to build.
It appears that the problem is caused by attempting to use the target name in makefile macro names without replacing the space. For example if you have a target named "Spiffy Command-Line Tool", build.make will contain a macro named "Spiffy Command__Line Tool_OBJECTS".

Given that the hyphen is replaced by a double underscore, it looks like CMake already does some name-mangling, it just doesn't handle spaces, currently.
No tags attached.
Issue History
2012-04-17 16:34Erik JensenNew Issue
2012-04-18 10:04Brad KingNote Added: 0029212
2012-04-18 10:04Brad KingStatusnew => backlog
2012-04-18 10:04Brad KingSummaryInvaled NMake makefiles generated when target name contains spaces => CMake does not reject unsupported logical target names
2013-11-08 17:11Stephen KellyNote Added: 0034428
2013-11-08 17:11Stephen KellyStatusbacklog => resolved
2013-11-08 17:11Stephen KellyFixed in Version => CMake 3.0
2013-11-08 17:11Stephen KellyResolutionopen => fixed
2013-11-08 17:11Stephen KellyAssigned To => Stephen Kelly
2014-06-02 08:37Robert MaynardNote Added: 0036008
2014-06-02 08:37Robert MaynardStatusresolved => closed

Notes
(0029212)
Brad King   
2012-04-18 10:04   
We don't intend to support code like

 add_executable("exe name with spaces" ...)

directly. The bug is that this is not rejected with a nice error. We'll need to add a CMake Policy to restrict logical target names to some supported set.

Meanwhile if you want an executable with a space in its name then create it like this:

 add_executable(exe_name_with_spaces ...)
 set_property(TARGET exe_name_with_spaces PROPERTY OUTPUT_NAME "exe name with spaces")
(0034428)
Stephen Kelly   
2013-11-08 17:11   
Done:

 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=05f5fde0 [^]
(0036008)
Robert Maynard   
2014-06-02 08:37   
Closing resolved issues that have not been updated in more than 4 months.