Skip to content

Commit

Permalink
Merge aacc4fb into c468fc0
Browse files Browse the repository at this point in the history
  • Loading branch information
dbrnz committed Sep 27, 2019
2 parents c468fc0 + aacc4fb commit df5db1d
Show file tree
Hide file tree
Showing 154 changed files with 10,526 additions and 377 deletions.
186 changes: 169 additions & 17 deletions CMakeLists.txt
Expand Up @@ -29,8 +29,9 @@ option(USE_PREBUILT_LIBXDIFF_PACKAGE "Use the pre-built version of the LibXDiff
option(USE_PREBUILT_LLVMCLANG_PACKAGE "Use the pre-built version of the LLVMClang package" ON)
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_PACKAGE "Use the pre-built version of the Python package" ON)
option(USE_PREBUILT_PYTHON_LIBRARY_PACKAGE "Use the pre-built version of the Python library package" ON)
option(USE_PREBUILT_PYTHON_PACKAGES_PACKAGE "Use the pre-built version of Python site packages" ON)
option(USE_PREBUILT_PYTHONQT_PACKAGE "Use the pre-built version of the Python Qt 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 @@ -425,6 +426,7 @@ if(APPLE)
QtPrintSupport
QtQml
QtQuick
QtQuickWidgets
QtSensors
QtSql
QtSvg
Expand Down Expand Up @@ -616,6 +618,15 @@ 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
# when the Python library is not being built

if(USE_PREBUILT_PYTHON_LIBRARY_PACKAGE)
set(PYTHON_INTERFACE
src/plugins/pythoninterface.cpp
)
endif()

# Files that make up the GUI version of OpenCOR

set(SOURCES
Expand Down Expand Up @@ -644,6 +655,7 @@ set(SOURCES
src/plugins/plugininterface.cpp
src/plugins/pluginmanager.cpp
src/plugins/preferencesinterface.cpp
${PYTHON_INTERFACE}
src/plugins/solverinterface.cpp
src/plugins/viewinterface.cpp
src/plugins/windowinterface.cpp
Expand Down Expand Up @@ -818,7 +830,7 @@ if(ENABLE_TESTS)
endif()
endif()

# Specify a target to help us build certain plugins (e.g. our Python plugin)
# Specify a target to help us build certain plugins (e.g. our Python library plugin)

set(PROJECT_BUILD_TARGET ${PROJECT_NAME}Build)

Expand Down Expand Up @@ -855,13 +867,15 @@ if(ENABLE_TEST_PLUGINS)
)
endif()

set(PLUGINS
set(THIRDPARTY_BASE_PLUGINS
thirdParty/OpenSSL
thirdParty/zlib
)

set(PLUGIN_PLUGINS
thirdParty/libSBML
thirdParty/Python
thirdParty/PythonPackages
thirdParty/PythonQtAPI

${SAMPLE_PLUGINS}
${TEST_PLUGINS}
Expand All @@ -882,6 +896,9 @@ set(PLUGINS
miscellaneous/Compiler
miscellaneous/Core
miscellaneous/HelpWindow
miscellaneous/JupyterKernel
miscellaneous/PythonQtConsoleWindow
miscellaneous/Python
miscellaneous/WebBrowserWindow

organisation/FileBrowserWindow
Expand All @@ -901,6 +918,8 @@ set(PLUGINS
support/CellMLSupport
support/COMBINESupport
support/PMRSupport
support/PythonSupport
support/PythonQtSupport
support/SEDMLSupport
support/SimulationSupport
support/StandardSupport
Expand Down Expand Up @@ -928,18 +947,43 @@ set(PLUGINS
)

if(ENABLE_TEST_PLUGINS)
list(APPEND PLUGINS
list(APPEND PLUGIN_PLUGINS
thirdParty/Zinc

widget/ZincWidget
)
endif()

if(USE_PREBUILT_PYTHON_LIBRARY_PACKAGE)
# We are not building the Python library, so build all our plugins

set(PLUGINS
${THIRDPARTY_BASE_PLUGINS}

thirdParty/PythonLibrary

${PLUGIN_PLUGINS}
)
else()
# We want to build our copy of the Python library package, so don't build any
# plugins apart from third party ones that are part of Python, since others may
# require Python headers that don't yet exist

set(PLUGINS
${THIRDPARTY_BASE_PLUGINS}

thirdParty/PythonLibrary
)
add_definitions(-DEXCLUDE_PYTHON)
endif()

if(NOT USE_PREBUILT_QTWEBKIT_PACKAGE)
# We want to build our copy of the QtWebKit package, so don't build any
# of our plugins since some of them may require QtWebKit

set(PLUGINS)
set(PYTHON_INTERFACE)
add_definitions(-DEXCLUDE_PYTHON)
endif()

foreach(PLUGIN ${PLUGINS})
Expand All @@ -956,16 +1000,19 @@ foreach(PLUGIN ${PLUGINS})
add_subdirectory(src/plugins/${PLUGIN})
endforeach()

# Fetch parts of our documentation and build it
if(USE_PREBUILT_PYTHON_LIBRARY_PACKAGE)
# We have already built Python and hence have Sphinx available, so we can
# fetch parts of our documentation and build it

execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/doc
${PROJECT_BUILD_DIR}/doc)
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/doc
${PROJECT_BUILD_DIR}/doc)

configure_file(${PROJECT_BUILD_DIR}/doc/${CMAKE_PROJECT_NAME}.qhcp.in
${PROJECT_BUILD_DIR}/doc/${CMAKE_PROJECT_NAME}.qhcp)
configure_file(${PROJECT_BUILD_DIR}/doc/${CMAKE_PROJECT_NAME}.qhcp.in
${PROJECT_BUILD_DIR}/doc/${CMAKE_PROJECT_NAME}.qhcp)

build_documentation(user)
build_documentation(developer)
build_documentation(user)
build_documentation(developer)
endif()

# Build the GUI version of OpenCOR

Expand All @@ -976,12 +1023,20 @@ if(APPLE)
endif()

add_executable(${CMAKE_PROJECT_NAME} WIN32 MACOSX_BUNDLE
${PYTHON_INTERFACE}
${SOURCES}
${RESOURCES}
)

add_definitions(-D${CMAKE_PROJECT_NAME}_MAIN)

# 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 @@ -992,6 +1047,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 @@ -1001,6 +1057,16 @@ foreach(REQUIRED_QT_MODULE ${REQUIRED_QT_MODULES})
)
endforeach()

# Under Linux the Python library 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} PythonLibraryPlugin)
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 @@ -1010,10 +1076,22 @@ if(WIN32)
set(WINDOWS_CLI_PROJECT_NAME ${CMAKE_PROJECT_NAME}_com)

add_executable(${WINDOWS_CLI_PROJECT_NAME}
${PYTHON_INTERFACE}
${WINDOWS_CLI_SOURCES}
${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}
)

target_compile_definitions(${WINDOWS_CLI_PROJECT_NAME}
PRIVATE CLI_VERSION)

Expand Down Expand Up @@ -1071,7 +1149,7 @@ if(APPLE)
else()
# Make sure that OpenCOR uses RPATH rather than RUNPATH on Linux

if(NOT WIN32 AND NOT APPLE)
if(NOT WIN32)
runpath2rpath(${PROJECT_NAME} ${PROJECT_BUILD_DIR}/${CMAKE_PROJECT_NAME})
endif()

Expand Down Expand Up @@ -1221,7 +1299,7 @@ if(WIN32)

# Qt libraries required by OpenCOR

foreach(QT_LIBRARY Core Gui Help Multimedia MultimediaWidgets Network OpenGL Positioning PrintSupport Qml Quick Sensors Sql Svg ${TEST} WebChannel ${WEBKIT} ${WEBKITWIDGETS} Widgets Xml XmlPatterns)
foreach(QT_LIBRARY Core Gui Help Multimedia MultimediaWidgets Network OpenGL Positioning PrintSupport Qml Quick QuickWidgets Sensors Sql Svg ${TEST} WebChannel ${WEBKIT} ${WEBKITWIDGETS} Widgets Xml XmlPatterns)
windows_deploy_qt_library(Qt5${QT_LIBRARY})
endforeach()

Expand All @@ -1239,6 +1317,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 @@ -1271,6 +1371,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 @@ -1289,18 +1395,42 @@ 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)

set(SH_FILENAME ${PROJECT_BUILD_DIR}/${CMAKE_PROJECT_NAME}.sh)

configure_file(${CMAKE_SOURCE_DIR}/distrib/macos/application.sh.in
${SH_FILENAME})
${SH_FILENAME} @ONLY)

install(FILES ${SH_FILENAME}
DESTINATION .
RENAME ${CMAKE_PROJECT_NAME}
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)

else()
# Select TGZ as the packager on Linux

Expand Down Expand Up @@ -1337,7 +1467,7 @@ else()
# unnecessarily cumbersome to use, it's better to deploy one Qt
# library at a time...

foreach(QT_LIBRARY Core DBus Gui Help Multimedia MultimediaWidgets Network OpenGL Positioning PrintSupport Qml Quick Sensors Sql Svg ${TEST} WebChannel ${WEBKIT} ${WEBKITWIDGETS} Widgets XcbQpa Xml XmlPatterns)
foreach(QT_LIBRARY Core DBus Gui Help Multimedia MultimediaWidgets Network OpenGL Positioning PrintSupport Qml Quick QuickWidgets Sensors Sql Svg ${TEST} WebChannel ${WEBKIT} ${WEBKITWIDGETS} Widgets XcbQpa Xml XmlPatterns)
if( "${QT_LIBRARY}" STREQUAL "${WEBKIT}"
OR "${QT_LIBRARY}" STREQUAL "${WEBKITWIDGETS}")
set(REAL_QT_LIBRARY_DIR ${QTWEBKIT_LIBRARIES_DIR})
Expand All @@ -1356,12 +1486,34 @@ 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)

configure_file(${CMAKE_SOURCE_DIR}/distrib/linux/application.sh.in
${SH_FILENAME})
${SH_FILENAME} @ONLY)

install(FILES ${SH_FILENAME}
DESTINATION .
Expand Down

0 comments on commit df5db1d

Please sign in to comment.