From 89b790d72f4d49aea1f80cd35858770410abc705 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon=20H=C3=A6gland?= Date: Tue, 31 May 2022 12:19:50 +0200 Subject: [PATCH 1/2] Install install.py Install the install.py python script such that it can be used by opm-simulators when building against an installed opm-common --- CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 29ea77e87..15958a907 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -441,6 +441,9 @@ if (OPM_ENABLE_PYTHON) # setup-install.sh - and completely bypass cmake in the installation phase. if (OPM_INSTALL_PYTHON) install( CODE "execute_process(COMMAND ${Python3_EXECUTABLE} ${PROJECT_BINARY_DIR}/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 "share/opm/python" ) endif() # Observe that if the opmcommon library has been built as a shared library the From 32c3d9bcb07c5319429dea8c3e7ce02b6544bc22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon=20H=C3=A6gland?= Date: Fri, 3 Jun 2022 09:03:34 +0200 Subject: [PATCH 2/2] Add the python script directory to opm-project-config Uses GNUInstallDIrs' CMAKE_INSTALL_DATAROOTDIR as top directory for common python scripts. Also adds that location to opm-project-config.cmake.in such that other opm modules can easily lookup the common scripts --- CMakeLists.txt | 5 ++++- cmake/Templates/opm-project-config.cmake.in | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 15958a907..d7ad834da 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -214,6 +214,9 @@ if (OPM_ENABLE_PYTHON) # Compatibility settings for PythonInterp and PythonLibs # used e.g. in FindCwrap, pybind11 set(PYTHON_EXECUTABLE ${Python3_EXECUTABLE}) + # Directory to install common (for opm modules) python scripts + include (GNUInstallDirs) + set(OPM_PYTHON_COMMON_DIR "${CMAKE_INSTALL_DATAROOTDIR}/opm/python") endif() # We always need the PYTHON_INCLUDE_DIR. Unfortunately # When we build pypi packages CMake will fail to determine @@ -443,7 +446,7 @@ if (OPM_ENABLE_PYTHON) install( CODE "execute_process(COMMAND ${Python3_EXECUTABLE} ${PROJECT_BINARY_DIR}/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 "share/opm/python" ) + install( PROGRAMS "python/install.py" DESTINATION "${OPM_PYTHON_COMMON_DIR}" ) endif() # Observe that if the opmcommon library has been built as a shared library the diff --git a/cmake/Templates/opm-project-config.cmake.in b/cmake/Templates/opm-project-config.cmake.in index a232a4097..fd726c520 100644 --- a/cmake/Templates/opm-project-config.cmake.in +++ b/cmake/Templates/opm-project-config.cmake.in @@ -35,6 +35,9 @@ if(NOT @opm-project_NAME@_FOUND) # actual code is self contained - and can be used downstream without awareness of this. set (@opm-project_NAME@_EMBEDDED_PYTHON @OPM_ENABLE_EMBEDDED_PYTHON@) + # Directory for common (across opm modules) Python scripts + set(@opm-project_NAME@_PYTHON_COMMON_DIR "${@opm-project_NAME@_PREFIX}/@OPM_PYTHON_COMMON_DIR@") + # libraries come from the build tree where this file was generated set (@opm-project_NAME@_LIBRARY "@opm-project_LIBRARY@") set (@opm-project_NAME@_LIBRARIES ${@opm-project_NAME@_LIBRARY} "@opm-project_LIBRARIES@") @@ -58,6 +61,7 @@ if(NOT @opm-project_NAME@_FOUND) string(REPLACE ${@opm-project_NAME@_PREFIX} ${DEST_PREFIX} @opm-project_NAME@_INCLUDE_DIRS "${@opm-project_NAME@_INCLUDE_DIRS}") string(REPLACE ${@opm-project_NAME@_PREFIX} ${DEST_PREFIX} @opm-project_NAME@_LIBRARY_DIRS "${@opm-project_NAME@_LIBRARY_DIRS}") string(REPLACE ${@opm-project_NAME@_PREFIX} ${DEST_PREFIX} @opm-project_NAME@_LIBRARY "${@opm-project_NAME@_LIBRARY}") + string(REPLACE ${@opm-project_NAME@_PREFIX} ${DEST_PREFIX} @opm-project_NAME@_PYTHON_COMMON_DIR "${@opm-project_NAME@_PYTHON_COMMON_DIR}") endif()