Skip to content

Commit

Permalink
Merge 49b4d53 into 2a6aad9
Browse files Browse the repository at this point in the history
  • Loading branch information
dbrnz committed Oct 15, 2019
2 parents 2a6aad9 + 49b4d53 commit f2643b4
Show file tree
Hide file tree
Showing 158 changed files with 10,689 additions and 432 deletions.
122 changes: 122 additions & 0 deletions CMakeLists.txt
Expand Up @@ -31,6 +31,7 @@ option(USE_PREBUILT_LLVMCLANG_PACKAGE "Use the pre-built version of the LLVMClan
option(USE_PREBUILT_OAUTH_PACKAGE "Use the pre-built version of the OAuth package" ON)
option(USE_PREBUILT_OPENSSL_PACKAGE "Use the pre-built version of the OpenSSL package" ON)
option(USE_PREBUILT_PYTHON_PACKAGES_PACKAGE "Use the pre-built version of various Python packages" ON)
option(USE_PREBUILT_PYTHONQT_PACKAGE "Use the pre-built version of the PythonQt package" ON)
option(USE_PREBUILT_QSCINTILLA_PACKAGE "Use the pre-built version of the QScintilla package" ON)
option(USE_PREBUILT_QWT_PACKAGE "Use the pre-built version of the Qwt package" ON)
option(USE_PREBUILT_SUNDIALS_PACKAGE "Use the pre-built version of the SUNDIALS package" ON)
Expand Down Expand Up @@ -620,6 +621,13 @@ configure_file(${CMAKE_SOURCE_DIR}/res/common.qrc.in
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 @@ -648,6 +656,7 @@ set(SOURCES
src/plugins/plugininterface.cpp
src/plugins/pluginmanager.cpp
src/plugins/preferencesinterface.cpp
${PYTHON_INTERFACE_FILENAME}
src/plugins/solverinterface.cpp
src/plugins/viewinterface.cpp
src/plugins/windowinterface.cpp
Expand Down Expand Up @@ -685,6 +694,7 @@ if(WIN32)
src/plugins/plugininfo.cpp
src/plugins/plugininterface.cpp
src/plugins/pluginmanager.cpp
${PYTHON_INTERFACE_FILENAME}
src/plugins/solverinterface.cpp

src/windows/main.cpp
Expand Down Expand Up @@ -865,6 +875,7 @@ if(USE_PREBUILT_QTWEBKIT_PACKAGE)
list(APPEND PLUGINS
thirdParty/libSBML
thirdParty/PythonPackages
thirdParty/PythonQtAPI

dataStore/BioSignalMLDataStore
dataStore/CSVDataStore
Expand All @@ -882,6 +893,9 @@ if(USE_PREBUILT_QTWEBKIT_PACKAGE)
miscellaneous/Compiler
miscellaneous/Core
miscellaneous/HelpWindow
miscellaneous/JupyterKernel
miscellaneous/PythonQtConsoleWindow
miscellaneous/PythonShell
miscellaneous/WebBrowserWindow

organisation/FileBrowserWindow
Expand All @@ -901,6 +915,8 @@ if(USE_PREBUILT_QTWEBKIT_PACKAGE)
support/CellMLSupport
support/COMBINESupport
support/PMRSupport
support/PythonSupport
support/PythonQtSupport
support/SEDMLSupport
support/SimulationSupport
support/StandardSupport
Expand Down Expand Up @@ -958,6 +974,10 @@ if(USE_PREBUILT_QTWEBKIT_PACKAGE)
add_definitions(-DENABLE_TEST_PLUGINS)
endif()

# Let OpenCOR know that we want Python support

add_definitions(-DPYTHON_SUPPORT)

# Let OpenCOR know about the prebuilt version of our QtWebKit package
# being used

Expand Down Expand Up @@ -1013,6 +1033,13 @@ add_definitions(-D${CMAKE_PROJECT_NAME}_MAIN)

target_compile_definitions(${CMAKE_PROJECT_NAME} PRIVATE GUI_SUPPORT)

# We can't compile Python interface code until after the Python headers are in
# place

if(NOT "${PYTHON_DEPENDENCIES}" STREQUAL "")
add_dependencies(${CMAKE_PROJECT_NAME} ${PYTHON_DEPENDENCIES})
endif()

set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES
OUTPUT_NAME ${CMAKE_PROJECT_NAME}
LINK_FLAGS "${LINK_FLAGS_PROPERTIES}"
Expand All @@ -1023,6 +1050,7 @@ configure_clang_and_clang_tidy(${CMAKE_PROJECT_NAME})
if(WIN32)
target_link_libraries(${CMAKE_PROJECT_NAME}
${Qt5Core_QTMAIN_LIBRARIES}
${PYTHON_LIBRARY}
)
endif()

Expand All @@ -1032,6 +1060,16 @@ foreach(REQUIRED_QT_MODULE ${REQUIRED_QT_MODULES})
)
endforeach()

# Under Linux, the Python package needs linking directly to the executable as
# otherwise extension DSOs (which are loaded using dlopen()) can't find symbols
# (see https://www.akkadia.org/drepper/dsohowto.pdf for details)

if(NOT WIN32 AND NOT APPLE)
include_directories(${PYTHON_INCLUDE_DIR})
target_link_libraries(${CMAKE_PROJECT_NAME} ${PYTHON_LIBRARY})
add_dependencies(${CMAKE_PROJECT_NAME} PythonPlugin)
endif()

# Build the CLI version of OpenCOR (Windows specific)
# Note: when it comes to WINDOWS_CLI_PROJECT_NAME, we used to have it set to
# ${CMAKE_PROJECT_NAME}.com, but Ninja found a duplicate rule (from a copy
Expand All @@ -1045,6 +1083,17 @@ if(WIN32)
${WINDOWS_CLI_RESOURCES}
)

# We can't compile Python interface code until after the Python headers are
# in place

if(NOT "${PYTHON_DEPENDENCIES}" STREQUAL "")
add_dependencies(${WINDOWS_CLI_PROJECT_NAME} ${PYTHON_DEPENDENCIES})
endif()

target_link_libraries(${WINDOWS_CLI_PROJECT_NAME}
${PYTHON_LIBRARY}
)

set_target_properties(${WINDOWS_CLI_PROJECT_NAME} PROPERTIES
LINK_FLAGS "${LINK_FLAGS_PROPERTIES}"
)
Expand Down Expand Up @@ -1267,6 +1316,28 @@ if(WIN32)
windows_deploy_qt_plugin(sqldrivers qsqlite)
windows_deploy_qt_plugin(styles qwindowsvistastyle)

# Python runtime libraries and utilities

INSTALL(DIRECTORY ${PROJECT_BUILD_DIR}/Python
DESTINATION .)

# Scripts to setup and run Python and Jupyter

set(RUN_PYTHON_FILENAME "${PROJECT_BUILD_DIR}/run_python.bat")
configure_file(${CMAKE_SOURCE_DIR}/distrib/windows/run_python.bat.in
${RUN_PYTHON_FILENAME})

install(FILES ${CMAKE_SOURCE_DIR}/distrib/windows/IPython.bat
${CMAKE_SOURCE_DIR}/distrib/windows/JupyterLab.bat
${CMAKE_SOURCE_DIR}/distrib/windows/Notebook.bat
${CMAKE_SOURCE_DIR}/distrib/windows/run_jupyter.bat
${CMAKE_SOURCE_DIR}/distrib/windows/set_python_path.bat
${RUN_PYTHON_FILENAME}
DESTINATION .)

install(FILES ${CMAKE_SOURCE_DIR}/distrib/windows/start_jupyter.py
DESTINATION ./Python/Scripts)

# Batch and VBScript files to run OpenCOR (useful when downloading a ZIPped
# version of OpenCOR)

Expand Down Expand Up @@ -1299,6 +1370,12 @@ if(WIN32)
\\\${UnregisterExtension} \\\".cellml\\\" \\\"CellML File\\\"
System::Call \\\"Shell32::SHChangeNotify(i 0x08000000, i 0, i 0, i 0)\\\"
")

# Update Python scripts to refer to our installed Python

set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS
"${CPACK_NSIS_EXTRA_INSTALL_COMMANDS} Exec '\\\"\\\$INSTDIR\\\\Python\\\\bin\\\\python.exe\\\" \\\"\\\$INSTDIR\\\\Python\\\\Scripts\\\\set_python_path.py\\\" \\\"\\\$INSTDIR\\\\Python\\\" -s'
")
endif()
elseif(APPLE)
# Select PackageMaker and ZIP as the packagers on macOS
Expand All @@ -1317,6 +1394,29 @@ elseif(APPLE)
install(TARGETS ${CMAKE_PROJECT_NAME} BUNDLE
DESTINATION .)

# Shell scripts to setup and run Python and Jupyter

set(RUN_JUPYTER_FILENAME ${PROJECT_BUILD_DIR}/run_jupyter.sh)
configure_file(${CMAKE_SOURCE_DIR}/distrib/macos/run_jupyter.sh.in
${RUN_JUPYTER_FILENAME} @ONLY)

set(RUN_PYTHON_FILENAME ${PROJECT_BUILD_DIR}/run_python.sh)
configure_file(${CMAKE_SOURCE_DIR}/distrib/macos/run_python.sh.in
${RUN_PYTHON_FILENAME} @ONLY)

set(SET_PYTHON_PATH_FILENAME ${PROJECT_BUILD_DIR}/set_python_path.sh)
configure_file(${CMAKE_SOURCE_DIR}/distrib/macos/set_python_path.sh.in
${SET_PYTHON_PATH_FILENAME} @ONLY)

install(FILES ${CMAKE_SOURCE_DIR}/distrib/macos/ipython.sh
${CMAKE_SOURCE_DIR}/distrib/macos/jupyterlab.sh
${CMAKE_SOURCE_DIR}/distrib/macos/notebook.sh
${RUN_JUPYTER_FILENAME}
${RUN_PYTHON_FILENAME}
${SET_PYTHON_PATH_FILENAME}
DESTINATION .
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)

# Shell script to run OpenCOR (useful when downloading a ZIPped version of
# OpenCOR)

Expand Down Expand Up @@ -1384,6 +1484,28 @@ else()
linux_deploy_qt_plugin(sqldrivers qsqlite)
linux_deploy_qt_plugin(xcbglintegrations qxcb-egl-integration qxcb-glx-integration)


# Python runtime libraries and utilities

INSTALL(DIRECTORY ${PROJECT_BUILD_DIR}/python
DESTINATION .
USE_SOURCE_PERMISSIONS)

# Shell scripts to setup and run Python and Jupyter

set(RUN_PYTHON_FILENAME ${PROJECT_BUILD_DIR}/run_python.sh)
configure_file(${CMAKE_SOURCE_DIR}/distrib/linux/run_python.sh.in
${RUN_PYTHON_FILENAME} @ONLY)

install(FILES ${CMAKE_SOURCE_DIR}/distrib/linux/ipython.sh
${CMAKE_SOURCE_DIR}/distrib/linux/jupyterlab.sh
${CMAKE_SOURCE_DIR}/distrib/linux/notebook.sh
${CMAKE_SOURCE_DIR}/distrib/linux/run_jupyter.sh
${CMAKE_SOURCE_DIR}/distrib/linux/set_python_path.sh
${RUN_PYTHON_FILENAME}
DESTINATION .
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)

# Shell script to run OpenCOR

set(SH_FILENAME ${PROJECT_BUILD_DIR}/${CMAKE_PROJECT_NAME}.sh)
Expand Down
38 changes: 25 additions & 13 deletions cmake/common.cmake
Expand Up @@ -138,6 +138,10 @@ macro(build_documentation DOCUMENTATION_NAME)
${PROJECT_BUILD_DIR}/doc/${DOCUMENTATION_NAME}
)

# Make our local target depend on having Python fully installed

add_dependencies(${DOCUMENTATION_BUILD} ${PYTHON_DEPENDENCIES})

# Make our local target depend on our project build target and make our
# documentation build target depend on our local target

Expand Down Expand Up @@ -188,6 +192,7 @@ macro(add_plugin PLUGIN_NAME)
SYSTEM_BINARIES
DEPENDS_ON
TESTS
BYPRODUCTS
)

