summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@qt.io>2019-02-15 11:45:34 +0100
committerSimon Hausmann <simon.hausmann@qt.io>2019-02-20 11:14:59 +0000
commitd885226544c81f92ec897ff6fd08d84d2903d4a2 (patch)
tree7caeb6dc65dd40e741e6b446db3f06ba2e95ac06 /src
parent22bd8576cb65e0aef5cdbb51b1e5f55843bc5e3f (diff)
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>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/CMakeLists.txt22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/corelib/CMakeLists.txt b/src/corelib/CMakeLists.txt
index 06cd3e6f8d..5c35826cb1 100644
--- a/src/corelib/CMakeLists.txt
+++ b/src/corelib/CMakeLists.txt
@@ -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: qmake condition: (linux*|hurd*):!cross_compile:!static:!*-armcc*
-# FIXME: qmake gets the elf interpreter out of /bin/ls
-find_program(HOST_ELF_INTERPRETER NAMES ld-linux-x86-64.so.2 PATHS /lib /lib64 NO_DEFAULT_PATH)
-if (LINUX AND NOT CMAKE_CROSSCOMPILING AND HOST_ELF_INTERPRETER_FOUND)
- qt_internal_add_link_flags(Core "-Wl,-e,qt_core_boilerplate")
- target_compile_definitions(Core PRIVATE ELF_INTERPRETER="${HOST_ELF_INTERPRETER}")
+if (LINUX AND NOT CMAKE_CROSSCOMPILING AND BUILD_SHARED_LIBS)
+ if (NOT DEFINED ELF_INTERPRETER)
+ execute_process(COMMAND ${CMAKE_COMMAND} -E env LC_ALL=C readelf -l /bin/ls
+ RESULT_VARIABLE readelf_ok
+ OUTPUT_VARIABLE readelf_output
+ )
+ 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()