[Midnightbsd-cvs] mports [15588] trunk/Mk/extensions/cmake.mk: refactor cmake.mk to maintain some compatibility with freebsd ports.
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Thu Nov 14 19:52:27 EST 2013
Revision: 15588
http://svnweb.midnightbsd.org/mports/?rev=15588
Author: laffer1
Date: 2013-11-14 19:52:27 -0500 (Thu, 14 Nov 2013)
Log Message:
-----------
refactor cmake.mk to maintain some compatibility with freebsd ports.
Modified Paths:
--------------
trunk/Mk/extensions/cmake.mk
Modified: trunk/Mk/extensions/cmake.mk
===================================================================
--- trunk/Mk/extensions/cmake.mk 2013-11-15 00:52:04 UTC (rev 15587)
+++ trunk/Mk/extensions/cmake.mk 2013-11-15 00:52:27 UTC (rev 15588)
@@ -1,56 +1,79 @@
# $MidnightBSD$
#
-
-.if !defined(_POSTMKINCLUDED) && !defined(Cmake_Pre_Include)
-
-Cmake_Pre_Include = cmake.mk
-
-# USE_CMAKE - If set, this port uses cmake.
+# Provide support for CMake based projects
#
+# MAINTAINER: kde at FreeBSD.org
+#
+# Feature: cmake
+# Usage: USES=cmake or USES=cmake:ARGS
+# Valid ARGS: outsource
+# ARGS description:
+# outsource perform an out-of-source build
+#
+#
+# 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
+#
+# Variables for ports:
# CMAKE_ENV - Environment passed to cmake.
-# Default: ${CONFIGURE_ENV}
+# Default: ${CONFIGURE_ENV}
# CMAKE_ARGS - Arguments passed to cmake
-# Default: see below
+# Default: see below
# CMAKE_BUILD_TYPE - Type of build (cmake predefined build types).
-# Projects may have their own build profiles.
-# CMake supports the following types: Debug,
-# Release, RelWithDebInfo and MinSizeRel.
-# Debug and Release profiles respect system
-# CFLAGS, RelWithDebInfo and MinSizeRel will set
-# CFLAGS to "-O2 -g" and "-Os -DNDEBUG".
-# Default: Release, if WITH_DEBUG is not set,
-# Debug otherwise
-# CMAKE_VERBOSE - Verbose build
-# Default: not set
-# CMAKE_OUTSOURCE - Instruct to perform an out-of-source build
-# Default: not set
-# CMAKE_SOURCE_PATH - Path to sourcedir for cmake
-# Default: ${WRKSRC}
-# CMAKE_INSTALL_PREFIX - prefix for cmake to use for installation.
-# Default: ${PREFIX}
+# Projects may have their own build profiles.
+# CMake supports the following types: Debug,
+# Release, RelWithDebInfo and MinSizeRel.
+# Debug and Release profiles respect system
+# CFLAGS, RelWithDebInfo and MinSizeRel will set
+# CFLAGS to "-O2 -g" and "-Os -DNDEBUG".
+# Default: Release, if WITH_DEBUG is not set,
+# Debug otherwise
+# CMAKE_SOURCE_PATH - Path to the source directory
+# Default: ${WRKSRC}
#
-#
-# $FreeBSD: ports/Mk/bsd.cmake.mk,v 1.13 2011/11/10 19:50:26 rakuco Exp $
+# Deprecated variables:
+# CMAKE_OUTSOURCE - Instruct to perform an out-of-source build.
+# Deprecated, use 'USES+= cmake:outsource' instead.
-CMAKE_MAINTAINER= ports at MidnightBSD.org
+.if !defined(_POSTMKINCLUDED) && !defined(_INCLUDE_USES_CMAKE_MK)
+_INCLUDE_USES_CMAKE_MK= yes
-#
-# CMAKE_BIN is the location where the cmake port installs the cmake
-# executable
-#
-# CMAKE_PORT is where the cmake port is located in the ports tree
-#
+_valid_ARGS= outsource run
+_cmake_ARGS= ${cmake_ARGS:C/\:/ /g}
+
+# Sanity check
+.if defined(cmake_ARGS)
+. for arg in ${_cmake_ARGS}
+. if empty(_valid_ARGS:M${arg})
+IGNORE= Incorrect 'USES+= cmake:${cmake_ARGS}' usage: argument [${arg}] is not recognized
+. endif
+. endfor
+.endif
+
CMAKE_BIN= ${LOCALBASE}/bin/cmake
-CMAKE_PORT= ${PORTSDIR}/devel/cmake
+BUILD_DEPENDS+= ${CMAKE_BIN}:${PORTSDIR}/devel/cmake
-#
-# Make sure we depend on cmake
-#
-BUILD_DEPENDS+= ${CMAKE_BIN}:${CMAKE_PORT}
+.if ${_cmake_ARGS:Mrun}
+RUN_DEPENDS+= ${CMAKE_BIN}:${PORTSDIR}/devel/cmake
+.endif
-#
-# Default environment and arguments to cmake
-#
+.if defined(WITH_DEBUG)
+CMAKE_BUILD_TYPE?= Debug
+.else
+CMAKE_BUILD_TYPE?= Release
+.endif #defined(WITH_DEBUG)
+
+PLIST_SUB+= CMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE:L}"
+
+.if defined(STRIP) && ${STRIP} != ""
+INSTALL_TARGET?= install/strip
+.endif
+
CMAKE_ENV?= ${CONFIGURE_ENV}
CMAKE_ARGS+= -DCMAKE_C_COMPILER:STRING="${CC}" \
-DCMAKE_CXX_COMPILER:STRING="${CXX}" \
@@ -63,7 +86,7 @@
-DCMAKE_EXE_LINKER_FLAGS:STRING="${LDFLAGS}" \
-DCMAKE_MODULE_LINKER_FLAGS:STRING="${LDFLAGS}" \
-DCMAKE_SHARED_LINKER_FLAGS:STRING="${LDFLAGS}" \
- -DCMAKE_INSTALL_PREFIX:PATH="${CMAKE_INSTALL_PREFIX}" \
+ -DCMAKE_INSTALL_PREFIX:PATH="${PREFIX}" \
-DCMAKE_BUILD_TYPE:STRING="${CMAKE_BUILD_TYPE}" \
-DTHREADS_HAVE_PTHREAD_ARG:BOOL=YES
@@ -72,42 +95,27 @@
CMAKE_NOCOLOR= yes
.endif
-#
-# Default build type and sourcedir
-#
+.if defined(CMAKE_VERBOSE)
+CMAKE_ARGS+= -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON
+.endif
+.if defined(CMAKE_NOCOLOR)
+CMAKE_ARGS+= -DCMAKE_COLOR_MAKEFILE:BOOL=OFF
+.endif
+
+_CMAKE_MSG= "===> Performing in-source build"
CMAKE_SOURCE_PATH?= ${WRKSRC}
-.if defined(CMAKE_OUTSOURCE)
+
+.if ${_cmake_ARGS:Moutsource}
+_CMAKE_MSG= "===> Performing out-of-source build"
CONFIGURE_WRKSRC= ${WRKDIR}/.build
BUILD_WRKSRC= ${CONFIGURE_WRKSRC}
INSTALL_WRKSRC= ${CONFIGURE_WRKSRC}
.endif
-CMAKE_INSTALL_PREFIX?= ${PREFIX}
-.if defined(WITH_DEBUG)
-CMAKE_BUILD_TYPE?= Debug
-.else
-CMAKE_BUILD_TYPE?= Release
-.endif
-
-.if defined(STRIP) && ${STRIP} != ""
-INSTALL_TARGET?= install/strip
-.endif
-
-PLIST_SUB+= CMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE:L}"
-
-#
-# Force makefile verbosity if needed
-#
-.if defined(CMAKE_VERBOSE) || defined(BATCH)
-CMAKE_ARGS+= -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON
-.endif
-
-#
-# Redefine do-configure target
-#
.if !target(do-configure)
do-configure:
- @${MKDIR} ${CONFIGURE_WRKSRC}
+ @${ECHO_MSG} ${_CMAKE_MSG}
+ ${MKDIR} ${CONFIGURE_WRKSRC}
@cd ${CONFIGURE_WRKSRC}; ${SETENV} ${CMAKE_ENV} ${CMAKE_BIN} ${CMAKE_ARGS} ${CMAKE_SOURCE_PATH}
.endif
@@ -125,4 +133,4 @@
DESTDIRNAME= DESTDIR
-.endif # defined(_POSTMKINCLUDED) && !defined(Cmake_Post_Include)
+.endif
More information about the Midnightbsd-cvs
mailing list