cmake_parse_arguments(ARG "${OPTIONS}" "${ONE_VALUE_KEYWORDS}" "${MULTI_VALUE_KEYWORDS}" ${ARGN})
Expand Down Expand Up @@ -276,22 +281,28 @@ macro(add_plugin PLUGIN_NAME)
)
endforeach()

# External binaries

if(NOT "${ARG_EXTERNAL_BINARIES_DIR}" STREQUAL "")
# Create a custom target for copying binaries
IF((NOT "${ARG_EXTERNAL_BINARIES_DIR}" STREQUAL "")
OR ( NOT "${ARG_EXTERNAL_DESTINATION_DIR}" STREQUAL ""
AND NOT "${ARG_EXTERNAL_SOURCE_DIR}" STREQUAL ""))
# Create a custom target for installing files
# Note: this is to prevent Ninja from getting confused with circular
# references...
# Note: we use this target in the PythonQtAPI build script when setting
# the PYTHON_DEPENDENCIES list

set(COPY_EXTERNAL_BINARIES_TARGET "COPY_${PROJECT_NAME}_EXTERNAL_BINARIES")
SET(INSTALL_EXTERNAL_FILES_TARGET "${PROJECT_NAME}_INSTALL_EXTERNAL_FILES")

add_custom_target(${COPY_EXTERNAL_BINARIES_TARGET})
add_dependencies(${PROJECT_NAME} ${COPY_EXTERNAL_BINARIES_TARGET})
ADD_CUSTOM_TARGET(${INSTALL_EXTERNAL_FILES_TARGET})
ADD_DEPENDENCIES(${PROJECT_NAME} ${INSTALL_EXTERNAL_FILES_TARGET})

