Skip to content

Commit

Permalink
Added OpenSSL as a third-party plugin (closes #1101).
Browse files Browse the repository at this point in the history
  • Loading branch information
agarny committed May 10, 2017
2 parents 5737e13 + 403a7b2 commit d2d30ad
Show file tree
Hide file tree
Showing 10 changed files with 443 additions and 151 deletions.
32 changes: 8 additions & 24 deletions CMakeLists.txt
Expand Up @@ -18,10 +18,11 @@ OPTION(USE_PREBUILT_LIBGIT2_PLUGIN "Use the pre-built version of the libgit2 plu
OPTION(USE_PREBUILT_LIBXDIFF_PLUGIN "Use the pre-built version of the LibXDiff plugin" ON)
OPTION(USE_PREBUILT_LLVM_PLUGIN "Use the pre-built version of the LLVM plugin" ON)
OPTION(USE_PREBUILT_OAUTH_PLUGIN "Use the pre-built version of the OAuth plugin" ON)
OPTION(USE_PREBUILT_OPENSSL_PACKAGE "Use the pre-built version of the OpenSSL package" ON)
OPTION(USE_PREBUILT_QSCINTILLA_PLUGIN "Use the pre-built version of the QScintilla plugin" ON)
OPTION(USE_PREBUILT_QWT_PLUGIN "Use the pre-built version of the Qwt plugin" ON)
OPTION(USE_PREBUILT_SUNDIALS_PLUGIN "Use the pre-built version of the SUNDIALS plugin" ON)
OPTION(USE_PREBUILT_ZLIB_PLUGIN "Use the pre-built version of the zlib plugin" ON)
OPTION(USE_PREBUILT_ZLIB_PACKAGE "Use the pre-built version of the zlib package" ON)

# Initialise the project

Expand Down Expand Up @@ -337,6 +338,7 @@ SET(PLUGINS
thirdParty/LibXDiff
thirdParty/LLVM
thirdParty/OAuth
thirdParty/OpenSSL
thirdParty/QScintilla
thirdParty/Qwt
thirdParty/SUNDIALS
Expand Down Expand Up @@ -469,9 +471,9 @@ FOREACH(REQUIRED_QT_MODULE ${REQUIRED_QT_MODULES})
ENDFOREACH()

# Build the CLI version of OpenCOR (Windows specific)
# Note: when it comes WINDOWS_CLI_PROJECT_NAME, we used to have it set to
# ${CMAKE_PROJECT_NAME}.com, but Ninja used to find a duplicate rule (from
# a copy command), so we use '_' instead of '.'...
# 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
# command), so now we use '_' instead of '.'...

IF(WIN32)
QT5_WRAP_CPP(WINDOWS_CLI_SOURCES_MOC ${WINDOWS_CLI_HEADERS_MOC})
Expand Down Expand Up @@ -537,16 +539,6 @@ IF(APPLE)

MACOS_CLEAN_UP_FILE_WITH_QT_DEPENDENCIES(${CMAKE_PROJECT_NAME} ${PROJECT_BUILD_DIR}/${CMAKE_PROJECT_NAME}.app/Contents/MacOS ${CMAKE_PROJECT_NAME})

# Deploy the OpenSSL libraries

FOREACH(OPENSSL_LIBRARY ${OPENSSL_LIBRARIES})
GET_FILENAME_COMPONENT(REAL_OPENSSL_LIBRARY ${OPENSSL_LIBRARY} REALPATH)
GET_FILENAME_COMPONENT(REAL_OPENSSL_LIBRARY_DIRNAME ${REAL_OPENSSL_LIBRARY} DIRECTORY)
GET_FILENAME_COMPONENT(REAL_OPENSSL_LIBRARY_FILENAME ${REAL_OPENSSL_LIBRARY} NAME)

MACOS_DEPLOY_LIBRARY(${REAL_OPENSSL_LIBRARY_DIRNAME} ${REAL_OPENSSL_LIBRARY_FILENAME})
ENDFOREACH()

# Deploy our Qt libraries
# Note: the Qt Brew formula that we use on Travis CI misses QtDBus, which
# results in some of our tests generating messages about two
Expand Down Expand Up @@ -642,14 +634,6 @@ ELSE()
${WINDOWS_KIT_DIRNAME}/ucrtbase.dll
)

RETRIEVE_BINARY_FILE(distrib/windows libeay32.dll d34a0ba0dd7b3b1f900a7e02772e197e974b4a73)
RETRIEVE_BINARY_FILE(distrib/windows ssleay32.dll 2ee9966a0fc163da58408d91be36b84fa287c10b)

LIST(APPEND ADDITIONAL_FILES
${CMAKE_SOURCE_DIR}/distrib/bin/libeay32.dll
${CMAKE_SOURCE_DIR}/distrib/bin/ssleay32.dll
)

FOREACH(ADDITIONAL_FILE ${ADDITIONAL_FILES})
GET_FILENAME_COMPONENT(DIRNAME ${ADDITIONAL_FILE} DIRECTORY)
GET_FILENAME_COMPONENT(FILENAME ${ADDITIONAL_FILE} NAME)
Expand Down Expand Up @@ -851,9 +835,9 @@ ELSE()
DESTINATION lib
RENAME libstdc++.so.6)

# Libraries needed on Fedora, but not on Ubuntu
# Library needed on Fedora, but not on Ubuntu

FOREACH(LIBRARY bz2.so.1.0 crypto.so.1.0.0 ssl.so.1.0.0)
FOREACH(LIBRARY bz2.so.1.0)
SET(FULL_LIBRARY ${CMAKE_SHARED_LIBRARY_PREFIX}${LIBRARY})

GET_FILENAME_COMPONENT(REAL_FULL_LIBRARY /lib/x86_64-linux-gnu/${FULL_LIBRARY} REALPATH)
Expand Down
80 changes: 4 additions & 76 deletions cmake/common.cmake
Expand Up @@ -55,14 +55,6 @@ MACRO(INITIALISE_PROJECT)
MESSAGE(FATAL_ERROR "${CMAKE_PROJECT_NAME} can only be built in release or debug mode...")
ENDIF()

# Make sure that OpenSSL is available on Linux and macOS
# Note: it's currently needed for libgit2, but it might be needed for other
# things too in the future, so make sure it's available...

IF(NOT WIN32)
FIND_PACKAGE(OpenSSL REQUIRED QUIET)
ENDIF()

# Required Qt modules and packages

IF(ENABLE_TESTS)
Expand Down Expand Up @@ -285,7 +277,7 @@ MACRO(INITIALISE_PROJECT)

ADD_DEFINITIONS(-DQT_DEPRECATED_WARNINGS)

# Let OpenCOR know about the options with which it was built
# Let OpenCOR know about some of the options with which it was built

IF(ENABLE_SAMPLE_PLUGINS)
ADD_DEFINITIONS(-DENABLE_SAMPLE_PLUGINS)
Expand All @@ -295,38 +287,6 @@ MACRO(INITIALISE_PROJECT)
ADD_DEFINITIONS(-DENABLE_TEST_PLUGINS)
ENDIF()

IF(ENABLE_TESTS)
ADD_DEFINITIONS(-DENABLE_TESTS)
ENDIF()

IF(USE_PREBUILT_LIBGIT2_PLUGIN)
ADD_DEFINITIONS(-DUSE_PREBUILT_LIBGIT2_PLUGIN)
ENDIF()

IF(USE_PREBUILT_LIBXDIFF_PLUGIN)
ADD_DEFINITIONS(-DUSE_PREBUILT_LIBXDIFF_PLUGIN)
ENDIF()

IF(USE_PREBUILT_LLVM_PLUGIN)
ADD_DEFINITIONS(-DUSE_PREBUILT_LLVM_PLUGIN)
ENDIF()

IF(USE_PREBUILT_QSCINTILLA_PLUGIN)
ADD_DEFINITIONS(-DUSE_PREBUILT_QSCINTILLA_PLUGIN)
ENDIF()

IF(USE_PREBUILT_QWT_PLUGIN)
ADD_DEFINITIONS(-DUSE_PREBUILT_QWT_PLUGIN)
ENDIF()

IF(USE_PREBUILT_SUNDIALS_PLUGIN)
ADD_DEFINITIONS(-DUSE_PREBUILT_SUNDIALS_PLUGIN)
ENDIF()

IF(USE_PREBUILT_ZLIB_PLUGIN)
ADD_DEFINITIONS(-DUSE_PREBUILT_ZLIB_PLUGIN)
ENDIF()

# On macOS, make sure that we support 10.8 and later, unless a specific
# deployment target has been specified

Expand Down Expand Up @@ -1233,35 +1193,6 @@ MACRO(MACOS_CLEAN_UP_FILE PROJECT_TARGET DIRNAME FILENAME)
ADD_CUSTOM_COMMAND(TARGET ${PROJECT_TARGET} POST_BUILD
COMMAND install_name_tool -id @rpath/${FILENAME} ${FULL_FILENAME})
ENDIF()

# Make sure that the file refers to our embedded copy of OpenSSL
# Note: we try two different paths for a given OpenSSL library since the
# former path will be used by libssl.1.0.0.dylib while the latter path
# will be used by our plugins...

FOREACH(OPENSSL_LIBRARY ${OPENSSL_LIBRARIES})
GET_FILENAME_COMPONENT(REAL_OPENSSL_LIBRARY ${OPENSSL_LIBRARY} REALPATH)
GET_FILENAME_COMPONENT(REAL_OPENSSL_LIBRARY_DIRNAME ${OPENSSL_LIBRARY} DIRECTORY)
GET_FILENAME_COMPONENT(REAL_OPENSSL_LIBRARY_FILENAME ${REAL_OPENSSL_LIBRARY} NAME)

IF("${PROJECT_TARGET}" STREQUAL "DIRECT")
EXECUTE_PROCESS(COMMAND install_name_tool -change ${REAL_OPENSSL_LIBRARY}
@rpath/${REAL_OPENSSL_LIBRARY_FILENAME}
${FULL_FILENAME})
EXECUTE_PROCESS(COMMAND install_name_tool -change ${REAL_OPENSSL_LIBRARY_DIRNAME}/${REAL_OPENSSL_LIBRARY_FILENAME}
@rpath/${REAL_OPENSSL_LIBRARY_FILENAME}
${FULL_FILENAME})
ELSE()
ADD_CUSTOM_COMMAND(TARGET ${PROJECT_TARGET} POST_BUILD
COMMAND install_name_tool -change ${REAL_OPENSSL_LIBRARY}
@rpath/${REAL_OPENSSL_LIBRARY_FILENAME}
${FULL_FILENAME})
ADD_CUSTOM_COMMAND(TARGET ${PROJECT_TARGET} POST_BUILD
COMMAND install_name_tool -change ${REAL_OPENSSL_LIBRARY_DIRNAME}/${REAL_OPENSSL_LIBRARY_FILENAME}
@rpath/${REAL_OPENSSL_LIBRARY_FILENAME}
${FULL_FILENAME})
ENDIF()
ENDFOREACH()
ENDMACRO()

#===============================================================================
Expand Down Expand Up @@ -1385,10 +1316,6 @@ MACRO(CREATE_PACKAGE_FILE PACKAGE_NAME PACKAGE_VERSION DIRNAME)

SET(REAL_DIRNAME "${PROJECT_SOURCE_DIR}/${DIRNAME}")

# The package name in uppercase

STRING(TOUPPER ${PACKAGE_NAME} UPPER_PACKAGE_NAME)

# Remove any historical package archive

SET(COMPRESSED_FILENAME ${PROJECT_BUILD_DIR}/${PACKAGE_NAME}.${PACKAGE_VERSION}.${TARGET_PLATFORM}.tar.gz)
Expand Down Expand Up @@ -1453,7 +1380,7 @@ IF(EXISTS ${COMPRESSED_FILENAME})
STRING(REPLACE \"\;\" \"\\n \" SHA1_VALUES \"\$\{SHA1_VALUES\}\")
MESSAGE(\"To retrieve the '${PACKAGE_NAME}' package, please call:
RETRIEVE_PACKAGE_FILE(${PACKAGE_NAME} \\$\\{${UPPER_PACKAGE_NAME}_VERSION\\}
RETRIEVE_PACKAGE_FILE(${PACKAGE_NAME} \\$\\{PACKAGE_VERSION\\}
\\$\\{RELATIVE_PROJECT_SOURCE_DIR\\} \$\{SHA1_VALUE\}
SHA1_FILES \\$\\{SHA1_FILES\\}
SHA1_VALUES \$\{SHA1_VALUES\}
Expand Down Expand Up @@ -1578,10 +1505,11 @@ MACRO(RETRIEVE_PACKAGE_FILE PACKAGE_NAME PACKAGE_VERSION DIRNAME SHA1_VALUE)

MESSAGE("Retrieving the '${PACKAGE_NAME}' package...")

STRING(TOLOWER ${PACKAGE_NAME} LOWER_PACKAGE_NAME)
SET(COMPRESSED_FILENAME ${PACKAGE_NAME}.${PACKAGE_VERSION}.${TARGET_PLATFORM}.tar.gz)
SET(FULL_COMPRESSED_FILENAME ${REAL_DIRNAME}/${COMPRESSED_FILENAME})

FILE(DOWNLOAD "https://github.com/opencor/${PACKAGE_NAME}/releases/download/v${PACKAGE_VERSION}/${COMPRESSED_FILENAME}" ${FULL_COMPRESSED_FILENAME}
FILE(DOWNLOAD "https://github.com/opencor/${LOWER_PACKAGE_NAME}/releases/download/v${PACKAGE_VERSION}/${COMPRESSED_FILENAME}" ${FULL_COMPRESSED_FILENAME}
SHOW_PROGRESS STATUS STATUS)

# Uncompress the compressed version of the package, should we have
Expand Down
2 changes: 1 addition & 1 deletion doc/downloads/index.js
Expand Up @@ -37,7 +37,7 @@ var jsonData = { "versions": [
}
],
"changes": [
{ "change": "<strong>General:</strong> OpenGL now works in an Ubuntu virtual machine (see issue <a href=\"https://github.com/opencor/opencor/issues/1307\">#1307</a>)." }
{ "change": "<strong>General:</strong> OpenGL now works in an Ubuntu virtual machine (see issue <a href=\"https://github.com/opencor/opencor/issues/1307\">#1307</a>). Added OpenSSL as a third-party plugin (see issue <a href=\"https://github.com/opencor/opencor/issues/1101\">#1101</a>)." }
]
},
{ "major": 0, "minor": 4, "patch": 1, "day": 20, "month": 5, "year": 2015, "type": 0,
Expand Down
9 changes: 1 addition & 8 deletions src/plugins/miscellaneous/Compiler/src/compilerengine.cpp
Expand Up @@ -186,20 +186,13 @@ bool CompilerEngine::compileCode(const QString &pCode)
driver.setCheckInputsExist(false);

// Get a compilation object to which we pass some arguments
// Note: on Windows, we have both a pre-built release and a pre-built debug
// version of LLVM, so we make sure that we use the right flags for
// the right version, not least because with LLVM 3.9.x, to use an
// optimisation flag with a pre-built debug version of LLVM results in
// some of the Compiler and CellMLSupport tests to fail...

llvm::StringRef dummyFileName("dummyFile.c");
llvm::SmallVector<const char *, 16> compilationArguments;

compilationArguments.push_back("clang");
compilationArguments.push_back("-fsyntax-only");
#if defined(QT_DEBUG) \
&& ( (defined(USE_PREBUILT_LLVM_PLUGIN) && defined(Q_OS_WIN)) \
|| !defined(USE_PREBUILT_LLVM_PLUGIN))
#ifdef QT_DEBUG
compilationArguments.push_back("-g");
compilationArguments.push_back("-O0");
#else
Expand Down

0 comments on commit d2d30ad

Please sign in to comment.