Setting {ALL,INSTALL,FAKE,TEST}_TARGET in cmake ports has no effect
unless you handroll do-* targets.
In general, the default "all", "install" and "test"/"check" targets make
no sense with CMake, since the default target to build is derived during
configure.
Make devel/cmake default to empty *_TARGET to reflect that.
This way it can distinguish between default bsd.port.mk(5) and explicit
values in ports Makefiles.
Make devel/cmake pass explicitly set targets.
Handle ALL_TARGET and INSTALL_TARGET for build and install, only.
Tests are built and run with ctest(1) which works differently.
According to
$ grep -Fw -r -e MODCMAKE_BUILD_TARGET -e MODCMAKE_INSTALL_TARGET
./devel/range-v3/Makefile: ${MODCMAKE_BUILD_TARGET}
./net/libtorrent-rasterbar/Makefile: @${MODCMAKE_BUILD_TARGET} -t
${ALL_TARGET}
./net/libtorrent-rasterbar/Makefile: @${MODCMAKE_BUILD_TARGET}
./security/keepassxc/Makefile: @${MODCMAKE_BUILD_TARGET} -t ${ALL_TARGET}
./security/keepassxc/Makefile: @${MODCMAKE_BUILD_TARGET}
./shells/fish/Makefile: ${MODCMAKE_BUILD_TARGET} -t ${TEST_TARGET}
only libtorrent-rasterbar and keepassxc are effected, where we can now
drop the handrolled do-build target.
range-v3 and fish manually build tests in their *-test targets and do
not fiddle with ALL_TARGET or INSTALL_TARGET, so no behaviour change.
It looks like this is pretty contained, but I might've missed something.
Should this go through a bulk?
Feedback? Objection? OK?
Index: devel/cmake/cmake.port.mk
===================================================================
RCS file: /cvs/ports/devel/cmake/cmake.port.mk,v
retrieving revision 1.79
diff -u -p -r1.79 cmake.port.mk
--- devel/cmake/cmake.port.mk 29 Oct 2022 04:11:21 -0000 1.79
+++ devel/cmake/cmake.port.mk 22 Jan 2023 15:27:14 -0000
@@ -33,6 +33,22 @@ MODCMAKE_INSTALL_TARGET = cd ${WRKBUILD}
MODCMAKE_TEST_TARGET = cd ${WRKBUILD} && exec ${SETENV} ${ALL_TEST_ENV} \
ctest ${_MAKE_VERBOSE} -j ${MAKE_JOBS}
+# Default targets are only known after configure, see cmake-buildsystem(7) and
+# cmake-properties(7) BUILDSYSTEM_TARGETS.
+# Overrule bsd.port.mk defaults.
+ALL_TARGET ?= # empty
+INSTALL_TARGET ?= # empty
+
+# Only pass explicitly set targets.
+# Do not quote, cmake(1) -t takes multiple target arguments.
+.if !empty(ALL_TARGET)
+MODCMAKE_BUILD_TARGET += -t ${ALL_TARGET}
+.endif
+
+.if !empty(INSTALL_TARGET)
+MODCMAKE_INSTALL_TARGET += -t ${INSTALL_TARGET}
+.endif
+
.if !target(do-build)
do-build:
@${MODCMAKE_BUILD_TARGET}
Index: security/keepassxc/Makefile
===================================================================
RCS file: /cvs/ports/security/keepassxc/Makefile,v
retrieving revision 1.50
diff -u -p -r1.50 Makefile
--- security/keepassxc/Makefile 15 Jan 2023 11:39:19 -0000 1.50
+++ security/keepassxc/Makefile 22 Jan 2023 15:09:36 -0000
@@ -93,9 +93,6 @@ post-patch:
browser/BrowserSettingsWidget.cpp \
browser/NativeMessageInstaller.cpp
-do-build:
- @${MODCMAKE_BUILD_TARGET} -t ${ALL_TARGET}
-
# build whatever is left (ca. 200 GUI test files)
pre-test:
@${MODCMAKE_BUILD_TARGET}
Index: net/libtorrent-rasterbar/Makefile
===================================================================
RCS file: /cvs/ports/net/libtorrent-rasterbar/Makefile,v
retrieving revision 1.30
diff -u -p -r1.30 Makefile
--- net/libtorrent-rasterbar/Makefile 21 Jan 2023 09:45:24 -0000 1.30
+++ net/libtorrent-rasterbar/Makefile 22 Jan 2023 15:09:02 -0000
@@ -39,9 +39,6 @@ CONFIGURE_ARGS += -DCMAKE_CXX_STANDARD=1
ALL_TARGET = torrent-rasterbar \
python-libtorrent
-do-build:
- @${MODCMAKE_BUILD_TARGET} -t ${ALL_TARGET}
-
# build whatever is left (+200 test files)
pre-test:
@${MODCMAKE_BUILD_TARGET}