if(NOT "${ARG_DEPENDS_ON}" STREQUAL "")
add_dependencies(${COPY_EXTERNAL_BINARIES_TARGET} ${ARG_DEPENDS_ON})
endif()
IF(NOT "${ARG_DEPENDS_ON}" STREQUAL "")
ADD_DEPENDENCIES(${INSTALL_EXTERNAL_FILES_TARGET} ${ARG_DEPENDS_ON})
ENDIF()
ENDIF()

# External binaries

if(NOT "${ARG_EXTERNAL_BINARIES_DIR}" STREQUAL "")
foreach(ARG_EXTERNAL_BINARY ${ARG_EXTERNAL_BINARIES})
# Make sure that the external binary exists

Expand All @@ -304,7 +315,7 @@ macro(add_plugin PLUGIN_NAME)
AND "${ARG_DEPENDS_ON}" STREQUAL "")
set(COPY_TARGET DIRECT)
else()
set(COPY_TARGET ${COPY_EXTERNAL_BINARIES_TARGET})
set(COPY_TARGET ${INSTALL_EXTERNAL_FILES_TARGET})
endif()

# Copy the external binary to its destination directory, so we can
Expand Down Expand Up @@ -376,9 +387,10 @@ macro(add_plugin PLUGIN_NAME)

