Skip to content

Commit

Permalink
Merge b75be1f into aef1098
Browse files Browse the repository at this point in the history
  • Loading branch information
dbrnz committed Nov 25, 2019
2 parents aef1098 + b75be1f commit 2f90a70
Showing 1 changed file with 88 additions and 2 deletions.
90 changes: 88 additions & 2 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,6 +98,32 @@ if(WIN32)
)
endif()

if(NOT APPLE)
# On Linux and Windows we build bzip2.
# Note: it is provided by macOS...

set(BZIP2_VERSION "1.0.8")

# On Linux we bundle bzip2 with Python.
# Note: it is statically linked on Windows...

if(UNIX)
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})
else()
set(BZIP2_LIBRARY libbz2${CMAKE_STATIC_LIBRARY_SUFFIX})
endif()
endif()

if(NOT APPLE)
# On Windows and Linux, we bundle SQLite3 with Python
# Note: it is statically linked on macOS...
Expand Down Expand Up @@ -198,6 +226,58 @@ else()
set(PYTHON_READLINE_OPTION -DUSE_SYSTEM_READLINE=ON)
endif()

if(NOT APPLE)
# We 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()
else()
# macOS provides bzip2

find_package(BZip2 REQUIRED)
endif()

# Jupyter and IPython require SQLite3

if(WIN32)
Expand Down Expand Up @@ -257,8 +337,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 +379,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 @@ -354,6 +434,12 @@ else()

${PYTHON_READLINE_OPTION}

# Link to 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 2f90a70

Please sign in to comment.