aboutsummaryrefslogtreecommitdiffstats
path: root/cmake/global_flags.linker.gnu.cmake
blob: 5b32a8868fd73b529e72e375374a4001e259678b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
if (ANDROID)
  # NDK r23 onwards has stopped using libgcc:
  # - https://github.com/android/ndk/wiki/Changelog-r23#changes
  # - https://github.com/android/ndk/issues/1230
  #   LLVM's libunwind is now used instead of libgcc for all architectures rather than just 32-bit Arm.
  # - https://github.com/android/ndk/issues/1231
  #   LLVM's libclang_rt.builtins is now used instead of libgcc.
  if (CMAKE_ANDROID_NDK_VERSION GREATER_EQUAL 23)
    # Use toolchain defaults to link with libunwind/clang_rt.builtins
    add_link_options("-nostdlib++")
  else ()
    # Preserve old behaviour: specify runtime libs manually
    add_link_options(-nodefaultlibs)
    link_libraries(gcc)
    if (CMAKE_ANDROID_ARCH_ABI STREQUAL "armeabi-v7a")
      link_libraries(unwind)
    endif()
  endif()
elseif (CMAKE_SYSTEM_NAME MATCHES "^(Darwin|Linux)$")
  add_link_options("-nodefaultlibs")
endif()

if (APPLE)
  set(CMAKE_SHARED_LINKER_FLAGS "-undefined dynamic_lookup")
endif()