Skip to content

Commit

Permalink
Merge 333c5a0 into aef1098
Browse files Browse the repository at this point in the history
  • Loading branch information
dbrnz committed Nov 26, 2019
2 parents aef1098 + 333c5a0 commit e4c58c3
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 16 deletions.
11 changes: 2 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -635,13 +635,6 @@ set(I18N_QRC_FILENAME ${PROJECT_BUILD_DIR}/res/i18n.qrc)
configure_file(${CMAKE_SOURCE_DIR}/res/common.qrc.in ${COMMON_QRC_FILENAME})
configure_file(${CMAKE_SOURCE_DIR}/res/i18n.qrc.in ${I18N_QRC_FILENAME})

# The Python interface depends on Python headers, so we only include it if we
# are using the prebuilt version of our Python and QtWebKit packages

if(USE_PREBUILT_PYTHON_AND_QTWEBKIT_PACKAGES)
set(PYTHON_INTERFACE_FILENAME src/plugins/pythoninterface.cpp)
endif()

# Files that make up the GUI version of OpenCOR

set(SOURCES
Expand Down Expand Up @@ -670,7 +663,7 @@ set(SOURCES
src/plugins/plugininterface.cpp
src/plugins/pluginmanager.cpp
src/plugins/preferencesinterface.cpp
${PYTHON_INTERFACE_FILENAME}
src/plugins/pythoninterface.cpp
src/plugins/solverinterface.cpp
src/plugins/viewinterface.cpp
src/plugins/windowinterface.cpp
Expand Down Expand Up @@ -708,7 +701,7 @@ if(WIN32)
src/plugins/plugininfo.cpp
src/plugins/plugininterface.cpp
src/plugins/pluginmanager.cpp
${PYTHON_INTERFACE_FILENAME}
src/plugins/pythoninterface.cpp
src/plugins/solverinterface.cpp

src/windows/main.cpp
Expand Down
101 changes: 94 additions & 7 deletions src/plugins/thirdParty/Python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ endif()

set(EXTERNAL_BINARIES_DIR ${FULL_LOCAL_EXTERNAL_PACKAGE_DIR}/${LIBRARY_DIR})

# Specify the package's files

set(EXTERNAL_BINARIES
${SHARED_LIBRARY}
)
Expand All @@ -96,8 +98,33 @@ if(WIN32)
)
endif()

# Do a few things that are specific to Windows and Linux

if(NOT APPLE)
# On Windows and Linux, we bundle SQLite3 with Python
# Build bzip2
# Note: bzip2 is provided by macOS...

set(BZIP2_VERSION "1.0.8")

# Statically link bzip2 on Windows while bundle it on Linux

if(WIN32)
set(BZIP2_LIBRARY libbz2${CMAKE_STATIC_LIBRARY_SUFFIX})
else()
set(BZIP2_SHARED_LIBRARY ${CMAKE_SHARED_LIBRARY_PREFIX}bz2${CMAKE_SHARED_LIBRARY_SUFFIX})

list(APPEND EXTERNAL_BINARIES
${BZIP2_SHARED_LIBRARY}
)

list(APPEND SHA1_FILES
${LIBRARY_DIR}/${BZIP2_SHARED_LIBRARY}
)

set(BZIP2_LIBRARY ${BZIP2_SHARED_LIBRARY}.${BZIP2_VERSION})
endif()

# Bundle SQLite3 with Python
# Note: it is statically linked on macOS...

set(SQLITE3_SHARED_LIBRARY ${CMAKE_SHARED_LIBRARY_PREFIX}sqlite3${CMAKE_SHARED_LIBRARY_SUFFIX})
Expand Down Expand Up @@ -180,11 +207,12 @@ if(USE_PREBUILT_PYTHON_PACKAGE)
40af4e4c511a9a3a4b6a47446505c1fb60881d59)
else()
retrieve_package_file(${PACKAGE_NAME} ${PACKAGE_VERSION}
${FULL_LOCAL_EXTERNAL_PACKAGE_DIR} 1cba87d6b63612d68220b99e700129b58ec9c69d
${FULL_LOCAL_EXTERNAL_PACKAGE_DIR} 8a32d24a1275a1bbaf2cef7811f6cd5a21b370bf
PACKAGE_REPOSITORY ${PACKAGE_REPOSITORY}
SHA1_FILES ${SHA1_FILES}
SHA1_VALUES 64a4e7209f41144c49809e53d9b2a51b27e69b12
6338b2c1af385ee874996e3ab60ed06b1004f3b7
SHA1_VALUES 06aec6cd236cefb7206f1f6f43fa6220e398adff
dad9acba5c825edab5af6e825ae1715d0842e825
57534423f92eb3a881b8dc781efb6857cc257874
561eee6b2f229c953eae711f40b25e834fb1124a)
endif()
else()
Expand All @@ -198,6 +226,59 @@ else()
set(PYTHON_READLINE_OPTION -DUSE_SYSTEM_READLINE=ON)
endif()

