2018-01-10 09:24:23 -06:00
|
|
|
project(opm-common C CXX)
|
2021-03-26 03:16:01 -05:00
|
|
|
cmake_minimum_required (VERSION 3.10)
|
2015-05-08 09:51:22 -05:00
|
|
|
|
2015-09-08 03:39:49 -05:00
|
|
|
option(SIBLING_SEARCH "Search for other modules in sibling directories?" ON)
|
|
|
|
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/Modules)
|
|
|
|
set(OPM_MACROS_ROOT ${PROJECT_SOURCE_DIR})
|
2015-05-08 09:51:22 -05:00
|
|
|
|
2018-03-05 05:46:51 -06:00
|
|
|
option(ENABLE_ECL_INPUT "Enable eclipse input support?" ON)
|
|
|
|
option(ENABLE_ECL_OUTPUT "Enable eclipse output support?" ON)
|
2019-01-22 01:27:03 -06:00
|
|
|
option(ENABLE_MOCKSIM "Build the mock simulator for io testing" ON)
|
2019-06-27 08:19:03 -05:00
|
|
|
option(OPM_ENABLE_PYTHON "Enable python bindings?" OFF)
|
2022-04-29 05:11:52 -05:00
|
|
|
option(OPM_INSTALL_PYTHON "Install python bindings?" ON)
|
2021-03-10 08:31:04 -06:00
|
|
|
option(OPM_ENABLE_EMBEDDED_PYTHON "Enable embedded python?" OFF)
|
2018-03-05 05:46:51 -06:00
|
|
|
|
|
|
|
# Output implies input
|
|
|
|
if(ENABLE_ECL_OUTPUT)
|
|
|
|
set(ENABLE_ECL_INPUT ON)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# And likewise, no input means no output
|
|
|
|
if(NOT ENABLE_ECL_INPUT)
|
|
|
|
set(ENABLE_ECL_OUTPUT OFF)
|
|
|
|
endif()
|
|
|
|
|
2018-10-09 10:42:37 -05:00
|
|
|
|
2015-09-08 03:39:49 -05:00
|
|
|
# not the same location as most of the other projects; this hook overrides
|
|
|
|
macro (dir_hook)
|
|
|
|
endmacro (dir_hook)
|
2015-05-26 06:59:10 -05:00
|
|
|
|
2015-09-21 07:21:21 -05:00
|
|
|
# We need to define this variable in the installed cmake config file.
|
2018-07-12 04:41:46 -05:00
|
|
|
set(OPM_PROJECT_EXTRA_CODE_INSTALLED "#ENABLE_ECL_INPUT is needed by opm-common-prereq.cmake
|
|
|
|
set(ENABLE_ECL_INPUT ${ENABLE_ECL_INPUT})
|
|
|
|
set(OPM_MACROS_ROOT ${CMAKE_INSTALL_PREFIX}/share/opm)
|
2018-07-06 03:49:08 -05:00
|
|
|
list(APPEND CMAKE_MODULE_PATH \${OPM_MACROS_ROOT}/cmake/Modules)
|
2022-10-04 07:07:07 -05:00
|
|
|
include(OpmPackage) #Make macros available after find_package(opm-common)")
|
2015-09-21 07:21:21 -05:00
|
|
|
|
2018-07-12 04:41:46 -05:00
|
|
|
set(OPM_PROJECT_EXTRA_CODE_INTREE "#ENABLE_ECL_INPUT is needed by opm-common-prereq.cmake
|
|
|
|
set(ENABLE_ECL_INPUT ${ENABLE_ECL_INPUT})
|
|
|
|
set(OPM_MACROS_ROOT ${OPM_MACROS_ROOT})
|
2018-07-06 03:49:08 -05:00
|
|
|
list(APPEND CMAKE_MODULE_PATH \${OPM_MACROS_ROOT}/cmake/Modules)
|
2022-10-04 07:07:07 -05:00
|
|
|
include(OpmPackage) #Make macros available after find_package(opm-common)")
|
2018-03-05 05:46:51 -06:00
|
|
|
if(ENABLE_ECL_OUTPUT)
|
|
|
|
set(OPM_PROJECT_EXTRA_CODE_INSTALLED "${OPM_PROJECT_EXTRA_CODE_INSTALLED}
|
2018-08-04 01:00:16 -05:00
|
|
|
set(COMPARE_ECL_COMMAND ${CMAKE_INSTALL_PREFIX}/bin${${name}_VER_DIR}/compareECL)
|
2021-09-22 11:45:10 -05:00
|
|
|
set(OPM_PACK_COMMAND ${CMAKE_INSTALL_PREFIX}/bin${${name}_VER_DIR}/opmpack)
|
|
|
|
set(RST_DECK_COMMAND ${CMAKE_INSTALL_PREFIX}/bin${${name}_VER_DIR}/rst_deck)")
|
2018-03-05 05:46:51 -06:00
|
|
|
|
|
|
|
set(OPM_PROJECT_EXTRA_CODE_INTREE "${OPM_PROJECT_EXTRA_CODE_INTREE}
|
2018-08-04 01:00:16 -05:00
|
|
|
set(COMPARE_ECL_COMMAND ${PROJECT_BINARY_DIR}/bin/compareECL)
|
2021-09-22 11:45:10 -05:00
|
|
|
set(OPM_PACK_COMMAND ${PROJECT_BINARY_DIR}/bin/opmpack)
|
|
|
|
set(RST_DECK_COMMAND ${PROJECT_BINARY_DIR}/bin/rst_deck)")
|
2018-03-05 05:46:51 -06:00
|
|
|
endif()
|
2015-09-09 09:23:26 -05:00
|
|
|
|
2015-09-08 03:39:49 -05:00
|
|
|
# project information is in dune.module. Read this file and set variables.
|
|
|
|
# we cannot generate dune.module since it is read by dunecontrol before
|
|
|
|
# the build starts, so it makes sense to keep the data there then.
|
|
|
|
include (OpmInit)
|
2020-04-02 12:52:21 -05:00
|
|
|
OpmSetPolicies()
|
2015-09-08 03:39:49 -05:00
|
|
|
|
2018-03-12 08:21:26 -05:00
|
|
|
# Look for the opm-tests repository; if found the variable
|
|
|
|
# HAVE_OPM_TESTS will be set to true.
|
|
|
|
include(Findopm-tests)
|
2018-03-05 05:46:51 -06:00
|
|
|
|
2015-09-08 03:39:49 -05:00
|
|
|
# list of prerequisites for this particular project; this is in a
|
|
|
|
# separate file (in cmake/Modules sub-directory) because it is shared
|
|
|
|
# with the find module
|
|
|
|
include (${project}-prereqs)
|
|
|
|
|
2022-11-30 05:44:17 -06:00
|
|
|
# source_hook runs before config_hook and the former needs fmt, hence this
|
|
|
|
# needs to be here.
|
|
|
|
if(fmt_FOUND)
|
|
|
|
# OpmSatellites will not add the library, do it here.
|
|
|
|
list(APPEND opm-common_LIBRARIES fmt::fmt)
|
|
|
|
else()
|
2023-11-21 07:18:55 -06:00
|
|
|
include(DownloadFmt)
|
2021-03-11 13:00:56 -06:00
|
|
|
endif()
|
|
|
|
|
2022-01-27 08:15:45 -06:00
|
|
|
if(OPM_ENABLE_EMBEDDED_PYTHON AND NOT OPM_ENABLE_PYTHON)
|
|
|
|
# This needs to be here to run before source_hook
|
|
|
|
message(WARNING "Inconsistent settings: OPM_ENABLE_PYTHON=OFF and "
|
|
|
|
"OPM_ENABLE_EMBEDDED_PYTHON=ON. Please use OPM_ENABLE_PYTHON=ON to "
|
|
|
|
"activate. Will disable embedded python in this run.")
|
|
|
|
set(OPM_ENABLE_EMBEDDED_PYTHON OFF CACHE BOOL "Enable embedded python?" FORCE)
|
|
|
|
endif()
|
2015-09-08 03:39:49 -05:00
|
|
|
# read the list of components from this file (in the project directory);
|
|
|
|
# it should set various lists with the names of the files to include
|
|
|
|
include (CMakeLists_files.cmake)
|
|
|
|
|
|
|
|
macro (config_hook)
|
2018-03-05 05:46:51 -06:00
|
|
|
if(ENABLE_ECL_INPUT)
|
|
|
|
# For this project
|
2020-09-18 04:19:41 -05:00
|
|
|
include_directories(${EXTRA_INCLUDES} ${PROJECT_BINARY_DIR}/include)
|
2018-03-05 05:46:51 -06:00
|
|
|
# For downstreams
|
|
|
|
list(APPEND EXTRA_INCLUDES ${PROJECT_BINARY_DIR}/include)
|
|
|
|
set(OPM_PROJECT_EXTRA_CODE_INTREE "${OPM_PROJECT_EXTRA_CODE_INTREE}
|
|
|
|
list(APPEND opm-common_INCLUDE_DIRS ${EXTRA_INCLUDES})")
|
|
|
|
if(ENABLE_ECL_INPUT)
|
|
|
|
set(OPM_PROJECT_EXTRA_CODE_INTREE "${OPM_PROJECT_EXTRA_CODE_INTREE}
|
|
|
|
set(HAVE_ECL_INPUT 1)")
|
|
|
|
set(OPM_PROJECT_EXTRA_CODE_INSTALLED "${OPM_PROJECT_EXTRA_CODE_INSTALLED}
|
|
|
|
set(HAVE_ECL_INPUT 1)")
|
2022-11-30 05:27:27 -06:00
|
|
|
set(HAVE_ECL_INPUT 1)
|
2018-03-05 05:46:51 -06:00
|
|
|
endif()
|
|
|
|
if(ENABLE_ECL_OUTPUT)
|
|
|
|
set(OPM_PROJECT_EXTRA_CODE_INTREE "${OPM_PROJECT_EXTRA_CODE_INTREE}
|
|
|
|
set(HAVE_ECL_OUTPUT 1)")
|
|
|
|
set(OPM_PROJECT_EXTRA_CODE_INSTALLED "${OPM_PROJECT_EXTRA_CODE_INSTALLED}
|
|
|
|
set(HAVE_ECL_OUTPUT 1)")
|
|
|
|
endif()
|
2023-02-09 15:08:13 -06:00
|
|
|
# We need to use the correct search mode. Otherwise not finding one
|
|
|
|
# boost component beloq will mark the previously found ones as not
|
|
|
|
# found again. (Code stolen from UseDynamicBoost.cmake
|
|
|
|
if(Boost_DIR)
|
|
|
|
set(_Boost_CONFIG_MODE CONFIG)
|
|
|
|
endif()
|
|
|
|
find_package(Boost COMPONENTS filesystem regex system unit_test_framework ${_Boost_CONFIG_MODE})
|
2018-03-05 05:46:51 -06:00
|
|
|
|
|
|
|
if (HAVE_DYNAMIC_BOOST_TEST)
|
|
|
|
set_target_properties(Boost::unit_test_framework PROPERTIES INTERFACE_COMPILE_DEFINITIONS BOOST_TEST_DYN_LINK=1)
|
|
|
|
endif()
|
|
|
|
endif()
|
2022-11-30 05:27:27 -06:00
|
|
|
|
2015-09-08 03:39:49 -05:00
|
|
|
endmacro (config_hook)
|
|
|
|
|
|
|
|
macro (prereqs_hook)
|
|
|
|
endmacro (prereqs_hook)
|
|
|
|
|
|
|
|
macro (sources_hook)
|
2023-11-21 07:18:55 -06:00
|
|
|
if(NOT cjson_FOUND)
|
|
|
|
include(DownloadCjson)
|
|
|
|
include_directories(${cjson_SOURCE_DIR})
|
|
|
|
list(APPEND opm-common_SOURCES ${cjson_SOURCE_DIR}/cJSON.c)
|
|
|
|
endif()
|
|
|
|
|
2018-03-05 05:46:51 -06:00
|
|
|
if(ENABLE_ECL_INPUT)
|
|
|
|
# Keyword generation
|
|
|
|
include(GenerateKeywords.cmake)
|
|
|
|
|
|
|
|
# Append generated sources
|
2019-12-30 08:26:17 -06:00
|
|
|
list(INSERT opm-common_SOURCES 0 ${PROJECT_BINARY_DIR}/ParserInit.cpp)
|
|
|
|
foreach (name A B C D E F G H I J K L M N O P Q R S T U V W X Y Z)
|
|
|
|
list(INSERT opm-common_SOURCES 0 ${PROJECT_BINARY_DIR}/ParserKeywords/${name}.cpp)
|
2023-01-20 12:49:37 -06:00
|
|
|
list(INSERT opm-common_SOURCES 0 ${PROJECT_BINARY_DIR}/ParserKeywords/ParserInit${name}.cpp)
|
2023-03-08 12:47:36 -06:00
|
|
|
list(INSERT opm-common_SOURCES 0 ${PROJECT_BINARY_DIR}/ParserKeywords/Builtin${name}.cpp)
|
2022-10-04 07:07:07 -05:00
|
|
|
list(INSERT opm-common_HEADERS 0 ${PROJECT_BINARY_DIR}/include/opm/input/eclipse/Parser/ParserKeywords/${name}.hpp)
|
2019-12-30 08:26:17 -06:00
|
|
|
endforeach()
|
2021-11-15 02:58:00 -06:00
|
|
|
if (OPM_ENABLE_EMBEDDED_PYTHON)
|
2021-03-04 12:12:47 -06:00
|
|
|
list(INSERT opm-common_SOURCES 0 ${PROJECT_BINARY_DIR}/python/cxx/builtin_pybind11.cpp)
|
|
|
|
endif()
|
2018-03-05 05:46:51 -06:00
|
|
|
endif()
|
2021-12-14 01:06:42 -06:00
|
|
|
set_source_files_properties(src/opm/input/eclipse/Python/Python.cpp
|
2019-09-04 05:50:43 -05:00
|
|
|
PROPERTIES COMPILE_FLAGS -Wno-shadow)
|
2023-03-09 05:28:53 -06:00
|
|
|
if(QuadMath_FOUND)
|
|
|
|
get_target_property(qm_defs QuadMath::QuadMath INTERFACE_COMPILE_DEFINITIONS)
|
|
|
|
get_target_property(qm_options QuadMath::QuadMath INTERFACE_COMPILE_OPTIONS)
|
|
|
|
set_source_files_properties(src/opm/material/components/CO2.cpp
|
2023-03-09 05:29:32 -06:00
|
|
|
src/opm/material/densead/Evaluation.cpp
|
2023-03-09 05:28:53 -06:00
|
|
|
PROPERTIES COMPILE_DEFINITIONS "${qm_defs}"
|
|
|
|
COMPILE_OPTIONS "${qm_options}")
|
|
|
|
endif()
|
|
|
|
|
2015-09-08 03:39:49 -05:00
|
|
|
endmacro (sources_hook)
|
|
|
|
|
|
|
|
macro (fortran_hook)
|
|
|
|
endmacro (fortran_hook)
|
|
|
|
|
|
|
|
macro (files_hook)
|
|
|
|
endmacro (files_hook)
|
2015-05-26 06:59:10 -05:00
|
|
|
|
2015-09-08 03:39:49 -05:00
|
|
|
macro (tests_hook)
|
2018-03-05 05:46:51 -06:00
|
|
|
if(ENABLE_ECL_INPUT)
|
|
|
|
include(ExtraTests.cmake)
|
|
|
|
endif()
|
2015-09-08 03:39:49 -05:00
|
|
|
endmacro (tests_hook)
|
2015-05-26 06:59:10 -05:00
|
|
|
|
2018-03-05 05:46:51 -06:00
|
|
|
macro (install_hook)
|
|
|
|
install(DIRECTORY ${PROJECT_BINARY_DIR}/include/
|
|
|
|
DESTINATION include
|
|
|
|
PATTERN *.hpp)
|
|
|
|
endmacro (install_hook)
|
|
|
|
|
2022-09-09 00:38:37 -05:00
|
|
|
# Used to append entries from one list to another.
|
|
|
|
# The output list is suitable for use in setup.py subtitution
|
|
|
|
macro(append_quoted OUT IN)
|
|
|
|
foreach(ENTRY ${${IN}})
|
|
|
|
list(APPEND ${OUT} "'${ARGN}${ENTRY}'")
|
|
|
|
endforeach()
|
|
|
|
endmacro()
|
|
|
|
|
2019-10-31 00:43:34 -05:00
|
|
|
# If opm-common is configured to embed the python interpreter we must make sure
|
|
|
|
# that all downstream modules link libpython transitively. Due to the required
|
|
|
|
# integration with Python+cmake machinery provided by pybind11 this is done by
|
|
|
|
# manually adding to the opm-common_LIBRARIES variable here, and not in the
|
2023-01-06 08:59:34 -06:00
|
|
|
# OpmLibMain function. Here only the library dependency is implemented, the
|
2019-10-31 00:43:34 -05:00
|
|
|
# bulk of the python configuration is further down in the file.
|
|
|
|
if (OPM_ENABLE_PYTHON)
|
2021-03-12 09:47:27 -06:00
|
|
|
# We need to be compatible with older CMake versions
|
|
|
|
# that do not offer FindPython3
|
|
|
|
# e.g. Ubuntu LTS 18.04 uses cmake 3.10
|
|
|
|
if(${CMAKE_VERSION} VERSION_LESS "3.12.0")
|
|
|
|
find_package(PythonInterp REQUIRED)
|
2021-03-15 04:19:10 -05:00
|
|
|
if (OPM_ENABLE_EMBEDDED_PYTHON)
|
|
|
|
find_package(PythonLibs REQUIRED)
|
|
|
|
list(APPEND opm-common_LIBRARIES ${PYTHON_LIBRARIES})
|
|
|
|
endif()
|
2021-03-12 09:47:27 -06:00
|
|
|
if(PYTHON_VERSION_MAJOR LESS 3)
|
|
|
|
message(SEND_ERROR "OPM requires version 3 of Python but only version ${PYTHON_VERSION_STRING} was found")
|
|
|
|
endif()
|
|
|
|
set(Python3_EXECUTABLE ${PYTHON_EXECUTABLE})
|
|
|
|
set(Python3_LIBRARIES ${PYTHON_LIBRARIES})
|
2022-07-27 11:08:10 -05:00
|
|
|
set(Python3_VERSION "${PYTHON_VERSION_STRING}")
|
2022-06-07 01:19:15 -05:00
|
|
|
set(Python3_VERSION_MINOR ${PYTHON_VERSION_MINOR})
|
2021-03-12 09:47:27 -06:00
|
|
|
else()
|
2021-03-16 14:18:39 -05:00
|
|
|
# Be backwards compatible.
|
|
|
|
if(PYTHON_EXECUTABLE AND NOT Python3_EXECUTABLE)
|
|
|
|
set(Python3_EXECUTABLE ${PYTHON_EXECUTABLE})
|
|
|
|
endif()
|
2023-04-19 08:26:23 -05:00
|
|
|
# We always need to search for Development as we use
|
|
|
|
# pybind11_add_module even if don't embed Python
|
2023-04-27 04:20:41 -05:00
|
|
|
if (NOT OPM_ENABLE_EMBEDDED_PYTHON)
|
2023-05-02 01:57:39 -05:00
|
|
|
if(${CMAKE_VERSION} VERSION_LESS "3.18.0")
|
|
|
|
find_package(Python3 REQUIRED COMPONENTS Interpreter Development)
|
|
|
|
else()
|
|
|
|
find_package(Python3 REQUIRED COMPONENTS Interpreter Development.Module)
|
|
|
|
endif()
|
2023-04-27 04:20:41 -05:00
|
|
|
else()
|
2023-05-02 01:57:39 -05:00
|
|
|
if(${CMAKE_VERSION} VERSION_LESS "3.18.0")
|
|
|
|
find_package(Python3 REQUIRED COMPONENTS Interpreter Development)
|
|
|
|
else()
|
|
|
|
find_package(Python3 REQUIRED COMPONENTS Interpreter Development.Embed Development.Module)
|
|
|
|
endif()
|
2021-03-15 04:19:10 -05:00
|
|
|
get_target_property(_lib_path Python3::Python IMPORTED_LOCATION)
|
|
|
|
set(PYTHON_LIBRARY ${_lib_path})
|
2021-03-16 14:15:00 -05:00
|
|
|
set(PYTHON_LIBRARIES {PYTHON_LIBRARY})
|
|
|
|
list(APPEND opm-common_LIBRARIES ${PYTHON_LIBRARY})
|
2021-03-16 13:33:43 -05:00
|
|
|
set(PYTHON_INCLUDE_DIRS ${Python3_INCLUDE_DIRS})
|
2021-03-15 04:19:10 -05:00
|
|
|
endif()
|
2022-06-07 01:19:15 -05:00
|
|
|
if(Python3_VERSION_MINOR LESS 3)
|
|
|
|
# Python native namespace packages requires python >= 3.3
|
|
|
|
message(SEND_ERROR "OPM requires python >= 3.3 but only version ${Python3_VERSION} was found")
|
|
|
|
endif()
|
2022-03-15 05:27:42 -05:00
|
|
|
|
2021-03-12 09:48:26 -06:00
|
|
|
# Compatibility settings for PythonInterp and PythonLibs
|
2021-03-16 13:33:43 -05:00
|
|
|
# used e.g. in FindCwrap, pybind11
|
2021-03-12 09:48:26 -06:00
|
|
|
set(PYTHON_EXECUTABLE ${Python3_EXECUTABLE})
|
2022-06-03 02:03:34 -05:00
|
|
|
# Directory to install common (for opm modules) python scripts
|
|
|
|
include (GNUInstallDirs)
|
|
|
|
set(OPM_PYTHON_COMMON_DIR "${CMAKE_INSTALL_DATAROOTDIR}/opm/python")
|
2022-10-05 01:44:57 -05:00
|
|
|
set(OPM_PROJECT_EXTRA_CODE_INTREE "${OPM_PROJECT_EXTRA_CODE_INTREE}
|
|
|
|
set(opm-common_PYTHON_COMMON_DIR ${PROJECT_SOURCE_DIR}/python)")
|
|
|
|
set(OPM_PROJECT_EXTRA_CODE_INSTALLED "${OPM_PROJECT_EXTRA_CODE_INSTALLED}
|
|
|
|
set(opm-common_PYTHON_COMMON_DIR ${CMAKE_INSTALL_PREFIX}/${OPM_PYTHON_COMMON_DIR})")
|
2019-10-31 00:43:34 -05:00
|
|
|
endif()
|
2021-03-16 13:33:43 -05:00
|
|
|
# We always need the PYTHON_INCLUDE_DIR. Unfortunately
|
|
|
|
# When we build pypi packages CMake will fail to determine
|
|
|
|
# these via the usual find_package(PythonLibs or
|
|
|
|
# find_package(Python3 REQUIRED COMPONENTS Interpreter Development)
|
|
|
|
# Hence we overwrite them here.
|
|
|
|
if(NOT PYTHON_INCLUDE_DIRS)
|
2021-03-19 13:15:23 -05:00
|
|
|
execute_process(COMMAND "${PYTHON_EXECUTABLE}" "-c" "from distutils import sysconfig; print(sysconfig.get_python_inc(plat_specific=True), end=\"\");"
|
2021-03-16 13:33:43 -05:00
|
|
|
RESULT_VARIABLE _PYTHON_DIR_SUCCESS
|
|
|
|
OUTPUT_VARIABLE PYTHON_INCLUDE_DIR
|
|
|
|
ERROR_VARIABLE _PYTHON_ERROR_VALUE)
|
|
|
|
if(NOT _PYTHON_DIR_SUCCESS MATCHES 0)
|
|
|
|
message(FATAL_ERROR "Could not determine Python include directory. Error: ${_PYTHON_ERROR_VALUE}.")
|
|
|
|
endif()
|
|
|
|
set(PYTHON_INCLUDE_DIRS ${PYTHON_INCLUDE_DIR})
|
|
|
|
endif()
|
2021-03-15 15:55:40 -05:00
|
|
|
find_package(pybind11 2.2 CONFIG)
|
|
|
|
if (NOT pybind11_FOUND)
|
2023-09-07 08:33:14 -05:00
|
|
|
include(DownloadPyBind11)
|
2021-03-15 15:55:40 -05:00
|
|
|
endif()
|
2019-10-31 00:43:34 -05:00
|
|
|
endif()
|
|
|
|
|
|
|
|
|
2015-09-08 03:39:49 -05:00
|
|
|
# all setup common to the OPM library modules is done here
|
|
|
|
include (OpmLibMain)
|
2015-09-09 09:23:37 -05:00
|
|
|
|
2022-11-30 05:44:52 -06:00
|
|
|
if (ENABLE_MOCKSIM AND ENABLE_ECL_INPUT)
|
2018-10-09 10:42:37 -05:00
|
|
|
add_library(mocksim
|
|
|
|
msim/src/msim.cpp)
|
|
|
|
target_link_libraries(mocksim opmcommon)
|
|
|
|
target_include_directories(mocksim PUBLIC msim/include)
|
|
|
|
add_executable(msim examples/msim.cpp)
|
|
|
|
target_link_libraries(msim mocksim)
|
|
|
|
|
2020-03-22 15:35:59 -05:00
|
|
|
if (Boost_UNIT_TEST_FRAMEWORK_FOUND)
|
|
|
|
set(_libs mocksim opmcommon
|
|
|
|
${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
|
|
|
|
|
2020-04-15 14:04:26 -05:00
|
|
|
foreach( test test_msim test_msim_ACTIONX test_msim_EXIT)
|
2020-03-22 15:35:59 -05:00
|
|
|
opm_add_test(${test} SOURCES tests/msim/${test}.cpp
|
|
|
|
LIBRARIES ${_libs}
|
|
|
|
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/tests
|
|
|
|
CONDITION ${HAVE_ECL_INPUT})
|
|
|
|
endforeach()
|
|
|
|
endif()
|
2018-10-09 10:42:37 -05:00
|
|
|
endif()
|
|
|
|
|
2018-09-07 05:46:42 -05:00
|
|
|
# Build the compare utilities
|
|
|
|
if(ENABLE_ECL_INPUT)
|
2019-05-02 08:01:20 -05:00
|
|
|
add_executable(compareECL
|
|
|
|
test_util/EclFilesComparator.cpp
|
|
|
|
test_util/EclRegressionTest.cpp
|
|
|
|
test_util/compareECL.cpp
|
|
|
|
)
|
|
|
|
|
|
|
|
add_executable(convertECL
|
|
|
|
test_util/convertECL.cpp
|
|
|
|
)
|
|
|
|
|
2019-10-23 05:32:38 -05:00
|
|
|
add_executable(summary
|
|
|
|
test_util/summary.cpp
|
|
|
|
)
|
|
|
|
|
2021-12-03 07:08:41 -06:00
|
|
|
add_executable(arraylist
|
|
|
|
test_util/arraylist.cpp
|
|
|
|
)
|
|
|
|
|
2020-11-02 15:14:49 -06:00
|
|
|
add_executable(rewriteEclFile
|
|
|
|
test_util/rewriteEclFile.cpp
|
|
|
|
)
|
|
|
|
|
2021-12-03 07:08:41 -06:00
|
|
|
foreach(target compareECL convertECL summary rewriteEclFile arraylist)
|
2019-05-02 08:01:20 -05:00
|
|
|
target_link_libraries(${target} opmcommon)
|
2019-03-28 09:03:20 -05:00
|
|
|
install(TARGETS ${target} DESTINATION bin)
|
|
|
|
endforeach()
|
2018-09-07 05:46:42 -05:00
|
|
|
|
|
|
|
# Add the tests
|
2019-05-02 08:01:20 -05:00
|
|
|
set(_libs opmcommon
|
2018-09-07 05:46:42 -05:00
|
|
|
${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
|
2019-05-02 08:01:20 -05:00
|
|
|
|
|
|
|
opm_add_test(test_EclFilesComparator
|
|
|
|
CONDITION
|
2020-02-19 05:24:53 -06:00
|
|
|
ENABLE_ECL_INPUT AND Boost_UNIT_TEST_FRAMEWORK_FOUND
|
2019-05-02 08:01:20 -05:00
|
|
|
SOURCES
|
|
|
|
tests/test_EclFilesComparator.cpp
|
|
|
|
test_util/EclFilesComparator.cpp
|
|
|
|
LIBRARIES
|
|
|
|
${_libs}
|
|
|
|
WORKING_DIRECTORY
|
|
|
|
${PROJECT_BINARY_DIR}/tests
|
|
|
|
)
|
|
|
|
|
|
|
|
opm_add_test(test_EclRegressionTest
|
|
|
|
CONDITION
|
2020-02-19 05:24:53 -06:00
|
|
|
ENABLE_ECL_INPUT AND Boost_UNIT_TEST_FRAMEWORK_FOUND
|
2019-05-02 08:01:20 -05:00
|
|
|
SOURCES
|
|
|
|
tests/test_EclRegressionTest.cpp
|
|
|
|
test_util/EclFilesComparator.cpp
|
|
|
|
test_util/EclRegressionTest.cpp
|
|
|
|
LIBRARIES
|
|
|
|
${_libs}
|
|
|
|
WORKING_DIRECTORY
|
|
|
|
${PROJECT_BINARY_DIR}/tests
|
|
|
|
)
|
|
|
|
|
2018-09-07 05:46:42 -05:00
|
|
|
endif()
|
|
|
|
|
2022-11-30 05:27:27 -06:00
|
|
|
# Explicitly link tests needing dune-common.
|
|
|
|
# To avoid pulling dune-common into the opm-common interface
|
|
|
|
find_package(dune-common REQUIRED)
|
|
|
|
opm_need_version_of ("dune-common")
|
|
|
|
target_include_directories(dunecommon INTERFACE ${dune-common_INCLUDE_DIRS})
|
2023-05-30 03:40:55 -05:00
|
|
|
string(REPLACE " " ";" dflags "${dune-common_CXX_FLAGS}")
|
2022-11-30 05:27:27 -06:00
|
|
|
target_compile_options(dunecommon INTERFACE ${dflags})
|
|
|
|
target_compile_definitions(dunecommon INTERFACE DUNE_COMMON_VERSION_MAJOR=${DUNE_COMMON_VERSION_MAJOR})
|
|
|
|
target_compile_definitions(dunecommon INTERFACE DUNE_COMMON_VERSION_MINOR=${DUNE_COMMON_VERSION_MINOR})
|
|
|
|
target_compile_definitions(dunecommon INTERFACE DUNE_COMMON_VERSION_REVISION=${DUNE_COMMON_VERSION_REVISION})
|
2023-02-09 15:08:13 -06:00
|
|
|
if(Boost_UNIT_TEST_FRAMEWORK_FOUND)
|
2023-03-13 05:29:30 -05:00
|
|
|
foreach(src ${DUNE_TEST_SOURCE_FILES})
|
2023-02-09 15:08:13 -06:00
|
|
|
get_filename_component(tgt ${src} NAME_WE)
|
|
|
|
target_link_libraries(${tgt} dunecommon)
|
|
|
|
endforeach()
|
|
|
|
endif()
|
2023-03-13 05:29:30 -05:00
|
|
|
if(BUILD_EXAMPLES)
|
|
|
|
target_link_libraries(co2brinepvt dunecommon)
|
2023-05-05 10:09:42 -05:00
|
|
|
install(TARGETS co2brinepvt DESTINATION bin)
|
2023-03-13 05:29:30 -05:00
|
|
|
endif()
|
2022-11-30 05:27:27 -06:00
|
|
|
|
2021-06-11 09:29:42 -05:00
|
|
|
# Install build system files and documentation
|
|
|
|
install(DIRECTORY cmake
|
|
|
|
DESTINATION share/opm USE_SOURCE_PERMISSIONS
|
|
|
|
PATTERN "OPM-CMake.md" EXCLUDE)
|
|
|
|
|
|
|
|
install(FILES cmake/OPM-CMake.md
|
|
|
|
DESTINATION ${CMAKE_INSTALL_DOCDIR})
|
2018-09-19 04:40:20 -05:00
|
|
|
|
|
|
|
# Install tab completion skeleton
|
|
|
|
install(FILES etc/opm_bash_completion.sh.in DESTINATION share/opm/etc)
|
2019-06-14 06:20:51 -05:00
|
|
|
|
2019-06-27 08:19:03 -05:00
|
|
|
if (OPM_ENABLE_PYTHON)
|
2020-01-13 06:19:10 -06:00
|
|
|
make_directory(${PROJECT_BINARY_DIR}/python)
|
2020-01-26 01:40:53 -06:00
|
|
|
|
2020-06-16 06:06:52 -05:00
|
|
|
set(opm-common_PYTHON_PACKAGE_VERSION ${OPM_PYTHON_PACKAGE_VERSION_TAG})
|
2021-04-08 02:59:57 -05:00
|
|
|
|
2023-01-06 08:59:34 -06:00
|
|
|
add_custom_target(copy_python ALL
|
|
|
|
COMMAND ${Python3_EXECUTABLE} ${PROJECT_SOURCE_DIR}/python/install.py ${PROJECT_SOURCE_DIR}/python ${PROJECT_BINARY_DIR} 0)
|
2021-04-08 02:59:57 -05:00
|
|
|
|
2023-01-06 08:59:34 -06:00
|
|
|
file(COPY ${PROJECT_SOURCE_DIR}/python/README.md DESTINATION ${PROJECT_BINARY_DIR}/python)
|
2021-10-29 05:50:08 -05:00
|
|
|
|
2023-01-06 08:59:34 -06:00
|
|
|
pybind11_add_module(opmcommon_python
|
|
|
|
${PYTHON_CXX_SOURCE_FILES}
|
|
|
|
${PROJECT_BINARY_DIR}/python/cxx/builtin_pybind11.cpp)
|
|
|
|
target_link_libraries(opmcommon_python PRIVATE
|
|
|
|
opmcommon)
|
|
|
|
if(TARGET pybind11::pybind11)
|
|
|
|
target_link_libraries(opmcommon_python PRIVATE
|
|
|
|
pybind11::pybind11)
|
|
|
|
else()
|
|
|
|
target_include_directories(opmcommon_python SYSTEM PRIVATE ${pybind11_INCLUDE_DIRS})
|
2022-01-27 04:14:58 -06:00
|
|
|
endif()
|
2023-01-06 08:59:34 -06:00
|
|
|
set_target_properties(opmcommon_python PROPERTIES
|
|
|
|
LIBRARY_OUTPUT_DIRECTORY python/opm)
|
|
|
|
add_dependencies(opmcommon_python copy_python)
|
2022-01-27 04:14:58 -06:00
|
|
|
|
2023-01-06 08:59:34 -06:00
|
|
|
# Generate versioned setup.py
|
|
|
|
configure_file(${PROJECT_SOURCE_DIR}/python/setup.py.in
|
|
|
|
${PROJECT_BINARY_DIR}/python/setup.py.tmp)
|
|
|
|
file(GENERATE OUTPUT ${PROJECT_BINARY_DIR}/python/setup.py
|
|
|
|
INPUT ${PROJECT_BINARY_DIR}/python/setup.py.tmp)
|
2019-10-28 15:33:11 -05:00
|
|
|
|
2019-10-06 10:05:05 -05:00
|
|
|
# Since the installation of Python code is nonstandard it is protected by an
|
2019-10-06 10:08:05 -05:00
|
|
|
# extra cmake switch, OPM_INSTALL_PYTHON. If you prefer you can still invoke
|
|
|
|
# setup.py install manually - optionally with the generated script
|
|
|
|
# setup-install.sh - and completely bypass cmake in the installation phase.
|
2019-10-06 10:05:05 -05:00
|
|
|
if (OPM_INSTALL_PYTHON)
|
2023-01-06 08:59:34 -06:00
|
|
|
include(PyInstallPrefix)
|
|
|
|
install(TARGETS opmcommon_python DESTINATION ${DEST_PREFIX}${CMAKE_INSTALL_PREFIX}/${PYTHON_INSTALL_PREFIX}/opm)
|
|
|
|
install(
|
|
|
|
CODE "execute_process(
|
|
|
|
COMMAND ${PYTHON_EXECUTABLE}
|
|
|
|
python/install.py
|
|
|
|
${PROJECT_BINARY_DIR}/python/opm
|
|
|
|
${DEST_PREFIX}${CMAKE_INSTALL_PREFIX}/${PYTHON_INSTALL_PREFIX} 1)")
|
|
|
|
|
|
|
|
## Need to install this Python script such that it can be used by opm-simulators when building against an installed
|
|
|
|
## opm-common
|
|
|
|
install( PROGRAMS "python/install.py" DESTINATION "${OPM_PYTHON_COMMON_DIR}" )
|
2019-10-06 10:05:05 -05:00
|
|
|
endif()
|
2019-06-27 07:08:22 -05:00
|
|
|
|
2020-02-17 02:56:16 -06:00
|
|
|
# Observe that if the opmcommon library has been built as a shared library the
|
|
|
|
# python library opmcommon_python will in general not find it runtime while
|
|
|
|
# testing.
|
2019-06-27 07:08:22 -05:00
|
|
|
add_test(NAME python_tests
|
2020-01-13 06:19:10 -06:00
|
|
|
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/python
|
2023-01-13 11:12:31 -06:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E env LD_LIBRARY_PATH=${PROJECT_BINARY_DIR}/lib ${Python3_EXECUTABLE} -m unittest discover
|
2019-06-27 07:08:22 -05:00
|
|
|
)
|
|
|
|
|
2019-06-27 05:10:02 -05:00
|
|
|
set_target_properties(opmcommon PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
2020-07-01 02:25:11 -05:00
|
|
|
set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES ${PROJECT_BINARY_DIR}/python)
|
2019-09-05 01:34:08 -05:00
|
|
|
|
2019-09-02 11:27:22 -05:00
|
|
|
# -------------------------------------------------------------------------
|
|
|
|
# Let cmake configure some small shell scripts which can be used to simplify
|
2019-10-06 10:05:05 -05:00
|
|
|
# building, testing and installation of the Python extensions.
|
2019-09-05 01:34:08 -05:00
|
|
|
configure_file(python/setup-build.sh.in tmp/setup-build.sh)
|
|
|
|
file( COPY ${PROJECT_BINARY_DIR}/tmp/setup-build.sh
|
|
|
|
DESTINATION ${PROJECT_BINARY_DIR}
|
|
|
|
FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE )
|
|
|
|
|
|
|
|
configure_file(python/setup-test.sh.in tmp/setup-test.sh)
|
|
|
|
file( COPY ${PROJECT_BINARY_DIR}/tmp/setup-test.sh
|
|
|
|
DESTINATION ${PROJECT_BINARY_DIR}
|
|
|
|
FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE )
|
|
|
|
|
2019-10-06 10:05:05 -05:00
|
|
|
configure_file(python/setup-install.sh.in tmp/setup-install.sh)
|
|
|
|
file( COPY ${PROJECT_BINARY_DIR}/tmp/setup-install.sh
|
|
|
|
DESTINATION ${PROJECT_BINARY_DIR}
|
|
|
|
FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE )
|
|
|
|
|
2019-09-05 01:34:08 -05:00
|
|
|
configure_file(python/enable-python.sh.in enable-python.sh)
|
2019-06-14 06:20:51 -05:00
|
|
|
|
2019-09-02 11:27:22 -05:00
|
|
|
# -------------------------------------------------------------------------
|
|
|
|
# 2: Embed the Python interpreter for keywords like PYACTION and PYINPUT
|
2021-03-15 15:55:40 -05:00
|
|
|
target_include_directories(opmcommon SYSTEM PRIVATE "${pybind11_INCLUDE_DIRS}")
|
2019-09-02 11:27:22 -05:00
|
|
|
if (OPM_ENABLE_EMBEDDED_PYTHON)
|
2019-09-04 05:59:39 -05:00
|
|
|
target_link_libraries(opmcommon PUBLIC ${PYTHON_LIBRARY})
|
2019-09-02 11:27:22 -05:00
|
|
|
add_definitions(-DEMBEDDED_PYTHON)
|
|
|
|
endif()
|
|
|
|
endif()
|
2021-04-01 08:22:02 -05:00
|
|
|
|
|
|
|
install(DIRECTORY docs/man1 DESTINATION ${CMAKE_INSTALL_MANDIR}
|
|
|
|
FILES_MATCHING PATTERN "*.1")
|