aboutsummaryrefslogtreecommitdiffstats
path: root/cmake/global_flags.linker.gnu.cmake
blob: c527053100b58456c55a85e6d3e52bd6d42f17aa (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
26
27
28
29
add_link_options(
  -lc
  -lm
)

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 -lgcc)
    if (CMAKE_ANDROID_ARCH_ABI STREQUAL "armeabi-v7a")
      add_link_options("-lunwind")
    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()