if(APPLE)
# macOS provides bzip2

find_package(BZip2 REQUIRED)
else()
# Build bzip2 for Windows and Linux

set(BZIP2_LIBRARY_DIR ${PROJECT_BINARY_DIR}/bzip2-opencor-${BZIP2_VERSION})

if(NOT EXISTS ${BZIP2_LIBRARY_DIR}/bzlib.h)
set(BZIP2_SOURCE_ARCHIVE bzip2-${BZIP2_VERSION}.tar.gz)

message("Downloading '${BZIP2_SOURCE_ARCHIVE}'...")

file(DOWNLOAD https://github.com/opencor/bzip2/archive/opencor-${BZIP2_VERSION}.tar.gz ${PROJECT_BINARY_DIR}/downloads/${BZIP2_SOURCE_ARCHIVE}
SHOW_PROGRESS)

execute_process(COMMAND ${CMAKE_COMMAND} -E tar -xzf downloads/${BZIP2_SOURCE_ARCHIVE}
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
OUTPUT_QUIET)

message("Building '${BZIP2_LIBRARY}'...")

if(WIN32)
execute_process(COMMAND nmake -f makefile.msc lib
WORKING_DIRECTORY ${BZIP2_LIBRARY_DIR}
OUTPUT_QUIET)
else()
execute_process(COMMAND make -f Makefile-libbz2_so
WORKING_DIRECTORY ${BZIP2_LIBRARY_DIR}
OUTPUT_QUIET)

# Rename bzip2's library and copy it to the plugin's external
# binaries directory

file(RENAME ${BZIP2_LIBRARY_DIR}/${BZIP2_LIBRARY}
${BZIP2_LIBRARY_DIR}/${BZIP2_SHARED_LIBRARY})

file(COPY ${BZIP2_LIBRARY_DIR}/${BZIP2_SHARED_LIBRARY}
DESTINATION ${EXTERNAL_BINARIES_DIR}
FILE_PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
endif()
endif()

set(BZIP2_INCLUDE_DIR ${BZIP2_LIBRARY_DIR})

if(WIN32)
set(BZIP2_LIBRARIES ${BZIP2_LIBRARY_DIR}/${BZIP2_LIBRARY})
else()
set(BZIP2_LIBRARIES ${EXTERNAL_BINARIES_DIR}/${BZIP2_SHARED_LIBRARY})
endif()
endif()

# Jupyter and IPython require SQLite3

if(WIN32)
Expand Down Expand Up @@ -257,8 +338,6 @@ else()
if(NOT APPLE)
# Copy SQLite3's library to the plugin's external binaries directory

file(MAKE_DIRECTORY ${EXTERNAL_BINARIES_DIR})

execute_process(COMMAND ${CMAKE_COMMAND} -E copy ${SQLITE3_LIBRARY_DIR}/${SQLITE3_SHARED_LIBRARY}
${EXTERNAL_BINARIES_DIR})

Expand Down Expand Up @@ -301,6 +380,8 @@ else()
CMAKE_ARGS
${CMAKE_ARGS}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
${CMAKE_INSTALL_RPATH_OPTION}

Expand Down Expand Up @@ -337,7 +418,7 @@ else()

-DPYTHON_APPLY_PATCHES=${APPLY_PATCHES}

# Disable extension modules that we don't use or the platform
# Disable extension modules that we don't use or that the platform
# doesn't provide

-DENABLE_BSDDB=OFF
Expand All @@ -354,6 +435,12 @@ else()

${PYTHON_READLINE_OPTION}

# Link to the bzip2 library

-DUSE_SYSTEM_BZip2=OFF
-DBZIP2_INCLUDE_DIR=${BZIP2_INCLUDE_DIR}
-DBZIP2_LIBRARIES=${BZIP2_LIBRARIES}

# Use our OpenSSL

-DUSE_SYSTEM_OpenSSL=OFF
Expand Down

0 comments on commit e4c58c3

Please sign in to comment.