| 1 |
# $FreeBSD$ |
| 2 |
# |
| 3 |
# Provide support for CMake based projects |
| 4 |
# |
| 5 |
# Feature: cmake |
| 6 |
# Usage: USES=cmake or USES=cmake:ARGS |
| 7 |
# Valid ARGS: outsource |
| 8 |
# ARGS description: |
| 9 |
# outsource perform an out-of-source build |
| 10 |
# |
| 11 |
# |
| 12 |
# Additional variables that affect cmake behaviour: |
| 13 |
# |
| 14 |
# User defined variables: |
| 15 |
# CMAKE_VERBOSE - Enable verbose build output |
| 16 |
# Default: not set, unless BATCH or PACKAGE_BUILDING is defined |
| 17 |
# CMAKE_NOCOLOR - Disable colour build output |
| 18 |
# Default: not set, unless BATCH or PACKAGE_BUILDING is defined |
| 19 |
# CMAKE_NINJA - Use ninja instead of make(1) |
| 20 |
# |
| 21 |
# Variables for ports: |
| 22 |
# CMAKE_ARGS - Arguments passed to cmake |
| 23 |
# Default: see below |
| 24 |
# CMAKE_BUILD_TYPE - Type of build (cmake predefined build types). |
| 25 |
# Projects may have their own build profiles. |
| 26 |
# CMake supports the following types: Debug, |
| 27 |
# Release, RelWithDebInfo and MinSizeRel. |
| 28 |
# Debug and Release profiles respect system |
| 29 |
# CFLAGS, RelWithDebInfo and MinSizeRel will set |
| 30 |
# CFLAGS to "-O2 -g" and "-Os -DNDEBUG". |
| 31 |
# Default: Release, if WITH_DEBUG is not set, |
| 32 |
# Debug otherwise |
| 33 |
# CMAKE_SOURCE_PATH - Path to the source directory |
| 34 |
# Default: ${WRKSRC} |
| 35 |
# |
| 36 |
# MAINTAINER: kde@FreeBSD.org |
| 37 |
|
| 38 |
.if !defined(_INCLUDE_USES_CMAKE_MK) |
| 39 |
_INCLUDE_USES_CMAKE_MK= yes |
| 40 |
|
| 41 |
_valid_ARGS= outsource run |
| 42 |
|
| 43 |
# Sanity check |
| 44 |
.for arg in ${cmake_ARGS} |
| 45 |
. if empty(_valid_ARGS:M${arg}) |
| 46 |
IGNORE= Incorrect 'USES+= cmake:${cmake_ARGS}' usage: argument [${arg}] is not recognized |
| 47 |
. endif |
| 48 |
.endfor |
| 49 |
|
| 50 |
CMAKE_BIN= ${LOCALBASE}/bin/cmake |
| 51 |
BUILD_DEPENDS+= ${CMAKE_BIN}:devel/cmake |
| 52 |
|
| 53 |
.if ${cmake_ARGS:Mrun} |
| 54 |
RUN_DEPENDS+= ${CMAKE_BIN}:devel/cmake |
| 55 |
.endif |
| 56 |
|
| 57 |
.if defined(WITH_DEBUG) |
| 58 |
CMAKE_BUILD_TYPE?= Debug |
| 59 |
.else |
| 60 |
CMAKE_BUILD_TYPE?= Release |
| 61 |
.endif #defined(WITH_DEBUG) |
| 62 |
|
| 63 |
PLIST_SUB+= CMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE:tl}" |
| 64 |
|
| 65 |
.if defined(STRIP) && ${STRIP} != "" && !defined(WITH_DEBUG) |
| 66 |
INSTALL_TARGET?= install/strip |
| 67 |
.endif |
| 68 |
|
| 69 |
CMAKE_ARGS+= -DCMAKE_C_COMPILER:STRING="${CC}" \ |
| 70 |
-DCMAKE_CXX_COMPILER:STRING="${CXX}" \ |
| 71 |
-DCMAKE_C_FLAGS:STRING="${CFLAGS}" \ |
| 72 |
-DCMAKE_C_FLAGS_DEBUG:STRING="${CFLAGS}" \ |
| 73 |
-DCMAKE_C_FLAGS_RELEASE:STRING="${CFLAGS}" \ |
| 74 |
-DCMAKE_CXX_FLAGS:STRING="${CXXFLAGS}" \ |
| 75 |
-DCMAKE_CXX_FLAGS_DEBUG:STRING="${CXXFLAGS}" \ |
| 76 |
-DCMAKE_CXX_FLAGS_RELEASE:STRING="${CXXFLAGS}" \ |
| 77 |
-DCMAKE_EXE_LINKER_FLAGS:STRING="${LDFLAGS}" \ |
| 78 |
-DCMAKE_MODULE_LINKER_FLAGS:STRING="${LDFLAGS}" \ |
| 79 |
-DCMAKE_SHARED_LINKER_FLAGS:STRING="${LDFLAGS}" \ |
| 80 |
-DCMAKE_INSTALL_PREFIX:PATH="${CMAKE_INSTALL_PREFIX}" \ |
| 81 |
-DCMAKE_BUILD_TYPE:STRING="${CMAKE_BUILD_TYPE}" \ |
| 82 |
-DTHREADS_HAVE_PTHREAD_ARG:BOOL=YES \ |
| 83 |
-DCMAKE_INSTALL_RPATH_USE_LINK_PATH=YES |
| 84 |
|
| 85 |
CMAKE_INSTALL_PREFIX?= ${PREFIX} |
| 86 |
|
| 87 |
.if defined(BATCH) || defined(PACKAGE_BUILDING) |
| 88 |
CMAKE_VERBOSE= yes |
| 89 |
CMAKE_NOCOLOR= yes |
| 90 |
.endif |
| 91 |
|
| 92 |
.if defined(CMAKE_VERBOSE) |
| 93 |
CMAKE_ARGS+= -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON |
| 94 |
.endif |
| 95 |
.if defined(CMAKE_NOCOLOR) |
| 96 |
CMAKE_ARGS+= -DCMAKE_COLOR_MAKEFILE:BOOL=OFF |
| 97 |
.endif |
| 98 |
|
| 99 |
.if defined(CMAKE_NINJA) |
| 100 |
.include "${USESDIR}/ninja.mk" |
| 101 |
.endif |
| 102 |
|
| 103 |
_CMAKE_MSG= "===> Performing in-source build" |
| 104 |
CMAKE_SOURCE_PATH?= ${WRKSRC} |
| 105 |
|
| 106 |
.if ${cmake_ARGS:Moutsource} |
| 107 |
_CMAKE_MSG= "===> Performing out-of-source build" |
| 108 |
CONFIGURE_WRKSRC= ${WRKDIR}/.build |
| 109 |
BUILD_WRKSRC?= ${CONFIGURE_WRKSRC} |
| 110 |
INSTALL_WRKSRC?= ${CONFIGURE_WRKSRC} |
| 111 |
.endif |
| 112 |
|
| 113 |
.if !target(do-configure) |
| 114 |
do-configure: |
| 115 |
@${ECHO_MSG} ${_CMAKE_MSG} |
| 116 |
${MKDIR} ${CONFIGURE_WRKSRC} |
| 117 |
@cd ${CONFIGURE_WRKSRC}; ${SETENV} ${CONFIGURE_ENV} ${CMAKE_BIN} ${CMAKE_ARGS} ${CMAKE_SOURCE_PATH} |
| 118 |
.endif |
| 119 |
|
| 120 |
.endif #!defined(_INCLUDE_USES_CMAKE_MK) |