@@ -521,17 +521,6 @@ string(REGEX REPLACE "-stdlib=[a-zA-Z+]*" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}
521
521
list (APPEND COMPILER_RT_COMMON_CFLAGS ${stdlib_flag} )
522
522
list (APPEND COMPILER_RT_COMMON_LINK_FLAGS ${stdlib_flag} )
523
523
524
- # TODO: There's a lot of duplication across lib/*/tests/CMakeLists.txt files,
525
- # move some of the common flags to COMPILER_RT_UNITTEST_CFLAGS.
526
-
527
- # Unittests need access to C++ standard library.
528
- string (APPEND COMPILER_RT_TEST_COMPILER_CFLAGS " ${stdlib_flag} " )
529
-
530
- # When cross-compiling, COMPILER_RT_TEST_COMPILER_CFLAGS help in compilation
531
- # and linking of unittests.
532
- string (REPLACE " " ";" COMPILER_RT_UNITTEST_CFLAGS "${COMPILER_RT_TEST_COMPILER_CFLAGS} " )
533
- set (COMPILER_RT_UNITTEST_LINK_FLAGS ${COMPILER_RT_UNITTEST_CFLAGS} )
534
-
535
524
if (COMPILER_RT_USE_LLVM_UNWINDER )
536
525
if (COMPILER_RT_ENABLE_STATIC_UNWINDER )
537
526
set (unwinder_target unwind_static )
@@ -594,18 +583,25 @@ if (SANITIZER_TEST_CXX_LIBNAME STREQUAL "libc++")
594
583
else ()
595
584
set (cxx_target cxx_shared )
596
585
endif ()
597
- list (APPEND SANITIZER_TEST_CXX_LIBRARIES "$<$<TARGET_EXISTS:${cxx_target} >:$<TARGET_LINKER_FILE:${cxx_target} >>" )
598
- list (APPEND SANITIZER_TEST_CXX_CFLAGS "$<$<TARGET_EXISTS:cxx-headers>:-isystem$<JOIN:$<TARGET_PROPERTY:cxx-headers,INTERFACE_INCLUDE_DIRECTORIES>,$<SEMICOLON>-isystem>>" )
599
- # We are using the in tree libc++ so avoid including the default one.
600
- append_list_if (COMPILER_RT_HAS_NOSTDINCXX_FLAG -nostdinc++ COMPILER_RT_UNITTEST_CFLAGS )
601
- append_list_if (COMPILER_RT_HAS_NOSTDLIBXX_FLAG -nostdlib++ COMPILER_RT_UNITTEST_LINK_FLAGS )
586
+ list (APPEND SANITIZER_TEST_CXX_LIBRARIES "$<$<BOOL:$<TARGET_NAME_IF_EXISTS:${cxx_target} >>:$<TARGET_LINKER_FILE:${cxx_target} >>" )
602
587
else ()
603
588
append_list_if (COMPILER_RT_HAS_LIBCXX -lc++ SANITIZER_TEST_CXX_LIBRARIES )
604
589
endif ()
605
590
elseif (SANITIZER_TEST_CXX_LIBNAME STREQUAL "libstdc++" )
606
591
append_list_if (COMPILER_RT_HAS_LIBSTDCXX -lstdc++ SANITIZER_TEST_CXX_LIBRARIES )
607
592
endif ()
608
593
594
+ # TODO: There's a lot of duplication across lib/*/tests/CMakeLists.txt files,
595
+ # move some of the common flags to COMPILER_RT_UNITTEST_CFLAGS.
596
+
597
+ # Unittests need access to C++ standard library.
598
+ string (APPEND COMPILER_RT_TEST_COMPILER_CFLAGS " ${stdlib_flag} " )
599
+
600
+ # When cross-compiling, COMPILER_RT_TEST_COMPILER_CFLAGS help in compilation
601
+ # and linking of unittests.
602
+ string (REPLACE " " ";" COMPILER_RT_UNITTEST_CFLAGS "${COMPILER_RT_TEST_COMPILER_CFLAGS} " )
603
+ set (COMPILER_RT_UNITTEST_LINK_FLAGS ${COMPILER_RT_UNITTEST_CFLAGS} )
604
+
609
605
# Unittests support.
610
606
set (COMPILER_RT_GTEST_PATH ${LLVM_MAIN_SRC_DIR} /utils/unittest/googletest )
611
607
set (COMPILER_RT_GTEST_SOURCE ${COMPILER_RT_GTEST_PATH} /src/gtest-all.cc )
0 commit comments