Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/llvm/llvm-project.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTue Ly <lntue.h@gmail.com>2022-05-06 01:58:24 +0300
committerTue Ly <lntue.h@gmail.com>2022-05-08 20:33:45 +0300
commit13f358376a597077e93e11653b51648d4976b181 (patch)
tree5bd451ea7432fda62c066d40c1783deb4867bcdc /libc/cmake/modules
parent7e3aa70668aeb28e0d76c0d2807300eab337e0a7 (diff)
[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
Diffstat (limited to 'libc/cmake/modules')
-rw-r--r--libc/cmake/modules/LLVMLibCTestRules.cmake23
1 files changed, 10 insertions, 13 deletions
diff --git a/libc/cmake/modules/LLVMLibCTestRules.cmake b/libc/cmake/modules/LLVMLibCTestRules.cmake
index 4fe6834aecf7..3a1b9891e988 100644
--- a/libc/cmake/modules/LLVMLibCTestRules.cmake
+++ b/libc/cmake/modules/LLVMLibCTestRules.cmake
@@ -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}