MantisBT - CMake
View Issue Details
0012960CMakeCMakepublic2012-02-13 07:302014-10-06 10:32
Dimitri Merejkowsky 
Nils Gladitz 
normalminoralways
closedfixed 
 
 
0012960: CMake should reject targets with reserved names like "test"
CMake error out when trying to installing a target named 'test' in
enable_testing() is called


Create a new project with the following CMakeLists.txt and an empty
test.cpp file

cmake_minimum_required(VERSION 2.8)
project(cmake_bug)
enable_testing()

add_executable(test test.cpp)
install(TARGETS test
  RUNTIME DESTINATION bin)

Run CMake:

WARNING: Target "test" has EXCLUDE_FROM_ALL set and will not be built by default but an install rule has been provided for it. CMake does not define behavior for this case.
CMake Internal Error (please report a bug) in CMakeLists.txt:
  cmTarget::GetOutputInfo called for test which has type GLOBAL_TARGET

No tags attached.
related to 0008438closed Kitware Robot add_dependencies() for "build-in cmake targets" 
related to 0006348closed Kitware Robot custom global targets (targets which when built from the root build all targets with the same name in subdirs) 
Issue History
2012-02-13 07:30Dimitri MerejkowskyNew Issue
2012-02-13 08:59Brad KingNote Added: 0028569
2012-02-13 09:07Dimitri MerejkowskyNote Added: 0028571
2012-02-13 09:47Brad KingStatusnew => backlog
2012-02-13 09:47Brad KingSummaryCannot install a target named 'test' => CMake should reject targets with reserved names like "test"
2012-02-13 09:48Brad KingRelationship addedrelated to 0008438
2012-02-13 09:49Brad KingRelationship addedrelated to 0006348
2014-03-02 14:56Nils GladitzNote Added: 0035223
2014-03-02 14:56Nils GladitzStatusbacklog => resolved
2014-03-02 14:56Nils GladitzResolutionopen => fixed
2014-03-02 14:56Nils GladitzAssigned To => Nils Gladitz
2014-10-06 10:32Robert MaynardNote Added: 0036922
2014-10-06 10:32Robert MaynardStatusresolved => closed

Notes
(0028569)
Brad King   
2012-02-13 08:59   
The "make test" target is to run tests. You can't add another target with that name. If you want an executable named "test" then use another target and set its OUTPUT_NAME property:

 add_executable(mytest test.cpp)
 set_property(TARGET mytest PROPERTY OUTPUT_NAME test)
(0028571)
Dimitri Merejkowsky   
2012-02-13 09:07   
Yeah I know.

But should not I get an error message when I try to create the target 'test' ?

(something like:

-- add_executable called with a reserved target name "test"
   If you want an executable named "test" then use another target and set its OUTPUT_NAME property:
   
   add_executable(mytest test.cpp)
   set_property(TARGET mytest PROPERTY OUTPUT_NAME test)

) ?
(0035223)
Nils Gladitz   
2014-03-02 14:56   
This is now covered by policy CMP0037.
(0036922)
Robert Maynard   
2014-10-06 10:32   
Closing resolved issues that have not been updated in more than 4 months.