MantisBT - CMake
View Issue Details
0013170CMakeCMakepublic2012-04-25 15:472014-10-06 10:32
Daniel Franke 
Nils Gladitz 
normalminoralways
closedfixed 
 
 
0013170: add_executable(test) & ENABLE_TESTING
Reduced testcase:

$ cat test.c
int main() {}

$ cat CMakeLists.txt
cmake_minimum_required (VERSION 2.6)
project (foo C)
add_executable(test test.c)
ENABLE_TESTING ()

$ mkir build; cd build; cmake ..
[...]

$ make
[nothing happens]

Apparently the "test" target defined by ENABLE_TESTING nullifies any user-defined test target. Inexperienced users that only want to quickly, you know, test something, may end up hitting a wall with this ...

Maybe a developer warning on ENABLE_TESTING() that there already is a 'test' target and that it will be disabled would be nice?
No tags attached.
related to 0008438closed Kitware Robot add_dependencies() for "build-in cmake targets" 
Issue History
2012-04-25 15:47Daniel FrankeNew Issue
2012-04-25 16:05Eric NOULARDNote Added: 0029343
2012-04-26 08:15Brad KingRelationship addedrelated to 0008438
2012-04-26 08:16Brad KingNote Added: 0029348
2012-04-26 08:16Brad KingStatusnew => backlog
2014-03-02 14:58Nils GladitzNote Added: 0035224
2014-03-02 14:58Nils GladitzStatusbacklog => resolved
2014-03-02 14:58Nils GladitzResolutionopen => fixed
2014-03-02 14:58Nils GladitzAssigned To => Nils Gladitz
2014-10-06 10:32Robert MaynardNote Added: 0036923
2014-10-06 10:32Robert MaynardStatusresolved => closed

Notes
(0029343)
Eric NOULARD   
2012-04-25 16:05   
Yes right but if you add:
install(TARGETS test DESTINATION bin)

you get
-- Configuring done
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


I guess that when you are at it, you can get various
bizarre behavior if you chose target name to clash with builtin target name:
e.g.
add_executable(clean blah.c)

gives you:
$ make clean
Makefile:116: warning: overriding commands for target `clean'
Makefile:89: warning: ignoring old commands for target `clean'
[100%] Building C object CMakeFiles/clean.dir/blah.c.o
Linking C executable clean
[100%] Built target clean

I did not test all of clean, install, test and friends but yes
it should be forbidden to name a user target with the same name
as any builtin target and CMake shall give advice like
using the OUTPUT_NAME target property to avoid the name clash.
(0029348)
Brad King   
2012-04-26 08:16   
This may be fixable on its own but could also be done as part of issue 0008438.
(0035224)
Nils Gladitz   
2014-03-02 14:58   
This is now covered by policy CMP0037.
(0036923)
Robert Maynard   
2014-10-06 10:32   
Closing resolved issues that have not been updated in more than 4 months.