# Copy the entire source directory to the destination

add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
add_custom_command(TARGET ${INSTALL_EXTERNAL_FILES_TARGET}
COMMAND ${CMAKE_COMMAND} -E copy_directory ${ARG_EXTERNAL_SOURCE_DIR}
${ARG_EXTERNAL_DESTINATION_DIR})
${ARG_EXTERNAL_DESTINATION_DIR}
BYPRODUCTS ${ARG_BYPRODUCTS})
endif()

# System binaries
Expand Down
4 changes: 3 additions & 1 deletion distrib/linux/application.sh.in
@@ -1,3 +1,5 @@
#!/bin/sh

bin/${CMAKE_PROJECT_NAME} $*
OPENCOR_DIR="$(cd "$(dirname "$0")"; pwd)"

${OPENCOR_DIR}/bin/@CMAKE_PROJECT_NAME@ $*
9 changes: 9 additions & 0 deletions distrib/linux/ipython.sh
@@ -0,0 +1,9 @@
#!/bin/sh

# Get the script's directory, which should be OpenCOR's base directory

OPENCOR_DIR="$(cd "$(dirname "$0")"; pwd)"

# Start an IPython console attached to an OpenCOR kernel

${OPENCOR_DIR}/run_jupyter.sh console --kernel OpenCOR $*
9 changes: 9 additions & 0 deletions distrib/linux/jupyterlab.sh
@@ -0,0 +1,9 @@
#!/bin/sh

