Bug 210576 - [new feature] Mk/bsd.options.mk: opt_CMAKE_BOOL
Summary: [new feature] Mk/bsd.options.mk: opt_CMAKE_BOOL
Status: Closed FIXED
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-06-25 18:49 UTC by Adam Weinberger
Modified: 2016-06-28 08:09 UTC (History)
1 user (show)

See Also:


Attachments
opt_CMAKE_BOOL (1.29 KB, patch)
2016-06-25 18:49 UTC, Adam Weinberger
no flags Details | Diff
No fors (1.30 KB, patch)
2016-06-25 20:02 UTC, Adam Weinberger
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Adam Weinberger freebsd_committer freebsd_triage 2016-06-25 18:49:05 UTC
Created attachment 171795 [details]
opt_CMAKE_BOOL

Many ports that use cmake have to enable or disable boolean features.

ex.:
[adamw@apnoea ~] grep BOOL /usr/ports/audio/libsoxr/Makefile
CMAKE_MAKE_ARGS+=       -DWITH_LSR_BINDINGS:BOOL=ON \
                        -DBUILD_SHARED_LIBS:BOOL=ON
OPENMP_CMAKE_ON=        -DWITH_OPENMP:BOOL=ON
OPENMP_CMAKE_OFF=       -DWITH_OPENMP:BOOL=OFF
SIMD_CMAKE_OFF=         -DWITH_CR32S:BOOL=OFF \
                        -DWITH_CR64S:BOOL=OFF
AVFFT_CMAKE_ON=         -DWITH_AVFFT:BOOL=ON
AVFFT_CMAKE_OFF=        -DWITH_AVFFT:BOOL=OFF
PFFFT_CMAKE_ON=         -DWITH_PFFFT:BOOL=ON
PFFFT_CMAKE_OFF=        -DWITH_PFFFT:BOOL=OFF

By my count, there are about 225 ports that use this construct.

The attached patch adds a opt_CMAKE_BOOL helper. It makes the above be:

OPENMP_CMAKE_BOOL=    OPENMP
AVFFT_CMAKE_BOOL=     WITH_AVFFT
PFFFT_CMAKE_BOOL=     PFFFT

It only saves one line at a time, but it saves a lot of typing.
Comment 1 Adam Weinberger freebsd_committer freebsd_triage 2016-06-25 18:50:24 UTC
Typoed the example there. Of course it's:

OPENMP_CMAKE_BOOL=     WITH_OPENMP

etc.
Comment 2 Mathieu Arnold freebsd_committer freebsd_triage 2016-06-25 18:59:14 UTC
Would be nice if:

FOO_CMAKE_BOOL=     FOO BAR

worked ;-)
Comment 3 Mathieu Arnold freebsd_committer freebsd_triage 2016-06-25 19:05:44 UTC
(and not with a for loop)
Comment 4 Adam Weinberger freebsd_committer freebsd_triage 2016-06-25 20:02:27 UTC
Created attachment 171799 [details]
No fors

Okay. Here's a patch which handles multiple words, and doesn't have a for loop.
Comment 5 Mathieu Arnold freebsd_committer freebsd_triage 2016-06-25 21:16:36 UTC
If it works with make and fmake (on 9) feel free to commit it.
Comment 6 commit-hook freebsd_committer freebsd_triage 2016-06-25 22:24:30 UTC
A commit references this bug:

Author: adamw
Date: Sat Jun 25 22:23:37 UTC 2016
New revision: 417497
URL: https://svnweb.freebsd.org/changeset/ports/417497

Log:
  Add an opt_CMAKE_BOOL options helper.

    SOMEOPT_CMAKE_BOOL=	WITH_FOO BAR

  expands to:

    -DWITH_FOO:BOOL=true -DBAR:BOOL=true
  or
    -DWITH_FOO:BOOL=false -DBAR:BOOL=false

  PR:		210576
  Approved by:	portmgr (mat)

Changes:
  head/CHANGES
  head/Mk/bsd.options.mk
Comment 7 Adam Weinberger freebsd_committer freebsd_triage 2016-06-25 22:25:22 UTC
Committed. Thanks for such a quick review, mat!
Comment 8 Mathieu Arnold freebsd_committer freebsd_triage 2016-06-26 10:14:48 UTC
Oh, could you also add a CMAKE_BOOL_OFF that does the opposite, like all other options helpers have ?
Comment 10 commit-hook freebsd_committer freebsd_triage 2016-06-26 16:24:03 UTC
A commit references this bug:

Author: mat
Date: Sun Jun 26 16:23:37 UTC 2016
New revision: 417532
URL: https://svnweb.freebsd.org/changeset/ports/417532

Log:
  Add opt_CMAKE_BOOL_OFF, oposite of opt_CMAKE_BOOL.

  PR:		210576
  Sponsored by:	Absolight

Changes:
  head/Mk/bsd.options.mk
Comment 11 commit-hook freebsd_committer freebsd_triage 2016-06-28 08:09:22 UTC
A commit references this bug:

Author: mat
Date: Tue Jun 28 08:08:41 UTC 2016
New revision: 49014
URL: https://svnweb.freebsd.org/changeset/doc/49014

Log:
  Document opt_CMAKE_BOOL and opt_CMAKE_BOOL_OFF.

  PR:		210576
  Reviewed by:	wblock
  Sponsored by:	Absolight
  Differential Revision:	https://reviews.freebsd.org/D6970

Changes:
  head/en_US.ISO8859-1/books/porters-handbook/makefiles/chapter.xml