[CMake][9793] Fix RPATH when linking with XCode Python on MacOS#9802
[CMake][9793] Fix RPATH when linking with XCode Python on MacOS#9802etejedor merged 2 commits intoroot-project:masterfrom
Conversation
As found here: https://gitlab.kitware.com/cmake/cmake/-/issues/21947 we need to specify: target_link_options(target-name PRIVATE ${Python3_LINK_OPTIONS}) so that libROOTTPython and libPyMVA are linked with the right RPATH, when linking against the XCode Python(3) on MacOS(11,12). Otherwise, the following error appears when loading the libraries: cling::DynamicLibraryManager::loadLibrary(): dlopen(.../mac12/SPEC/soversion/V/master/build/lib/libROOTTPython.6.25.02.so, 0x0009): Library not loaded: @rpath/Python3.framework/Versions/3.8/Python3
|
Starting build on |
|
Build failed on mac11/cxx17. Failing tests: |
|
Build failed on mac1015/python3. Failing tests: |
lmoneta
left a comment
There was a problem hiding this comment.
Thank you Enric for this fix. I was suffering from this.
I have tested on my machine and this fixes the issue I was having with mac12.
The same fix is also needed in the pymva/test/CMakeLists.txt
as following:
index 0cb673469b..56df08754b 100644
--- a/tmva/pymva/test/CMakeLists.txt
+++ b/tmva/pymva/test/CMakeLists.txt
@@ -50,6 +50,10 @@ if(PY_TORCH_FOUND)
${CMAKE_SOURCE_DIR}/tmva/sofie/src/SOFIE_common.cxx
)
target_link_libraries(emitFromPyTorch ${PYTHON_LIBRARIES} ${Libraries})
+if(APPLE)
+ target_link_options(emitFromPyTorch PRIVATE ${PYTHON_LINK_OPTIONS_Development_Main})
+endif()
+
target_include_directories(emitFromPyTorch PRIVATE
${CMAKE_SOURCE_DIR}/tmva/sofie/inc
${CMAKE_SOURCE_DIR}/tmva/inc
@@ -108,6 +112,10 @@ if((PY_KERAS_FOUND AND PY_THEANO_FOUND) OR (PY_KERAS_FOUND AND PY_TENSORFLOW_FOU
${CMAKE_SOURCE_DIR}/tmva/sofie/src/SOFIE_common.cxx
)
target_link_libraries(emitFromKeras ${PYTHON_LIBRARIES} ${Libraries})
+if(APPLE)
+ target_link_options(emitFromKeras PRIVATE ${PYTHON_LINK_OPTIONS_Development_Main})
+endif()
+
target_include_directories(emitFromKeras PRIVATE
${CMAKE_SOURCE_DIR}/tmva/sofie/inc
${CMAKE_SOURCE_DIR}/tmva/inc
|
Build failed on windows10/cxx14. Failing tests: |
|
Build failed on ROOT-ubuntu2004/soversion. Failing tests: |
…Keras and emitFromPyTorch
|
Starting build on |
|
@lmoneta I added your patch, let's wait for the new round of builds and merge if all is ok. |
|
Build failed on ROOT-performance-centos8-multicore/default. Errors:
|
As found here:
https://gitlab.kitware.com/cmake/cmake/-/issues/21947
we need to specify:
target_link_options(target-name PRIVATE ${Python3_LINK_OPTIONS})
so that libROOTTPython and libPyMVA are linked with the right
RPATH, when linking against the XCode Python(3) on MacOS(11,12).
Otherwise, the following error appears when loading the libraries:
cling::DynamicLibraryManager::loadLibrary():
dlopen(.../mac12/SPEC/soversion/V/master/build/lib/libROOTTPython.6.25.02.so, 0x0009):
Library not loaded: @rpath/Python3.framework/Versions/3.8/Python3
Fixes #9793 .