Skip to content

Commit

Permalink
Merge 0f94a3c into f877460
Browse files Browse the repository at this point in the history
  • Loading branch information
dbrnz committed Oct 6, 2019
2 parents f877460 + 0f94a3c commit cc702d0
Show file tree
Hide file tree
Showing 156 changed files with 10,640 additions and 398 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 @@ -430,6 +431,7 @@ if(APPLE)
PrintSupport
Qml
Quick
QuickWidgets
Sensors
Sql
Svg
Expand Down Expand Up @@ -628,6 +630,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 @@ -656,6 +667,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 @@ -830,7 +842,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 @@ -867,13 +879,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 @@ -894,6 +908,9 @@ set(PLUGINS
miscellaneous/Compiler
miscellaneous/Core
miscellaneous/HelpWindow
miscellaneous/JupyterKernel
miscellaneous/PythonQtConsoleWindow
miscellaneous/Python
miscellaneous/WebBrowserWindow

organisation/FileBrowserWindow
Expand All @@ -913,6 +930,8 @@ set(PLUGINS
support/CellMLSupport
support/COMBINESupport
support/PMRSupport
support/PythonSupport
support/PythonQtSupport
support/SEDMLSupport
support/SimulationSupport
support/StandardSupport
Expand Down Expand Up @@ -940,18 +959,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 @@ -968,16 +1012,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 @@ -988,12 +1035,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 @@ -1004,6 +1059,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 @@ -1013,6 +1069,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 @@ -1022,10 +1088,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 @@ -1083,7 +1161,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 @@ -1233,7 +1311,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 @@ -1251,6 +1329,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 @@ -1283,6 +1383,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 @@ -1301,18 +1407,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 @@ -1349,7 +1479,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 @@ -1368,12 +1498,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 cc702d0

Please sign in to comment.