global_flags.linker.gnu.cmake 984 B

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