Skip to content

Commit

Permalink
: wip 2
Browse files Browse the repository at this point in the history
  • Loading branch information
pinkwah committed Apr 29, 2024
1 parent 2c73b52 commit 1fcce1d
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 21 deletions.
33 changes: 21 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
include(GNUInstallDirs)
include(TestBigEndian)

option(BUILD_TESTS "Should the tests be built" ON)
option(BUILD_APPLICATIONS "Should we build small utility applications" OFF)
option(BUILD_RD_SUMMARY "Build the commandline application rd_summary" OFF)
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
option(ERT_USE_OPENMP "Use OpenMP" OFF)
option(RST_DOC "Build RST documentation" OFF)
option(USE_RPATH "Don't strip RPATH from libraries and binaries" OFF)
option(USE_CONAN "Use Conan (https://conan.io) for package management" ON)

# -----------------------------------------------------------------
# Set default CMAKE_BUILD_TYPE
# -----------------------------------------------------------------
Expand Down Expand Up @@ -35,7 +44,8 @@ endif()
# https://docs.conan.io/en/latest/howtos/cmake_launch.html
# -----------------------------------------------------------------

if(NOT EXISTS "${CMAKE_BINARY_DIR}/conan.cmake")
if(USE_CONAN)
if(NOT EXISTS "${CMAKE_BINARY_DIR}/conan.cmake")
message(
STATUS
"Downloading conan.cmake from https://github.com/conan-io/cmake-conan")
Expand Down Expand Up @@ -77,6 +87,16 @@ conan_cmake_run(
GENERATORS
cmake_find_package)

find_package(Backward REQUIRED)
find_package(fmt REQUIRED)

else()

find_path(BACKWARD_DIR backward.hpp REQUIRED)
find_package(fmt REQUIRED)

endif(USE_CONAN)

# -----------------------------------------------------------------

set(RD_VERSION_MAJOR 0)
Expand Down Expand Up @@ -152,14 +172,6 @@ message(

# -----------------------------------------------------------------

option(BUILD_TESTS "Should the tests be built" OFF)
option(BUILD_APPLICATIONS "Should we build small utility applications" OFF)
option(BUILD_RD_SUMMARY "Build the commandline application rd_summary" OFF)
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
option(ERT_USE_OPENMP "Use OpenMP" OFF)
option(RST_DOC "Build RST documentation" OFF)
option(USE_RPATH "Don't strip RPATH from libraries and binaries" OFF)

set(EQUINOR_TESTDATA_ROOT
""
CACHE PATH "Root to Equinor internal testdata")
Expand Down Expand Up @@ -240,9 +252,6 @@ find_package(CXX11Features)

# -----------------------------------------------------------------

find_package(Backward REQUIRED)
find_package(fmt REQUIRED)

# create targets for (required and optional) dependencies to link to

find_package(OpenMP)
Expand Down
54 changes: 48 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,59 @@
# resdata

# ResData
Python package for reading and writing the result files from
reservoir simulators. The file types covered are the
RESTART, INIT, RFT, Summary and GRID files in unified and non-unified, and formatted and unformatted.

*resdata* is mainly developed on *Linux* and *macOS*, in addition there is a
portability layer which ensures that most of the functionality is available on
*Windows*. *resdata* was initially developed as part of the
ResData officially only supports Linux and macOS. It was initially developed as part of the
[_ert_](http://github.com/Equinor/ert) project.

## Using
[*resdata* is available on PyPI](https://pypi.org/project/resdata/) and can be installed into a [Python environment](https://docs.python.org/3/library/venv.html#creating-virtual-environments) with `pip`:
[ResData is available on PyPI](https://pypi.org/project/resdata/) and can be installed into a [Python virtual environment](https://docs.python.org/3/library/venv.html#creating-virtual-environments) with `pip`:

```sh
pip install resdata
```

## Building
ResData is a Python project with a C++ extension layer. Most of the functionality is implemented in C++ and uses [cwrap](https://github.com/equinor/cwrap) for binding it to Python.

A C++17-compatible compiler, like GCC 8+ or Clang 11+ is required. Other C++ dependencies are brought in automatically by [Conan](https://conan.io) during [CMake](https://cmake.org) compilation.

In a [Python virtual environment](https://docs.python.org/3/library/venv.html#creating-virtual-environments), run:
```sh
# Fetch directly from GitHub
pip install git+https://github.com/equinor/resdata

# If git-cloned, install local directory in editable mode
pip install --editable .
```

## Running tests
As this codebase contains both Python and C++ code, there are tests for both Python and C++.

### Python tests
These tests use [pytest](https://pytest.org) and require that ResData is installed into a Python virtualenv in `--editable` mode, as described in the [Building](#Building) section.

Ensure that pytest is installed and do the following to
```sh
# Install pytest
pip install pytest

# Run all tests in the python/tests directory
pytest python/tests
```

### C++ tests
ResData uses a homegrown testing suite as well as [Catch2, 2.x](https://github.com/catchorg/Catch2) which is compiled via CMake and ran using `ctest`.

Ensure that `cmake` and `conan` version 1 is installed.

```sh
# Generate CMake build files into `build/`
cmake -B build .

# Build project
cmake --build build

# Run all tests
ctest --test-dir build
```
7 changes: 4 additions & 3 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,14 @@ endif()
target_link_libraries(
resdata
PUBLIC ${m} ${dl} ${pthread} ${blas} ${zlib} ${shlwapi}
PRIVATE Backward::Backward fmt::fmt)
PRIVATE fmt::fmt)

target_include_directories(
resdata
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
$<INSTALL_INTERFACE:include>
${BACKWARD_DIR}
PRIVATE ${ZLIB_INCLUDE_DIRS} util include
${CMAKE_CURRENT_SOURCE_DIR}/private-include
${CMAKE_CURRENT_BINARY_DIR}/include)
Expand Down Expand Up @@ -204,10 +205,10 @@ if(CMAKE_COMPILER_IS_GNUCC)
else()
target_compile_options(rd_test_suite PRIVATE "--std=c++17")
endif()
target_link_libraries(rd_test_suite resdata Catch2::Catch2WithMain stdc++fs)
target_link_libraries(rd_test_suite resdata Catch2::Catch2 stdc++fs)
else()
target_compile_options(rd_test_suite PRIVATE "--std=c++17")
target_link_libraries(rd_test_suite resdata Catch2::Catch2WithMain)
target_link_libraries(rd_test_suite resdata Catch2::Catch2)
endif()
add_test(NAME rd_test_suite COMMAND rd_test_suite)

Expand Down

0 comments on commit 1fcce1d

Please sign in to comment.