[llvm-commits] [compiler-rt] r170698 - /compiler-rt/trunk/lib/sanitizer_common/tests/CMakeLists.txt
Alexey Samsonov
samsonov at google.com
Thu Dec 20 06:38:02 PST 2012
Author: samsonov
Date: Thu Dec 20 08:38:02 2012
New Revision: 170698
URL: http://llvm.org/viewvc/llvm-project?rev=170698&view=rev
Log:
[Sanitizer] Fix CMake build rules for sanitizer_common tests to respect universal static libraries on Mac
Modified:
compiler-rt/trunk/lib/sanitizer_common/tests/CMakeLists.txt
Modified: compiler-rt/trunk/lib/sanitizer_common/tests/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/tests/CMakeLists.txt?rev=170698&r1=170697&r2=170698&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/tests/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/sanitizer_common/tests/CMakeLists.txt Thu Dec 20 08:38:02 2012
@@ -15,6 +15,24 @@
include_directories(..)
include_directories(../..)
+# Adds static library which contains sanitizer_common object file
+# (universal binary on Mac and arch-specific object files on Linux).
+macro(add_sanitizer_common_lib library)
+ add_library(${library} STATIC ${ARGN})
+ set_target_properties(${library} PROPERTIES
+ ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
+ set(lib_name "lib${library}.a")
+ add_custom_target(${lib_name} DEPENDS ${library})
+endmacro()
+
+function(get_sanitizer_common_lib_for_arch arch lib_name)
+ if(APPLE)
+ set(${lib_name} "libRTSanitizerCommon.test.osx.a" PARENT_SCOPE)
+ else()
+ set(${lib_name} "libRTSanitizerCommon.test.${arch}.a" PARENT_SCOPE)
+ endif()
+endfunction()
+
# Sanitizer_common unit tests testsuite.
add_custom_target(SanitizerUnitTests)
set_target_properties(SanitizerUnitTests PROPERTIES
@@ -40,16 +58,7 @@
DEPS gtest ${SANITIZER_RUNTIME_LIBRARIES})
list(APPEND SANITIZER_TEST_OBJECTS ${output_obj})
endforeach()
- # Add static library which contains sanitizer_common
- # object files for given arch.
- set(SANITIZER_COMMON_LIB "RTSanitizerCommon.test.${arch}")
- add_library(${SANITIZER_COMMON_LIB} STATIC
- $<TARGET_OBJECTS:RTSanitizerCommon.${arch}>)
- set_target_properties(${SANITIZER_COMMON_LIB} PROPERTIES
- ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
- set(SANITIZER_COMMON_LIB_NAME "lib${SANITIZER_COMMON_LIB}.a")
- add_custom_target(${SANITIZER_COMMON_LIB_NAME}
- DEPENDS ${SANITIZER_COMMON_LIB})
+ get_sanitizer_common_lib_for_arch(${arch} SANITIZER_COMMON_LIB_NAME)
# Add unittest target.
set(SANITIZER_TEST_NAME "Sanitizer-${arch}-Test")
add_compiler_rt_test(SanitizerUnitTests ${SANITIZER_TEST_NAME}
@@ -59,6 +68,19 @@
endmacro()
if("${CMAKE_HOST_SYSTEM}" STREQUAL "${CMAKE_SYSTEM}" AND UNIX AND NOT ANDROID)
+ if(APPLE)
+ add_sanitizer_common_lib("RTSanitizerCommon.test.osx"
+ $<TARGET_OBJECTS:RTSanitizerCommon.osx>)
+ else()
+ if(CAN_TARGET_X86_64)
+ add_sanitizer_common_lib("RTSanitizerCommon.test.x86_64"
+ $<TARGET_OBJECTS:RTSanitizerCommon.x86_64>)
+ endif()
+ if(CAN_TARGET_I386)
+ add_sanitizer_common_lib("RTSanitizerCommon.test.i386"
+ $<TARGET_OBJECTS:RTSanitizerCommon.i386>)
+ endif()
+ endif()
if(CAN_TARGET_X86_64)
add_sanitizer_tests_for_arch(x86_64)
endif()
More information about the llvm-commits
mailing list