[AIX][cmake][NFC] Customize name of output atomic library

Let `archive-aix-libatomic` accept additional argument to customize name of output atomic library.

Reviewed By: jsji

Differential Revision: https://reviews.llvm.org/D120534
This commit is contained in:
Kai Luo 2022-02-28 02:27:26 +00:00
parent bcbb03754e
commit eb3730cf89
2 changed files with 9 additions and 9 deletions

View File

@ -24,7 +24,7 @@ function(get_aix_libatomic_type type)
endif()
endfunction()
macro(archive_aix_libatomic name)
macro(archive_aix_libatomic name libname)
cmake_parse_arguments(LIB
""
""
@ -33,7 +33,7 @@ macro(archive_aix_libatomic name)
set(objects_to_archive "")
foreach (arch ${LIB_ARCHS})
if(CAN_TARGET_${arch})
set(output_dir "${CMAKE_CURRENT_BINARY_DIR}/libatomic-${arch}.dir")
set(output_dir "${CMAKE_CURRENT_BINARY_DIR}/${libname}-${arch}.dir")
# FIXME: Target name should be kept consistent with definition
# in AddCompilerRT.cmake added by
# add_compiler_rt_runtime(<name> SHARED ...)
@ -67,14 +67,14 @@ macro(archive_aix_libatomic name)
get_compiler_rt_output_dir(${COMPILER_RT_DEFAULT_TARGET_ARCH} output_dir)
get_compiler_rt_install_dir(${COMPILER_RT_DEFAULT_TARGET_ARCH} install_dir)
endif()
add_custom_command(OUTPUT "${output_dir}/libatomic.a"
COMMAND ${CMAKE_AR} -X32_64 r "${output_dir}/libatomic.a"
add_custom_command(OUTPUT "${output_dir}/${libname}.a"
COMMAND ${CMAKE_AR} -X32_64 r "${output_dir}/${libname}.a"
${objects_to_archive}
DEPENDS ${objects_to_archive})
install(FILES "${output_dir}/libatomic.a"
install(FILES "${output_dir}/${libname}.a"
DESTINATION ${install_dir})
add_custom_target(aix-libatomic
DEPENDS "${output_dir}/libatomic.a")
add_custom_target(aix-${libname}
DEPENDS "${output_dir}/${libname}.a")
endif()
add_dependencies(${LIB_PARENT_TARGET} aix-libatomic)
add_dependencies(${LIB_PARENT_TARGET} aix-${libname})
endmacro()

View File

@ -803,7 +803,7 @@ if(COMPILER_RT_BUILD_STANDALONE_LIBATOMIC)
# archive, i.e., libatomic.a. Once cmake adds support of such usage for AIX,
# this ad-hoc part can be removed.
if(${CMAKE_SYSTEM_NAME} MATCHES "AIX")
archive_aix_libatomic(clang_rt.atomic
archive_aix_libatomic(clang_rt.atomic libatomic
ARCHS ${BUILTIN_SUPPORTED_ARCH}
PARENT_TARGET builtins-standalone-atomic)
endif()