blob: 0412c4a0b528da9ae3329ecb8ad2b42569a5da12 (
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
|
function(cpsc_prepare_linux_packages)
cpsc_find_dependency(PROGRAM cpsc_readlink NAMES readlink REQUIRED)
# Development packages can contain absolute links to runtime packages.
file(GLOB_RECURSE files LIST_DIRECTORIES FALSE "${CPSC_DEPS_ROOT}/*")
foreach(path IN LISTS files)
if(IS_SYMLINK "${path}")
execute_process(COMMAND "${cpsc_readlink}" "${path}" OUTPUT_VARIABLE target
OUTPUT_STRIP_TRAILING_WHITESPACE RESULT_VARIABLE result)
if(NOT result EQUAL 0)
message(FATAL_ERROR "Cannot read dependency symlink ${path}")
endif()
if(IS_ABSOLUTE "${target}" AND EXISTS "${CPSC_DEPS_ROOT}${target}")
get_filename_component(directory "${path}" DIRECTORY)
file(RELATIVE_PATH relative "${directory}" "${CPSC_DEPS_ROOT}${target}")
file(REMOVE "${path}")
execute_process(COMMAND "${CMAKE_COMMAND}" -E create_symlink
"${relative}" "${path}" RESULT_VARIABLE result)
if(NOT result EQUAL 0)
message(FATAL_ERROR "Cannot relocate dependency symlink ${path}")
endif()
endif()
elseif(path MATCHES "\\.cmake$")
# For example, Debian's LLVMSupport interface hard-codes libz3.so.
file(READ "${path}" contents)
string(REGEX MATCHALL "/(usr/)?lib[^\" ;()\n]+" references "${contents}")
foreach(reference IN LISTS references)
if(EXISTS "${CPSC_DEPS_ROOT}${reference}")
string(REPLACE "${reference}" "${CPSC_DEPS_ROOT}${reference}"
contents "${contents}")
endif()
endforeach()
file(WRITE "${path}" "${contents}")
endif()
endforeach()
endfunction()
|