From 6bb0157dcaacec571b7c35ac0ce192e73b608f53 Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Wed, 11 Apr 2018 05:16:11 +0000 Subject: [PATCH] [XRay][compiler-rt] Fix osx-based builds This is a follow-up to D45474. llvm-svn: 329776 --- compiler-rt/lib/xray/tests/CMakeLists.txt | 33 ++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/compiler-rt/lib/xray/tests/CMakeLists.txt b/compiler-rt/lib/xray/tests/CMakeLists.txt index 0d419a1..2f06bfe 100644 --- a/compiler-rt/lib/xray/tests/CMakeLists.txt +++ b/compiler-rt/lib/xray/tests/CMakeLists.txt @@ -34,13 +34,18 @@ function(get_xray_lib_for_arch arch lib) endfunction() set(XRAY_TEST_ARCH ${XRAY_SUPPORTED_ARCH}) +set(XRAY_UNITTEST_LINK_FLAGS ${CMAKE_THREAD_LIBS_INIT}) +if (NOT APPLE) + append_list_if(COMPILER_RT_HAS_LIBM -lm XRAY_UNITTEST_LINK_FLAGS) + append_list_if(COMPILER_RT_HAS_LIBRT -lrt XRAY_UNITTEST_LINK_FLAGS) + append_list_if(COMPILER_RT_HAS_LIBDL -ldl XRAY_UNITTEST_LINK_FLAGS) + append_list_if(COMPILER_RT_HAS_LIBPTHREAD -pthread XRAY_UNITTEST_LINK_FLAGS) +endif() + macro(add_xray_unittest testname) cmake_parse_arguments(TEST "" "" "SOURCES;HEADERS" ${ARGN}) if(UNIX AND NOT APPLE) set(CMAKE_DL_LIBS_INIT "") - foreach(lib ${CMAKE_DL_LIBS}) - list(APPEND CMAKE_DL_LIBS_INIT -l${lib}) - endforeach() foreach(arch ${XRAY_TEST_ARCH}) set(TEST_OBJECTS) get_xray_lib_for_arch(${arch} XRAY_RUNTIME_LIBS) @@ -55,9 +60,7 @@ macro(add_xray_unittest testname) RUNTIME "${XRAY_RUNTIME_LIBS}" DEPS gtest xray CFLAGS ${XRAY_UNITTEST_CFLAGS} - LINK_FLAGS ${TARGET_LINK_FLAGS} - -lstdc++ -lm ${CMAKE_THREAD_LIBS_INIT} - ${CMAKE_DL_LIBS_INIT} -lrt) + LINK_FLAGS ${TARGET_LINK_FLAGS} ${XRAY_UNITTEST_LINK_FLAGS} -lstdc++) set_target_properties(XRayUnitTests PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) endforeach() @@ -66,11 +69,19 @@ endmacro() if(COMPILER_RT_CAN_EXECUTE_TESTS) foreach(arch ${XRAY_SUPPORTED_ARCH}) - add_xray_lib("RTXRay.test.${arch}" - $ - $ - $ - $) + if (APPLE) + add_xray_lib("RTXRay.test.osx" + $ + $ + $ + $) + else() + add_xray_lib("RTXRay.test.${arch}" + $ + $ + $ + $) + endif() endforeach() add_subdirectory(unit) endif() -- 2.7.4