[llvm-commits] [compiler-rt] r172826 - in /compiler-rt/trunk: CMakeLists.txt cmake/Modules/AddCompilerRT.cmake cmake/Modules/CompilerRTUnittests.cmake cmake/Modules/CompilerRTUtils.cmake lib/asan/tests/CMakeLists.txt lib/interception/CMakeLists.txt lib/msan/tests/CMakeLists.txt lib/sanitizer_common/CMakeLists.txt lib/sanitizer_common/tests/CMakeLists.txt
Alexey Samsonov
samsonov at google.com
Fri Jan 18 08:05:21 PST 2013
Author: samsonov
Date: Fri Jan 18 10:05:21 2013
New Revision: 172826
URL: http://llvm.org/viewvc/llvm-project?rev=172826&view=rev
Log:
CMake: create AddCompilerRT module and implement convenience add_compiler_rt_object_library function
Added:
compiler-rt/trunk/cmake/Modules/AddCompilerRT.cmake
compiler-rt/trunk/cmake/Modules/CompilerRTUtils.cmake
Removed:
compiler-rt/trunk/cmake/Modules/CompilerRTUnittests.cmake
Modified:
compiler-rt/trunk/CMakeLists.txt
compiler-rt/trunk/lib/asan/tests/CMakeLists.txt
compiler-rt/trunk/lib/interception/CMakeLists.txt
compiler-rt/trunk/lib/msan/tests/CMakeLists.txt
compiler-rt/trunk/lib/sanitizer_common/CMakeLists.txt
compiler-rt/trunk/lib/sanitizer_common/tests/CMakeLists.txt
Modified: compiler-rt/trunk/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/CMakeLists.txt?rev=172826&r1=172825&r2=172826&view=diff
==============================================================================
--- compiler-rt/trunk/CMakeLists.txt (original)
+++ compiler-rt/trunk/CMakeLists.txt Fri Jan 18 10:05:21 2013
@@ -20,6 +20,7 @@
${CMAKE_MODULE_PATH}
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules"
)
+include(AddCompilerRT)
set(COMPILER_RT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
@@ -123,23 +124,6 @@
list(APPEND SANITIZER_COMMON_CFLAGS -mmacosx-version-min=10.5)
endif()
-# Because compiler-rt spends a lot of time setting up custom compile flags,
-# define a handy helper function for it. The compile flags setting in CMake
-# has serious issues that make its syntax challenging at best.
-function(set_target_compile_flags target)
- foreach(arg ${ARGN})
- set(argstring "${argstring} ${arg}")
- endforeach()
- set_property(TARGET ${target} PROPERTY COMPILE_FLAGS "${argstring}")
-endfunction()
-
-function(set_target_link_flags target)
- foreach(arg ${ARGN})
- set(argstring "${argstring} ${arg}")
- endforeach()
- set_property(TARGET ${target} PROPERTY LINK_FLAGS "${argstring}")
-endfunction()
-
# Compute the Clang version from the LLVM version.
# FIXME: We should be able to reuse CLANG_VERSION variable calculated
# in Clang cmake files, instead of copying the rules here.
Added: compiler-rt/trunk/cmake/Modules/AddCompilerRT.cmake
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/cmake/Modules/AddCompilerRT.cmake?rev=172826&view=auto
==============================================================================
--- compiler-rt/trunk/cmake/Modules/AddCompilerRT.cmake (added)
+++ compiler-rt/trunk/cmake/Modules/AddCompilerRT.cmake Fri Jan 18 10:05:21 2013
@@ -0,0 +1,49 @@
+include(AddLLVM)
+include(LLVMParseArguments)
+include(CompilerRTUtils)
+
+# Tries to add "object library" target for a given architecture
+# with name "<name>.<arch>" if architecture can be targeted.
+# add_compiler_rt_object_library(<name> <arch>
+# SOURCES <source files>
+# CFLAGS <compile flags>)
+macro(add_compiler_rt_object_library name arch)
+ if(CAN_TARGET_${arch})
+ parse_arguments(LIB "SOURCES;CFLAGS" "" ${ARGN})
+ add_library(${name}.${arch} OBJECT ${LIB_SOURCES})
+ set_target_compile_flags(${name}.${arch}
+ ${TARGET_${arch}_CFLAGS} ${LIB_CFLAGS})
+ else()
+ message(FATAL_ERROR "Archtecture ${arch} can't be targeted")
+ endif()
+endmacro()
+
+# Unittests support.
+set(COMPILER_RT_GTEST_PATH ${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest)
+set(COMPILER_RT_GTEST_SOURCE ${COMPILER_RT_GTEST_PATH}/gtest-all.cc)
+set(COMPILER_RT_GTEST_INCLUDE_CFLAGS
+ -DGTEST_NO_LLVM_RAW_OSTREAM=1
+ -I${COMPILER_RT_GTEST_PATH}/include
+)
+
+# Use Clang to link objects into a single executable with just-built
+# Clang, using specific link flags. Make executable a part of provided
+# test_suite.
+# add_compiler_rt_test(<test_suite> <test_name>
+# OBJECTS <object files>
+# DEPS <deps (e.g. runtime libs)>
+# LINK_FLAGS <link flags>)
+macro(add_compiler_rt_test test_suite test_name)
+ parse_arguments(TEST "OBJECTS;DEPS;LINK_FLAGS" "" ${ARGN})
+ get_unittest_directory(OUTPUT_DIR)
+ file(MAKE_DIRECTORY ${OUTPUT_DIR})
+ set(output_bin "${OUTPUT_DIR}/${test_name}")
+ add_custom_command(
+ OUTPUT ${output_bin}
+ COMMAND clang ${TEST_OBJECTS} -o "${output_bin}"
+ ${TEST_LINK_FLAGS}
+ DEPENDS clang ${TEST_DEPS})
+ add_custom_target(${test_name} DEPENDS ${output_bin})
+ # Make the test suite depend on the binary.
+ add_dependencies(${test_suite} ${test_name})
+endmacro()
Removed: compiler-rt/trunk/cmake/Modules/CompilerRTUnittests.cmake
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/cmake/Modules/CompilerRTUnittests.cmake?rev=172825&view=auto
==============================================================================
--- compiler-rt/trunk/cmake/Modules/CompilerRTUnittests.cmake (original)
+++ compiler-rt/trunk/cmake/Modules/CompilerRTUnittests.cmake (removed)
@@ -1,31 +0,0 @@
-include(AddLLVM)
-include(LLVMParseArguments)
-
-set(COMPILER_RT_GTEST_PATH ${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest)
-set(COMPILER_RT_GTEST_SOURCE ${COMPILER_RT_GTEST_PATH}/gtest-all.cc)
-set(COMPILER_RT_GTEST_INCLUDE_CFLAGS
- -DGTEST_NO_LLVM_RAW_OSTREAM=1
- -I${COMPILER_RT_GTEST_PATH}/include
-)
-
-# Use Clang to link objects into a single executable with just-built
-# Clang, using specific link flags. Make executable a part of provided
-# test_suite.
-# add_compiler_rt_test(<test_suite> <test_name>
-# OBJECTS <object files>
-# DEPS <deps (e.g. runtime libs)>
-# LINK_FLAGS <link flags>)
-macro(add_compiler_rt_test test_suite test_name)
- parse_arguments(TEST "OBJECTS;DEPS;LINK_FLAGS" "" ${ARGN})
- get_unittest_directory(OUTPUT_DIR)
- file(MAKE_DIRECTORY ${OUTPUT_DIR})
- set(output_bin "${OUTPUT_DIR}/${test_name}")
- add_custom_command(
- OUTPUT ${output_bin}
- COMMAND clang ${TEST_OBJECTS} -o "${output_bin}"
- ${TEST_LINK_FLAGS}
- DEPENDS clang ${TEST_DEPS})
- add_custom_target(${test_name} DEPENDS ${output_bin})
- # Make the test suite depend on the binary.
- add_dependencies(${test_suite} ${test_name})
-endmacro()
Added: compiler-rt/trunk/cmake/Modules/CompilerRTUtils.cmake
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/cmake/Modules/CompilerRTUtils.cmake?rev=172826&view=auto
==============================================================================
--- compiler-rt/trunk/cmake/Modules/CompilerRTUtils.cmake (added)
+++ compiler-rt/trunk/cmake/Modules/CompilerRTUtils.cmake Fri Jan 18 10:05:21 2013
@@ -0,0 +1,17 @@
+# Because compiler-rt spends a lot of time setting up custom compile flags,
+# define a handy helper function for it. The compile flags setting in CMake
+# has serious issues that make its syntax challenging at best.
+function(set_target_compile_flags target)
+ foreach(arg ${ARGN})
+ set(argstring "${argstring} ${arg}")
+ endforeach()
+ set_property(TARGET ${target} PROPERTY COMPILE_FLAGS "${argstring}")
+endfunction()
+
+function(set_target_link_flags target)
+ foreach(arg ${ARGN})
+ set(argstring "${argstring} ${arg}")
+ endforeach()
+ set_property(TARGET ${target} PROPERTY LINK_FLAGS "${argstring}")
+endfunction()
+
Modified: compiler-rt/trunk/lib/asan/tests/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/tests/CMakeLists.txt?rev=172826&r1=172825&r2=172826&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/tests/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/asan/tests/CMakeLists.txt Fri Jan 18 10:05:21 2013
@@ -11,7 +11,6 @@
include(CheckCXXCompilerFlag)
include(CompilerRTCompile)
-include(CompilerRTUnittests)
include_directories(..)
include_directories(../..)
Modified: compiler-rt/trunk/lib/interception/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/interception/CMakeLists.txt?rev=172826&r1=172825&r2=172826&view=diff
==============================================================================
--- compiler-rt/trunk/lib/interception/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/interception/CMakeLists.txt Fri Jan 18 10:05:21 2013
@@ -27,21 +27,18 @@
filter_available_targets(INTERCEPTION_TARGETS x86_64 i386)
set_target_properties(RTInterception.osx PROPERTIES
OSX_ARCHITECTURES "${INTERCEPTION_TARGETS}")
+elseif(ANDROID)
+ add_library(RTInterception.arm.android OBJECT ${INTERCEPTION_SOURCES})
+ set_target_compile_flags(RTInterception.arm.android
+ ${INTERCEPTION_CFLAGS})
else()
# Otherwise, build separate libraries for each target.
if(CAN_TARGET_x86_64)
- add_library(RTInterception.x86_64 OBJECT ${INTERCEPTION_SOURCES})
- set_target_compile_flags(RTInterception.x86_64
- ${INTERCEPTION_CFLAGS} ${TARGET_x86_64_CFLAGS})
+ add_compiler_rt_object_library(RTInterception x86_64
+ SOURCES ${INTERCEPTION_SOURCES} CFLAGS ${INTERCEPTION_CFLAGS})
endif()
- if(CAN_TARGET_i386)
- add_library(RTInterception.i386 OBJECT ${INTERCEPTION_SOURCES})
- set_target_compile_flags(RTInterception.i386
- ${INTERCEPTION_CFLAGS} ${TARGET_i386_CFLAGS})
- endif()
- if(ANDROID)
- add_library(RTInterception.arm.android OBJECT ${INTERCEPTION_SOURCES})
- set_target_compile_flags(RTInterception.arm.android
- ${INTERCEPTION_CFLAGS})
+ if (CAN_TARGET_i386)
+ add_compiler_rt_object_library(RTInterception i386
+ SOURCES ${INTERCEPTION_SOURCES} CFLAGS ${INTERCEPTION_CFLAGS})
endif()
endif()
Modified: compiler-rt/trunk/lib/msan/tests/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/tests/CMakeLists.txt?rev=172826&r1=172825&r2=172826&view=diff
==============================================================================
--- compiler-rt/trunk/lib/msan/tests/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/msan/tests/CMakeLists.txt Fri Jan 18 10:05:21 2013
@@ -1,7 +1,6 @@
include(CheckCXXCompilerFlag)
include(CompilerRTCompile)
include(CompilerRTLink)
-include(CompilerRTUnittests)
include_directories(..)
include_directories(../..)
Modified: compiler-rt/trunk/lib/sanitizer_common/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/CMakeLists.txt?rev=172826&r1=172825&r2=172826&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/sanitizer_common/CMakeLists.txt Fri Jan 18 10:05:21 2013
@@ -58,26 +58,23 @@
set_target_properties(RTSanitizerCommon.osx PROPERTIES
OSX_ARCHITECTURES "${SANITIZER_TARGETS}")
list(APPEND SANITIZER_RUNTIME_LIBRARIES RTSanitizerCommon.osx)
+elseif(ANDROID)
+ add_library(RTSanitizerCommon.arm.android OBJECT ${SANITIZER_SOURCES})
+ set_target_compile_flags(RTSanitizerCommon.arm.android
+ ${SANITIZER_CFLAGS})
+ list(APPEND SANITIZER_RUNTIME_LIBRARIES RTSanitizerCommon.arm.android)
else()
# Otherwise, build separate libraries for each target.
if(CAN_TARGET_x86_64)
- add_library(RTSanitizerCommon.x86_64 OBJECT ${SANITIZER_SOURCES})
- set_target_compile_flags(RTSanitizerCommon.x86_64
- ${SANITIZER_CFLAGS} ${TARGET_x86_64_CFLAGS})
+ add_compiler_rt_object_library(RTSanitizerCommon x86_64
+ SOURCES ${SANITIZER_SOURCES} CFLAGS ${SANITIZER_CFLAGS})
list(APPEND SANITIZER_RUNTIME_LIBRARIES RTSanitizerCommon.x86_64)
endif()
if(CAN_TARGET_i386)
- add_library(RTSanitizerCommon.i386 OBJECT ${SANITIZER_SOURCES})
- set_target_compile_flags(RTSanitizerCommon.i386
- ${SANITIZER_CFLAGS} ${TARGET_i386_CFLAGS})
+ add_compiler_rt_object_library(RTSanitizerCommon i386
+ SOURCES ${SANITIZER_SOURCES} CFLAGS ${SANITIZER_CFLAGS})
list(APPEND SANITIZER_RUNTIME_LIBRARIES RTSanitizerCommon.i386)
endif()
- if(ANDROID)
- add_library(RTSanitizerCommon.arm.android OBJECT ${SANITIZER_SOURCES})
- set_target_compile_flags(RTSanitizerCommon.arm.android
- ${SANITIZER_CFLAGS})
- list(APPEND SANITIZER_RUNTIME_LIBRARIES RTSanitizerCommon.arm.android)
- endif()
endif()
# Unit tests for common sanitizer runtime.
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=172826&r1=172825&r2=172826&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/tests/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/sanitizer_common/tests/CMakeLists.txt Fri Jan 18 10:05:21 2013
@@ -1,5 +1,4 @@
include(CompilerRTCompile)
-include(CompilerRTUnittests)
set(SANITIZER_UNITTESTS
sanitizer_allocator_test.cc
More information about the llvm-commits
mailing list