aboutsummaryrefslogtreecommitdiff
path: root/toolchain/specifydependencies.cmake
diff options
context:
space:
mode:
authorAleix Pol <aleixpol@kde.org>2017-12-20 20:42:59 +0100
committerAleix Pol <aleixpol@kde.org>2017-12-20 22:35:02 +0100
commitc91c3650968d828d52291f97f835a5a04024c2e0 (patch)
tree7e33c1f3a718d0e9d97d5f6616339c30e20ffc43 /toolchain/specifydependencies.cmake
parent24134c972e375bebad45c860c413233b60863852 (diff)
downloadextra-cmake-modules-c91c3650968d828d52291f97f835a5a04024c2e0.tar.gz
extra-cmake-modules-c91c3650968d828d52291f97f835a5a04024c2e0.tar.bz2
Use readelf to find project dependenciesv5.42.0-rc1v5.42.0
Summary: We were using a link.txt file that cmake used to generate, on newer cmake versions it doesn't anymore. Instead use readelf, much like androiddeployqt does, to extract the depenencies. Catch: It relies on having all the binaries being at the same subdirectory, which is the default in ECM since not long ago. Test Plan: Build kirigamigallery with it Reviewers: #frameworks, #build_system, aacid Reviewed By: aacid Subscribers: mart Tags: #frameworks, #build_system Differential Revision: https://phabricator.kde.org/D8173
Diffstat (limited to 'toolchain/specifydependencies.cmake')
-rw-r--r--toolchain/specifydependencies.cmake34
1 files changed, 18 insertions, 16 deletions
diff --git a/toolchain/specifydependencies.cmake b/toolchain/specifydependencies.cmake
index 65e875bf..8965d6da 100644
--- a/toolchain/specifydependencies.cmake
+++ b/toolchain/specifydependencies.cmake
@@ -1,27 +1,29 @@
-file(READ "${TARGET_DIR}/CMakeFiles/${TARGET_NAME}.dir/link.txt" out)
+execute_process(COMMAND readelf --wide --dynamic ${TARGET} ERROR_VARIABLE readelf_errors OUTPUT_VARIABLE out RESULT_VARIABLE result)
-string(FIND "${out}" "-o ${TARGET_NAME}" POS) #we trim the initial arguments, we want the ones in the end. we find the target
-string(SUBSTRING "${out}" ${POS} -1 out) #we
-string(REGEX MATCHALL "(/|\\.\\./|\\./)[^ ]+\\.so" outout "${out}")
-string(STRIP "${outout}" outout)
-string(REPLACE " /" ";/" outout "${outout}")
+if (NOT result EQUAL 0)
+ message(FATAL_ERROR "readelf failed on ${TARGET} exit(${result}): ${readelf_errors}")
+endif()
+string(REPLACE "\n" ";" lines "${out}")
set(extralibs)
-foreach(lib IN LISTS outout) #now we filter Qt5 libraries, because Qt wants to take care about these itself
- if(NOT ${lib} MATCHES ".*/libQt5.*")
- # resolve relative paths
- if(${lib} MATCHES "^(\\.\\./|\\./)")
- set(lib "${TARGET_DIR}/${lib}")
- endif()
- if(extralibs)
- set(extralibs "${extralibs},${lib}")
+foreach(line ${lines})
+ string(REGEX MATCH ".*\\(NEEDED\\) +Shared library: +\\[(.+)\\]$" matched ${line})
+ set(currentLib ${CMAKE_MATCH_1})
+
+ if(NOT ${currentLib} MATCHES "libQt5.*" AND matched)
+ find_file(ourlib-${currentLib} ${currentLib} HINTS ${OUTPUT_DIR} ${EXPORT_DIR} ${ECM_ADDITIONAL_FIND_ROOT_PATH} NO_DEFAULT_PATH PATH_SUFFIXES lib)
+
+ if(ourlib-${currentLib})
+ list(APPEND extralibs "${ourlib-${currentLib}}")
else()
- set(extralibs "${lib}")
+ message(STATUS "could not find ${currentLib} in ${OUTPUT_DIR} ${EXPORT_DIR}/lib/ ${ECM_ADDITIONAL_FIND_ROOT_PATH}")
endif()
endif()
endforeach()
+
if(extralibs)
- set(extralibs "\"android-extra-libs\": \"${extralibs}\",")
+ string(REPLACE ";" "," libs "${extralibs}")
+ set(extralibs "\"android-extra-libs\": \"${libs}\",")
endif()
set(extraplugins)