Page MenuHomeFreeBSD

RFC: Add CMAKE_ON and CMAKE_OFF to cmake.mk
ClosedPublic

Authored by tcberner on Dec 26 2017, 12:48 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Jun 29, 2:28 PM
Unknown Object (File)
Sat, Jun 29, 2:28 PM
Unknown Object (File)
Sat, Jun 29, 2:28 PM
Unknown Object (File)
Sat, Jun 29, 2:28 PM
Unknown Object (File)
Sat, Jun 29, 2:28 PM
Unknown Object (File)
Sat, Jun 29, 2:15 PM
Unknown Object (File)
Mon, Jun 24, 7:31 AM
Unknown Object (File)
Apr 26 2024, 2:11 AM
Subscribers

Details

Summary

Lot's of ports pass a list of -DFOO:BOOL=OFF -DBAR:BOOL=ON to CMAKE_ARGS, which is both tedious to write and read.

The options framework provides a nicer interface <opt>_CMAKE_ON and <opt>_CMAKE_OFF where on can just pass FOO and BAR -- making it shorter and more readable.

So

CMAKE_ARGS=	-DFOO:BOOL=TRUE \
		-DBAR:BOOL=FALSE \
		[other args]

could now be written as

CMAKE_ON=	FOO
CMAKE_OFF=	BAR
CMAKE_ARGS=	[other args]

The attached diff extends cmake.mk with this behaviour.

  • As an example the ports devel/cmake-gui and devel/cmake-doc are included too.

Diff Detail

Repository
rP FreeBSD ports repository
Lint
No Lint Coverage
Unit
No Test Coverage
Build Status
Buildable 13950
Build 14145: arc lint + arc unit

Event Timeline

There are already _CMAKE_BOOL and _CMAKE_BOOL_OFF helpers doing this.

There are already _CMAKE_BOOL and _CMAKE_BOOL_OFF helpers doing this.

Hm, really?

Yes, that I know off :) -- but this here is for use outside of options -- maybe, I was describing it poorly, sorry.

Personally I don't see a huge improvement here, nor do I see why boolean CMake variables should be treated differently from the rest, but no objections if you feel like adding this.

Mk/Uses/cmake.mk
28

-D<var>:BOOL=TRUE.

29

And likewise here.

devel/cmake-gui/Makefile
28–29

Probably a good time to sort this list too.

They could be treated differently to reduce unnecessary typing -- but I see what you mean.

Mk/Uses/cmake.mk
95–97

For new code, we try to prefix local variables with an _, so _bool_kind would be nice here.

devel/cmake-doc/Makefile
25

What about a:

CMAKE_STR=   CMAKE_DOC_DIR="${DOCSDIR_REL}"

I like it, since it pulls all of the boolean handling into something that looks consistent in the Makefile. It will need some PHB work, later, to give it some nice docs.

Mk/Uses/cmake.mk
29

Actually -D<var>:BOOL=OFF , or =ON

devel/cmake-doc/Makefile
25

Not sure if facetious .. there's no other support already for string options, string options themselves are fairly uncommon, the amount of typing saved is lower .. and there's less consistency to be gained here. IOW, I think this is pushing things too far.

  • Rename internal variable to _bool_kind
  • Fix comment
  • Order variables in cmake-gui
This revision is now accepted and ready to land.Dec 31 2017, 9:37 AM
This revision was automatically updated to reflect the committed changes.