View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0013170CMakeCMakepublic2012-04-25 15:472014-10-06 10:32
ReporterDaniel Franke 
Assigned ToNils Gladitz 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionfixed 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0013170: add_executable(test) & ENABLE_TESTING
DescriptionReduced 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?
TagsNo tags attached.
Attached Files

 Relationships
related to 0008438closedKitware Robot add_dependencies() for "build-in cmake targets" 

  Notes
(0029343)
Eric NOULARD (developer)
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 (manager)
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 (developer)
2014-03-02 14:58

This is now covered by policy CMP0037.
(0036923)
Robert Maynard (manager)
2014-10-06 10:32

Closing resolved issues that have not been updated in more than 4 months.

 Issue History
Date Modified Username Field Change
2012-04-25 15:47 Daniel Franke New Issue
2012-04-25 16:05 Eric NOULARD Note Added: 0029343
2012-04-26 08:15 Brad King Relationship added related to 0008438
2012-04-26 08:16 Brad King Note Added: 0029348
2012-04-26 08:16 Brad King Status new => backlog
2014-03-02 14:58 Nils Gladitz Note Added: 0035224
2014-03-02 14:58 Nils Gladitz Status backlog => resolved
2014-03-02 14:58 Nils Gladitz Resolution open => fixed
2014-03-02 14:58 Nils Gladitz Assigned To => Nils Gladitz
2014-10-06 10:32 Robert Maynard Note Added: 0036923
2014-10-06 10:32 Robert Maynard Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team