Warning, /frameworks/extra-cmake-modules/toolchain/specifydependencies.cmake is written in an unsupported language. File is not indexed.
0001
0002 function(list_dependencies target libs)
0003 execute_process(COMMAND readelf --wide --dynamic ${target} ERROR_VARIABLE readelf_errors OUTPUT_VARIABLE out RESULT_VARIABLE result)
0004
0005 if (NOT result EQUAL 0)
0006 message(FATAL_ERROR "readelf failed on ${target} exit(${result}): ${readelf_errors}")
0007 endif()
0008
0009 string(REPLACE "\n" ";" lines "${out}")
0010 set(extralibs ${${libs}})
0011 foreach(line ${lines})
0012 string(REGEX MATCH ".*\\(NEEDED\\) +Shared library: +\\[(.+)\\]$" matched ${line})
0013 set(currentLib ${CMAKE_MATCH_1})
0014
0015 if(NOT ${currentLib} MATCHES "libQt5.*" AND matched)
0016 find_file(ourlib-${currentLib} ${currentLib} HINTS ${OUTPUT_DIR} ${EXPORT_DIR} ${ECM_ADDITIONAL_FIND_ROOT_PATH} NO_DEFAULT_PATH PATH_SUFFIXES lib)
0017
0018 if(ourlib-${currentLib})
0019 list(APPEND extralibs "${ourlib-${currentLib}}")
0020 else()
0021 message(STATUS "could not find ${currentLib} in ${OUTPUT_DIR} ${EXPORT_DIR} ${ECM_ADDITIONAL_FIND_ROOT_PATH}")
0022 endif()
0023 endif()
0024 endforeach()
0025 set(${libs} ${extralibs} PARENT_SCOPE)
0026 endfunction()
0027
0028 list_dependencies(${TARGET} extralibs)
0029
0030 function(contains_library libpath IS_EQUAL)
0031 get_filename_component (name ${libpath} NAME)
0032 unset (IS_EQUAL PARENT_SCOPE)
0033
0034 foreach (extralib ${extralibs})
0035 get_filename_component (extralibname ${extralib} NAME)
0036 if (${extralibname} STREQUAL ${name})
0037 set (IS_EQUAL TRUE PARENT_SCOPE)
0038 break()
0039 endif()
0040 endforeach()
0041 endfunction()
0042
0043 if (ANDROID_EXTRA_LIBS)
0044 foreach (extralib ${ANDROID_EXTRA_LIBS})
0045 contains_library(${extralib} IS_EQUAL)
0046
0047 if (IS_EQUAL)
0048 message (STATUS "found duplicate, skipping: " ${extralib})
0049 else()
0050 message(STATUS "manually specified extra library: " ${extralib})
0051 list(APPEND extralibs ${extralib})
0052 endif()
0053 endforeach()
0054 endif()
0055
0056 set(extraplugins)
0057 foreach(folder "plugins" "share" "lib/qml") #now we check for folders with extra stuff
0058 set(plugin "${EXPORT_DIR}/${folder}")
0059 if(EXISTS "${plugin}")
0060 list(APPEND extraplugins "${plugin}")
0061 endif()
0062 endforeach()
0063
0064 if(EXISTS "module-plugins")
0065 file(READ "module-plugins" moduleplugins)
0066 foreach(module ${moduleplugins})
0067 list_dependencies(${module} extralibs)
0068 endforeach()
0069 list(REMOVE_DUPLICATES extralibs)
0070 endif()
0071
0072 if(extralibs)
0073 string(REPLACE ";" "," extralibs "${extralibs}")
0074 set(extralibs "\"android-extra-libs\": \"${extralibs}\",")
0075 endif()
0076
0077 if(extraplugins)
0078 string(REPLACE ";" "," extraplugins "${extraplugins}")
0079 set(extraplugins "\"android-extra-plugins\": \"${extraplugins}\",")
0080 endif()
0081
0082 file(READ "${INPUT_FILE}" CONTENTS)
0083 if(EXISTS "stl") # only provided for legacy pre-Clang toolchains
0084 file(READ "stl" stl_contents)
0085 endif()
0086
0087 file(READ "ranlib" ranlib_contents)
0088 string(REGEX MATCH ".+/toolchains/llvm/prebuilt/.+/bin/(.+)-ranlib" USE_LLVM ${ranlib_contents})
0089 if (USE_LLVM)
0090 string(REPLACE "##ANDROID_TOOL_PREFIX##" "llvm" NEWCONTENTS "${CONTENTS}")
0091 string(REPLACE "##ANDROID_COMPILER_PREFIX##" "${CMAKE_MATCH_1}" NEWCONTENTS "${NEWCONTENTS}")
0092 string(REPLACE "##USE_LLVM##" true NEWCONTENTS "${NEWCONTENTS}")
0093 else()
0094 string(REGEX MATCH ".+/toolchains/(.+)-([^\\-]+)/prebuilt/.+/bin/(.+)-ranlib" RANLIB_PATH_MATCH ${ranlib_contents})
0095 if (NOT RANLIB_PATH_MATCH)
0096 message(FATAL_ERROR "Couldn't parse the components of the path to ${ranlib_contents}")
0097 endif()
0098 string(REPLACE "##ANDROID_TOOL_PREFIX##" "${CMAKE_MATCH_1}" NEWCONTENTS "${CONTENTS}")
0099 string(REPLACE "##ANDROID_COMPILER_PREFIX##" "${CMAKE_MATCH_3}" NEWCONTENTS "${NEWCONTENTS}")
0100 string(REPLACE "##USE_LLVM##" false NEWCONTENTS "${NEWCONTENTS}")
0101 endif()
0102
0103 string(REPLACE "##ANDROID_TOOLCHAIN_VERSION##" "${CMAKE_MATCH_2}" NEWCONTENTS "${NEWCONTENTS}") # not used when USE_LLVM is set
0104
0105 string(REPLACE "##EXTRALIBS##" "${extralibs}" NEWCONTENTS "${NEWCONTENTS}")
0106 string(REPLACE "##EXTRAPLUGINS##" "${extraplugins}" NEWCONTENTS "${NEWCONTENTS}")
0107 string(REPLACE "##CMAKE_CXX_STANDARD_LIBRARIES##" "${stl_contents}" NEWCONTENTS "${NEWCONTENTS}")
0108 file(WRITE "${OUTPUT_FILE}" ${NEWCONTENTS})