[Midnightbsd-cvs] mports [23285] trunk/Mk/extensions/cmake.mk: default to ninja

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Mon Apr 30 19:34:20 EDT 2018


Revision: 23285
          http://svnweb.midnightbsd.org/mports/?rev=23285
Author:   laffer1
Date:     2018-04-30 19:34:20 -0400 (Mon, 30 Apr 2018)
Log Message:
-----------
default to ninja

Modified Paths:
--------------
    trunk/Mk/extensions/cmake.mk

Modified: trunk/Mk/extensions/cmake.mk
===================================================================
--- trunk/Mk/extensions/cmake.mk	2018-04-30 23:30:36 UTC (rev 23284)
+++ trunk/Mk/extensions/cmake.mk	2018-04-30 23:34:20 UTC (rev 23285)
@@ -4,20 +4,29 @@
 #
 # Feature:		cmake
 # Usage:		USES=cmake or USES=cmake:ARGS
-# Valid ARGS:		outsource
+# Valid ARGS:		outsource, run, noninja
 # ARGS description:
 # outsource		perform an out-of-source build
+# noninja		don't use ninja instead of make
+#			Setting this should be an exception, and hints to an issue
+#			inside the ports build system.
+#			A few corner cases never use ninja, and are handled, to reduce
+#			the usage of 'noninja'.:
+#				1) fortran ports
+#				2) ports that set BUILD_- or INSTALL_WRKSRC to
+#				   something different than CONFIGURE_WRKSRC
+# run			add a runtime dependency on cmake
 #
 #
 # Additional variables that affect cmake behaviour:
 #
 # User defined variables:
-# CMAKE_VERBOSE		- Enable verbose build output
-#			Default: not set, until BATCH or PACKAGE_BUILDING is defined
 # CMAKE_NOCOLOR		- Disable colour build output
-#			Default: not set, until BATCH or PACKAGE_BUILDING is defined
+#			Default: not set, unless BATCH or PACKAGE_BUILDING is defined
 #
 # Variables for ports:
+# CMAKE_ON		Appends -D<var>:bool=ON  to the CMAKE_ARGS,
+# CMAKE_OFF		Appends -D<var>:bool=OFF to the CMAKE_ARGS.
 # CMAKE_ARGS		- Arguments passed to cmake
 #			Default: see below
 # CMAKE_BUILD_TYPE	- Type of build (cmake predefined build types).
@@ -35,7 +44,7 @@
 .if !defined(_POSTMKINCLUDED) && !defined(_INCLUDE_USES_CMAKE_MK)
 _INCLUDE_USES_CMAKE_MK=	yes
 
-_valid_ARGS=		outsource run
+_valid_ARGS=		outsource run noninja
 
 # Sanity check
 .for arg in ${cmake_ARGS}
@@ -45,10 +54,10 @@
 .endfor
 
 CMAKE_BIN=		${LOCALBASE}/bin/cmake
-BUILD_DEPENDS+=		${CMAKE_BIN}:${PORTSDIR}/devel/cmake
+BUILD_DEPENDS+=		${CMAKE_BIN}:devel/cmake
 
 .if ${cmake_ARGS:Mrun}
-RUN_DEPENDS+=		${CMAKE_BIN}:${PORTSDIR}/devel/cmake
+RUN_DEPENDS+=		${CMAKE_BIN}:devel/cmake
 .endif
 
 .if defined(WITH_DEBUG)
@@ -80,6 +89,13 @@
 			-DCMAKE_INSTALL_RPATH_USE_LINK_PATH=YES \
 			-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON
 
+# Handle the option-like CMAKE_ON and CMAKE_OFF lists.
+.for _bool_kind in ON OFF
+.  if defined(CMAKE_${_bool_kind})
+CMAKE_ARGS+=		${CMAKE_${_bool_kind}:C/.*/-D&:BOOL=${_bool_kind}/}
+.  endif
+.endfor
+
 CMAKE_INSTALL_PREFIX?=	${PREFIX}
 
 .if defined(BATCH) || defined(PACKAGE_BUILDING) || defined(MAGUS)
@@ -90,10 +106,6 @@
 CMAKE_ARGS+=		-DCMAKE_COLOR_MAKEFILE:BOOL=OFF
 .endif
 
-.if defined(CMAKE_NINJA)
-.include "${PORTSDIR}/Mk/extensions/ninja.mk"
-.endif
-
 _CMAKE_MSG=		"===>  Performing in-source build"
 CMAKE_SOURCE_PATH?=	${WRKSRC}
 
@@ -105,6 +117,20 @@
 TEST_WRKSRC?=		${CONFIGURE_WRKSRC}
 .endif
 
+# By default we use the ninja generator.
+#  Except, if cmake:run is set (cmake not wanted as generator)
+#             fortran is used, as the ninja-generator does not handle it.
+#             or if CONFIGURE_WRKSRC does not match  BUILD_WRKSRC or INSTALL_WRKSRC
+#             as the build.ninja file won't be where ninja expects it.
+.if empty(cmake_ARGS:Mnoninja) && empty(cmake_ARGS:Mrun) && empty(USES:Mfortran)
+.  if "${CONFIGURE_WRKSRC}" == "${BUILD_WRKSRC}" && "${CONFIGURE_WRKSRC}" == "${INSTALL_WRKSRC}"
+.    if ! empty(USES:Mgmake)
+BROKEN=		USES=gmake is incompatible with cmake's ninja-generator
+.    endif
+.      include "${USESDIR}/ninja.mk"
+.  endif
+.endif
+
 .if !target(do-configure)
 do-configure:
 	@${ECHO_MSG} ${_CMAKE_MSG}



More information about the Midnightbsd-cvs mailing list