Skip to content

Commit

Permalink
Some minor changes needed to get OpenCOR to build on Ubuntu 18.04 LTS.
Browse files Browse the repository at this point in the history
  • Loading branch information
agarny committed May 10, 2018
2 parents 83ea018 + 116f084 commit b1de3d6
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 18 deletions.
25 changes: 12 additions & 13 deletions CMakeLists.txt
Expand Up @@ -1150,6 +1150,10 @@ else()

copy_file_to_build_dir(DIRECT ${QT_BINARY_DIR} . ${ORIG_MESA_FILENAME} ${DEST_MESA_FILENAME})
copy_file_to_build_dir(DIRECT ${QT_BINARY_DIR} bin ${ORIG_MESA_FILENAME} ${DEST_MESA_FILENAME})
else()
# Make sure that OpenCOR uses RPATH rather than RUNPATH

runpath2rpath(${PROJECT_NAME} ${PROJECT_BUILD_DIR}/bin/${CMAKE_PROJECT_NAME})
endif()
endif()

Expand Down Expand Up @@ -1299,16 +1303,16 @@ else()

install(TARGETS ${CMAKE_PROJECT_NAME} RUNTIME DESTINATION bin)

# Libraries needed on Ubuntu
# Libraries needed on Ubuntu 16.04 LTS

foreach(LIBRARY app base interfaces pbutils reamer video)
set(FULL_LIBRARY ${CMAKE_SHARED_LIBRARY_PREFIX}gst${LIBRARY}-0.10${CMAKE_SHARED_LIBRARY_SUFFIX}.0)

get_filename_component(REAL_FULL_LIBRARY /usr/lib/x86_64-linux-gnu/${FULL_LIBRARY} REALPATH)

install(FILES ${REAL_FULL_LIBRARY}
DESTINATION lib
RENAME ${FULL_LIBRARY})
if(EXISTS ${REAL_FULL_LIBRARY})
linux_deploy_system_library(${REAL_FULL_LIBRARY} ${FULL_LIBRARY})
endif()
endforeach()

# Mesa library
Expand Down Expand Up @@ -1352,19 +1356,14 @@ else()

# JPEG and PNG are needed by QtWebKit and may not be present on a user's
# system
# Note: this works for Ubuntu 16.04 LTS, so for other versions QtWebKit will
# have to be rebuilt and the JPEG and PNG library versions updated...

find_package(JPEG REQUIRED QUIET)
find_package(PNG REQUIRED QUIET)

get_filename_component(REAL_JPEG_LIBRARY ${JPEG_LIBRARY} REALPATH)
get_filename_component(REAL_PNG_LIBRARY ${PNG_LIBRARY} REALPATH)

install(FILES ${REAL_JPEG_LIBRARY}
DESTINATION lib
RENAME libjpeg.so.8)
install(FILES ${REAL_PNG_LIBRARY}
DESTINATION lib
RENAME libpng12.so.0)
linux_deploy_system_library(${JPEG_LIBRARY} libjpeg.so.8)
linux_deploy_system_library(${PNG_LIBRARY} libpng12.so.0)

# Shell script to run OpenCOR

Expand Down
24 changes: 23 additions & 1 deletion cmake/common.cmake
Expand Up @@ -323,10 +323,13 @@ macro(add_plugin PLUGIN_NAME)
COMMAND ${CMAKE_COMMAND} -E copy ${PLUGIN_BUILD_DIR}/${PLUGIN_FILENAME}
${DEST_PLUGINS_DIR}/${PLUGIN_FILENAME})

# Clean up our plugin, if we are on macOS
# Clean up our plugin, if we are on macOS, our make sure that it uses RPATH
# rather than RUNPATH on Linux

if(APPLE)
macos_clean_up_file_with_qt_dependencies(${PROJECT_NAME} ${DEST_PLUGINS_DIR} ${PLUGIN_FILENAME})
elseif(NOT WIN32)
runpath2rpath(${PROJECT_NAME} ${DEST_PLUGINS_DIR}/${PLUGIN_FILENAME})
endif()

# Package the plugin, but only if we are not on macOS since it will have
Expand Down Expand Up @@ -664,6 +667,25 @@ endmacro()

#===============================================================================

macro(linux_deploy_system_library FILENAME NEW_FILENAME)
# Copy the system library to the build/lib folder, so we can test things
# without first having to deploy OpenCOR

get_filename_component(REAL_FULL_FILENAME ${FILENAME} REALPATH)
get_filename_component(REAL_DIRNAME ${REAL_FULL_FILENAME} DIRECTORY)
get_filename_component(REAL_FILENAME ${REAL_FULL_FILENAME} NAME)

copy_file_to_build_dir(DIRECT ${REAL_DIRNAME} lib ${REAL_FILENAME} ${NEW_FILENAME})

# Deploy the system library

install(FILES ${REAL_FULL_FILENAME}
DESTINATION lib
RENAME ${NEW_FILENAME})
endmacro()

#===============================================================================

macro(macos_clean_up_file PROJECT_TARGET DIRNAME FILENAME)
# Strip the file of all its local symbols

Expand Down
7 changes: 6 additions & 1 deletion src/plugins/api/CellMLAPI/src/cellmlapibegin.h
Expand Up @@ -21,10 +21,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// CellML API begin
//==============================================================================

#ifdef Q_OS_WIN
#if defined(Q_OS_WIN)
#pragma warning(push)
#pragma warning(disable: 4091)
#pragma warning(disable: 4290)
#elif defined(Q_OS_LINUX)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated"
#elif !defined(Q_OS_MAC)
#error Unsupported platform
#endif

//==============================================================================
Expand Down
6 changes: 5 additions & 1 deletion src/plugins/api/CellMLAPI/src/cellmlapiend.h
Expand Up @@ -21,8 +21,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// CellML API end
//==============================================================================

#ifdef Q_OS_WIN
#if defined(Q_OS_WIN)
#pragma warning(pop)
#elif defined(Q_OS_LINUX)
#pragma GCC diagnostic pop
#elif !defined(Q_OS_MAC)
#error Unsupported platform
#endif

//==============================================================================
Expand Down
5 changes: 3 additions & 2 deletions src/plugins/miscellaneous/Core/src/corecliutils.cpp
Expand Up @@ -770,8 +770,9 @@ void cleanDomElement(QDomElement &pDomElement,
// before removing them from the element and adding a new attribute that
// will later on be used for string replacement

static const int AttributeNumberWidth = ceil(log(ULLONG_MAX));

static quint64 attributeNumber = 0;
static const int ULLONG_WIDTH = ceil(log(ULLONG_MAX));

if (pDomElement.hasAttributes()) {
QStringList serialisedAttributes = QStringList();
Expand Down Expand Up @@ -825,7 +826,7 @@ void cleanDomElement(QDomElement &pDomElement,

// Keep track of the serialisation of the element's attribute

QString elementAttributes = QString("Element%1Attributes").arg(++attributeNumber, ULLONG_WIDTH, 10, QChar('0'));
QString elementAttributes = QString("Element%1Attributes").arg(++attributeNumber, AttributeNumberWidth, 10, QChar('0'));

pElementsAttributes.insert(elementAttributes, serialisedAttributes.join(' ').toUtf8());

Expand Down

0 comments on commit b1de3d6

Please sign in to comment.