[CMAKE] Use find_program to get the location of LD when building with clang

This commit is contained in:
Jérôme Gardou 2021-04-09 10:32:12 +02:00
parent 83e1afe12a
commit b379743ccb

View file

@ -55,11 +55,8 @@ set(CMAKE_ASM_CREATE_STATIC_LIBRARY ${CMAKE_C_CREATE_STATIC_LIBRARY})
set(CMAKE_C_STANDARD_LIBRARIES "-lgcc" CACHE STRING "Standard C Libraries") set(CMAKE_C_STANDARD_LIBRARIES "-lgcc" CACHE STRING "Standard C Libraries")
set(CMAKE_CXX_STANDARD_LIBRARIES "-lgcc" CACHE STRING "Standard C++ Libraries") set(CMAKE_CXX_STANDARD_LIBRARIES "-lgcc" CACHE STRING "Standard C++ Libraries")
if (DEFINED CMAKE_SYSROOT) find_program (LD_EXECUTABLE ${GCC_TOOLCHAIN_PREFIX}ld)
set(LD_EXECUTABLE ${CMAKE_SYSROOT}/bin/${GCC_TOOLCHAIN_PREFIX}ld) message(STATUS "Using linker ${LD_EXECUTABLE}")
else()
set(LD_EXECUTABLE ${GCC_TOOLCHAIN_PREFIX}ld)
endif()
set(CMAKE_SHARED_LINKER_FLAGS_INIT "-nostdlib -Wl,--enable-auto-image-base,--disable-auto-import -fuse-ld=${LD_EXECUTABLE}") set(CMAKE_SHARED_LINKER_FLAGS_INIT "-nostdlib -Wl,--enable-auto-image-base,--disable-auto-import -fuse-ld=${LD_EXECUTABLE}")
set(CMAKE_MODULE_LINKER_FLAGS_INIT "-nostdlib -Wl,--enable-auto-image-base,--disable-auto-import -fuse-ld=${LD_EXECUTABLE}") set(CMAKE_MODULE_LINKER_FLAGS_INIT "-nostdlib -Wl,--enable-auto-image-base,--disable-auto-import -fuse-ld=${LD_EXECUTABLE}")