tech-pkg archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

cmake/build.mk



Hi!

Following a discussion we had earlier about improving cmake support,
I've created a devel/cmake/build.mk (to match devel/meson/build.mk).

Compare to 'USE_CMAKE' it adds support for multiple BUILD_DIRS, has
better defaults, and adds support for building using ninja-build.

I've tried it out on archivers/libzip, diff attached.

I think this can go in now and can then be improved in-tree; if a
package doesn't work well with it, it can keep using USE_CMAKE for
now, but the long-term plan is to migrate from USE_CMAKE to including
this new file and removing the USE_CMAKE support from the
infrastructure.

Comments?
 Thomas
Index: Makefile
===================================================================
RCS file: /cvsroot/pkgsrc/archivers/libzip/Makefile,v
retrieving revision 1.60
diff -u -r1.60 Makefile
--- Makefile	28 Jun 2022 20:14:51 -0000	1.60
+++ Makefile	26 Jul 2022 20:16:08 -0000
@@ -12,7 +12,7 @@
 COMMENT=		C library to manipulate zip archives
 LICENSE=		modified-bsd
 
-USE_CMAKE=		yes
+#USE_CMAKE=		yes
 USE_TOOLS+=		perl:build
 
 TEST_TARGET=		test
@@ -25,4 +25,5 @@
 .include "../../archivers/bzip2/buildlink3.mk"
 .include "../../archivers/xz/buildlink3.mk"
 .include "../../archivers/zstd/buildlink3.mk"
+.include "../../devel/cmake/build.mk"
 .include "../../mk/bsd.pkg.mk"
# $NetBSD$

CMAKE_REQD?=	0
.for version in ${CMAKE_REQD}
TOOL_DEPENDS+=	cmake>=${version}:../../devel/cmake
.endfor

CMAKE_BUILD_DIR?=	cmake-pkgsrc-build
CMAKE_USE_NINJA?=	no
.if ${CMAKE_USE_NINJA} == "yes"
TOOL_DEPENDS+=		ninja-build-[0-9]*:../../devel/ninja-build
CMAKE_BUILD_SYSTEM?=	Ninja
CMAKE_BUILD_TOOL?=	ninja
CMAKE_BUILD_ARGS?=	-j ${_MAKE_JOBS_N:U1}
CMAKE_INSTALL_ARGS?=	# empty
.else
CMAKE_BUILD_SYSTEM?=	"Unix Makefiles"
CMAKE_BUILD_TOOL?=	${MAKE}
CMAKE_INSTALL_ARGS?=	# empty
.endif

CONFIGURE_DIRS?=	.
BUILD_DIRS?=		${CONFIGURE_DIRS}
INSTALL_DIRS?=		${CONFIGURE_DIRS}
TEST_DIRS?=		${CONFIGURE_DIRS}

.PHONY: cmake-configure cmake-build cmake-install cmake-test

.include "../../mk/bsd.prefs.mk"

do-configure: cmake-configure
cmake-configure:
.for d in ${CONFIGURE_DIRS}
	cd ${WRKSRC}/${d} && ${SETENV} ${MAKE_ENV} cmake \
		--install-prefix ${PREFIX} \
		-B ${CMAKE_BUILD_DIR} \
		-G ${CMAKE_BUILD_SYSTEM} \
		${CMAKE_ARGS}
.endfor

do-build: cmake-build
cmake-build:
.for d in ${BUILD_DIRS}
	cd ${WRKSRC}/${d}/${CMAKE_BUILD_DIR} && \
		${SETENV} ${MAKE_ENV} ${CMAKE_BUILD_TOOL} ${CMAKE_BUILD_ARGS}
.endfor

do-install: cmake-install
cmake-install:
.for d in ${INSTALL_DIRS}
	cd ${WRKSRC}/${d}/${CMAKE_BUILD_DIR} && \
		${SETENV} ${INSTALL_ENV} ${CMAKE_BUILD_TOOL} ${CMAKE_INSTALL_ARGS} install
.endfor

do-test: cmake-test
cmake-test:
.for d in ${TEST_DIRS}
	cd ${WRKSRC}/${d}/${CMAKE_BUILD_DIR} && ${SETENV} ${TEST_ENV} \
	    ${CMAKE_BUILD_TOOL} ${CMAKE_BUILD_ARGS} test
.endfor


Home | Main Index | Thread Index | Old Index