diff options
author | Gunnar Beutner <gbeutner@serenityos.org> | 2021-04-29 22:58:05 +0200 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2021-04-30 09:14:43 +0200 |
commit | 8ae07945845eab0cb350d6f72bd6eb5a12766114 (patch) | |
tree | ebfd22c43316c9d3608001c02e76bc547e71ff3e /CMakeLists.txt | |
parent | 55446172cb7ecfc3b6183bbf09d06dd10a56c8fa (diff) | |
download | serenity-8ae07945845eab0cb350d6f72bd6eb5a12766114.zip |
CMake: Fix building libraries on macOS
When building libraries on macOS they'd be missing the SONAME
attribute which causes the linker to embed relative paths into
other libraries and executables:
Dynamic section at offset 0x52794 contains 28 entries:
Type Name/Value
(NEEDED) Shared library: [libgcc_s.so]
(NEEDED) Shared library: [Userland/Libraries/LibCrypt/libcrypt.so]
(NEEDED) Shared library: [Userland/Libraries/LibCrypto/libcrypto.so]
(NEEDED) Shared library: [Userland/Libraries/LibC/libc.so]
(NEEDED) Shared library: [libsystem.so]
(NEEDED) Shared library: [libm.so]
(NEEDED) Shared library: [libc.so]
The dynamic linker then fails to load those libraries which makes
the system unbootable.
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 88bca2e1f9..a4b186cad2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -140,9 +140,10 @@ foreach(lang ASM C CXX OBJC OBJCXX) unset(CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG) unset(CMAKE_${lang}_SYSROOT_FLAG) if (CMAKE_SYSTEM_NAME MATCHES Darwin) - ## MacOS Workaround. Don't generate install_name flag when cross compiling + ## macOS workaround. Use GNU ld flags for SONAMEs. set(CMAKE_${lang}_CREATE_SHARED_LIBRARY - "<CMAKE_${lang}_COMPILER> <LANGUAGE_COMPILE_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS> <LINK_FLAGS> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>") + "<CMAKE_${lang}_COMPILER> <LANGUAGE_COMPILE_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS> <LINK_FLAGS> <SONAME_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>") + set(CMAKE_SHARED_LIBRARY_SONAME_${lang}_FLAG "-Wl,-soname,") endif() endforeach() |