update flag to accommodate changes in clang

This commit is contained in:
Axel Kohlmeyer
2025-05-07 17:13:36 -04:00
parent ac556104c1
commit acd53ebd7c

View File

@ -26,10 +26,17 @@ if(ENABLE_TESTING)
OR ((CMAKE_LINUX_DISTRO STREQUAL "Fedora") AND (CMAKE_DISTRO_VERSION VERSION_GREATER 30)))
include(CheckCXXCompilerFlag)
set(CMAKE_CUSTOM_LINKER_DEFAULT default)
check_cxx_compiler_flag(-fuse-ld=mold HAVE_MOLD_LINKER_FLAG)
check_cxx_compiler_flag(-fuse-ld=lld HAVE_LLD_LINKER_FLAG)
check_cxx_compiler_flag(-fuse-ld=gold HAVE_GOLD_LINKER_FLAG)
check_cxx_compiler_flag(-fuse-ld=bfd HAVE_BFD_LINKER_FLAG)
if((CMAKE_CXX_COMPILER_ID STREQUAL "Clang") AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 19.9))
check_cxx_compiler_flag(--ld-path=mold HAVE_MOLD_LINKER_FLAG)
check_cxx_compiler_flag(--ld-path=lld HAVE_LLD_LINKER_FLAG)
check_cxx_compiler_flag(--ld-path=gold HAVE_GOLD_LINKER_FLAG)
check_cxx_compiler_flag(--ld-path=bfd HAVE_BFD_LINKER_FLAG)
else()
check_cxx_compiler_flag(-fuse-ld=mold HAVE_MOLD_LINKER_FLAG)
check_cxx_compiler_flag(-fuse-ld=lld HAVE_LLD_LINKER_FLAG)
check_cxx_compiler_flag(-fuse-ld=gold HAVE_GOLD_LINKER_FLAG)
check_cxx_compiler_flag(-fuse-ld=bfd HAVE_BFD_LINKER_FLAG)
endif()
find_program(HAVE_MOLD_LINKER_BIN ld.mold)
find_program(HAVE_LLD_LINKER_BIN lld ld.lld)
find_program(HAVE_GOLD_LINKER_BIN ld.gold)
@ -48,7 +55,11 @@ if(ENABLE_TESTING)
validate_option(CMAKE_CUSTOM_LINKER CMAKE_CUSTOM_LINKER_VALUES)
mark_as_advanced(CMAKE_CUSTOM_LINKER)
if(NOT "${CMAKE_CUSTOM_LINKER}" STREQUAL "default")
target_link_options(lammps PUBLIC -fuse-ld=${CMAKE_CUSTOM_LINKER})
if((CMAKE_CXX_COMPILER_ID STREQUAL "Clang") AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 19.9))
target_link_options(lammps PUBLIC --ld-path=${CMAKE_CUSTOM_LINKER})
else()
target_link_options(lammps PUBLIC -fuse-ld=${CMAKE_CUSTOM_LINKER})
endif()
endif()
endif()
endif()