Fix ELF interpreter detection
Use the same approach as with qmake, by using readelf -l /bin/ls and then a regular expression to extract the program interpreter path. It's a little simpler in cmake because we can avoid the perl dance and quotes and just use cmake's built-in regular expression matching. This change also excludes static builds, as with qmake. Change-Id: I699e166c4b38b3fe98e6390316206109ad6363f9 Reviewed-by: Kevin Funk <kevin.funk@kdab.com>
This commit is contained in:
parent
22bd8576cb
commit
d885226544
@ -268,12 +268,22 @@ set_property(TARGET Core APPEND PROPERTY PRIVATE_HEADER "${CMAKE_CURRENT_BINARY_
|
|||||||
|
|
||||||
# FIXME: tools still have a lot of special stuff that is not ported!
|
# FIXME: tools still have a lot of special stuff that is not ported!
|
||||||
|
|
||||||
# FIXME: qmake condition: (linux*|hurd*):!cross_compile:!static:!*-armcc*
|
if (LINUX AND NOT CMAKE_CROSSCOMPILING AND BUILD_SHARED_LIBS)
|
||||||
# FIXME: qmake gets the elf interpreter out of /bin/ls
|
if (NOT DEFINED ELF_INTERPRETER)
|
||||||
find_program(HOST_ELF_INTERPRETER NAMES ld-linux-x86-64.so.2 PATHS /lib /lib64 NO_DEFAULT_PATH)
|
execute_process(COMMAND ${CMAKE_COMMAND} -E env LC_ALL=C readelf -l /bin/ls
|
||||||
if (LINUX AND NOT CMAKE_CROSSCOMPILING AND HOST_ELF_INTERPRETER_FOUND)
|
RESULT_VARIABLE readelf_ok
|
||||||
qt_internal_add_link_flags(Core "-Wl,-e,qt_core_boilerplate")
|
OUTPUT_VARIABLE readelf_output
|
||||||
target_compile_definitions(Core PRIVATE ELF_INTERPRETER="${HOST_ELF_INTERPRETER}")
|
)
|
||||||
|
if ("${readelf_ok}" STREQUAL "0" AND "${readelf_output}" MATCHES "program interpreter: (.*)]")
|
||||||
|
set(ELF_INTERPRETER "${CMAKE_MATCH_1}" CACHE INTERNAL "ELF interpreter location")
|
||||||
|
else
|
||||||
|
set(ELF_INTERPRETER "" CACHE INTERNAL "ELF interpreter location")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
if (ELF_INTERPRETER)
|
||||||
|
qt_internal_add_link_flags(Core "-Wl,-e,qt_core_boilerplate")
|
||||||
|
target_compile_definitions(Core PRIVATE ELF_INTERPRETER="${ELF_INTERPRETER}")
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user