blob: 07fdff8293439cfc2ff7dccad9e3ad50c7686075 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
# $NetBSD: build.mk,v 1.5 2022/09/28 10:05:35 markd Exp $
#
# This Makefile fragment supports building using the CMake build tool.
#
# User-settable variables:
#
# CMAKE_GENERATOR
# Which build tool to use.
#
# Possible: make ninja
# Default: make
#
# Package-settable variables:
#
# CMAKE_CONFIGURE_ARGS
# Arguments to pass to CMake during the configure stage. Defaults
# to CMAKE_ARGS for backwards compatibility with USE_CMAKE.
#
# CMAKE_BUILD_ARGS
# Arguments to pass to CMake during build. Default: empty
#
# CMAKE_INSTALL_ARGS
# Arguments to pass to CMake during installation: Default: empty
#
# CONFIGURE_DIRS
# Directories relative to WRKSRC in which to run CMake. Usually
# only one, the toplevel.
#
# BUILD_DIRS
# Directories relative to WRKSRC in which to build. Defaults
# to CONFIGURE_DIRS.
#
# TEST_DIRS
# Directories relative to WRKSRC in which to run the tests. Defaults
# to CONFIGURE_DIRS.
#
# INSTALL_DIRS
# Directories relative to WRKSRC in which to run the 'install'
# step. Defaults to CONFIGURE_DIRS.
CMAKE_REQD?= 0
.for version in ${CMAKE_REQD}
TOOL_DEPENDS+= cmake>=${version}:../../devel/cmake
.endfor
CMAKE_CONFIGURE_ARGS?= ${CMAKE_ARGS}
CONFIGURE_ENV+= BUILDLINK_DIR=${BUILDLINK_DIR}
CMAKE_BUILD_DIR?= cmake-pkgsrc-build
CMAKE_GENERATOR?= make
CMAKE_BUILD_ARGS?= -j ${_MAKE_JOBS_N:U1}
CMAKE_INSTALL_ARGS?= # empty
.if ${CMAKE_GENERATOR} == "ninja"
TOOL_DEPENDS+= ninja-build-[0-9]*:../../devel/ninja-build
_CMAKE_BUILD_SYSTEM?= Ninja
_CMAKE_BUILD_TOOL?= ninja
.else
_CMAKE_BUILD_SYSTEM?= Unix Makefiles
_CMAKE_BUILD_TOOL?= ${MAKE_PROGRAM}
.endif
CONFIGURE_DIRS?= .
BUILD_DIRS?= ${CONFIGURE_DIRS}
TEST_DIRS?= ${CONFIGURE_DIRS}
INSTALL_DIRS?= ${CONFIGURE_DIRS}
.PHONY: cmake-configure cmake-build cmake-test cmake-install
do-configure: cmake-configure
cmake-configure:
.for d in ${CONFIGURE_DIRS}
${RUN} cd ${WRKSRC}/${d} && ${SETENV} ${CONFIGURE_ENV} cmake \
--install-prefix ${PREFIX} \
-B ${CMAKE_BUILD_DIR} \
-G ${_CMAKE_BUILD_SYSTEM:Q} \
${CMAKE_CONFIGURE_ARGS}
.endfor
do-build: cmake-build
cmake-build:
.for d in ${BUILD_DIRS}
${RUN} cd ${WRKSRC}/${d}/${CMAKE_BUILD_DIR} && \
${SETENV} ${MAKE_ENV} \
${_CMAKE_BUILD_TOOL} ${CMAKE_BUILD_ARGS}
.endfor
do-test: cmake-test
cmake-test:
.for d in ${TEST_DIRS}
${RUN} cd ${WRKSRC}/${d}/${CMAKE_BUILD_DIR} && \
${SETENV} ${TEST_ENV} \
${_CMAKE_BUILD_TOOL} ${CMAKE_BUILD_ARGS} ${TEST_TARGET}
.endfor
do-install: cmake-install
cmake-install:
.for d in ${INSTALL_DIRS}
${RUN} cd ${WRKSRC}/${d}/${CMAKE_BUILD_DIR} && \
${SETENV} ${INSTALL_ENV} \
${_CMAKE_BUILD_TOOL} ${CMAKE_INSTALL_ARGS} ${INSTALL_TARGET}
.endfor
_VARGROUPS+= cmake
_USER_VARS.cmake+= CMAKE_GENERATOR
_PKG_VARS.cmake+= CMAKE_REQD
_PKG_VARS.cmake+= CMAKE_CONFIGURE_ARGS CONFIGURE_DIRS
_PKG_VARS.cmake+= CMAKE_BUILD_ARGS BUILD_DIRS
_PKG_VARS.cmake+= TEST_DIRS TEST_TARGET
_PKG_VARS.cmake+= CMAKE_INSTALL_ARGS INSTALL_DIRS INSTALL_TARGET
_SYS_VARS.cmake+= CMAKE_BUILD_DIR
_USE_VARS.cmake+= CMAKE_ARGS
_USE_VARS.cmake+= CONFIGURE_ENV MAKE_ENV TEST_ENV INSTALL_ENV
_IGN_VARS.cmake+= BUILDLINK_DIR WRKSRC PREFIX
_IGN_VARS.cmake+= SETENV TOOL_DEPENDS
_IGN_VARS.cmake+= _CMAKE_BUILD_SYSTEM _CMAKE_BUILD_TOOL _MAKE_JOBS_N
_LISTED_VARS.cmake+= *_ARGS
_SORTED_VARS.cmake+= *_ENV
|