| @@ -1,112 +1,114 @@ | | | @@ -1,112 +1,114 @@ |
1 | # $NetBSD: cmake.mk,v 1.18 2020/05/12 17:36:20 rillig Exp $ | | 1 | # $NetBSD: cmake.mk,v 1.19 2020/06/13 15:11:11 ryoon Exp $ |
2 | # | | 2 | # |
3 | # This file handles packages that use CMake as their primary build | | 3 | # This file handles packages that use CMake as their primary build |
4 | # system. For more information about CMake, see http://www.cmake.org/. | | 4 | # system. For more information about CMake, see http://www.cmake.org/. |
5 | # | | 5 | # |
6 | # Package-settable variables: | | 6 | # Package-settable variables: |
7 | # | | 7 | # |
8 | # CMAKE_DEPENDENCIES_REWRITE | | 8 | # CMAKE_DEPENDENCIES_REWRITE |
9 | # A list of files (XXX: variable name) relative to WRKSRC in | | 9 | # A list of files (XXX: variable name) relative to WRKSRC in |
10 | # which, after configuring the package, buildlink3 dependencies | | 10 | # which, after configuring the package, buildlink3 dependencies |
11 | # are resolved to the real ones. | | 11 | # are resolved to the real ones. |
12 | # | | 12 | # |
13 | # CMAKE_MODULE_PATH_OVERRIDE | | 13 | # CMAKE_MODULE_PATH_OVERRIDE |
14 | # A list of files relative to WRKSRC in which the CMAKE_MODULE_PATH | | 14 | # A list of files relative to WRKSRC in which the CMAKE_MODULE_PATH |
15 | # variable is adjusted to include the path from the pkgsrc wrappers. | | 15 | # variable is adjusted to include the path from the pkgsrc wrappers. |
16 | # The file ${WRKSRC}/CMakeLists.txt is always appended to this list. | | 16 | # The file ${WRKSRC}/CMakeLists.txt is always appended to this list. |
17 | # | | 17 | # |
18 | # CMAKE_PKGSRC_BUILD_FLAGS | | 18 | # CMAKE_PKGSRC_BUILD_FLAGS |
19 | # If set to yes, disable compiler optimization flags associated | | 19 | # If set to yes, disable compiler optimization flags associated |
20 | # with the CMAKE_BUILD_TYPE setting (for pkgsrc these come in from | | 20 | # with the CMAKE_BUILD_TYPE setting (for pkgsrc these come in from |
21 | # the user via variables like CFLAGS). The default is yes, but you can | | 21 | # the user via variables like CFLAGS). The default is yes, but you can |
22 | # set it to no for pkgsrc packages that do not use a compiler to avoid | | 22 | # set it to no for pkgsrc packages that do not use a compiler to avoid |
23 | # cmake "Manually-specified variables were not used by the project" | | 23 | # cmake "Manually-specified variables were not used by the project" |
24 | # warnings associated with this variable. | | 24 | # warnings associated with this variable. |
25 | # | | 25 | # |
26 | # CMAKE_PREFIX_PATH | | 26 | # CMAKE_PREFIX_PATH |
27 | # A list of directories to add the CMAKE_PREFIX_PATH cmake variable. | | 27 | # A list of directories to add the CMAKE_PREFIX_PATH cmake variable. |
28 | # If a package installs its contents in ${PREFIX}/package instead of | | 28 | # If a package installs its contents in ${PREFIX}/package instead of |
29 | # ${PREFIX} and it installs cmake modules there | | 29 | # ${PREFIX} and it installs cmake modules there |
30 | # "CMAKE_PREFIX_PATH += ${PREFIX}/package" should be in its | | 30 | # "CMAKE_PREFIX_PATH += ${PREFIX}/package" should be in its |
31 | # buildlink3.mk so that packages that depend on it can find its | | 31 | # buildlink3.mk so that packages that depend on it can find its |
32 | # cmake modules if they use cmake to build. | | 32 | # cmake modules if they use cmake to build. |
33 | # | | 33 | # |
34 | # CMAKE_USE_GNU_INSTALL_DIRS | | 34 | # CMAKE_USE_GNU_INSTALL_DIRS |
35 | # If set to yes, set GNU standard installation directories with pkgsrc | | 35 | # If set to yes, set GNU standard installation directories with pkgsrc |
36 | # configured settings. The default is yes. | | 36 | # configured settings. The default is yes. |
37 | # | | 37 | # |
38 | # CMAKE_INSTALL_PREFIX | | 38 | # CMAKE_INSTALL_PREFIX |
39 | # Destination directory to install software. The default is ${PREFIX}. | | 39 | # Destination directory to install software. The default is ${PREFIX}. |
40 | # | | 40 | # |
41 | | | 41 | |
42 | _CMAKE_DIR= ${BUILDLINK_DIR}/cmake-Modules | | 42 | _CMAKE_DIR= ${BUILDLINK_DIR}/cmake-Modules |
43 | | | 43 | |
44 | CMAKE_USE_GNU_INSTALL_DIRS?= yes | | 44 | CMAKE_USE_GNU_INSTALL_DIRS?= yes |
45 | | | 45 | |
46 | CMAKE_INSTALL_PREFIX?= ${PREFIX} | | 46 | CMAKE_INSTALL_PREFIX?= ${PREFIX} |
47 | | | 47 | |
48 | CMAKE_ARGS+= -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX} | | 48 | CMAKE_ARGS+= -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX} |
49 | CMAKE_ARGS+= -DCMAKE_MODULE_PATH:PATH=${_CMAKE_DIR} | | 49 | CMAKE_ARGS+= -DCMAKE_MODULE_PATH:PATH=${_CMAKE_DIR} |
50 | .if empty(CMAKE_PKGSRC_BUILD_FLAGS:M[nN][oO]) | | 50 | .if empty(CMAKE_PKGSRC_BUILD_FLAGS:M[nN][oO]) |
51 | CMAKE_ARGS+= -DCMAKE_PKGSRC_BUILD_FLAGS:BOOL=TRUE | | 51 | CMAKE_ARGS+= -DCMAKE_PKGSRC_BUILD_FLAGS:BOOL=TRUE |
52 | .endif | | 52 | .endif |
53 | .if ${OPSYS} != "Darwin" | | 53 | .if ${OPSYS} != "Darwin" |
54 | CMAKE_ARGS+= -DCMAKE_SKIP_RPATH:BOOL=TRUE | | 54 | CMAKE_ARGS+= -DCMAKE_SKIP_RPATH:BOOL=TRUE |
55 | .else | | 55 | .else |
56 | CMAKE_ARGS+= -DCMAKE_SKIP_RPATH:BOOL=FALSE | | 56 | CMAKE_ARGS+= -DCMAKE_SKIP_RPATH:BOOL=FALSE |
57 | CMAKE_ARGS+= -DCMAKE_INSTALL_NAME_DIR:PATH=${PREFIX}/lib | | 57 | CMAKE_ARGS+= -DCMAKE_INSTALL_NAME_DIR:PATH=${PREFIX}/lib |
58 | .endif | | 58 | .endif |
59 | .if defined(CMAKE_USE_GNU_INSTALL_DIRS) && empty(CMAKE_USE_GNU_INSTALL_DIRS:M[nN][oO]) | | 59 | .if defined(CMAKE_USE_GNU_INSTALL_DIRS) && empty(CMAKE_USE_GNU_INSTALL_DIRS:M[nN][oO]) |
60 | CMAKE_ARGS+= -DCMAKE_INSTALL_LIBDIR:PATH=lib | | 60 | CMAKE_ARGS+= -DCMAKE_INSTALL_LIBDIR:PATH=lib |
61 | CMAKE_ARGS+= -DCMAKE_INSTALL_MANDIR:PATH=${PKGMANDIR} | | 61 | CMAKE_ARGS+= -DCMAKE_INSTALL_MANDIR:PATH=${PKGMANDIR} |
62 | . if defined(INFO_FILES) | | 62 | . if defined(INFO_FILES) |
63 | CMAKE_ARGS+= -DCMAKE_INSTALL_INFODIR:PATH=${PKGINFODIR} | | 63 | CMAKE_ARGS+= -DCMAKE_INSTALL_INFODIR:PATH=${PKGINFODIR} |
64 | . endif | | 64 | . endif |
65 | . if defined(USE_PKGLOCALEDIR) && empty(USE_PKGLOCALEDIR:M[nN][oO]) | | 65 | . if defined(USE_PKGLOCALEDIR) && empty(USE_PKGLOCALEDIR:M[nN][oO]) |
66 | CMAKE_ARGS+= -DCMAKE_INSTALL_LOCALEDIR:PATH=${PKGLOCALEDIR}/locale | | 66 | CMAKE_ARGS+= -DCMAKE_INSTALL_LOCALEDIR:PATH=${PKGLOCALEDIR}/locale |
67 | . endif | | 67 | . endif |
68 | .endif | | 68 | .endif |
69 | | | 69 | |
70 | .if defined(CMAKE_PREFIX_PATH) | | 70 | .if defined(CMAKE_PREFIX_PATH) |
71 | CMAKE_ARGS+=-DCMAKE_PREFIX_PATH:PATH=${CMAKE_PREFIX_PATH:ts;:Q} | | 71 | CMAKE_ARGS+=-DCMAKE_PREFIX_PATH:PATH=${CMAKE_PREFIX_PATH:ts;:Q} |
72 | .endif | | 72 | .endif |
73 | | | 73 | |
74 | CMAKE_MODULE_PATH_OVERRIDE+= CMakeLists.txt | | 74 | CMAKE_MODULE_PATH_OVERRIDE+= CMakeLists.txt |
75 | | | 75 | |
76 | ### configure-cmake-override modifies the cmake CMakeLists.txt file in | | 76 | ### configure-cmake-override modifies the cmake CMakeLists.txt file in |
77 | ### ${WRKSRC} so that if CMAKE_MODULE_PATH is set we add our Module | | 77 | ### ${WRKSRC} so that if CMAKE_MODULE_PATH is set we add our Module |
78 | ### directory before any others. | | 78 | ### directory before any others. |
79 | ### | | 79 | ### |
80 | | | 80 | |
81 | SUBST_CLASSES+= cmake | | 81 | SUBST_CLASSES+= cmake |
82 | SUBST_STAGE.cmake= do-configure-pre-hook | | 82 | SUBST_STAGE.cmake= do-configure-pre-hook |
83 | SUBST_MESSAGE.cmake= Fixing CMAKE_MODULE_PATH in CMakeLists.txt | | 83 | SUBST_MESSAGE.cmake= Fixing CMAKE_MODULE_PATH in CMakeLists.txt |
84 | SUBST_FILES.cmake= ${CMAKE_MODULE_PATH_OVERRIDE} | | 84 | SUBST_FILES.cmake= ${CMAKE_MODULE_PATH_OVERRIDE} |
85 | SUBST_SED.cmake= \ | | 85 | SUBST_SED.cmake= \ |
86 | 's|set *( *CMAKE_MODULE_PATH |set (CMAKE_MODULE_PATH "${_CMAKE_DIR}" |' | | 86 | -e 's|set *( *CMAKE_MODULE_PATH |set (CMAKE_MODULE_PATH "${_CMAKE_DIR}" |' |
| | | 87 | SUBST_SED.cmake+= \ |
| | | 88 | -e 's|SET *( *CMAKE_MODULE_PATH |SET (CMAKE_MODULE_PATH "${_CMAKE_DIR}" |' |
87 | SUBST_NOOP_OK.cmake= yes # not all packages need this | | 89 | SUBST_NOOP_OK.cmake= yes # not all packages need this |
88 | | | 90 | |
89 | do-configure-pre-hook: __cmake-copy-module-tree | | 91 | do-configure-pre-hook: __cmake-copy-module-tree |
90 | __cmake-copy-module-tree: .PHONY | | 92 | __cmake-copy-module-tree: .PHONY |
91 | ${RUN} cd ${PKGSRCDIR}/mk; ${CP} -R cmake-Modules ${_CMAKE_DIR} | | 93 | ${RUN} cd ${PKGSRCDIR}/mk; ${CP} -R cmake-Modules ${_CMAKE_DIR} |
92 | | | 94 | |
93 | ### The cmake function export_library_dependencies() writes out | | 95 | ### The cmake function export_library_dependencies() writes out |
94 | ### library dependency info to a file and this may contain buildlink | | 96 | ### library dependency info to a file and this may contain buildlink |
95 | ### paths. | | 97 | ### paths. |
96 | ### cmake-dependencies-rewrite modifies any such files, listed in | | 98 | ### cmake-dependencies-rewrite modifies any such files, listed in |
97 | ### ${CMAKE_DEPENDENCIES_REWRITE} (relative to ${WRKSRC}) to have the | | 99 | ### ${CMAKE_DEPENDENCIES_REWRITE} (relative to ${WRKSRC}) to have the |
98 | ### real dependencies | | 100 | ### real dependencies |
99 | ### | | 101 | ### |
100 | | | 102 | |
101 | do-configure-post-hook: __cmake-dependencies-rewrite | | 103 | do-configure-post-hook: __cmake-dependencies-rewrite |
102 | __cmake-dependencies-rewrite: .PHONY | | 104 | __cmake-dependencies-rewrite: .PHONY |
103 | @${STEP_MSG} "Rewrite cmake Dependencies files" | | 105 | @${STEP_MSG} "Rewrite cmake Dependencies files" |
104 | .if defined(CMAKE_DEPENDENCIES_REWRITE) && !empty(CMAKE_DEPENDENCIES_REWRITE) | | 106 | .if defined(CMAKE_DEPENDENCIES_REWRITE) && !empty(CMAKE_DEPENDENCIES_REWRITE) |
105 | ${RUN} \ | | 107 | ${RUN} \ |
106 | cd ${WRKSRC}; \ | | 108 | cd ${WRKSRC}; \ |
107 | for file in ${CMAKE_DEPENDENCIES_REWRITE}; do \ | | 109 | for file in ${CMAKE_DEPENDENCIES_REWRITE}; do \ |
108 | ${TEST} -f "$$file" || continue; \ | | 110 | ${TEST} -f "$$file" || continue; \ |
109 | ${AWK} -f ${PKGSRCDIR}/mk/configure/cmake-rewrite.awk ${BUILDLINK_DIR} $$file > $$file.override; \ | | 111 | ${AWK} -f ${PKGSRCDIR}/mk/configure/cmake-rewrite.awk ${BUILDLINK_DIR} $$file > $$file.override; \ |
110 | ${MV} -f $$file.override $$file; \ | | 112 | ${MV} -f $$file.override $$file; \ |
111 | done | | 113 | done |
112 | .endif | | 114 | .endif |