Merge pull request #1432 from joakim-hove/python-rpath
Pass RPATH to the python setup.py based build system
This commit is contained in:
@@ -253,12 +253,34 @@ if (OPM_ENABLE_PYTHON)
|
||||
string(REPLACE ";" ":" _setup_include_dirs "${_opmcommon_include_dirs}")
|
||||
|
||||
if (CMAKE_PREFIX_PATH)
|
||||
set(_opmcommon_lib_dirs ${PROJECT_BINARY_DIR}/lib ${CMAKE_PREFIX_PATH}/lib)
|
||||
set(_opmcommon_lib_dirs ${PROJECT_BINARY_DIR}/lib ${CMAKE_PREFIX_PATH}/${CMAKE_INSTALL_LIBDIR})
|
||||
else()
|
||||
set(_opmcommon_lib_dirs ${PROJECT_BINARY_DIR}/lib)
|
||||
endif()
|
||||
string(REPLACE ";" ":" _setup_lib_dirs "${_opmcommon_lib_dirs}")
|
||||
|
||||
if (USE_RUNPATH)
|
||||
set (_python_rpath_list)
|
||||
if (CMAKE_PREFIX_PATH)
|
||||
foreach(path ${CMAKE_PREFIX_PATH})
|
||||
list(APPEND _python_rpath_list "${path}/${CMAKE_INSTALL_LIBDIR}")
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
if (BUILD_SHARED_LIBS)
|
||||
list(APPEND _python_rpath_list "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
|
||||
endif()
|
||||
|
||||
if (_python_rpath_list)
|
||||
string(REPLACE ";" ":" _rpath "${_python_rpath_list}")
|
||||
set( _rpath_arg "--rpath=${_rpath}")
|
||||
else()
|
||||
set(_rpath_arg "")
|
||||
endif()
|
||||
else()
|
||||
set( _rpath_arg "")
|
||||
endif()
|
||||
|
||||
execute_process(COMMAND ${PYTHON_EXECUTABLE} target_name.py
|
||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/python
|
||||
OUTPUT_VARIABLE python_lib_target)
|
||||
@@ -274,6 +296,7 @@ if (OPM_ENABLE_PYTHON)
|
||||
build_ext
|
||||
--build-lib=${PROJECT_BINARY_DIR}/python/python/opm
|
||||
--library-dirs=${_setup_lib_dirs}
|
||||
${_rpath_arg}
|
||||
--include-dirs=${_setup_include_dirs}
|
||||
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/python
|
||||
COMMENT "Building python bindings")
|
||||
|
||||
@@ -10,10 +10,11 @@
|
||||
|
||||
cp -r @PROJECT_SOURCE_DIR@/python @PROJECT_BINARY_DIR@
|
||||
cd @PROJECT_BINARY_DIR@/python
|
||||
rm -f python/opm/libopmcommon_python.so
|
||||
rm -f python/opm/libopmcommon_python*
|
||||
|
||||
export CC=@CMAKE_CXX_COMPILER@
|
||||
|
||||
@PYTHON_EXECUTABLE@ setup.py build build_ext --build-lib=python/opm \
|
||||
--library-dirs=@_setup_lib_dirs@ \
|
||||
@_rpath_arg@ \
|
||||
--include-dirs=@_setup_include_dirs@
|
||||
|
||||
@@ -58,19 +58,7 @@ ext_modules = [
|
||||
language='c++',
|
||||
undef_macros=["NDEBUG"],
|
||||
include_dirs=["pybind11/include"]
|
||||
),
|
||||
|
||||
Extension(
|
||||
'libopmioecl_python',
|
||||
[
|
||||
'cxx/eclipse_io.cpp',
|
||||
],
|
||||
libraries=['opmcommon', 'boost_filesystem', 'boost_regex'],
|
||||
language='c++',
|
||||
undef_macros=["NDEBUG"],
|
||||
include_dirs=["pybind11/include"]
|
||||
)
|
||||
|
||||
]
|
||||
|
||||
setup(
|
||||
@@ -87,7 +75,7 @@ setup(
|
||||
'opm.tools'
|
||||
],
|
||||
ext_modules=ext_modules,
|
||||
package_data={'opm': ['libopmcommon_python{}'.format(suffix), 'libopmioecl_python'.format(suffix)]},
|
||||
package_data={'opm': ['libopmcommon_python{}'.format(suffix)]},
|
||||
include_package_data=True,
|
||||
license='Open Source',
|
||||
zip_safe=False,
|
||||
|
||||
Reference in New Issue
Block a user