[cmake-developers] OUTPUT_NAME bug that appears for the case of the "Ninja" generator on Windows (Wine)

Alan W. Irwin irwin at beluga.phys.uvic.ca
Tue Jun 11 12:34:14 EDT 2013


4 of the 5 projects I have implemented in my "Build Projects" project
build without issues using the "Ninja" generator for the Wine version
of Windows. However, the 5th project (which builds without issues for
all other generator and platform combinations accessible to me) had a
build bug for the "Ninja" generator which I finally simplified down to
the attached compressed tarball containing the hello_world_lib source
tree and resulting build tree.

The CMakeLists.txt file that is contained in the attached tarball
for this simplified project is

******************
project(hello_world C)
cmake_minimum_required(VERSION 2.8.10.2)

option(BUILD_SHARED_LIBS "Build shared libraries" ON)

add_library(hello_world hello_world.c)

add_executable(test_hello_world test_hello_world.c)
target_link_libraries(test_hello_world hello_world)

set_property(TARGET test_hello_world PROPERTY OUTPUT_NAME "hello_world")
******************

This project builds without issues with "Ninja" (and "Unix Makefiles) on Linux and
with "MSYS Makefiles" on Wine, but generates a cyclical dependency
error for the "Ninja" on Wine case.

Here is how the build_dir part of the attached tarball was created.
(If you do this yourself, please use a name different from build_dir
to preseve the build_dir results generated on my system.)

bash.exe-3.1$ pwd
/z/home/wine/newstart/hello_world_lib/build_dir
bash.exe-3.1$ rm -rf /z/home/wine/newstart/hello_world_lib/build_dir/*
bash.exe-3.1$ cmake -G"Ninja" ..
-- The C compiler identification is GNU 4.7.2
-- Check for working C compiler using: Ninja
-- Check for working C compiler using: Ninja -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Configuring done
-- Generating done
-- Build files have been written to:
Z:/home/wine/newstart/hello_world_lib/build_dir
bash.exe-3.1$ ninja -v  >& build_all.out

The issue shows up in that captured file

bash.exe-3.1$ cat build_all.out
ninja: warning: multiple rules generate libhello_world.dll.a. builds
involving this target will not be correct; continuing anyway
ninja: error: dependency cycle: hello_world.exe ->
libhello_world.dll.a -> hello_world.exe

If in the above CMakeList.txt file the last line which changes the
OUTPUT_NAME property is commented out or changed to

set_property(TARGET test_hello_world PROPERTY OUTPUT_NAME "hello_world1")

the project builds (and runs) without issues for all cases.  The same
is also true if the library is built statically.  So the key elements
required to trip over this bug are a shared library build and renaming
the executable result to have the same name kernel as the shared
library.

I am running into this issue for my Wine platform and for a ninja.exe
that I built myself on that platform.  So it is possible it could be
an issue with either of those that is causing the above issue that
shows up at build time.
But the version of Wine I am using has been completely
reliable in all other cases, ninja.exe does have that record of
success with 4 of the 5 projects, and changing the name kernel to
anything other than the name kernel of the library also works without
issues.

So I think the most likely explanation of the above issue is a bug in
the "Ninja" generator for the Windows platform case which will also
show up for the Microsoft version of Windows.  However, that obviously
needs confirmation which I request before writing this up as a CMake
bug report. (For the record I am using a binary version of
CMake-2.8.10.2 downloaded from the CMake site maintained by Kitware.)

In the likely case that it does turn out to be a bug in the "Ninja"
generator for the Windows platform case (whether Microsoft or Wine
version) the issue should be obvious (at least to someone with
knowledge of the ninja build rule syntax) in the generated ninja build
rules that are contained in the build_dir part of the attached
tarball.  Would someone here please take a look to see if they can
spot the issue?  (I don't currently have the required ninja build rule
syntax expertise because I just started using ninja two days ago).

Alan
__________________________
Alan W. Irwin

Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).

Programming affiliations with the FreeEOS equation-of-state
implementation for stellar interiors (freeeos.sf.net); the Time
Ephemerides project (timeephem.sf.net); PLplot scientific plotting
software package (plplot.sf.net); the libLASi project
(unifont.org/lasi); the Loads of Linux Links project (loll.sf.net);
and the Linux Brochure Project (lbproject.sf.net).
__________________________

Linux-powered Science
__________________________
-------------- next part --------------
A non-text attachment was scrubbed...
Name: hello_world_lib.tar.gz
Type: application/octet-stream
Size: 19980 bytes
Desc: Compressed complete source tree and build tree demonstrating the issue
URL: <http://public.kitware.com/pipermail/cmake-developers/attachments/20130611/ced20371/attachment-0002.obj>


More information about the cmake-developers mailing list