From 41c709ef6f3e64c0b359b05823d1ae04bcde34ea Mon Sep 17 00:00:00 2001 From: Stenzek Date: Sat, 19 Oct 2024 13:10:19 +1000 Subject: [PATCH] CMake: Reference shaderc/spirv-cross unconditionally Should fix build with Vulkan disabled. --- CMakeModules/DuckStationDependencies.cmake | 22 ++++++++++------------ src/util/CMakeLists.txt | 10 ++++------ 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/CMakeModules/DuckStationDependencies.cmake b/CMakeModules/DuckStationDependencies.cmake index cc23c80a7..029e2b970 100644 --- a/CMakeModules/DuckStationDependencies.cmake +++ b/CMakeModules/DuckStationDependencies.cmake @@ -38,19 +38,17 @@ if(ENABLE_WAYLAND) find_package(Wayland REQUIRED Egl) endif() -if(ENABLE_VULKAN) - find_package(Shaderc REQUIRED) - find_package(spirv_cross_c_shared REQUIRED) +find_package(Shaderc REQUIRED) +find_package(spirv_cross_c_shared REQUIRED) - if(LINUX) - # We need to add the rpath for shaderc to the executable. - get_target_property(SHADERC_LIBRARY Shaderc::shaderc_shared IMPORTED_LOCATION) - get_filename_component(SHADERC_LIBRARY_DIRECTORY ${SHADERC_LIBRARY} DIRECTORY) - list(APPEND CMAKE_BUILD_RPATH ${SHADERC_LIBRARY_DIRECTORY}) - get_target_property(SPIRV_CROSS_LIBRARY spirv-cross-c-shared IMPORTED_LOCATION) - get_filename_component(SPIRV_CROSS_LIBRARY_DIRECTORY ${SPIRV_CROSS_LIBRARY} DIRECTORY) - list(APPEND CMAKE_BUILD_RPATH ${SPIRV_CROSS_LIBRARY_DIRECTORY}) - endif() +if(LINUX AND NOT (ALLOW_INSTALL AND INSTALL_SELF_CONTAINED)) + # We need to add the rpath for shaderc to the executable. + get_target_property(SHADERC_LIBRARY Shaderc::shaderc_shared IMPORTED_LOCATION) + get_filename_component(SHADERC_LIBRARY_DIRECTORY ${SHADERC_LIBRARY} DIRECTORY) + list(APPEND CMAKE_BUILD_RPATH ${SHADERC_LIBRARY_DIRECTORY}) + get_target_property(SPIRV_CROSS_LIBRARY spirv-cross-c-shared IMPORTED_LOCATION) + get_filename_component(SPIRV_CROSS_LIBRARY_DIRECTORY ${SPIRV_CROSS_LIBRARY} DIRECTORY) + list(APPEND CMAKE_BUILD_RPATH ${SPIRV_CROSS_LIBRARY_DIRECTORY}) endif() if(LINUX) diff --git a/src/util/CMakeLists.txt b/src/util/CMakeLists.txt index bf70eb87a..7a7437843 100644 --- a/src/util/CMakeLists.txt +++ b/src/util/CMakeLists.txt @@ -168,12 +168,10 @@ if(ENABLE_VULKAN) target_link_libraries(util PUBLIC vulkan-headers) endif() -if(ENABLE_VULKAN OR APPLE) - # shaderc/spirv-cross is loaded dynamically to reduce module loads on startup. - get_target_property(SHADERC_INCLUDE_DIR Shaderc::shaderc_shared INTERFACE_INCLUDE_DIRECTORIES) - get_target_property(SPIRV_CROSS_INCLUDE_DIR spirv-cross-c-shared INTERFACE_INCLUDE_DIRECTORIES) - target_include_directories(util PUBLIC ${SHADERC_INCLUDE_DIR} ${SPIRV_CROSS_INCLUDE_DIR}) -endif() +# shaderc/spirv-cross is loaded dynamically to reduce module loads on startup. +get_target_property(SHADERC_INCLUDE_DIR Shaderc::shaderc_shared INTERFACE_INCLUDE_DIRECTORIES) +get_target_property(SPIRV_CROSS_INCLUDE_DIR spirv-cross-c-shared INTERFACE_INCLUDE_DIRECTORIES) +target_include_directories(util PUBLIC ${SHADERC_INCLUDE_DIR} ${SPIRV_CROSS_INCLUDE_DIR}) if(NOT ANDROID) target_sources(util PRIVATE