Make it possible to build Octave plugins independent to main build

The building of Octave plugins within main ResInsight build on RHEL8 cause the build to use gcc-12, and gcc-12 is extremely slow when building opm-common.

Adjust the CMake configuration so it is possible to build the Octave plugins as an independent build job. The plugin binaries can then be uploaded to an external server. The main ResInsight build  can download the binaries and include them in the install package for ResInsight.

Use the flag RESINSIGHT_USE_EXTERNAL_OCTAVE_PLUGINS to download external Octave plugin binaries.
This commit is contained in:
Magne Sjaastad 2024-06-04 07:42:50 +02:00 committed by GitHub
parent 1c899df063
commit b050cac1d2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
47 changed files with 566 additions and 271 deletions

View File

@ -23,6 +23,10 @@ jobs:
find -name CMake*.txt | xargs ~/.local/bin/cmake-format -c ${{ github.workspace }}/cmake/cmake-format.py -i
cd ..
cd Octave
find -name CMake*.txt | xargs ~/.local/bin/cmake-format -c ${{ github.workspace }}/cmake/cmake-format.py -i
cd ..
cd Fwk/AppFwk
find -name CMake*.txt | xargs ~/.local/bin/cmake-format -c ${{ github.workspace }}/cmake/cmake-format.py -i
cd ..

View File

