Bug 213331 - USES=gmake can break CMAKE_NINJA=yes
Summary: USES=gmake can break CMAKE_NINJA=yes
Status: Closed Overcome By Events
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Ports Framework (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Port Management Team
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-10-09 09:24 UTC by Raphael Kubo da Costa
Modified: 2017-06-25 21:09 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Raphael Kubo da Costa freebsd_committer 2016-10-09 09:24:05 UTC
When a user has CMAKE_NINJA=yes set in /etc/make.conf to use ninja instead of make to build a CMake-based port, that can be overridden when a port has USES=gmake after USES=cmake, leading to a build and stage failure.

For example, building x11/kde4-workspace with CMAKE_NINJA=yes causes Uses/gmake.mk to override MAKE_CMD, and `make build' or `make stage' end up calling gmake instead of ninja. Since CMake generated build.ninja files, gmake will not do anything other than printing its version information.
Comment 1 Antoine Brodin freebsd_committer 2016-10-09 15:45:52 UTC
I think that a port should have only 1 USES that sets MAKE_CMD.

If it needs 2 tools, like scons calling gmake, it should have USES=scons + a build dependency on gmake.

Can't you use something like this?

.if !defined(CMAKE_NINJA)
USES+= gmake
.endif

Also "USES=gmake cmake" is different from "USES=cmake gmake" but it's quite dirty to rely on this.
Comment 2 Raphael Kubo da Costa freebsd_committer 2016-10-12 17:48:47 UTC
(In reply to Antoine Brodin from comment #1)
> Can't you use something like this?
>
> .if !defined(CMAKE_NINJA)
> USES+= gmake
> .endif

The problem with this is that it adds a burden to every single port that uses CMake and cannot be built with bmake, which is not very feasible.

One thing tcberner@ thought of a while ago was this in Uses/cmake.mk:
    .if ${USES:Mgmake}
    .include ${USESDIR}/gmake.mk
    .endif
    .if defined(CMAKE_NINJA)
    .include "${USESDIR}/ninja.mk"
    .endif

which would give preference to ninja as expected. Would something like this be OK?
Comment 3 Antoine Brodin freebsd_committer 2016-10-24 06:41:30 UTC
(In reply to Raphael Kubo da Costa from comment #2)
This will still bring gmake in the build depends.

Maybe a USES= cmake:something, which brings either gmake.mk or ninja.mk depending on CMAKE_NINJA?
Comment 4 Antoine Brodin freebsd_committer 2016-12-11 17:49:31 UTC
I think that there should be an exp-run with CMAKE_NINJA=yes and USES=gmake neutralized to determine what are the actual needs of the ports:

- Are there ports that build fine with gmake but fail to build with ninja?
- Are there ports that build fine with bsd make but fail to build with ninja?
- Are there ports that build fine with either gmake or ninja?

Something like:

    .if defined(CMAKE_NINJA)
    # Neutralize gmake.mk for the exp-run
    _INCLUDE_USES_GMAKE_MK= yes
    .include "${USESDIR}/ninja.mk"
    .endif
Comment 5 Raphael Kubo da Costa freebsd_committer 2016-12-28 12:22:29 UTC
(In reply to Antoine Brodin from comment #4)
> I think that there should be an exp-run with CMAKE_NINJA=yes and USES=gmake
> neutralized to determine what are the actual needs of the ports:
> 
> - Are there ports that build fine with gmake but fail to build with ninja?
> - Are there ports that build fine with bsd make but fail to build with ninja?
> - Are there ports that build fine with either gmake or ninja?

I work on that, but what's the desired effect of those results on this bug?
Comment 6 commit-hook freebsd_committer 2017-06-25 21:08:38 UTC
A commit references this bug:

Author: tcberner
Date: Sun Jun 25 21:08:06 UTC 2017
New revision: 444324
URL: https://svnweb.freebsd.org/changeset/ports/444324

Log:
  Make ninja opt-out in cmake.mk

  Using ninja instead of make (1) can lead to significant speed ups while building.
  Therefore switch from having the ninja generator opt-in to having it opt-out.

  Previously cmake-ports that wanted to use ninja could set
      CMAKE_NINJA=yes
  now, ports that do not work with ninja can set
      cmake:<existing args>,noninja
  Note, that needing this should be an exception and most often points to a broken
  cmake of the port.

  The ports using cmake were modified
  * removed USES=gmake, if ninja is used
  * removed MAKE_ARGS, if ninja is used
  * added the cmake-argument noninja if necessary

  PR:		219629
  PR:		213331
  Exp-run by:	antoine
  Reviewed by:	rakuco
  Differential Revision:	https://reviews.freebsd.org/D10748

Changes:
  head/CHANGES
  head/Mk/Uses/cmake.mk
  head/Mk/bsd.sanity.mk
  head/astro/marble/Makefile
  head/audio/csound6/Makefile
  head/audio/fluidsynth/Makefile
  head/audio/libgme/Makefile
  head/cad/kicad/Makefile
  head/cad/opencascade/Makefile
  head/cad/openvsp/Makefile
  head/chinese/fcitx/Makefile
  head/chinese/ibus-chewing/Makefile
  head/comms/uhd/Makefile
  head/comms/usrp/Makefile
  head/databases/cppdb/Makefile
  head/databases/evolution-data-server/Makefile
  head/databases/mariadb100-server/Makefile
  head/databases/mariadb55-server/Makefile
  head/databases/mysql55-server/Makefile
  head/databases/mysql56-server/Makefile
  head/databases/mysql57-server/Makefile
  head/databases/mysql80-server/Makefile
  head/databases/mysqlwsrep56-server/Makefile
  head/databases/percona55-server/Makefile
  head/databases/percona56-server/Makefile
  head/databases/percona57-server/Makefile
  head/databases/tarantool/Makefile
  head/databases/xtrabackup/Makefile
  head/deskutils/kdeconnect/Makefile
  head/deskutils/kdepim4/Makefile
  head/deskutils/owncloudclient/Makefile
  head/devel/bullet/Makefile
  head/devel/compiler-rt/Makefile
  head/devel/doxygen/Makefile
  head/devel/flang/Makefile
  head/devel/flang-clang/Makefile
  head/devel/kapptemplate/Makefile
  head/devel/kdevelop-kde4/Makefile
  head/devel/kdevelop-php/Makefile
  head/devel/libzrtpcpp/Makefile
  head/devel/llvm-cheri/Makefile
  head/devel/llvm-devel/Makefile
  head/devel/llvm38/Makefile
  head/devel/llvm39/Makefile
  head/devel/llvm40/Makefile
  head/devel/mongo-c-driver/Makefile
  head/devel/rapidjson/Makefile
  head/devel/tesla/Makefile
  head/devel/xxhash/files/
  head/devel/xxhash/files/patch-git_5ab73ee
  head/editors/codelite/Makefile
  head/editors/jucipp/Makefile
  head/editors/kate-plugin-pate/Makefile
  head/editors/neovim/Makefile
  head/games/hedgewars/Makefile
  head/games/openclonk/Makefile
  head/games/openmw/Makefile
  head/games/palomino/Makefile
  head/games/solarus/Makefile
  head/games/vavoom/Makefile
  head/graphics/aseprite/Makefile
  head/graphics/darktable/Makefile
  head/graphics/digikam-kde4/Makefile.common
  head/graphics/ilmbase/files/patch-git_8eed7012
  head/graphics/inkscape/Makefile
  head/graphics/luxrender/Makefile
  head/graphics/mitsuba/Makefile
  head/graphics/opensubdiv/Makefile
  head/graphics/osg-devel/Makefile
  head/graphics/osgearth/Makefile
  head/graphics/rawtherapee/Makefile
  head/graphics/tulip/Makefile
  head/graphics/waffle/Makefile
  head/graphics/xcftools/Makefile
  head/irc/weechat/Makefile
  head/lang/beignet/Makefile
  head/lang/io/Makefile
  head/lang/sagittarius-scheme/Makefile
  head/mail/evolution/Makefile
  head/mail/evolution-ews/Makefile
  head/mail/libcmime/Makefile
  head/mail/libvmime/Makefile
  head/mail/spmfilter/Makefile
  head/mail/spmfilter-clamav/Makefile
  head/math/metis/Makefile
  head/math/parmetis/Makefile
  head/math/stp/Makefile
  head/multimedia/avidemux/Makefile.common
  head/multimedia/gstreamer-qt4/Makefile
  head/multimedia/plexhometheater/Makefile
  head/multimedia/zoneminder/Makefile
  head/multimedia/zoneminder-h264/Makefile
  head/net/ceph-devel/Makefile
  head/net/tigervnc/Makefile
  head/net-im/licq/Makefile
  head/net-im/ring-gnome/Makefile
  head/net-im/ring-libclient/Makefile
  head/science/paraview/Makefile
  head/security/kwalletmanager/Makefile
  head/security/libzrtpcppcore/Makefile
  head/sysutils/baloo/Makefile
  head/sysutils/conky/Makefile
  head/sysutils/fluent-bit/Makefile
  head/sysutils/kcm-polkit-kde/Makefile
  head/sysutils/osquery/Makefile
  head/textproc/clucene/Makefile
  head/textproc/zxing-cpp/Makefile
  head/www/h2o/Makefile
  head/www/webkit2-gtk3/Makefile
  head/x11/kde4-runtime/Makefile
  head/x11/kde4-workspace/Makefile
  head/x11/virtualgl/Makefile
  head/x11-themes/kde4-style-bespin/Makefile
  head/x11-themes/kde4-windeco-crystal/Makefile
  head/x11-wm/pawm/Makefile