summaryrefslogtreecommitdiffstats
path: root/src/cmake-conf.mk
blob: 925f12f04e0baf1bc96d918217e78983771980c7 (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
# This file is part of MXE. See LICENSE.md for licensing information.

PKG            := cmake-conf
$(PKG)_VERSION := 1
$(PKG)_UPDATE  := echo 1
$(PKG)_TARGETS := $(BUILD) $(MXE_TARGETS)
$(PKG)_FILE_DEPS := $(wildcard $(PWD)/src/cmake/conf/*)

define $(PKG)_BUILD
    # create the CMake toolchain file using template
    # individual packages (e.g. hdf5) should add their
    # own files under CMAKE_TOOLCHAIN_DIR

    mkdir -p '$(CMAKE_TOOLCHAIN_DIR)'
    touch '$(CMAKE_TOOLCHAIN_DIR)/.gitkeep'
    cmake-configure-file \
        -DCMAKE_VERSION=$(cmake_VERSION) \
        -DCMAKE_SHARED_BOOL=$(CMAKE_SHARED_BOOL) \
        -DCMAKE_STATIC_BOOL=$(CMAKE_STATIC_BOOL) \
        -DLIBTYPE=$(if $(BUILD_SHARED),SHARED,STATIC) \
        -DPREFIX=$(PREFIX) \
        -DTARGET=$(TARGET) \
        -DBUILD=$(BUILD) \
        -DCMAKE_TOOLCHAIN_DIR='$(CMAKE_TOOLCHAIN_DIR)' \
        -DINPUT='$(PWD)/src/cmake/conf/mxe-conf.cmake.in' \
        -DOUTPUT='$(CMAKE_TOOLCHAIN_FILE)'

    #create prefixed cmake wrapper script
    cmake-configure-file \
        -DCMAKE_VERSION=$(cmake_VERSION) \
        -DPREFIX=$(PREFIX) \
        -DTARGET=$(TARGET) \
        -DBUILD=$(BUILD) \
        -DCMAKE_TOOLCHAIN_FILE='$(CMAKE_TOOLCHAIN_FILE)' \
        -DCMAKE_RUNRESULT_FILE='$(CMAKE_RUNRESULT_FILE)' \
        -DINPUT='$(PWD)/src/cmake/conf/target-cmake.in' \
        -DOUTPUT='$(PREFIX)/bin/$(TARGET)-cmake'
    chmod 0755 '$(PREFIX)/bin/$(TARGET)-cmake'

    ln -sf '$(PREFIX)/$(BUILD)/bin/cpack' '$(PREFIX)/bin/$(TARGET)-cpack'
endef

define $(PKG)_BUILD_$(BUILD)
    # install cmake modules
    mkdir -p '$(PREFIX)/share/cmake/modules'
    $(INSTALL) -m644 '$(PWD)/src/cmake/modules/'* '$(PREFIX)/share/cmake/modules'

    # install cmake-configure-file for general use
    # cmake-configure-file -DINPUT -DOUTPUT -DFOO -DBAR -D...
    mkdir -p '$(PREFIX)/bin'
    echo 'configure_file($${INPUT} $${OUTPUT} @ONLY)' \
        > '$(PREFIX)/share/cmake/modules/configure_file.cmake'
    (echo '#!/usr/bin/env bash'; \
     echo 'exec "$(PREFIX)/$(BUILD)/bin/cmake" "$$@" \
                    -P "$(PREFIX)/share/cmake/modules/configure_file.cmake"'; \
    ) \
             > '$(PREFIX)/bin/cmake-configure-file'
    chmod 0755 '$(PREFIX)/bin/cmake-configure-file'
endef