CMakeLists.txt 4.24 KB
Newer Older
1 2
SET(PREFIX_ext_python "${EXTPREFIX}" )
if (UNIX)
Boudewijn Rempt's avatar
Boudewijn Rempt committed
3
    if (APPLE)
4
    set(PYTHON_VERSION "3.5")
Boudewijn Rempt's avatar
Boudewijn Rempt committed
5 6 7 8 9 10
    ExternalProject_Add( ext_python
	    DOWNLOAD_DIR ${EXTERNALS_DOWNLOAD_DIR}
    	URL http://files.kde.org/krita/build/dependencies/Python-3.5.2.tar.gz
        URL_MD5 ea334d398990037a4b8be324bd475c83
        
        PATCH_COMMAND ${PATCH_COMMAND} -p1 -i ${CMAKE_CURRENT_SOURCE_DIR}/pyport_osx.diff
11
            COMMAND ${PATCH_COMMAND} -p1 -i ${CMAKE_CURRENT_SOURCE_DIR}/osx_fixappinstall.diff
Boudewijn Rempt's avatar
Boudewijn Rempt committed
12

13 14
        CONFIGURE_COMMAND <SOURCE_DIR>/configure MACOSX_DEPLOYMENT_TARGET=10.11 -prefix=${PREFIX_ext_python} ${GLOBAL_AUTOMAKE_PROFILE}
        CONFIGURE_COMMAND <SOURCE_DIR>/configure MACOSX_DEPLOYMENT_TARGET=10.11 -prefix=${PREFIX_ext_python} --with-cxx-main=/usr/bin/g++ --without-ensurepip --without-gcc --enable-shared
15
            --with-cxx-main=/usr/bin/g++ --without-ensurepip --disable-tests --without-test --without-tests --enable-framework=${PREFIX_ext_python}/lib
Boudewijn Rempt's avatar
Boudewijn Rempt committed
16 17
        BUILD_COMMAND make
        INSTALL_COMMAND make install
18 19 20 21 22 23 24
            COMMAND ${CMAKE_COMMAND} -E copy ${PREFIX_ext_python}/bin/python3 ${PREFIX_ext_python}/bin/python
            COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/sitecustomize.py ${PREFIX_ext_python}/lib/Python.framework/Versions/Current/lib/python${PYTHON_VERSION}/
            COMMAND ${CMAKE_COMMAND} -E create_symlink ./lib/python${PYTHON_VERSION}/site-packages ${PREFIX_ext_python}/lib/Python.framework/Versions/Current/site-packages
            # CMake FindPythonLib can't find framework libraries, lack of mantainer for Python
            COMMAND find ${PREFIX_ext_python}/lib/Python.framework/Versions/Current/lib -type l -d 1
            | grep -o "[^/]*$"
            | xargs -I FILE ${CMAKE_COMMAND} -E create_symlink ./Python.framework/Python ${PREFIX_ext_python}/lib/FILE
Boudewijn Rempt's avatar
Boudewijn Rempt committed
25 26 27 28 29 30

        UPDATE_COMMAND ""
	    ALWAYS 0
    )
    else()

31 32 33 34 35 36 37 38 39 40 41 42 43
    ExternalProject_Add( ext_python
	    DOWNLOAD_DIR ${EXTERNALS_DOWNLOAD_DIR}
    	URL http://files.kde.org/krita/build/dependencies/Python-3.5.2.tar.gz
        URL_MD5 ea334d398990037a4b8be324bd475c83
        
        CONFIGURE_COMMAND <SOURCE_DIR>/configure --prefix=${PREFIX_ext_python}  ${GLOBAL_AUTOMAKE_PROFILE} --enable-shared
        BUILD_COMMAND make
        INSTALL_COMMAND make install
                        COMMAND ${CMAKE_COMMAND} -E copy ${PREFIX_ext_python}/bin/python3 ${PREFIX_ext_python}/bin/python

        UPDATE_COMMAND ""
	    ALWAYS 0
    )
Boudewijn Rempt's avatar
Boudewijn Rempt committed
44
    endif()
45
elseif(MINGW)
46
    if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
47
        ExternalProject_Add( ext_python
48
            DOWNLOAD_DIR ${EXTERNALS_DOWNLOAD_DIR}
49 50
            URL https://www.python.org/ftp/python/3.6.2/python-3.6.2-embed-amd64.zip
            URL_MD5 0fdfe9f79e0991815d6fc1712871c17f
51

52
            INSTALL_DIR ${PREFIX_ext_python}
53 54
            CONFIGURE_COMMAND ""
            BUILD_COMMAND ${CMAKE_COMMAND} -E echo deploying python3 64-bit binary
55
            INSTALL_COMMAND ${CMAKE_COMMAND} -E copy_directory <SOURCE_DIR>/ ${PREFIX_ext_python}/python
56 57
                    COMMAND ${CMAKE_COMMAND} -E copy <SOURCE_DIR>/python3.dll ${PREFIX_ext_python}/bin
                    COMMAND ${CMAKE_COMMAND} -E copy <SOURCE_DIR>/python36.dll ${PREFIX_ext_python}/bin
58
                    COMMAND ${CMAKE_COMMAND} -E copy <SOURCE_DIR>/vcruntime140.dll ${PREFIX_ext_python}/bin
59 60 61
            UPDATE_COMMAND ""
        )
    else("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
62
        ExternalProject_Add( ext_python
63
            DOWNLOAD_DIR ${EXTERNALS_DOWNLOAD_DIR}
64 65
            URL https://www.python.org/ftp/python/3.6.2/python-3.6.2-embed-win32.zip
            URL_MD5 2ca4768fdbadf6e670e97857bfab83e8
66

67
            INSTALL_DIR ${PREFIX_ext_python}
68 69
            CONFIGURE_COMMAND ""
            BUILD_COMMAND ${CMAKE_COMMAND} -E echo deploying python3 32-bit binary
70
            INSTALL_COMMAND ${CMAKE_COMMAND} -E copy_directory <SOURCE_DIR>/ ${PREFIX_ext_python}/python
71 72
                    COMMAND ${CMAKE_COMMAND} -E copy <SOURCE_DIR>/python3.dll ${PREFIX_ext_python}/bin
                    COMMAND ${CMAKE_COMMAND} -E copy <SOURCE_DIR>/python36.dll ${PREFIX_ext_python}/bin
73
                    COMMAND ${CMAKE_COMMAND} -E copy <SOURCE_DIR>/vcruntime140.dll ${PREFIX_ext_python}/bin
74 75 76 77
            UPDATE_COMMAND ""
        )
    endif("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")

78
endif()