SPIRV-Tools-shared.patch 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. From 1504af077935a0bfd1b1b59f77d8b1cd89f913b5 Mon Sep 17 00:00:00 2001
  2. From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= <rverschelde@gmail.com>
  3. Date: Mon, 10 Dec 2018 13:05:15 +0100
  4. Subject: [PATCH] CMake: Allow linking against system-installed SPIRV-Tools
  5. Fixes #1585.
  6. ---
  7. CMakeLists.txt | 7 ++++++-
  8. SPIRV/CMakeLists.txt | 21 +++++++++++++--------
  9. 2 files changed, 19 insertions(+), 9 deletions(-)
  10. diff --git a/CMakeLists.txt b/CMakeLists.txt
  11. index ada2b8fb9..22243f491 100644
  12. --- a/CMakeLists.txt
  13. +++ b/CMakeLists.txt
  14. @@ -320,7 +320,12 @@ if(BUILD_EXTERNAL AND IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/External)
  15. add_subdirectory(External)
  16. endif()
  17. -if(NOT TARGET SPIRV-Tools-opt)
  18. +find_package(PkgConfig)
  19. +if(PkgConfig_FOUND)
  20. + pkg_check_modules(SPIRV-Tools SPIRV-Tools)
  21. +endif()
  22. +# Former would be system-installed, later is from External
  23. +if(NOT SPIRV-Tools_FOUND AND NOT TARGET SPIRV-Tools-opt)
  24. set(ENABLE_OPT OFF)
  25. endif()
  26. diff --git a/SPIRV/CMakeLists.txt b/SPIRV/CMakeLists.txt
  27. index d699daddb..28beb47bb 100644
  28. --- a/SPIRV/CMakeLists.txt
  29. +++ b/SPIRV/CMakeLists.txt
  30. @@ -91,14 +91,19 @@ if(WIN32 AND BUILD_SHARED_LIBS)
  31. endif()
  32. if(ENABLE_OPT)
  33. - target_include_directories(SPIRV
  34. - PRIVATE ${spirv-tools_SOURCE_DIR}/include
  35. - PRIVATE ${spirv-tools_SOURCE_DIR}/source
  36. - )
  37. - target_link_libraries(SPIRV PRIVATE MachineIndependent SPIRV-Tools-opt)
  38. - target_include_directories(SPIRV PUBLIC
  39. - $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../External>
  40. - $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/External>)
  41. + if(SPIRV-Tools_FOUND)
  42. + target_include_directories(SPIRV PUBLIC ${SPIRV-Tools_INCLUDEDIR})
  43. + target_link_libraries(SPIRV glslang ${SPIRV-Tools_LIBRARIES})
  44. + else()
  45. + target_include_directories(SPIRV
  46. + PRIVATE ${spirv-tools_SOURCE_DIR}/include
  47. + PRIVATE ${spirv-tools_SOURCE_DIR}/source
  48. + )
  49. + target_link_libraries(SPIRV PRIVATE MachineIndependent SPIRV-Tools-opt)
  50. + target_include_directories(SPIRV PUBLIC
  51. + $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../External>
  52. + $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/External>)
  53. + endif()
  54. else()
  55. target_link_libraries(SPIRV PRIVATE MachineIndependent)
  56. endif(ENABLE_OPT)