Changeset View
Changeset View
Standalone View
Standalone View
Mk/Uses/cmake.mk
# $FreeBSD$ | # $FreeBSD$ | ||||
# | # | ||||
# Provide support for CMake based projects | # Provide support for CMake based projects | ||||
# | # | ||||
# Feature: cmake | # Feature: cmake | ||||
# Usage: USES=cmake or USES=cmake:ARGS | # Usage: USES=cmake or USES=cmake:ARGS | ||||
# Valid ARGS: outsource | # Valid ARGS: outsource, run, noninja | ||||
# ARGS description: | # ARGS description: | ||||
# outsource perform an out-of-source build | # 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: | # Additional variables that affect cmake behaviour: | ||||
# | # | ||||
# User defined variables: | # User defined variables: | ||||
# CMAKE_NOCOLOR - Disable colour build output | # CMAKE_NOCOLOR - Disable colour build output | ||||
# Default: not set, unless BATCH or PACKAGE_BUILDING is defined | # Default: not set, unless BATCH or PACKAGE_BUILDING is defined | ||||
# CMAKE_NINJA - Use ninja instead of make(1) | |||||
# | # | ||||
# Variables for ports: | # Variables for ports: | ||||
# CMAKE_ARGS - Arguments passed to cmake | # CMAKE_ARGS - Arguments passed to cmake | ||||
# Default: see below | # Default: see below | ||||
# CMAKE_BUILD_TYPE - Type of build (cmake predefined build types). | # CMAKE_BUILD_TYPE - Type of build (cmake predefined build types). | ||||
# Projects may have their own build profiles. | # Projects may have their own build profiles. | ||||
# CMake supports the following types: Debug, | # CMake supports the following types: Debug, | ||||
# Release, RelWithDebInfo and MinSizeRel. | # Release, RelWithDebInfo and MinSizeRel. | ||||
# Debug and Release profiles respect system | # Debug and Release profiles respect system | ||||
# CFLAGS, RelWithDebInfo and MinSizeRel will set | # CFLAGS, RelWithDebInfo and MinSizeRel will set | ||||
# CFLAGS to "-O2 -g" and "-Os -DNDEBUG". | # CFLAGS to "-O2 -g" and "-Os -DNDEBUG". | ||||
# Default: Release, if WITH_DEBUG is not set, | # Default: Release, if WITH_DEBUG is not set, | ||||
# Debug otherwise | # Debug otherwise | ||||
# CMAKE_SOURCE_PATH - Path to the source directory | # CMAKE_SOURCE_PATH - Path to the source directory | ||||
# Default: ${WRKSRC} | # Default: ${WRKSRC} | ||||
# | # | ||||
# MAINTAINER: kde@FreeBSD.org | # MAINTAINER: kde@FreeBSD.org | ||||
.if !defined(_INCLUDE_USES_CMAKE_MK) | .if !defined(_INCLUDE_USES_CMAKE_MK) | ||||
_INCLUDE_USES_CMAKE_MK= yes | _INCLUDE_USES_CMAKE_MK= yes | ||||
_valid_ARGS= outsource run | _valid_ARGS= outsource run noninja | ||||
# Sanity check | # Sanity check | ||||
.for arg in ${cmake_ARGS} | .for arg in ${cmake_ARGS} | ||||
. if empty(_valid_ARGS:M${arg}) | . if empty(_valid_ARGS:M${arg}) | ||||
IGNORE= Incorrect 'USES+= cmake:${cmake_ARGS}' usage: argument [${arg}] is not recognized | IGNORE= Incorrect 'USES+= cmake:${cmake_ARGS}' usage: argument [${arg}] is not recognized | ||||
. endif | . endif | ||||
.endfor | .endfor | ||||
Show All 38 Lines | |||||
.if defined(BATCH) || defined(PACKAGE_BUILDING) | .if defined(BATCH) || defined(PACKAGE_BUILDING) | ||||
CMAKE_NOCOLOR= yes | CMAKE_NOCOLOR= yes | ||||
.endif | .endif | ||||
.if defined(CMAKE_NOCOLOR) | .if defined(CMAKE_NOCOLOR) | ||||
CMAKE_ARGS+= -DCMAKE_COLOR_MAKEFILE:BOOL=OFF | CMAKE_ARGS+= -DCMAKE_COLOR_MAKEFILE:BOOL=OFF | ||||
.endif | .endif | ||||
.if defined(CMAKE_NINJA) | |||||
.include "${USESDIR}/ninja.mk" | |||||
.endif | |||||
_CMAKE_MSG= "===> Performing in-source build" | _CMAKE_MSG= "===> Performing in-source build" | ||||
mat: remove empty line. | |||||
CMAKE_SOURCE_PATH?= ${WRKSRC} | CMAKE_SOURCE_PATH?= ${WRKSRC} | ||||
.if ${cmake_ARGS:Moutsource} | .if ${cmake_ARGS:Moutsource} | ||||
_CMAKE_MSG= "===> Performing out-of-source build" | _CMAKE_MSG= "===> Performing out-of-source build" | ||||
CONFIGURE_WRKSRC= ${WRKDIR}/.build | CONFIGURE_WRKSRC= ${WRKDIR}/.build | ||||
BUILD_WRKSRC?= ${CONFIGURE_WRKSRC} | BUILD_WRKSRC?= ${CONFIGURE_WRKSRC} | ||||
INSTALL_WRKSRC?= ${CONFIGURE_WRKSRC} | INSTALL_WRKSRC?= ${CONFIGURE_WRKSRC} | ||||
TEST_WRKSRC?= ${CONFIGURE_WRKSRC} | 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 | .endif | ||||
.if !target(do-configure) | .if !target(do-configure) | ||||
do-configure: | do-configure: | ||||
@${ECHO_MSG} ${_CMAKE_MSG} | @${ECHO_MSG} ${_CMAKE_MSG} | ||||
${MKDIR} ${CONFIGURE_WRKSRC} | ${MKDIR} ${CONFIGURE_WRKSRC} | ||||
@cd ${CONFIGURE_WRKSRC}; ${SETENV} ${CONFIGURE_ENV} ${CMAKE_BIN} ${CMAKE_ARGS} ${CMAKE_SOURCE_PATH} | @cd ${CONFIGURE_WRKSRC}; ${SETENV} ${CONFIGURE_ENV} ${CMAKE_BIN} ${CMAKE_ARGS} ${CMAKE_SOURCE_PATH} | ||||
.endif | .endif | ||||
.endif #!defined(_INCLUDE_USES_CMAKE_MK) | .endif #!defined(_INCLUDE_USES_CMAKE_MK) |
remove empty line.