apiaryio / drafter

API Blueprint Parser (C++)
https://apiblueprint.org/
MIT License
301 stars 54 forks source link

Ninja can no longer build due to cycling input #774

Open kylef opened 4 years ago

kylef commented 4 years ago
$ mkdir build
$ cd build
$ cmake -GNinja ..
-- The C compiler identification is AppleClang 11.0.0.11000033
-- The CXX compiler identification is AppleClang 11.0.0.11000033
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Setting build type to 'Release' as none was specified.
-- Testing dependencies .
-- Setting up tests for production...
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/kyle/Projects/apiaryio/drafter/build

$ ninja
ninja: warning: phony target 'src/drafter' names itself as an input; ignoring [-w phonycycle=warn]
ninja: warning: multiple rules generate src/drafter. builds involving this target will not be correct; continuing anyway [-w dupbuild=warn]
ninja: error: dependency cycle: src/drafter -> src/CMakeFiles/drafter -> src/drafter
kylef commented 4 years ago

I’ve spent a bit of time on this, the underlying problem is that the drafter-cli target has an output name of drafter (the binary name is drafter). We also have a custom aggregate target called drafter which runs the targets drafter-cli, libdrafter etc at the same time.

Various package managers script (homebrew, aur, dockerfiles) use make drafter (thus this is expected and depended upon behaviour). make drafter builds everything needed for make install to work.

While this works fine with the makefile generator, under ninja both these parts cause different targets with the same name. This also results in circular reference because the drafter aggregate target which depends on drafter-cli (which ninja calls drafter). This problem manifests differently in newer versions of CMake.

I don’t see an easy solution.

SMillerDev commented 1 year ago

Homebrew is now over to a full CMake build