Blame view

morfeusz/python/CMakeLists.txt 3.21 KB
Michał Lenart authored
1
2
3

# SWIG
#set(CMAKE_SWIG_OUTDIR swig)
Michał Lenart authored
4
#~ FIND_PACKAGE (SWIG REQUIRED)
Michał Lenart authored
5
FIND_PACKAGE (PythonLibs)
Michał Lenart authored
6
#~ INCLUDE (${SWIG_USE_FILE})
Michał Lenart authored
7
8

set (PYMORFEUSZ_VERSION "0.1.0")
Michał Lenart authored
9
10

# SWIG Java
Michał Lenart authored
11
12
INCLUDE_DIRECTORIES (${PYTHON_INCLUDE_PATH})
INCLUDE_DIRECTORIES (..)
Michał Lenart authored
13
Michał Lenart authored
14
Michał Lenart authored
15
16
set (SWIG_PYTHON_OUTFILE_CXX "${CMAKE_CURRENT_BINARY_DIR}/swigPYTHON.cpp")
set (SWIG_PYTHON_OUTFILE_PY "${CMAKE_CURRENT_BINARY_DIR}/morfeusz2.py")
Michał Lenart authored
17
add_custom_command ( 
Michał Lenart authored
18
    OUTPUT "${SWIG_PYTHON_OUTFILE_CXX}" "${SWIG_PYTHON_OUTFILE_PY}"
Michał Lenart authored
19
    COMMAND swig -python -c++ -o "${SWIG_PYTHON_OUTFILE_CXX}" "${CMAKE_SOURCE_DIR}/morfeusz/morfeusz.i"
Michał Lenart authored
20
21
    DEPENDS libmorfeusz
)
Michał Lenart authored
22
add_custom_target (generate_python_wrapper
Michał Lenart authored
23
        DEPENDS "${SWIG_PYTHON_OUTFILE_CXX}" "${SWIG_PYTHON_OUTFILE_PY}")
Michał Lenart authored
24
Michał Lenart authored
25
set (SETUP_PY_IN "${CMAKE_CURRENT_SOURCE_DIR}/setup.py.in")
Michał Lenart authored
26
set (SETUP_PY_TMP    "${CMAKE_CURRENT_BINARY_DIR}/setupTmp.py")
Michał Lenart authored
27
set (SETUP_PY    "${CMAKE_CURRENT_BINARY_DIR}/setup.py")
Michał Lenart authored
28
set (DEPS        "${SWIG_PYTHON_OUTFILE_CXX}" "${SWIG_PYTHON_OUTFILE_PY}")
Michał Lenart authored
29
set (OUTPUT      "${CMAKE_CURRENT_BINARY_DIR}/build")
Michał Lenart authored
30
Michał Lenart authored
31
configure_file (${SETUP_PY_IN} ${SETUP_PY})
Michał Lenart authored
32
Michał Lenart authored
33
add_custom_target (generate_python_setup_file
Michał Lenart authored
34
        DEPENDS ${SETUP_PY})
Michał Lenart authored
35
Michał Lenart authored
36
37
38
add_custom_command (OUTPUT ${OUTPUT}
                       COMMAND python
                       ARGS ${SETUP_PY} build
Michał Lenart authored
39
                       DEPENDS generate_python_wrapper generate_python_setup_file libmorfeusz)
Michał Lenart authored
40
Michał Lenart authored
41
add_custom_target (build_python_wrapper
Michał Lenart authored
42
43
        DEPENDS ${OUTPUT})
Michał Lenart authored
44
add_custom_target (pymorfeusz
Michał Lenart authored
45
        DEPENDS generate_python_wrapper generate_python_setup_file libmorfeusz build_python_wrapper)
Michał Lenart authored
46
47
48
49

if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
    add_custom_target (install-python
        COMMAND python ${SETUP_PY} install --home=${CMAKE_INSTALL_PREFIX}
Michał Lenart authored
50
        DEPENDS pymorfeusz
Michał Lenart authored
51
52
    )
    add_custom_target (package-python-bin
Michał Lenart authored
53
        COMMAND python ${SETUP_PY} bdist_egg -d "${TARGET_DIR}" --plat-name "${CMAKE_SYSTEM_NAME}-${ARCHITECTURE}"
Michał Lenart authored
54
55
        DEPENDS pymorfeusz
    )
Michał Lenart authored
56
    set (PACKAGE_DEPENDS "package-python-bin")
Michał Lenart authored
57
Michał Lenart authored
58
    add_custom_target (package-python-deb-sdist
Michał Lenart authored
59
        COMMAND python ${SETUP_PY} --command-packages=stdeb.command sdist_dsc --depends "${CPACK_DEBIAN_PACKAGE_NAME}" --copyright-file "${PROJECT_SOURCE_DIR}/License.txt"
Michał Lenart authored
60
61
62
63
64
65
66
67
68
69
70
71
        DEPENDS pymorfeusz
    )
    add_custom_target (package-python-deb-build
        COMMAND debuild -us -uc
        WORKING_DIRECTORY deb_dist/morfeusz2-${PYMORFEUSZ_VERSION}
        DEPENDS package-python-deb-sdist
    )
    add_custom_target(package-python-deb
        COMMAND mkdir -p "${TARGET_DIR}" && cp ${CMAKE_CURRENT_BINARY_DIR}/deb_dist/python-morfeusz2*.deb "${TARGET_DIR}"
        DEPENDS package-python-deb-build
    )
    list (APPEND PACKAGE_DEPENDS package-python-deb)
Michał Lenart authored
72
73
74
    message ("PACKAGE_DEPENDS=${PACKAGE_DEPENDS}")
    add_custom_target (package-python
        DEPENDS pymorfeusz ${PACKAGE_DEPENDS})
Michał Lenart authored
75
76
77
78
79
80
81
82
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Windows" AND NOT CMAKE_CROSSCOMPILING)
    add_custom_target (package-python-win-installer
        COMMAND python ${SETUP_PY} bdist_wininst -d ${TARGET_DIR} --plat-name "${CMAKE_SYSTEM_NAME}-${ARCHITECTURE}"
        DEPENDS pymorfeusz
    )
    list (APPEND PACKAGE_DEPENDS package-python-win-installer)
    add_custom_target (package-python
        DEPENDS pymorfeusz ${PACKAGE_DEPENDS})
Michał Lenart authored
83
endif ()