mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-02-05 00:49:43 +00:00
[libc] Add LINK_LIBRARIES option to add_fp_unittest and add_libc_unittest.
This is needed to prepare for adding FLAGS option. Reviewed By: sivachandra Differential Revision: https://reviews.llvm.org/D125055
This commit is contained in:
parent
7e3aa70668
commit
13f358376a
@ -63,7 +63,7 @@ endfunction(get_object_files_for_test)
|
||||
# HDRS <list of .h files for the test>
|
||||
# DEPENDS <list of dependencies>
|
||||
# COMPILE_OPTIONS <list of special compile options for this target>
|
||||
# LINK_OPTIONS <list of special linking options for this target>
|
||||
# LINK_LIBRARIES <list of linking libraries for this target>
|
||||
# )
|
||||
function(add_libc_unittest target_name)
|
||||
if(NOT LLVM_INCLUDE_TESTS)
|
||||
@ -72,10 +72,9 @@ function(add_libc_unittest target_name)
|
||||
|
||||
cmake_parse_arguments(
|
||||
"LIBC_UNITTEST"
|
||||
"NO_RUN_POSTBUILD" # Optional arguments
|
||||
"NO_RUN_POSTBUILD;NO_LIBC_UNITTEST_TEST_MAIN" # Optional arguments
|
||||
"SUITE;CXX_STANDARD" # Single value arguments
|
||||
"SRCS;HDRS;DEPENDS;COMPILE_OPTIONS;LINK_OPTIONS" # Multi-value arguments
|
||||
"NO_LIBC_UNITTEST_TEST_MAIN"
|
||||
"SRCS;HDRS;DEPENDS;COMPILE_OPTIONS;LINK_LIBRARIES" # Multi-value arguments
|
||||
${ARGN}
|
||||
)
|
||||
if(NOT LIBC_UNITTEST_SRCS)
|
||||
@ -147,13 +146,8 @@ function(add_libc_unittest target_name)
|
||||
)
|
||||
endif()
|
||||
|
||||
target_link_libraries(${fq_target_name} PRIVATE ${link_object_files})
|
||||
if(LIBC_UNITTEST_LINK_OPTIONS)
|
||||
target_link_options(
|
||||
${fq_target_name}
|
||||
PRIVATE ${LIBC_UNITTEST_LINK_OPTIONS}
|
||||
)
|
||||
endif()
|
||||
# Test object files will depend on LINK_LIBRARIES passed down from `add_fp_unittest`
|
||||
list(PREPEND LIBC_UNITTEST_LINK_LIBRARIES ${link_object_files})
|
||||
|
||||
set_target_properties(${fq_target_name}
|
||||
PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
||||
@ -163,12 +157,15 @@ function(add_libc_unittest target_name)
|
||||
${fq_deps_list}
|
||||
)
|
||||
|
||||
# LibcUnitTest and libc_test_utils should not depend on anything in LINK_LIBRARIES.
|
||||
if(NO_LIBC_UNITTEST_TEST_MAIN)
|
||||
target_link_libraries(${fq_target_name} PRIVATE LibcUnitTest libc_test_utils)
|
||||
list(APPEND LIBC_UNITTEST_LINK_LIBRARIES LibcUnitTest libc_test_utils)
|
||||
else()
|
||||
target_link_libraries(${fq_target_name} PRIVATE LibcUnitTest LibcUnitTestMain libc_test_utils)
|
||||
list(APPEND LIBC_UNITTEST_LINK_LIBRARIES LibcUnitTest LibcUnitTestMain libc_test_utils)
|
||||
endif()
|
||||
|
||||
target_link_libraries(${fq_target_name} PRIVATE ${LIBC_UNITTEST_LINK_LIBRARIES})
|
||||
|
||||
if(NOT LIBC_UNITTEST_NO_RUN_POSTBUILD)
|
||||
add_custom_command(
|
||||
TARGET ${fq_target_name}
|
||||
|
@ -3,7 +3,7 @@ function(add_fp_unittest name)
|
||||
"MATH_UNITTEST"
|
||||
"NEED_MPFR" # Optional arguments
|
||||
"" # Single value arguments
|
||||
"" # Multi-value arguments
|
||||
"LINK_LIBRARIES" # Multi-value arguments
|
||||
${ARGN}
|
||||
)
|
||||
|
||||
@ -14,15 +14,16 @@ function(add_fp_unittest name)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
add_libc_unittest(${name} ${MATH_UNITTEST_UNPARSED_ARGUMENTS})
|
||||
get_fq_target_name(${name} fq_target_name)
|
||||
if (NOT TARGET ${fq_target_name})
|
||||
return()
|
||||
endif()
|
||||
if(MATH_UNITTEST_NEED_MPFR)
|
||||
target_link_libraries(${fq_target_name} PRIVATE libcMPFRWrapper -lmpfr -lgmp)
|
||||
list(APPEND MATH_UNITTEST_LINK_LIBRARIES libcMPFRWrapper -lmpfr -lgmp)
|
||||
endif()
|
||||
target_link_libraries(${fq_target_name} PRIVATE LibcFPTestHelpers)
|
||||
list(APPEND MATH_UNITTEST_LINK_LIBRARIES LibcFPTestHelpers)
|
||||
|
||||
add_libc_unittest(
|
||||
${name}
|
||||
"${MATH_UNITTEST_UNPARSED_ARGUMENTS}"
|
||||
LINK_LIBRARIES "${MATH_UNITTEST_LINK_LIBRARIES}"
|
||||
)
|
||||
endfunction(add_fp_unittest)
|
||||
|
||||
add_subdirectory(__support)
|
||||
|
@ -15,10 +15,8 @@ add_libc_unittest(
|
||||
libc.include.stdio
|
||||
libc.include.stdlib
|
||||
libc.src.__support.File.file
|
||||
)
|
||||
|
||||
target_link_libraries(
|
||||
libc.test.src.__support.File.file_test PRIVATE LibcMemoryHelpers
|
||||
LINK_LIBRARIES
|
||||
LibcMemoryHelpers
|
||||
)
|
||||
|
||||
if (TARGET libc.src.__support.File.platform_file)
|
||||
|
@ -60,7 +60,7 @@ add_fp_unittest(
|
||||
libc.include.math
|
||||
libc.src.math.expf
|
||||
libc.src.__support.FPUtil.fputil
|
||||
LINK_OPTIONS
|
||||
LINK_LIBRARIES
|
||||
-lpthread
|
||||
)
|
||||
|
||||
@ -77,7 +77,7 @@ add_fp_unittest(
|
||||
libc.include.math
|
||||
libc.src.math.exp2f
|
||||
libc.src.__support.FPUtil.fputil
|
||||
LINK_OPTIONS
|
||||
LINK_LIBRARIES
|
||||
-lpthread
|
||||
)
|
||||
|
||||
@ -95,7 +95,7 @@ add_fp_unittest(
|
||||
libc.src.math.expf
|
||||
libc.src.math.expm1f
|
||||
libc.src.__support.FPUtil.fputil
|
||||
LINK_OPTIONS
|
||||
LINK_LIBRARIES
|
||||
-lpthread
|
||||
)
|
||||
|
||||
@ -112,7 +112,7 @@ add_fp_unittest(
|
||||
libc.include.math
|
||||
libc.src.math.logf
|
||||
libc.src.__support.FPUtil.fputil
|
||||
LINK_OPTIONS
|
||||
LINK_LIBRARIES
|
||||
-lpthread
|
||||
)
|
||||
|
||||
@ -129,7 +129,7 @@ add_fp_unittest(
|
||||
libc.include.math
|
||||
libc.src.math.log10f
|
||||
libc.src.__support.FPUtil.fputil
|
||||
LINK_OPTIONS
|
||||
LINK_LIBRARIES
|
||||
-lpthread
|
||||
)
|
||||
|
||||
@ -146,7 +146,7 @@ add_fp_unittest(
|
||||
libc.include.math
|
||||
libc.src.math.log1pf
|
||||
libc.src.__support.FPUtil.fputil
|
||||
LINK_OPTIONS
|
||||
LINK_LIBRARIES
|
||||
-lpthread
|
||||
)
|
||||
|
||||
@ -163,7 +163,7 @@ add_fp_unittest(
|
||||
libc.include.math
|
||||
libc.src.math.log2f
|
||||
libc.src.__support.FPUtil.fputil
|
||||
LINK_OPTIONS
|
||||
LINK_LIBRARIES
|
||||
-lpthread
|
||||
)
|
||||
|
||||
@ -182,6 +182,6 @@ add_fp_unittest(
|
||||
libc.src.__support.FPUtil.fputil
|
||||
COMPILE_OPTIONS
|
||||
-O3
|
||||
LINK_OPTIONS
|
||||
LINK_LIBRARIES
|
||||
-lpthread
|
||||
)
|
||||
|
@ -59,14 +59,10 @@ add_libc_unittest(
|
||||
libc.src.stdio.fread
|
||||
libc.src.stdio.fseek
|
||||
libc.src.stdio.fwrite
|
||||
LINK_LIBRARIES
|
||||
LibcMemoryHelpers
|
||||
)
|
||||
|
||||
if(TARGET libc.test.src.stdio.fopencookie_test)
|
||||
target_link_libraries(
|
||||
libc.test.src.stdio.fopencookie_test PRIVATE LibcMemoryHelpers
|
||||
)
|
||||
endif()
|
||||
|
||||
add_subdirectory(printf_core)
|
||||
|
||||
add_subdirectory(testdata)
|
||||
|
@ -7,10 +7,10 @@ add_libc_unittest(
|
||||
DEPENDS
|
||||
libc.src.stdio.printf_core.parser
|
||||
libc.src.__support.arg_list
|
||||
LINK_LIBRARIES
|
||||
LibcPrintfHelpers
|
||||
)
|
||||
|
||||
target_link_libraries(libc.test.src.stdio.printf_core.parser_test PRIVATE LibcPrintfHelpers)
|
||||
|
||||
add_libc_unittest(
|
||||
string_writer_test
|
||||
SUITE
|
||||
|
@ -259,10 +259,11 @@ function(add_libc_multi_impl_test name)
|
||||
${fq_config_name}
|
||||
COMPILE_OPTIONS
|
||||
${LIBC_COMPILE_OPTIONS_NATIVE}
|
||||
LINK_LIBRARIES
|
||||
LibcMemoryHelpers
|
||||
${ARGN}
|
||||
)
|
||||
get_fq_target_name(${fq_config_name}_test fq_target_name)
|
||||
target_link_libraries(${fq_target_name} PRIVATE LibcMemoryHelpers)
|
||||
else()
|
||||
message(STATUS "Skipping test for '${fq_config_name}' insufficient host cpu features '${required_cpu_features}'")
|
||||
endif()
|
||||
|
Loading…
x
Reference in New Issue
Block a user