Use the new opm-common_PYTHON_COMMON_DIR

Use the new opm-common_PYTHON_COMMON_DIR to locate the install.py
script if we are building against an installed opm-common.
This commit is contained in:
Håkon Hægland 2022-06-03 09:10:44 +02:00
parent 9b0c63b325
commit 19b074805d

View File

@ -61,11 +61,10 @@ if(OPM_ENABLE_PYTHON_TESTS)
-m unittest test/test_schedule.py) -m unittest test/test_schedule.py)
endif() endif()
set(_opm_common_python_script_dir "${opm-common_DIR}/python")
set(_opm_common_dir "${opm-common_DIR}") if (NOT EXISTS "${_opm_common_python_script_dir}/install.py" )
if (NOT EXISTS "${_opm_common_dir}/python/install.py" )
# if the install.py script does not exist, assume that we are building against an installed opm-common # if the install.py script does not exist, assume that we are building against an installed opm-common
set(_opm_common_dir "${DEST_PREFIX}${CMAKE_INSTALL_PREFIX}/share/opm") set(_opm_common_python_script_dir "${opm-common_PYTHON_COMMON_DIR}")
endif() endif()
# NOTE: instead of using file( COPY ...) which copies the files at configure time (not at build time) # NOTE: instead of using file( COPY ...) which copies the files at configure time (not at build time)
@ -73,7 +72,7 @@ endif()
# update the files if they have been modified. We use the install.py script in opm-common, see also # update the files if they have been modified. We use the install.py script in opm-common, see also
# CMakeLists.txt in opm-common # CMakeLists.txt in opm-common
add_custom_target(copy_python ALL add_custom_target(copy_python ALL
COMMAND ${PYTHON_EXECUTABLE} ${_opm_common_dir}/python/install.py COMMAND ${PYTHON_EXECUTABLE} "${_opm_common_python_script_dir}/install.py"
${PROJECT_SOURCE_DIR}/python ${PROJECT_BINARY_DIR} 0) ${PROJECT_SOURCE_DIR}/python ${PROJECT_BINARY_DIR} 0)
# Since the installation of Python code is nonstandard it is protected by an # Since the installation of Python code is nonstandard it is protected by an
@ -86,7 +85,7 @@ if (OPM_INSTALL_PYTHON)
install( install(
CODE "execute_process( CODE "execute_process(
COMMAND ${PYTHON_EXECUTABLE} COMMAND ${PYTHON_EXECUTABLE}
${_opm_common_dir}/python/install.py ${_opm_common_python_script_dir}/install.py
${PROJECT_BINARY_DIR}/python/opm2 ${PROJECT_BINARY_DIR}/python/opm2
${DEST_PREFIX}${CMAKE_INSTALL_PREFIX}/${PYTHON_INSTALL_PREFIX} 1)") ${DEST_PREFIX}${CMAKE_INSTALL_PREFIX}/${PYTHON_INSTALL_PREFIX} 1)")
endif() endif()