summaryrefslogtreecommitdiff
path: root/dev-util/spirv-tools/files/spirv-tools-1.3.211-cmake-librt.patch
blob: 48afd5a736f1632866eaf5fbbbbd45785f258c04 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
https://github.com/KhronosGroup/SPIRV-Tools/commit/cb96abbf7affd986016f17dd09f9f971138a922b

From: Chad Versace <chad@kiwitree.net>
Date: Thu, 14 Apr 2022 06:04:12 -0700
Subject: [PATCH] Fix CMake for librt (#4773)

In the installed file
/usr/lib64/cmake/SPIRV-Tools/SPIRV-ToolsTarget.cmake, occurences of
librt in the INTERFACE_LINK_LIBRARIES property are incorrect.  The
property contains the absolute path to librt. In most situations, this
produces no problem. But when building in a sysroot, which is commonly
done when cross-compiling, the absolute path breaks dependent projects.

For example, when building spirv-tools using the Chrome OS SDK, and
targeting the board 'volteer', where the build sysroot is
'/build/volteer', the file includes this line
    INTERFACE_LINK_LIBRARIES "/build/volteer/usr/lib64/librt.so"
when it should instead say
    INTERFACE_LINK_LIBRARIES "rt"

The CMake documentation agrees [1]:
    Note that it is not advisable to populate the
    INTERFACE_LINK_LIBRARIES of a target with absolute paths to
    dependencies. That would hard-code into installed packages the
    library file paths for dependencies as found on the machine the
    package was made on.

[1] https://cmake.org/cmake/help/latest/prop_tgt/INTERFACE_LINK_LIBRARIES.html
--- a/source/CMakeLists.txt
+++ b/source/CMakeLists.txt
@@ -407,7 +407,7 @@ if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
   find_library(LIBRT rt)
   if(LIBRT)
     foreach(target ${SPIRV_TOOLS_TARGETS})
-      target_link_libraries(${target} ${LIBRT})
+      target_link_libraries(${target} rt)
     endforeach()
   endif()
 endif()