Just noticed a problem in my example. In my attempt to simplify my example I
moved both outputs into the same folder which in my opinion is invalid because
both output file names are the same. However, the same basic setup does
reproduce the problem if you move the two targets into their own subdirs. I
was just trying to avoid describing that in the email. Here is what I mean
below:
Top level CMakeLists.txt:
cmake_minimum_required(VERSION 3.7)
enable_testing()
project("bugreproduce")
add_subdirectory("subdir")
add_subdirectory("subdir2")
subdir with CMakeLists.txt:
add_executable( "Foo.test" foo_test.cpp )
set_target_properties("Foo.test" PROPERTIES OUTPUT_NAME test )
add_test(NAME "Foo.test" COMMAND test)
subdir2 with CMakeLists.txt:
add_executable( "Bar.test" bar_test.cpp )
set_target_properties("Bar.test" PROPERTIES OUTPUT_NAME test )
add_test(NAME "Bar.test" COMMAND test )
Contents of both source files (obviously in their respective subdirectories):
int main( int, char** )
{
return 0;
}
Sorry for that.
From: Malfettone, Kris
Sent: Wednesday, February 15, 2017 9:07 AM
To: Malfettone, Kris <[email protected]>; Nils Gladitz
<[email protected]>; [email protected]
Subject: RE: [CMake] Potential bug: Having executables named "test" causes
Ninja generator to generate ambiguous rules...
So I was able to reproduce the problem with this very simple CMakeLists.txt
setup. I cannot attach source files due to my company's mail server
automatically stripping them out attachments with code but here is all you
would need to reproduce the problem:
Single CMakeLists.txt with the following:
cmake_minimum_required(VERSION 3.7)
enable_testing()
project("bugreproduce")
add_executable( "Foo.test" foo_test.cpp )
add_executable( "Bar.test" bar_test.cpp )
set_target_properties("Foo.test" PROPERTIES OUTPUT_NAME test )
set_target_properties("Bar.test" PROPERTIES OUTPUT_NAME test )
add_test(NAME "Foo.test" COMMAND test)
add_test(NAME "Bar.test" COMMAND test )
Two source files named foo_test.cpp and bar_test.cpp both containing the
following code in the same directory:
int main( int, char** )
{
return 0;
}
If you generate a Makefile based solution everything works fine. However, if
you generate a ninja based solution then you get the following:
ninja: warning: multiple rules generate test. builds involving this target will
not be correct; continuing anyway [-w dupbuild=warn]
ninja: warning: multiple rules generate test. builds involving this target will
not be correct; continuing anyway [-w dupbuild=warn]
-Kris
From: CMake [mailto:[email protected]] On Behalf Of Malfettone, Kris
Sent: Wednesday, February 15, 2017 8:27 AM
To: Nils Gladitz <[email protected]<mailto:[email protected]>>;
[email protected]<mailto:[email protected]>
Subject: Re: [CMake] Potential bug: Having executables named "test" causes
Ninja generator to generate ambiguous rules...
Good to know. Thanks for the quick response. Though I do not believe I am
violating that particular rule here. That is why I do not receive either a
warning or error from CMake in my output.
The only warning I see is from ninja:
ninja: warning: multiple rules generate MD/MDF/Formats/SIG/BCP/v0_1/test.
builds involving this target will not be correct; continuing anyway [-w
dupbuild=warn]
ninja: warning: multiple rules generate MD/MDF/Formats/SIG/BCP/v0_2/test.
builds involving this target will not be correct; continuing anyway [-w
dupbuild=warn]
ninja: warning: multiple rules generate test. builds involving this target will
not be correct; continuing anyway [-w dupbuild=warn]
I think the difference is that my target names are:
MD.MDF.Formats.SIG.BCP.v0_1.test
MD.MDF.Formats.SIG.BCP.v0_2.test
It is the ninja generator that is trying to setup aliases for each of them as a
shortened form. So I think one of the following statements are true:
* The cmake rule intended for the above two target names to be invalid.
But the check to issue a warning or error has a bug causing them to be missed.
This would explain why I do not get the error in my configure results.
* The cmake rule intended for the above two target names to be valid.
However, on further reflection the rule should be made stricter to include my
target names above. This would then require and update to the cmake code
checking that policy and lead to me actually getting a warning or error from
cmake during configure.
* The ninja generator has a bug and is setting up ambiguous aliases for
what CMake considers valid target names.
My project is huge so I will try and craft a simplified CMakeLists.txt example
to reproduce the problem as well.
Does this make sense? Am I still missing something?
-Kris
From: Nils Gladitz [mailto:[email protected]]
Sent: Wednesday, February 15, 2017 3:36 AM
To: Malfettone, Kris
<[email protected]<mailto:[email protected]>>;
[email protected]<mailto:[email protected]>
Subject: Re: [CMake] Potential bug: Having executables named "test" causes
Ninja generator to generate ambiguous rules...
On 14.02.2017 22:53, Malfettone, Kris wrote:
If so, are executables named "test" no longer supported?
Am I missing something or wrong in some way?
Issues existed before 3.0 but since 3.0 "test" and similarly problematic target
names have been explicitly reserved.
Any CMake Version >= 3.0 will issue a warning (when the required version is <
3.0) or an error (when the required version is >= 3.0) by default:
https://cmake.org/cmake/help/v3.8/policy/CMP0037.html
Nils
________________________________
IMPORTANT: The information contained in this email and/or its attachments is
confidential. If you are not the intended recipient, please notify the sender
immediately by reply and immediately delete this message and all its
attachments. Any review, use, reproduction, disclosure or dissemination of this
message or any attachment by an unintended recipient is strictly prohibited.
Neither this message nor any attachment is intended as or should be construed
as an offer, solicitation or recommendation to buy or sell any security or
other financial instrument. Neither the sender, his or her employer nor any of
their respective affiliates makes any warranties as to the completeness or
accuracy of any of the information contained herein or that this message or any
of its attachments is free of viruses.
________________________________
IMPORTANT: The information contained in this email and/or its attachments is
confidential. If you are not the intended recipient, please notify the sender
immediately by reply and immediately delete this message and all its
attachments. Any review, use, reproduction, disclosure or dissemination of this
message or any attachment by an unintended recipient is strictly prohibited.
Neither this message nor any attachment is intended as or should be construed
as an offer, solicitation or recommendation to buy or sell any security or
other financial instrument. Neither the sender, his or her employer nor any of
their respective affiliates makes any warranties as to the completeness or
accuracy of any of the information contained herein or that this message or any
of its attachments is free of viruses.
--
Powered by www.kitware.com
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Kitware offers various services to support the CMake community. For more
information on each offering, please visit:
CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake