diff options
author | Ed Schouten <ed@FreeBSD.org> | 2013-05-27 18:27:12 +0000 |
---|---|---|
committer | Ed Schouten <ed@FreeBSD.org> | 2013-05-27 18:27:12 +0000 |
commit | 11023dc647fd8f41418da90d59db138400d0f334 (patch) | |
tree | 50f0ab80515576749ef638dd0766b70a65904bfa /cmake | |
parent | 58aabf08b77d221489f10e274812ec60917c21a8 (diff) | |
download | src-11023dc647fd8f41418da90d59db138400d0f334.tar.gz src-11023dc647fd8f41418da90d59db138400d0f334.zip |
Import compiler-rt r182741.vendor/compiler-rt/compiler-rt-r182741
Notes
Notes:
svn path=/vendor/compiler-rt/dist/; revision=251034
svn path=/vendor/compiler-rt/compiler-rt-r182741/; revision=251036; tag=vendor/compiler-rt/compiler-rt-r182741
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/Modules/AddCompilerRT.cmake | 104 | ||||
-rw-r--r-- | cmake/Modules/CompilerRTUtils.cmake | 11 |
2 files changed, 109 insertions, 6 deletions
diff --git a/cmake/Modules/AddCompilerRT.cmake b/cmake/Modules/AddCompilerRT.cmake index e90253fdfa1e..bf114a401ef0 100644 --- a/cmake/Modules/AddCompilerRT.cmake +++ b/cmake/Modules/AddCompilerRT.cmake @@ -18,6 +18,92 @@ macro(add_compiler_rt_object_library name arch) endif() endmacro() +# Same as above, but adds universal osx library with name "<name>.osx" +# targeting multiple architectures. +# add_compiler_rt_osx_object_library(<name> ARCH <architectures> +# SOURCES <source files> +# CFLAGS <compile flags>) +macro(add_compiler_rt_osx_object_library name) + parse_arguments(LIB "ARCH;SOURCES;CFLAGS" "" ${ARGN}) + set(libname "${name}.osx") + add_library(${libname} OBJECT ${LIB_SOURCES}) + set_target_compile_flags(${libname} ${LIB_CFLAGS}) + set_target_properties(${libname} PROPERTIES OSX_ARCHITECTURES "${LIB_ARCH}") +endmacro() + +# Adds static runtime for a given architecture and puts it in the proper +# directory in the build and install trees. +# add_compiler_rt_static_runtime(<name> <arch> +# SOURCES <source files> +# CFLAGS <compile flags> +# DEFS <compile definitions> +# SYMS <symbols file>) +macro(add_compiler_rt_static_runtime name arch) + if(CAN_TARGET_${arch}) + parse_arguments(LIB "SOURCES;CFLAGS;DEFS;SYMS" "" ${ARGN}) + add_library(${name} STATIC ${LIB_SOURCES}) + # Setup compile flags and definitions. + set_target_compile_flags(${name} + ${TARGET_${arch}_CFLAGS} ${LIB_CFLAGS}) + set_property(TARGET ${name} APPEND PROPERTY + COMPILE_DEFINITIONS ${LIB_DEFS}) + # Setup correct output directory in the build tree. + set_target_properties(${name} PROPERTIES + ARCHIVE_OUTPUT_DIRECTORY ${COMPILER_RT_LIBRARY_OUTPUT_DIR}) + # Add installation command. + install(TARGETS ${name} + ARCHIVE DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR}) + # Generate the .syms file if possible. + if(LIB_SYMS) + get_target_property(libfile ${name} LOCATION) + configure_file(${LIB_SYMS} ${libfile}.syms) + install(FILES ${libfile}.syms + DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR}) + endif(LIB_SYMS) + else() + message(FATAL_ERROR "Archtecture ${arch} can't be targeted") + endif() +endmacro() + +# Same as add_compiler_rt_static_runtime, but creates a universal library +# for several architectures. +# add_compiler_rt_osx_static_runtime(<name> ARCH <architectures> +# SOURCES <source files> +# CFLAGS <compile flags> +# DEFS <compile definitions>) +macro(add_compiler_rt_osx_static_runtime name) + parse_arguments(LIB "ARCH;SOURCES;CFLAGS;DEFS" "" ${ARGN}) + add_library(${name} STATIC ${LIB_SOURCES}) + set_target_compile_flags(${name} ${LIB_CFLAGS}) + set_property(TARGET ${name} APPEND PROPERTY + COMPILE_DEFINITIONS ${LIB_DEFS}) + set_target_properties(${name} PROPERTIES + OSX_ARCHITECTURES "${LIB_ARCH}" + ARCHIVE_OUTPUT_DIRECTORY ${COMPILER_RT_LIBRARY_OUTPUT_DIR}) + install(TARGETS ${name} + ARCHIVE DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR}) +endmacro() + +# Adds dynamic runtime library on osx, which supports multiple architectures. +# add_compiler_rt_osx_dynamic_runtime(<name> ARCH <architectures> +# SOURCES <source files> +# CFLAGS <compile flags> +# DEFS <compile definitions> +# LINKFLAGS <link flags>) +macro(add_compiler_rt_osx_dynamic_runtime name) + parse_arguments(LIB "ARCH;SOURCES;CFLAGS;DEFS;LINKFLAGS" "" ${ARGN}) + add_library(${name} SHARED ${LIB_SOURCES}) + set_target_compile_flags(${name} ${LIB_CFLAGS}) + set_target_link_flags(${name} ${LIB_LINKFLAGS}) + set_property(TARGET ${name} APPEND PROPERTY + COMPILE_DEFINITIONS ${LIB_DEFS}) + set_target_properties(${name} PROPERTIES + OSX_ARCHITECTURES "${LIB_ARCH}" + LIBRARY_OUTPUT_DIRECTORY ${COMPILER_RT_LIBRARY_OUTPUT_DIR}) + install(TARGETS ${name} + LIBRARY DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR}) +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) @@ -35,15 +121,21 @@ set(COMPILER_RT_GTEST_INCLUDE_CFLAGS # 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} + set(output_bin "${CMAKE_CURRENT_BINARY_DIR}/${test_name}") + add_custom_target(${test_name} 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() + +macro(add_compiler_rt_resource_file target_name file_name) + set(src_file "${CMAKE_CURRENT_SOURCE_DIR}/${file_name}") + set(dst_file "${CLANG_RESOURCE_DIR}/${file_name}") + add_custom_target(${target_name} + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${src_file} ${dst_file} + DEPENDS ${file_name}) + # Install in Clang resource directory. + install(FILES ${file_name} DESTINATION ${LIBCLANG_INSTALL_PATH}) +endmacro() diff --git a/cmake/Modules/CompilerRTUtils.cmake b/cmake/Modules/CompilerRTUtils.cmake index 50f068091e64..f9760f40dbd5 100644 --- a/cmake/Modules/CompilerRTUtils.cmake +++ b/cmake/Modules/CompilerRTUtils.cmake @@ -15,3 +15,14 @@ function(set_target_link_flags target) set_property(TARGET ${target} PROPERTY LINK_FLAGS "${argstring}") endfunction() +# Check if a given flag is present in a space-separated flag_string. +# Store the result in out_var. +function(find_flag_in_string flag_string flag out_var) + string(REPLACE " " ";" flag_list ${flag_string}) + list(FIND flag_list ${flag} flag_pos) + if(NOT flag_pos EQUAL -1) + set(${out_var} TRUE PARENT_SCOPE) + else() + set(${out_var} FALSE PARENT_SCOPE) + endif() +endfunction() |