From faa9dbf709acf074811890dbdf82936cae4fc066 Mon Sep 17 00:00:00 2001 From: Jake Turner Date: Sat, 6 Mar 2021 05:03:45 +0000 Subject: [PATCH] Enable pyrenderdoc for Apple It was previously marked as disabled for Apple Required to build the python modules which are used by the testing framework Python imports .so libraries by default, change the shared library extension to .so for python modules on Apple --- qrenderdoc/CMakeLists.txt | 2 +- qrenderdoc/Code/pyrenderdoc/CMakeLists.txt | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/qrenderdoc/CMakeLists.txt b/qrenderdoc/CMakeLists.txt index 40413c752..551dde4f2 100644 --- a/qrenderdoc/CMakeLists.txt +++ b/qrenderdoc/CMakeLists.txt @@ -334,6 +334,6 @@ install (CODE "MESSAGE(\"NB: Your paths may vary.\")") endif() # if(ENABLE_QRENDERDOC) # Build python modules - primarily used for constructing documentation -if(ENABLE_PYRENDERDOC AND UNIX AND NOT APPLE) +if(ENABLE_PYRENDERDOC AND UNIX) add_subdirectory(Code/pyrenderdoc) endif() diff --git a/qrenderdoc/Code/pyrenderdoc/CMakeLists.txt b/qrenderdoc/Code/pyrenderdoc/CMakeLists.txt index c60c6ea27..5e1c44135 100644 --- a/qrenderdoc/Code/pyrenderdoc/CMakeLists.txt +++ b/qrenderdoc/Code/pyrenderdoc/CMakeLists.txt @@ -28,7 +28,13 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations") # Set up rpath to find librenderdoc.so set(CMAKE_SKIP_BUILD_RPATH TRUE) set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) -set(CMAKE_INSTALL_RPATH "$ORIGIN/:$ORIGIN/../lib${LIB_SUFFIX}/${LIB_SUBFOLDER_TRAIL_SLASH}") +if (APPLE) + set(CMAKE_MACOSX_RPATH TRUE) + set(CMAKE_INSTALL_RPATH "@loader_path/../lib") + set(CMAKE_BUILD_WITH_INSTALL_NAME_DIR TRUE) +else() + set(CMAKE_INSTALL_RPATH "$ORIGIN/:$ORIGIN/../lib${LIB_SUFFIX}/${LIB_SUBFOLDER_TRAIL_SLASH}") +endif() # Add python library set (CMAKE_SHARED_LINKER_FLAGS "${PYTHON_LIBRARY} ${CMAKE_SHARED_LINKER_FLAGS}") @@ -43,7 +49,7 @@ set_source_files_properties(${CMAKE_BINARY_DIR}/qrenderdoc/renderdoc_python.cxx target_compile_definitions(_renderdoc ${MODULE_DEFINES}) target_include_directories(_renderdoc ${MODULE_INCLUDES}) target_link_libraries(_renderdoc PRIVATE renderdoc) - + add_library(_qrenderdoc SHARED ${CMAKE_BINARY_DIR}/qrenderdoc/renderdoc_python.cxx ${CMAKE_BINARY_DIR}/qrenderdoc/qrenderdoc_python.cxx @@ -57,6 +63,12 @@ target_compile_definitions(_qrenderdoc ${MODULE_DEFINES}) target_include_directories(_qrenderdoc ${MODULE_INCLUDES}) target_link_libraries(_qrenderdoc PRIVATE renderdoc) +# Python expects .so extension when importing shared libraries on non-Windows platform +if(APPLE) + set_target_properties(_renderdoc PROPERTIES SUFFIX ".so") + set_target_properties(_qrenderdoc PROPERTIES SUFFIX ".so") +endif() + # Don't prefix with lib, python expects a bare .so. # Also rename to non-underscore due to this (We couldn't call the # python library 'renderdoc' since that would clash with the