@ -984,15 +984,32 @@ if(RESINSIGHT_ENABLE_GRPC)
endif()
add_subdirectory(ApplicationExeCode)
if(OCTAVE_MKOCTFILE)
message(STATUS "Adding OctavePlugin library")
add_subdirectory(OctavePlugin)
else(OCTAVE_MKOCTFILE)
message(
STATUS "Could not find OCTAVE_MKOCTFILE, skipping OctavePlugin library"
option(RESINSIGHT_USE_EXTERNAL_OCTAVE_PLUGINS "Use external Octave plugins" OFF)
if(RESINSIGHT_USE_EXTERNAL_OCTAVE_PLUGINS)
FetchContent_Declare(
external-octave_plugins
URL https://github.com/CeetronSolutions/resinsight-dependencies/releases/latest/download/OctavePlugins-0.1.1-Linux.tar.gz
)
endif(OCTAVE_MKOCTFILE)
FetchContent_Populate(external-octave_plugins)
file(GLOB FILE_AND_SYMLINKS ${external-octave_plugins_SOURCE_DIR}/*.oct)
install(
FILES ${FILE_AND_SYMLINKS}
DESTINATION ${RESINSIGHT_INSTALL_FOLDER}
OPTIONAL
)
else(RESINSIGHT_USE_EXTERNAL_OCTAVE_PLUGINS)
if(OCTAVE_MKOCTFILE)
message(STATUS "Adding OctavePlugin library")
add_subdirectory(Octave/OctavePlugin)
else(OCTAVE_MKOCTFILE)
message(
STATUS "Could not find OCTAVE_MKOCTFILE, skipping OctavePlugin library"
)
endif(OCTAVE_MKOCTFILE)
endif(RESINSIGHT_USE_EXTERNAL_OCTAVE_PLUGINS)
add_subdirectory(ThirdParty/extract-projectfile-versions)
install(TARGETS extract-projectfile-versions

33
Octave/CMakeLists.txt Normal file
View File

@ -0,0 +1,33 @@
cmake_minimum_required(VERSION 3.15)
project(OctavePlugins)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
find_package(Octave)
if(CEE_USE_QT6)
find_package(
Qt6
COMPONENTS
REQUIRED Core Gui OpenGL Widgets Network
)
set(QT_LIBRARIES Qt6::Core Qt6::Gui Qt6::OpenGL Qt6::Widgets Qt6::Network)
qt_standard_project_setup()
else()
find_package(
Qt5
COMPONENTS
REQUIRED Core Gui OpenGL Widgets Network
)
set(QT_LIBRARIES Qt5::Core Qt5::Gui Qt5::OpenGL Qt5::Widgets Qt5::Network)
endif()
add_subdirectory(OctavePlugin)
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set(CPACK_GENERATOR TGZ)
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set(CPACK_GENERATOR ZIP)
endif()
include(CPack)

View File

@ -0,0 +1,278 @@
# Some of the functionality in this CMakeLists.txt might be easier to maintain
# if we use a CMake macro to find configuration info for Octave This file is
# currently (2.8.12) not part of default CMake installation See
# http://www.cmake.org/Wiki/CMakeUserFindOctave
set(CPP_SOURCES
riGetActiveCellProperty.cpp
riSetActiveCellProperty.cpp
riGetActiveCellInfo.cpp
riGetMainGridDimensions.cpp
riGetNNCConnections.cpp
riGetNNCPropertyNames.cpp
riGetCurrentCase.cpp
riGetCaseGroups.cpp
riGetDynamicNNCValues.cpp
riGetStaticNNCValues.cpp
riGetSelectedCases.cpp
riGetSelectedCells.cpp
riGetCases.cpp
riGetTimeStepDates.cpp
riGetTimeStepDays.cpp
riGetGridDimensions.cpp
riGetCoarseningInfo.cpp
riGetCellCenters.cpp
riGetActiveCellCenters.cpp
riGetCellCorners.cpp
riGetActiveCellCorners.cpp
riGetGridProperty.cpp
riSetGridProperty.cpp
riGetGridPropertyForSelectedCells.cpp
riGetPropertyNames.cpp
riGetWellNames.cpp
riGetWellStatus.cpp
riGetWellCells.cpp
riSetNNCProperty.cpp
)
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
# since the compiler passes the option to the linker, double quoting is
# necessary
set(RPATH_COMMAND "-Wl,-rpath,'\\$$ORIGIN'")
endif()
# recreate the magic that CMake does for MacOS X frameworks in the include list
# when we call mkoctfile as a custom command
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(QT_INCLUDES)
set(QT_FRAMEWORKS)
# QT_INCLUDE_DIR contains two items; the first is the directory containing
# header files, the second is the framework. This setup is specially processed
# in include_directories (); CMake will add -F before the frameworks. We will
# have to replicate that setup here when we want to pass it directly to a
# command see <http://www.cmake.org/Bug/print_bug_page.php?bug_id=10632>
foreach(item IN ITEMS ${QT_QTNETWORK_INCLUDE_DIR} ${QT_QTCORE_INCLUDE_DIR}
${QT_INCLUDE_DIR}
)
if("${item}" MATCHES ".framework$")
get_filename_component(frmwrk_path ${item} PATH)
get_filename_component(frmwrk_name ${item} NAME_WE)
# mkoctfile doesn't support arbitrary compiler command, so we must wrap in
# -Wl, to pass to the linker
list(APPEND QT_FRAMEWORKS "-Wl,-F${frmwrk_path}")
list(APPEND QT_FRAMEWORKS "-Wl,-framework,${frmwrk_name}")
else()
list(APPEND QT_INCLUDES "-I${item}")
endif()
endforeach(item)
if(QT_INCLUDES)
list(REMOVE_DUPLICATES QT_INCLUDES)
endif()
if(QT_FRAMEWORKS)
list(REMOVE_DUPLICATES QT_FRAMEWORKS)
endif()
endif()
message(STATUS "Compiling Octave plugins using : ${OCTAVE_MKOCTFILE}")
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
option(RESINSIGHT_OCTAVE_PLUGIN_QT
"Compile Octave plugin using Qt located insided Octave root folder" ON
)
endif(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
if(RESINSIGHT_OCTAVE_PLUGIN_QT)
message(
STATUS
"Compiling Octave plugins using custom Qt located at ${OCTAVE_ROOT_DIR}"
)
if(EXISTS ${OCTAVE_ROOT_DIR}/qt5)
set(OCTAVE_QT_INCLUDE_DIR ${OCTAVE_ROOT_DIR}/qt5/include)
set(OCTAVE_QT_QTCORE_INCLUDE_DIR ${OCTAVE_ROOT_DIR}/qt5/include/QtCore)
set(OCTAVE_QT_QTNETWORK_INCLUDE_DIR
${OCTAVE_ROOT_DIR}/qt5/include/QtNetwork
)
set(OCTAVE_QT_LIBRARY_DIR ${OCTAVE_ROOT_DIR}/qt5/lib)
set(OCTAVE_QT_QTCORE_LIB Qt5Core)
set(OCTAVE_QT_QTNETWORK_LIB Qt5Network)
else()
set(OCTAVE_QT_INCLUDE_DIR ${OCTAVE_ROOT_DIR}/include)
set(OCTAVE_QT_QTCORE_INCLUDE_DIR ${OCTAVE_ROOT_DIR}/include/QtCore)
set(OCTAVE_QT_QTNETWORK_INCLUDE_DIR ${OCTAVE_ROOT_DIR}/include/QtNetwork)
set(OCTAVE_QT_LIBRARY_DIR ${OCTAVE_ROOT_DIR}/lib)
set(OCTAVE_QT_QTCORE_LIB QtCore4)
set(OCTAVE_QT_QTNETWORK_LIB QtNetwork4)
endif(EXISTS ${OCTAVE_ROOT_DIR}/qt5)
else()
if(Qt5Core_FOUND)
message(STATUS "Compiling Octave plugins using system Qt5")
set(OCTAVE_QT_QTCORE_INCLUDE_DIR ${Qt5Core_INCLUDE_DIRS})
set(OCTAVE_QT_QTNETWORK_INCLUDE_DIR ${Qt5Network_INCLUDE_DIRS})
set(OCTAVE_QT_LIBRARY_DIR ${QT_LIBRARY_DIR})
set(OCTAVE_QT_QTCORE_LIB Qt5Core)
set(OCTAVE_QT_QTNETWORK_LIB Qt5Network)
endif(Qt5Core_FOUND)
endif(RESINSIGHT_OCTAVE_PLUGIN_QT)
list(APPEND MKOCTFILE_INCLUDE_DIRS ${OCTAVE_QT_INCLUDE_DIR})
list(APPEND MKOCTFILE_INCLUDE_DIRS ${OCTAVE_QT_QTCORE_INCLUDE_DIR})
list(APPEND MKOCTFILE_INCLUDE_DIRS ${OCTAVE_QT_QTNETWORK_INCLUDE_DIR})
# Add socket interface source code folder
list(APPEND MKOCTFILE_INCLUDE_DIRS
${CMAKE_CURRENT_SOURCE_DIR}/../../ApplicationLibCode/SocketInterface
)
list(REMOVE_DUPLICATES MKOCTFILE_INCLUDE_DIRS)
foreach(item ${MKOCTFILE_INCLUDE_DIRS})
list(APPEND MKOCTFILE_INCLUDE_TEMP -I${item})
endforeach(item)
string(REPLACE ";" " " MKOCTFILE_INCLUDE_TEMP "${MKOCTFILE_INCLUDE_TEMP}")
# Use special command to avoid double quoting in add_custom_command()
separate_arguments(
MKOCTFILE_INCLUDE_COMMAND_STRING WINDOWS_COMMAND "${MKOCTFILE_INCLUDE_TEMP}"
)
# Clear the list of binary oct files to be produced
set(OCTAVE_BINARY_OCT_FILES)
if(OCTAVE_MKOCTFILE)
foreach(srcFileName IN LISTS CPP_SOURCES)
if(NOT IS_ABSOLUTE "${srcFileName}")
set(srcFileName "${CMAKE_CURRENT_SOURCE_DIR}/${srcFileName}")
endif()
get_filename_component(baseFilename "${srcFileName}" NAME_WE)
set(octFileName "${CMAKE_CURRENT_BINARY_DIR}/${baseFilename}.oct")
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
add_custom_command(
OUTPUT "${octFileName}"
COMMAND set "OCTAVE_HOME=${OCTAVE_ROOT_DIR}"
COMMAND set "PATH=%OCTAVE_HOME%\\bin;%PATH%"
COMMAND
${OCTAVE_MKOCTFILE} ${MKOCTFILE_INCLUDE_COMMAND_STRING}
${RPATH_COMMAND} -L${OCTAVE_QT_LIBRARY_DIR} -l${OCTAVE_QT_QTCORE_LIB}
-l${OCTAVE_QT_QTNETWORK_LIB} -o "${octFileName}" "${srcFileName}"
DEPENDS "${srcFileName}"
COMMENT "===> Generating ${octFileName}"
)
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
add_custom_command(
OUTPUT "${octFileName}"
COMMAND
${OCTAVE_MKOCTFILE} ${QT_INCLUDES} ${QT_FRAMEWORKS}
-I${ResInsight_SOURCE_DIR}/ApplicationLibCode/SocketInterface
${RPATH_COMMAND} -L${QT_LIBRARY_DIR} -Wl,-framework,QtCore
-Wl,-framework,QtNetwork -o "${octFileName}" "${srcFileName}"
DEPENDS "${srcFileName}"
COMMENT "===> Generating ${octFileName}"
)
else()
add_custom_command(
OUTPUT "${octFileName}"
COMMAND
OCTAVE_HOME=${OCTAVE_ROOT_DIR} ${OCTAVE_MKOCTFILE}
${MKOCTFILE_INCLUDE_COMMAND_STRING} ${RPATH_COMMAND}
-L${OCTAVE_QT_LIBRARY_DIR} -l${OCTAVE_QT_QTCORE_LIB}
-l${OCTAVE_QT_QTNETWORK_LIB} -o "${octFileName}" "${srcFileName}"
DEPENDS "${srcFileName}"
COMMENT "===> Generating ${octFileName}"
)
endif()
list(APPEND OCTAVE_BINARY_OCT_FILES "${octFileName}")
endforeach()
# Create depencedy string represeting the full path to all generated oct-files
foreach(item ${CPP_SOURCES})
string(REPLACE ".cpp" ".oct" item ${item})
list(APPEND DEPENDENCY_STRING ${CMAKE_CURRENT_BINARY_DIR}/${item})
endforeach(item)
# message("DEPENDENCY_STRING : ${DEPENDENCY_STRING}")
add_custom_target(
octave_plugins ALL
DEPENDS ${DEPENDENCY_STRING}
SOURCES ${CPP_SOURCES} riSettings.h
)
# Copy Octave generated *.oct files to application folder, will make it
# possible to use Octave functions directly from the location of the
# ResInsight binaries
if(TARGET ResInsight)
message(
STATUS
"Target ResInsight exists, add copy of Octave plugins to ApplicationExeCode folder"
)
# Make ResInsight dependant on Octave, makes it easiser to debug Octave
# functionality by compiling ResInsight
add_dependencies(ResInsight octave_plugins)
foreach(oct_bin ${OCTAVE_BINARY_OCT_FILES})
get_filename_component(Filename "${oct_bin}" NAME)
if(MSVC)
add_custom_command(
TARGET octave_plugins
POST_BUILD
COMMAND
${CMAKE_COMMAND} -E copy_if_different "${oct_bin}"
"${CMAKE_CURRENT_BINARY_DIR}/../../ApplicationExeCode/$<CONFIGURATION>/${Filename}"
)
else()
add_custom_command(
TARGET octave_plugins
POST_BUILD
COMMAND
${CMAKE_COMMAND} -E copy_if_different "${oct_bin}"
"${CMAKE_CURRENT_BINARY_DIR}/../../ApplicationExeCode/${Filename}"
)
endif(MSVC)
endforeach(oct_bin)
if(RESINSIGHT_PRIVATE_INSTALL)
install(FILES ${OCTAVE_BINARY_OCT_FILES}
DESTINATION ${RESINSIGHT_INSTALL_FOLDER}
)
else(RESINSIGHT_PRIVATE_INSTALL)
# probe for site location of .oct files
if(NOT OCTAVE_SITE_OCT_DIR)
find_program(
OCTAVE_CONFIG_COMMAND octave-config
DOC "Path to Octave component and library information retrieval"
)
exec_program(
${OCTAVE_CONFIG_COMMAND} ARGS
--oct-site-dir
OUTPUT_VARIABLE OCTAVE_SITE_OCT_DIR
)
set(OCTAVE_SITE_OCT_DIR
"${OCTAVE_SITE_OCT_DIR}"
CACHE LOCATION "Octave plugin directory"
)
endif(NOT OCTAVE_SITE_OCT_DIR)
install(FILES ${OCTAVE_BINARY_OCT_FILES}
DESTINATION ${OCTAVE_SITE_OCT_DIR}
)
endif(RESINSIGHT_PRIVATE_INSTALL)
else()
install(FILES ${OCTAVE_BINARY_OCT_FILES} DESTINATION .)
endif(TARGET ResInsight)
endif(OCTAVE_MKOCTFILE)

View File

@ -16,7 +16,7 @@
//
/////////////////////////////////////////////////////////////////////////////////
#include "../ApplicationLibCode/SocketInterface/RiaSocketServerDefines.h"
#include "../../ApplicationLibCode/SocketInterface/RiaSocketServerDefines.h"
namespace riOctavePlugin
{

View File

@ -0,0 +1,205 @@
# - Find Octave
# GNU Octave is a high-level interpreted language, primarily intended for numerical computations.
# available at http://www.gnu.org/software/octave/
#
# This module defines:
# OCTAVE_EXECUTABLE - octave interpreter
# OCTAVE_INCLUDE_DIRS - include path for mex.h, mexproto.h
# OCTAVE_LIBRARIES - required libraries: octinterp, octave, cruft
# OCTAVE_OCTINTERP_LIBRARY - path to the library octinterp
# OCTAVE_OCTAVE_LIBRARY - path to the library octave
# OCTAVE_CRUFT_LIBRARY - path to the library cruft
# OCTAVE_VERSION_STRING - octave version string
# OCTAVE_MAJOR_VERSION - major version
# OCTAVE_MINOR_VERSION - minor version
# OCTAVE_PATCH_VERSION - patch version
# OCTAVE_OCT_FILE_DIR - object files that will be dynamically loaded
# OCTAVE_OCT_LIB_DIR - oct libraries
# OCTAVE_ROOT_DIR - octave prefix
# OCTAVE_M_SITE_DIR - .m files site dir
# OCTAVE_OCT_SITE_DIR - .oct files site dir
#
# The macro octave_add_oct allows to create compiled modules.
# octave_add_oct (target_name
# [SOURCES] source1 [source2 ...]
# [LINK_LIBRARIES lib1 [lib2 ...]]
# [EXTENSION ext]
#)
#
# To install it, you can the use the variable OCTAVE_OCT_FILE_DIR as follow:
# file (RELATIVE_PATH PKG_OCTAVE_OCT_SITE_DIR ${OCTAVE_ROOT_DIR} ${OCTAVE_OCT_SITE_DIR})
# install (
# TARGETS target_name
# DESTINATION ${PKG_OCTAVE_OCT_SITE_DIR}
#)
#=============================================================================
# Copyright 2013, Julien Schueller
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# The views and conclusions contained in the software and documentation are those
# of the authors and should not be interpreted as representing official policies,
# either expressed or implied, of the FreeBSD Project.
#=============================================================================
find_program(OCTAVE_CONFIG_EXECUTABLE
NAMES octave-config
)
if (OCTAVE_CONFIG_EXECUTABLE)
execute_process (COMMAND ${OCTAVE_CONFIG_EXECUTABLE} -p OCTAVE_HOME
OUTPUT_VARIABLE OCTAVE_ROOT_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process (COMMAND ${OCTAVE_CONFIG_EXECUTABLE} --m-site-dir
OUTPUT_VARIABLE OCTAVE_M_SITE_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process (COMMAND ${OCTAVE_CONFIG_EXECUTABLE} --oct-site-dir
OUTPUT_VARIABLE OCTAVE_OCT_SITE_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process (COMMAND ${OCTAVE_CONFIG_EXECUTABLE} -p BINDIR
OUTPUT_VARIABLE OCTAVE_BIN_PATHS
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process (COMMAND ${OCTAVE_CONFIG_EXECUTABLE} -p OCTINCLUDEDIR
OUTPUT_VARIABLE OCTAVE_INCLUDE_PATHS
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process (COMMAND ${OCTAVE_CONFIG_EXECUTABLE} -p OCTLIBDIR
OUTPUT_VARIABLE OCTAVE_LIBRARIES_PATHS
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process (COMMAND ${OCTAVE_CONFIG_EXECUTABLE} -p OCTFILEDIR
OUTPUT_VARIABLE OCTAVE_OCT_FILE_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process (COMMAND ${OCTAVE_CONFIG_EXECUTABLE} -p OCTLIBDIR
OUTPUT_VARIABLE OCTAVE_OCT_LIB_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process (COMMAND ${OCTAVE_CONFIG_EXECUTABLE} -v
OUTPUT_VARIABLE OCTAVE_VERSION_STRING
OUTPUT_STRIP_TRAILING_WHITESPACE)
if (OCTAVE_VERSION_STRING)
string (REGEX REPLACE "([0-9]+)\\..*" "\\1" OCTAVE_MAJOR_VERSION ${OCTAVE_VERSION_STRING})
string (REGEX REPLACE "[0-9]+\\.([0-9]+).*" "\\1" OCTAVE_MINOR_VERSION ${OCTAVE_VERSION_STRING})
string (REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" OCTAVE_PATCH_VERSION ${OCTAVE_VERSION_STRING})
endif ()
endif ()
find_program(OCTAVE_EXECUTABLE
HINTS ${OCTAVE_BIN_PATHS}
NAMES octave
)
find_program(OCTAVE_MKOCTFILE
HINTS ${OCTAVE_BIN_PATHS}
NAMES mkoctfile
)
find_library(OCTAVE_OCTINTERP_LIBRARY
NAMES octinterp liboctinterp
HINTS ${OCTAVE_LIBRARIES_PATHS}
)
find_library(OCTAVE_OCTAVE_LIBRARY
NAMES octave liboctave
HINTS ${OCTAVE_LIBRARIES_PATHS}
)
find_library(OCTAVE_CRUFT_LIBRARY
NAMES cruft libcruft
HINTS ${OCTAVE_LIBRARIES_PATHS}
)
set (OCTAVE_LIBRARIES ${OCTAVE_OCTINTERP_LIBRARY})
list (APPEND OCTAVE_LIBRARIES ${OCTAVE_OCTAVE_LIBRARY})
if (OCTAVE_CRUFT_LIBRARY)
list (APPEND OCTAVE_LIBRARIES ${OCTAVE_CRUFT_LIBRARY})
endif ()
find_path (OCTAVE_INCLUDE_DIR
NAMES octave/oct.h
PATHS "${OCTAVE_INCLUDE_PATHS}/.."
)
set (OCTAVE_INCLUDE_DIRS ${OCTAVE_INCLUDE_DIR} ${OCTAVE_INCLUDE_DIR}/octave)
macro (octave_add_oct FUNCTIONNAME)
set (_CMD SOURCES)
set (_SOURCES)
set (_LINK_LIBRARIES)
set (_EXTENSION)
set (_OCT_EXTENSION oct)
foreach (_ARG ${ARGN})
if (${_ARG} MATCHES SOURCES)
set (_CMD SOURCES)
elseif (${_ARG} MATCHES LINK_LIBRARIES)
set (_CMD LINK_LIBRARIES)
elseif (${_ARG} MATCHES EXTENSION)
set (_CMD EXTENSION)
else ()
if (${_CMD} MATCHES SOURCES)
list (APPEND _SOURCES "${_ARG}")
elseif (${_CMD} MATCHES LINK_LIBRARIES)
list (APPEND _LINK_LIBRARIES "${_ARG}")
elseif (${_CMD} MATCHES EXTENSION)
set (_OCT_EXTENSION ${_ARG})
endif ()
endif ()
endforeach ()
add_library (${FUNCTIONNAME} SHARED ${_SOURCES})
target_link_libraries (${FUNCTIONNAME} ${OCTAVE_LIBRARIES} ${_LINK_LIBRARIES})
set_target_properties (${FUNCTIONNAME} PROPERTIES
PREFIX ""
SUFFIX ".${_OCT_EXTENSION}"
)
endmacro ()
# handle REQUIRED and QUIET options
include (FindPackageHandleStandardArgs)
find_package_handle_standard_args (Octave REQUIRED_VARS OCTAVE_EXECUTABLE OCTAVE_ROOT_DIR OCTAVE_INCLUDE_DIRS OCTAVE_LIBRARIES VERSION_VAR OCTAVE_VERSION_STRING)
mark_as_advanced (
OCTAVE_OCT_FILE_DIR
OCTAVE_OCT_LIB_DIR
OCTAVE_OCTINTERP_LIBRARY
OCTAVE_OCTAVE_LIBRARY
OCTAVE_CRUFT_LIBRARY
OCTAVE_LIBRARIES
OCTAVE_INCLUDE_DIR
OCTAVE_INCLUDE_DIRS
OCTAVE_ROOT_DIR
OCTAVE_VERSION_STRING
OCTAVE_MAJOR_VERSION
OCTAVE_MINOR_VERSION
OCTAVE_PATCH_VERSION
)

View File

@ -0,0 +1,20 @@
# -----------------------------
# Options effecting formatting.
# See: https://github.com/cheshirekow/cmake_format
# -----------------------------
with section("format"):
# How wide to allow formatted cmake files
line_width = 80
# How many spaces to tab for indent
tab_size = 2
# If true, separate flow control names from their parentheses with a space
separate_ctrl_name_with_space = False
# If true, separate function names from parentheses with a space
separate_fn_name_with_space = False
# If a statement is wrapped to more than one line, than dangle the closing
# parenthesis on its own line.
dangle_parens = True

View File

@ -1,262 +0,0 @@
# Some of the functionality in this CMakeLists.txt might be easier to maintain if we use a CMake macro to find configuration info for Octave
# This file is currently (2.8.12) not part of default CMake installation
# See http://www.cmake.org/Wiki/CMakeUserFindOctave
set(CPP_SOURCES
riGetActiveCellProperty.cpp
riSetActiveCellProperty.cpp
riGetActiveCellInfo.cpp
riGetMainGridDimensions.cpp
riGetNNCConnections.cpp
riGetNNCPropertyNames.cpp
riGetCurrentCase.cpp
riGetCaseGroups.cpp
riGetDynamicNNCValues.cpp
riGetStaticNNCValues.cpp
riGetSelectedCases.cpp
riGetSelectedCells.cpp
riGetCases.cpp
riGetTimeStepDates.cpp
riGetTimeStepDays.cpp
riGetGridDimensions.cpp
riGetCoarseningInfo.cpp
riGetCellCenters.cpp
riGetActiveCellCenters.cpp
riGetCellCorners.cpp
riGetActiveCellCorners.cpp
riGetGridProperty.cpp
riSetGridProperty.cpp
riGetGridPropertyForSelectedCells.cpp
riGetPropertyNames.cpp
riGetWellNames.cpp
riGetWellStatus.cpp
riGetWellCells.cpp
riSetNNCProperty.cpp
)
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
# since the compiler passes the option to the linker, double quoting is necessary
set (RPATH_COMMAND "-Wl,-rpath,'\\$$ORIGIN'")
endif()
# recreate the magic that CMake does for MacOS X frameworks in the
# include list when we call mkoctfile as a custom command
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set (QT_INCLUDES)
set (QT_FRAMEWORKS)
# QT_INCLUDE_DIR contains two items; the first is the directory
# containing header files, the second is the framework. This
# setup is specially processed in include_directories (); CMake
# will add -F before the frameworks. We will have to replicate
# that setup here when we want to pass it directly to a command
# see <http://www.cmake.org/Bug/print_bug_page.php?bug_id=10632>
foreach (item IN ITEMS ${QT_QTNETWORK_INCLUDE_DIR} ${QT_QTCORE_INCLUDE_DIR} ${QT_INCLUDE_DIR})
if ("${item}" MATCHES ".framework$")
get_filename_component (frmwrk_path ${item} PATH)
get_filename_component (frmwrk_name ${item} NAME_WE)
# mkoctfile doesn't support arbitrary compiler command,
# so we must wrap in -Wl, to pass to the linker
list (APPEND QT_FRAMEWORKS "-Wl,-F${frmwrk_path}")
list (APPEND QT_FRAMEWORKS "-Wl,-framework,${frmwrk_name}")
else ()
list (APPEND QT_INCLUDES "-I${item}")
endif ()
endforeach (item)
if (QT_INCLUDES)
list (REMOVE_DUPLICATES QT_INCLUDES)
endif ()
if (QT_FRAMEWORKS)
list (REMOVE_DUPLICATES QT_FRAMEWORKS)
endif ()
endif ()
message (STATUS "Compiling Octave plugins using : ${OCTAVE_MKOCTFILE}")
if (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
option(RESINSIGHT_OCTAVE_PLUGIN_QT "Compile Octave plugin using Qt located insided Octave root folder" ON)
endif(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
if(RESINSIGHT_OCTAVE_PLUGIN_QT)
message(STATUS "Compiling Octave plugins using custom Qt located at ${OCTAVE_ROOT_DIR}")
if (EXISTS ${OCTAVE_ROOT_DIR}/qt5)
SET(OCTAVE_QT_INCLUDE_DIR ${OCTAVE_ROOT_DIR}/qt5/include)
SET(OCTAVE_QT_QTCORE_INCLUDE_DIR ${OCTAVE_ROOT_DIR}/qt5/include/QtCore)
SET(OCTAVE_QT_QTNETWORK_INCLUDE_DIR ${OCTAVE_ROOT_DIR}/qt5/include/QtNetwork)
SET(OCTAVE_QT_LIBRARY_DIR ${OCTAVE_ROOT_DIR}/qt5/lib)
SET(OCTAVE_QT_QTCORE_LIB Qt5Core)
SET(OCTAVE_QT_QTNETWORK_LIB Qt5Network)
else ()
SET(OCTAVE_QT_INCLUDE_DIR ${OCTAVE_ROOT_DIR}/include)
SET(OCTAVE_QT_QTCORE_INCLUDE_DIR ${OCTAVE_ROOT_DIR}/include/QtCore)
SET(OCTAVE_QT_QTNETWORK_INCLUDE_DIR ${OCTAVE_ROOT_DIR}/include/QtNetwork)
SET(OCTAVE_QT_LIBRARY_DIR ${OCTAVE_ROOT_DIR}/lib)
SET(OCTAVE_QT_QTCORE_LIB QtCore4)
SET(OCTAVE_QT_QTNETWORK_LIB QtNetwork4)
endif(EXISTS ${OCTAVE_ROOT_DIR}/qt5)
else()
if (Qt5Core_FOUND)
message(STATUS "Compiling Octave plugins using system Qt5")
SET(OCTAVE_QT_QTCORE_INCLUDE_DIR ${Qt5Core_INCLUDE_DIRS})
SET(OCTAVE_QT_QTNETWORK_INCLUDE_DIR ${Qt5Network_INCLUDE_DIRS})
SET(OCTAVE_QT_LIBRARY_DIR ${QT_LIBRARY_DIR})
SET(OCTAVE_QT_QTCORE_LIB Qt5Core)
SET(OCTAVE_QT_QTNETWORK_LIB Qt5Network)
endif(Qt5Core_FOUND)
endif(RESINSIGHT_OCTAVE_PLUGIN_QT)
list (APPEND MKOCTFILE_INCLUDE_DIRS ${OCTAVE_QT_INCLUDE_DIR})
list (APPEND MKOCTFILE_INCLUDE_DIRS ${OCTAVE_QT_QTCORE_INCLUDE_DIR})
list (APPEND MKOCTFILE_INCLUDE_DIRS ${OCTAVE_QT_QTNETWORK_INCLUDE_DIR})
# Add socket interface source code folder
list (APPEND MKOCTFILE_INCLUDE_DIRS ${ResInsight_SOURCE_DIR}/ApplicationLibCode/SocketInterface)
list (REMOVE_DUPLICATES MKOCTFILE_INCLUDE_DIRS)
foreach (item ${MKOCTFILE_INCLUDE_DIRS})
list (APPEND MKOCTFILE_INCLUDE_TEMP -I${item})
endforeach (item)
string( REPLACE ";" " " MKOCTFILE_INCLUDE_TEMP "${MKOCTFILE_INCLUDE_TEMP}" )
# Use special command to avoid double quoting in add_custom_command()
separate_arguments(MKOCTFILE_INCLUDE_COMMAND_STRING WINDOWS_COMMAND "${MKOCTFILE_INCLUDE_TEMP}")
# Clear the list of binary oct files to be produced
set(OCTAVE_BINARY_OCT_FILES)
if (OCTAVE_MKOCTFILE)
foreach(srcFileName IN LISTS CPP_SOURCES)
if(NOT IS_ABSOLUTE "${srcFileName}")
set(srcFileName "${CMAKE_CURRENT_SOURCE_DIR}/${srcFileName}")
endif()
get_filename_component(baseFilename "${srcFileName}" NAME_WE)
set(octFileName "${CMAKE_CURRENT_BINARY_DIR}/${baseFilename}.oct")
if (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
add_custom_command(
OUTPUT "${octFileName}"
COMMAND set "OCTAVE_HOME=${OCTAVE_ROOT_DIR}"
COMMAND set "PATH=%OCTAVE_HOME%\\bin;%PATH%"
COMMAND ${OCTAVE_MKOCTFILE}
${MKOCTFILE_INCLUDE_COMMAND_STRING}
${RPATH_COMMAND}
-L${OCTAVE_QT_LIBRARY_DIR}
-l${OCTAVE_QT_QTCORE_LIB}
-l${OCTAVE_QT_QTNETWORK_LIB}
-o "${octFileName}" "${srcFileName}"
DEPENDS "${srcFileName}"
COMMENT "===> Generating ${octFileName}"
)
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
add_custom_command(
OUTPUT "${octFileName}"
COMMAND ${OCTAVE_MKOCTFILE}
${QT_INCLUDES}
${QT_FRAMEWORKS}
-I${ResInsight_SOURCE_DIR}/ApplicationLibCode/SocketInterface
${RPATH_COMMAND}
-L${QT_LIBRARY_DIR} -Wl,-framework,QtCore -Wl,-framework,QtNetwork
-o "${octFileName}"
"${srcFileName}"
DEPENDS "${srcFileName}"
COMMENT "===> Generating ${octFileName}"
)
else()
add_custom_command(
OUTPUT "${octFileName}"
COMMAND OCTAVE_HOME=${OCTAVE_ROOT_DIR}
${OCTAVE_MKOCTFILE}
${MKOCTFILE_INCLUDE_COMMAND_STRING}
${RPATH_COMMAND}
-L${OCTAVE_QT_LIBRARY_DIR}
-l${OCTAVE_QT_QTCORE_LIB}
-l${OCTAVE_QT_QTNETWORK_LIB}
-o "${octFileName}" "${srcFileName}"
DEPENDS "${srcFileName}"
COMMENT "===> Generating ${octFileName}"
)
endif()
list(APPEND OCTAVE_BINARY_OCT_FILES "${octFileName}")
endforeach()
# Create depencedy string represeting the full path to all generated oct-files
foreach (item ${CPP_SOURCES})
string( REPLACE ".cpp" ".oct" item ${item})
list (APPEND DEPENDENCY_STRING ${CMAKE_CURRENT_BINARY_DIR}/${item})
endforeach (item)
#message("DEPENDENCY_STRING : ${DEPENDENCY_STRING}")
add_custom_target(octave_plugins ALL DEPENDS
${DEPENDENCY_STRING}
SOURCES
${CPP_SOURCES}
riSettings.h
)
# Copy Octave generated *.oct files to application folder, will make it possible to use Octave functions
# directly from the location of the ResInsight binaries
if (true)
foreach (oct_bin ${OCTAVE_BINARY_OCT_FILES})
get_filename_component(Filename "${oct_bin}" NAME)
if(MSVC)
add_custom_command(TARGET octave_plugins POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${oct_bin}"
"${CMAKE_CURRENT_BINARY_DIR}/../ApplicationExeCode/$<CONFIGURATION>/${Filename}"
)
else()
add_custom_command(TARGET octave_plugins POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${oct_bin}"
"${CMAKE_CURRENT_BINARY_DIR}/../ApplicationExeCode/${Filename}"
)
endif()
endforeach( oct_bin )
endif()
# Make ResInsight dependant on Octave, makes it easiser to debug Octave functionality by compiling ResInsight
add_dependencies(ResInsight octave_plugins)
if (RESINSIGHT_PRIVATE_INSTALL)
install(FILES ${OCTAVE_BINARY_OCT_FILES} DESTINATION ${RESINSIGHT_INSTALL_FOLDER})
else (RESINSIGHT_PRIVATE_INSTALL)
# probe for site location of .oct files
if (NOT OCTAVE_SITE_OCT_DIR)
find_program (OCTAVE_CONFIG_COMMAND
octave-config
DOC "Path to Octave component and library information retrieval"
)
exec_program (${OCTAVE_CONFIG_COMMAND}
ARGS --oct-site-dir
OUTPUT_VARIABLE OCTAVE_SITE_OCT_DIR
)
set (OCTAVE_SITE_OCT_DIR "${OCTAVE_SITE_OCT_DIR}" CACHE LOCATION "Octave plugin directory")
endif (NOT OCTAVE_SITE_OCT_DIR)
install (FILES ${OCTAVE_BINARY_OCT_FILES}
DESTINATION ${OCTAVE_SITE_OCT_DIR}
)
endif (RESINSIGHT_PRIVATE_INSTALL)
endif (OCTAVE_MKOCTFILE)