2018-01-10 09:24:23 -06:00
|
|
|
project(opm-common C CXX)
|
2015-09-08 03:39:49 -05:00
|
|
|
cmake_minimum_required (VERSION 2.8)
|
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)
|
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)
|
|
|
|
include(OpmPackage) #Make macros availabe 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)
|
|
|
|
include(OpmPackage) #Make macros availabe 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)
|
|
|
|
set(OPM_PACK_COMMAND ${CMAKE_INSTALL_PREFIX}/bin${${name}_VER_DIR}/opmpack)")
|
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)
|
|
|
|
set(OPM_PACK_COMMAND ${PROJECT_BINARY_DIR}/bin/opmpack)")
|
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)
|
|
|
|
|
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)
|
|
|
|
|
|
|
|
# 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)
|
|
|
|
if(NOT cjson_FOUND)
|
|
|
|
list(APPEND EXTRA_INCLUDES ${PROJECT_SOURCE_DIR}/external/cjson)
|
|
|
|
endif()
|
|
|
|
# For this project
|
|
|
|
include_directories(${EXTRA_INCLUDES} ${PROJECT_BINARY_DIR}/include)
|
|
|
|
|
|
|
|
# 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)")
|
|
|
|
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()
|
|
|
|
|
|
|
|
# Configure boost targets for old cmake
|
|
|
|
include(cmake/Modules/BoostTargets.cmake)
|
|
|
|
|
|
|
|
if (HAVE_DYNAMIC_BOOST_TEST)
|
|
|
|
set_target_properties(Boost::unit_test_framework PROPERTIES INTERFACE_COMPILE_DEFINITIONS BOOST_TEST_DYN_LINK=1)
|
|
|
|
endif()
|
|
|
|
endif()
|
2015-09-08 03:39:49 -05:00
|
|
|
endmacro (config_hook)
|
|
|
|
|
|
|
|
macro (prereqs_hook)
|
|
|
|
endmacro (prereqs_hook)
|
|
|
|
|
|
|
|
macro (sources_hook)
|
2018-03-05 05:46:51 -06:00
|
|
|
if(ENABLE_ECL_INPUT)
|
|
|
|
# Keyword generation
|
|
|
|
include(GenerateKeywords.cmake)
|
|
|
|
|
|
|
|
# Append generated sources
|
|
|
|
list(APPEND opm-common_SOURCES ${PROJECT_BINARY_DIR}/ParserKeywords.cpp)
|
|
|
|
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)
|
|
|
|
|
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
|
|
|
|
2018-10-09 10:42:37 -05:00
|
|
|
if (ENABLE_MOCKSIM)
|
|
|
|
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)
|
|
|
|
|
|
|
|
set(_libs mocksim opmcommon
|
|
|
|
${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
|
|
|
|
|
2019-01-28 03:00:08 -06:00
|
|
|
foreach( test test_msim test_msim_ACTIONX )
|
2019-07-10 01:59:40 -05:00
|
|
|
opm_add_test(${test} SOURCES tests/msim/${test}.cpp
|
2019-02-15 04:02:53 -06:00
|
|
|
LIBRARIES ${_libs}
|
|
|
|
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/tests)
|
2018-10-09 10:42:37 -05:00
|
|
|
endforeach()
|
|
|
|
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-03-28 09:03:20 -05:00
|
|
|
foreach(target compareECL convertECL)
|
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
|
|
|
|
ENABLE_ECL_INPUT
|
|
|
|
SOURCES
|
|
|
|
tests/test_EclFilesComparator.cpp
|
|
|
|
test_util/EclFilesComparator.cpp
|
|
|
|
LIBRARIES
|
|
|
|
${_libs}
|
|
|
|
WORKING_DIRECTORY
|
|
|
|
${PROJECT_BINARY_DIR}/tests
|
|
|
|
)
|
|
|
|
|
|
|
|
opm_add_test(test_EclRegressionTest
|
|
|
|
CONDITION
|
|
|
|
ENABLE_ECL_INPUT
|
|
|
|
SOURCES
|
|
|
|
tests/test_EclRegressionTest.cpp
|
|
|
|
test_util/EclFilesComparator.cpp
|
|
|
|
test_util/EclRegressionTest.cpp
|
|
|
|
LIBRARIES
|
|
|
|
${_libs}
|
|
|
|
WORKING_DIRECTORY
|
|
|
|
${PROJECT_BINARY_DIR}/tests
|
|
|
|
)
|
|
|
|
|
|
|
|
foreach(test test_EclIO test_EGrid test_ERft test_ERst test_ESmry)
|
2019-02-15 04:02:53 -06:00
|
|
|
opm_add_test(${test} CONDITION ENABLE_ECL_INPUT
|
2019-03-28 05:55:50 -05:00
|
|
|
LIBRARIES ${_libs}
|
|
|
|
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/tests)
|
2019-02-15 04:02:53 -06:00
|
|
|
endforeach()
|
2018-09-07 05:46:42 -05:00
|
|
|
endif()
|
|
|
|
|
2015-09-09 09:23:37 -05:00
|
|
|
# Install build system files
|
|
|
|
install(DIRECTORY cmake DESTINATION share/opm)
|
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)
|
2019-08-13 08:54:59 -05:00
|
|
|
make_directory(${CMAKE_BINARY_DIR}/python)
|
2019-06-27 07:08:22 -05:00
|
|
|
if (EXISTS "/etc/debian_version")
|
|
|
|
set( PYTHON_PACKAGE_PATH "dist-packages")
|
|
|
|
else()
|
|
|
|
set( PYTHON_PACKAGE_PATH "site-packages")
|
|
|
|
endif()
|
2019-08-12 01:36:00 -05:00
|
|
|
set(PYTHON_INSTALL_PREFIX "lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/${PYTHON_PACKAGE_PATH}/opm" CACHE STRING "Subdirectory to install Python modules in")
|
2019-06-27 07:08:22 -05:00
|
|
|
|
|
|
|
get_target_property(_ecl_include_dirs ecl INTERFACE_INCLUDE_DIRECTORIES)
|
|
|
|
get_target_property(_opmcommon_include_dirs opmcommon INCLUDE_DIRECTORIES)
|
|
|
|
list(APPEND _opmcommon_include_dirs ${_ecl_include_dirs})
|
|
|
|
string(REPLACE ";" ":" _setup_include_dirs "${_opmcommon_include_dirs}")
|
|
|
|
|
|
|
|
get_target_property(_ecl_lib ecl LOCATION)
|
|
|
|
get_filename_component(_ecl_lib_dir ${_ecl_lib} DIRECTORY)
|
|
|
|
set(_opmcommon_lib_dirs ${_ecl_lib_dir} ${CMAKE_BINARY_DIR}/lib ${CMAKE_PREFIX_PATH}/lib)
|
|
|
|
string(REPLACE ";" ":" _setup_lib_dirs "${_opmcommon_lib_dirs}")
|
|
|
|
|
2019-08-12 01:36:00 -05:00
|
|
|
add_custom_command(OUTPUT python/python/opm/libopmcommon_python.so
|
2019-08-13 08:54:59 -05:00
|
|
|
DEPENDS python/cxx/connection.cpp
|
|
|
|
python/cxx/converters.hpp
|
|
|
|
python/cxx/deck.cpp
|
|
|
|
python/cxx/deck_keyword.cpp
|
|
|
|
python/cxx/eclipse_3d_properties.cpp
|
|
|
|
python/cxx/eclipse_config.cpp
|
|
|
|
python/cxx/eclipse_grid.cpp
|
|
|
|
python/cxx/eclipse_state.cpp
|
|
|
|
python/cxx/group.cpp
|
|
|
|
python/cxx/group_tree.cpp
|
|
|
|
python/cxx/parser.cpp
|
|
|
|
python/cxx/schedule.cpp
|
2019-08-15 04:19:18 -05:00
|
|
|
python/cxx/common.cpp
|
|
|
|
python/cxx/common.hpp
|
|
|
|
python/cxx/common_state.cpp
|
|
|
|
python/cxx/common_state.hpp
|
2019-08-13 08:54:59 -05:00
|
|
|
python/cxx/table_manager.cpp
|
|
|
|
python/cxx/well.cpp
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/python/ ${CMAKE_BINARY_DIR}/python
|
|
|
|
COMMAND python ${CMAKE_BINARY_DIR}/python/setup.py
|
2019-06-27 07:08:22 -05:00
|
|
|
build
|
|
|
|
build_ext
|
2019-08-12 01:36:00 -05:00
|
|
|
--build-lib=${CMAKE_BINARY_DIR}/python/python/opm
|
2019-06-27 07:08:22 -05:00
|
|
|
--library-dirs=${_setup_lib_dirs}
|
|
|
|
--include-dirs=${_setup_include_dirs}
|
2019-08-13 08:54:59 -05:00
|
|
|
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/python
|
|
|
|
COMMENT "Building python bindings")
|
2019-08-12 01:36:00 -05:00
|
|
|
add_custom_target(opmcommon_python ALL DEPENDS python/python/opm/libopmcommon_python.so)
|
|
|
|
add_dependencies(opmcommon_python opmcommon)
|
|
|
|
INSTALL( DIRECTORY ${CMAKE_BINARY_DIR}/python/python/opm/ DESTINATION ${CMAKE_INSTALL_PREFIX}/${PYTHON_INSTALL_PREFIX})
|
2019-06-27 07:08:22 -05:00
|
|
|
|
|
|
|
add_test(NAME python_tests
|
|
|
|
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/python
|
2019-08-12 01:36:00 -05:00
|
|
|
COMMAND python setup.py build_ext --dry-run --build-lib ${CMAKE_BINARY_DIR}/python/python/opm test
|
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)
|
2019-08-13 08:54:48 -05:00
|
|
|
set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES ${CMAKE_BINARY_DIR}/python/python)
|
2019-06-14 06:20:51 -05:00
|
|
|
endif()
|
|
|
|
|
|
|
|
|