# Get the script's directory, which should be OpenCOR's base directory

OPENCOR_DIR="$(cd "$(dirname "$0")"; pwd)"

# Start Jupyter Lab

${OPENCOR_DIR}/run_jupyter.sh lab --ip 127.0.0.1 $*
9 changes: 9 additions & 0 deletions distrib/linux/notebook.sh
@@ -0,0 +1,9 @@
#!/bin/sh

# Get the script's directory, which should be OpenCOR's base directory

OPENCOR_DIR="$(cd "$(dirname "$0")"; pwd)"

# Start Jupyter notebook

${OPENCOR_DIR}/run_jupyter.sh notebook --ip 127.0.0.1 $*
17 changes: 17 additions & 0 deletions distrib/linux/run_jupyter.sh
@@ -0,0 +1,17 @@
#!/bin/sh

# Get the script's directory, which should be OpenCOR's base directory

OPENCOR_DIR="$(cd "$(dirname "$0")"; pwd)"

# Make sure the path to Python is correct before starting Jupyter

${OPENCOR_DIR}/set_python_path.sh

# Make sure we can find the OpenCOR application to run as a Jupyter kernel

export PATH=${OPENCOR_DIR}:$PATH

# Start Jupyter

${OPENCOR_DIR}/python/bin/jupyter $*
13 changes: 13 additions & 0 deletions distrib/linux/run_python.sh.in
@@ -0,0 +1,13 @@
#!/bin/sh

# Get the script's directory, which should be OpenCOR's base directory

OPENCOR_DIR="$(cd "$(dirname "$0")"; pwd)"

# Make sure the path to Python is correct before starting Jupyter

${OPENCOR_DIR}/set_python_path.sh

# Start the OpenCOR plugin that runs Python code

${OPENCOR_DIR}/bin/@CMAKE_PROJECT_NAME@ -c Python $*
9 changes: 9 additions & 0 deletions distrib/linux/set_python_path.sh
@@ -0,0 +1,9 @@
#!/bin/sh

# Get the script's directory, which should be OpenCOR's base directory

OPENCOR_DIR="$(cd "$(dirname "$0")"; pwd)"

# Make sure the path to Python is correct

${OPENCOR_DIR}/python/bin/python ${OPENCOR_DIR}/python/bin/set_python_path.py ${OPENCOR_DIR}/python -s
4 changes: 3 additions & 1 deletion distrib/macos/application.sh.in
@@ -1,3 +1,5 @@
#!/bin/sh

${CMAKE_PROJECT_NAME}.app/Contents/MacOS/${CMAKE_PROJECT_NAME} $*
OPENCOR_DIR="$(cd "$(dirname "$0")"; pwd)"

${OPENCOR_DIR}/@CMAKE_PROJECT_NAME@.app/Contents/MacOS/@CMAKE_PROJECT_NAME@ $*

0 comments on commit f2643b4

Please sign in to comment.