From 1992183e8e3de7fbae1a86baf8948ff7c5d7b06b Mon Sep 17 00:00:00 2001 From: baldurk Date: Tue, 26 Sep 2017 11:00:17 +0100 Subject: [PATCH] Add support for specifying a subfolder under the lib/ target. Refs #750 * This allows a buidler to customise from e.g. /usr/lib/librenderdoc.so to /usr/lib/renderdoc/librenderdoc.so - which is harmless since the library is 'private' and not intended to be linked against directly. --- CMakeLists.txt | 14 ++++++++++++++ qrenderdoc/CMakeLists.txt | 3 +++ qrenderdoc/Code/pyrenderdoc/CMakeLists.txt | 2 +- qrenderdoc/qrenderdoc.pro | 2 +- renderdoc/CMakeLists.txt | 2 +- renderdoc/driver/vulkan/CMakeLists.txt | 2 +- renderdoc/os/posix/posix_process.cpp | 9 +++++++++ renderdoc/os/posix/posix_stringio.cpp | 13 +++++++++++-- renderdoccmd/CMakeLists.txt | 2 +- 9 files changed, 42 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 44d3bf701..fce5fa569 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,6 +40,20 @@ set(RENDERDOC_PLUGINS_PATH "" CACHE STRING "Path to RenderDoc plugins folder aft set(RENDERDOC_APK_PATH "" CACHE STRING "Path to RenderDocCmd.apk after installation of RenderDoc on host (either absolute or relative to binary)") set(RENDERDOC_LAYER_PATH "" CACHE STRING "Path to ABI directories (i.e. lib in lib/armeabi-v7a/libVkLayer_GLES_RenderDoc.so) after installation of RenderDoc on host (either absolute or relative to dir)") +set(LIB_SUFFIX "" CACHE STRING "Suffix for 'lib' folder in target directory structure. E.g. set to '64' to use /usr/local/lib64 instead of /usr/local/lib.") +set(LIB_SUBFOLDER "" CACHE STRING "Subfolder under the 'lib' folder in target directory structure. E.g. set to 'renderdoc' to use /usr/local/lib/renderdoc instead of /usr/local/lib.") + +if(NOT LIB_SUFFIX STREQUAL "") + add_definitions(-DRENDERDOC_LIB_SUFFIX=${LIB_SUFFIX}) +endif() + +set(LIB_SUBFOLDER_TRAIL_SLASH "") + +if(NOT LIB_SUBFOLDER STREQUAL "") + add_definitions(-DRENDERDOC_LIB_SUBFOLDER=${LIB_SUBFOLDER}) + set(LIB_SUBFOLDER_TRAIL_SLASH "${LIB_SUBFOLDER}/") +endif() + if(BUILD_VERSION_STABLE) add_definitions(-DRENDERDOC_STABLE_BUILD=1) endif() diff --git a/qrenderdoc/CMakeLists.txt b/qrenderdoc/CMakeLists.txt index 2df9ffa5a..516a5a592 100644 --- a/qrenderdoc/CMakeLists.txt +++ b/qrenderdoc/CMakeLists.txt @@ -102,6 +102,9 @@ file(WRITE "QMAKE_CXXFLAGS+=${QMAKE_CXXFLAGS}\n" "QMAKE_LFLAGS+=${QMAKE_LDFLAGS}\n" "\n" + "LIB_SUFFIX=${LIB_SUFFIX}\n" + "LIB_SUBFOLDER_TRAIL_SLASH=${LIB_SUBFOLDER_TRAIL_SLASH}\n" + "\n" # search for -lrenderdoc here "LIBS+=-L${CMAKE_RUNTIME_OUTPUT_DIRECTORY}\n" "\n" diff --git a/qrenderdoc/Code/pyrenderdoc/CMakeLists.txt b/qrenderdoc/Code/pyrenderdoc/CMakeLists.txt index 151094546..02aabb43a 100644 --- a/qrenderdoc/Code/pyrenderdoc/CMakeLists.txt +++ b/qrenderdoc/Code/pyrenderdoc/CMakeLists.txt @@ -33,7 +33,7 @@ set(MODULE_DEFINES # 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/") +set(CMAKE_INSTALL_RPATH "$ORIGIN/:$ORIGIN/../lib${LIB_SUFFIX}/${LIB_SUBFOLDER_TRAIL_SLASH}") # Add python library set (CMAKE_SHARED_LINKER_FLAGS "${PYTHON_LIBRARY} ${CMAKE_SHARED_LINKER_FLAGS}") diff --git a/qrenderdoc/qrenderdoc.pro b/qrenderdoc/qrenderdoc.pro index 0fe0aa6c3..a2d7dbf32 100644 --- a/qrenderdoc/qrenderdoc.pro +++ b/qrenderdoc/qrenderdoc.pro @@ -115,7 +115,7 @@ win32 { # Link against the core library LIBS += -lrenderdoc - QMAKE_LFLAGS += '-Wl,-rpath,\'\$$ORIGIN\',-rpath,\'\$$ORIGIN/../lib\'' + QMAKE_LFLAGS += '-Wl,-rpath,\'\$$ORIGIN\',-rpath,\'\$$ORIGIN/../lib'$$LIB_SUFFIX'/'$$LIB_SUBFOLDER_TRAIL_SLASH'\'' # Add the SWIG files that were generated in cmake SOURCES += $$CMAKE_DIR/qrenderdoc/renderdoc_python.cxx diff --git a/renderdoc/CMakeLists.txt b/renderdoc/CMakeLists.txt index 3efaa8e98..9764ded31 100644 --- a/renderdoc/CMakeLists.txt +++ b/renderdoc/CMakeLists.txt @@ -323,7 +323,7 @@ if(ANDROID) set_target_properties(renderdoc PROPERTIES OUTPUT_NAME "VkLayer_GLES_RenderDoc") endif() -install (TARGETS renderdoc DESTINATION lib${LIB_SUFFIX}) +install (TARGETS renderdoc DESTINATION lib${LIB_SUFFIX}/${LIB_SUBFOLDER}) # Copy in application API header to include install (FILES api/app/renderdoc_app.h DESTINATION include RENAME renderdoc.h) diff --git a/renderdoc/driver/vulkan/CMakeLists.txt b/renderdoc/driver/vulkan/CMakeLists.txt index 27f913f4a..0c5fc55f1 100644 --- a/renderdoc/driver/vulkan/CMakeLists.txt +++ b/renderdoc/driver/vulkan/CMakeLists.txt @@ -71,7 +71,7 @@ elseif(UNIX) set(json_in ${CMAKE_CURRENT_SOURCE_DIR}/renderdoc.json) set(json_out ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/renderdoc_capture.json) add_custom_command(OUTPUT ${json_out} - COMMAND sed '{s%\\[MAJOR\\]%${RENDERDOC_VERSION_MAJOR}%\; s%\\[MINOR\\]%${RENDERDOC_VERSION_MINOR}%\; s%...renderdoc.dll%${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}/librenderdoc.so%}' < ${json_in} > ${json_out} + COMMAND sed '{s%\\[MAJOR\\]%${RENDERDOC_VERSION_MAJOR}%\; s%\\[MINOR\\]%${RENDERDOC_VERSION_MINOR}%\; s%...renderdoc.dll%${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}/${LIB_SUBFOLDER_TRAIL_SLASH}librenderdoc.so%}' < ${json_in} > ${json_out} DEPENDS ${json_in}) add_custom_target(generate-json ALL DEPENDS ${json_out}) diff --git a/renderdoc/os/posix/posix_process.cpp b/renderdoc/os/posix/posix_process.cpp index 8e3734d9d..637c220f1 100644 --- a/renderdoc/os/posix/posix_process.cpp +++ b/renderdoc/os/posix/posix_process.cpp @@ -498,6 +498,15 @@ uint32_t Process::LaunchAndInjectIntoProcess(const char *app, const char *workin FileIO::GetExecutableFilename(binpath); binpath = dirname(binpath); libpath = binpath + "/../lib"; + +// point to the right customiseable path +#if defined(RENDERDOC_LIB_SUFFIX) + libpath += STRINGIZE(RENDERDOC_LIB_SUFFIX); +#endif + +#if defined(RENDERDOC_LIB_SUBFOLDER) + libpath += "/" STRINGIZE(RENDERDOC_LIB_SUBFOLDER); +#endif } string optstr; diff --git a/renderdoc/os/posix/posix_stringio.cpp b/renderdoc/os/posix/posix_stringio.cpp index ae508ac8c..0c1847da1 100644 --- a/renderdoc/os/posix/posix_stringio.cpp +++ b/renderdoc/os/posix/posix_stringio.cpp @@ -153,8 +153,17 @@ string GetReplayAppFilename() } // if it's not in the same directory, try in a sibling /bin - // e.g. /foo/bar/lib/librenderdoc.so -> /foo/bar/bin/qrenderdoc - replay = path + "/../bin/qrenderdoc"; + // + // start from our path + replay = path + "/"; + +// if there's a custom lib subfolder, go up one (e.g. /usr/lib/renderdoc/librenderdoc.so) +#if defined(RENDERDOC_LIB_SUBFOLDER) + replay += "../"; +#endif + + // leave the lib/ folder, and go into bin/ + replay += "../bin/qrenderdoc"; f = FileIO::fopen(replay.c_str(), "r"); if(f) diff --git a/renderdoccmd/CMakeLists.txt b/renderdoccmd/CMakeLists.txt index 3f9d95b28..86c55d0b0 100644 --- a/renderdoccmd/CMakeLists.txt +++ b/renderdoccmd/CMakeLists.txt @@ -45,7 +45,7 @@ if(ANDROID) else() set(CMAKE_SKIP_BUILD_RPATH TRUE) set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) - set(CMAKE_INSTALL_RPATH "$ORIGIN/:$ORIGIN/../lib/") + set(CMAKE_INSTALL_RPATH "$ORIGIN/:$ORIGIN/../lib${LIB_SUFFIX}/${LIB_SUBFOLDER_TRAIL_SLASH}") set(CMAKE_EXE_LINKER_FLAGS "${LINKER_FLAGS}") add_executable(renderdoccmd ${sources})