Add files from parent branch HEAD:
[pkgsrc.git] / mk / configure / cmake.mk
1 # $NetBSD: cmake.mk,v 1.5 2008/02/13 09:13:31 rillig Exp $
2 #
3 # This file handles packages that use CMake as their primary build
4 # system. For more information about CMake, see http://www.cmake.org/.
5 #
6 # === Package-settable variables ===
7 #
8 # CMAKE_DEPENDENCIES_REWRITE
9 #       A list of files (XXX: variable name) relative to WRKSRC in
10 #       which, after configuring the package, buildlink3 dependencies
11 #       are resolved to the real ones.
12 #
13 # CMAKE_MODULE_PATH_OVERRIDE
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.
16 #       The file ${WRKSRC}/CMakeLists.txt is always appended to this list.
17 #
18
19 _CMAKE_DIR=     ${BUILDLINK_DIR}/cmake-Modules
20
21 CMAKE_ARGS+=    -DCMAKE_INSTALL_PREFIX:PATH=${PREFIX}
22 CMAKE_ARGS+=    -DCMAKE_MODULE_PATH:PATH=${_CMAKE_DIR}
23 CMAKE_ARGS+=    -DCMAKE_SKIP_RPATH:BOOL=TRUE
24
25 CMAKE_MODULE_PATH_OVERRIDE+=    CMakeLists.txt
26
27 ### configure-cmake-override modifies the cmake CMakeLists.txt file in
28 ### ${WRKSRC} so that if CMAKE_MODULE_PATH is set we add our Module
29 ### directory before any others.
30 ###
31
32 SUBST_CLASSES+=         cmake
33 SUBST_STAGE.cmake=      do-configure-pre-hook
34 SUBST_MESSAGE.cmake=    Fixing CMAKE_MODULE_PATH in CMakeLists.txt
35 SUBST_FILES.cmake=      ${CMAKE_MODULE_PATH_OVERRIDE}
36 SUBST_SED.cmake=        \
37         's|set *( *CMAKE_MODULE_PATH |set (CMAKE_MODULE_PATH "${_CMAKE_DIR}" |'
38
39 do-configure-pre-hook: __cmake-copy-module-tree
40 __cmake-copy-module-tree: .PHONY
41         ${RUN} cd ${PKGSRCDIR}/mk; ${CP} -R cmake-Modules ${_CMAKE_DIR}
42
43 ### The cmake function export_library_dependencies() writes out
44 ### library dependency info to a file and this may contain buildlink
45 ### paths.
46 ### cmake-dependencies-rewrite modifies any such files, listed in
47 ### ${CMAKE_DEPENDENCIES_REWRITE} (relative to ${WRKSRC}) to have the
48 ### real dependencies
49 ###
50
51 do-configure-post-hook: __cmake-dependencies-rewrite
52 __cmake-dependencies-rewrite: .PHONY
53         @${STEP_MSG} "Rewrite cmake Dependencies files"
54 .if defined(CMAKE_DEPENDENCIES_REWRITE) && !empty(CMAKE_DEPENDENCIES_REWRITE)
55         ${RUN} \
56         cd ${WRKSRC};                                                   \
57         for file in ${CMAKE_DEPENDENCIES_REWRITE}; do                   \
58                 ${TEST} -f "$$file" || continue;                        \
59                 ${AWK} -f ${PKGSRCDIR}/mk/configure/cmake-rewrite.awk ${BUILDLINK_DIR} $$file > $$file.override; \
60                 ${MV} -f $$file.override $$file;                        \
61         done
62 .endif