您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 

67 行
2.8 KiB

  1. # The MIT License (MIT)
  2. #
  3. # Copyright (c)
  4. # 2013 Matthew Arsenault
  5. # 2015-2016 RWTH Aachen University, Federal Republic of Germany
  6. #
  7. # Permission is hereby granted, free of charge, to any person obtaining a copy
  8. # of this software and associated documentation files (the "Software"), to deal
  9. # in the Software without restriction, including without limitation the rights
  10. # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  11. # copies of the Software, and to permit persons to whom the Software is
  12. # furnished to do so, subject to the following conditions:
  13. #
  14. # The above copyright notice and this permission notice shall be included in all
  15. # copies or substantial portions of the Software.
  16. #
  17. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  18. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19. # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  20. # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  21. # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  22. # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  23. # SOFTWARE.
  24. # Helper function to get the language of a source file.
  25. function (sanitizer_lang_of_source FILE RETURN_VAR)
  26. get_filename_component(FILE_EXT "${FILE}" EXT)
  27. string(TOLOWER "${FILE_EXT}" FILE_EXT)
  28. string(SUBSTRING "${FILE_EXT}" 1 -1 FILE_EXT)
  29. get_property(ENABLED_LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES)
  30. foreach (LANG ${ENABLED_LANGUAGES})
  31. list(FIND CMAKE_${LANG}_SOURCE_FILE_EXTENSIONS "${FILE_EXT}" TEMP)
  32. if (NOT ${TEMP} EQUAL -1)
  33. set(${RETURN_VAR} "${LANG}" PARENT_SCOPE)
  34. return()
  35. endif ()
  36. endforeach()
  37. set(${RETURN_VAR} "" PARENT_SCOPE)
  38. endfunction ()
  39. # Helper function to get compilers used by a target.
  40. function (sanitizer_target_compilers TARGET RETURN_VAR)
  41. # Check if all sources for target use the same compiler. If a target uses
  42. # e.g. C and Fortran mixed and uses different compilers (e.g. clang and
  43. # gfortran) this can trigger huge problems, because different compilers may
  44. # use different implementations for sanitizers.
  45. set(BUFFER "")
  46. get_target_property(TSOURCES ${TARGET} SOURCES)
  47. foreach (FILE ${TSOURCES})
  48. # If expression was found, FILE is a generator-expression for an object
  49. # library. Object libraries will be ignored.
  50. string(REGEX MATCH "TARGET_OBJECTS:([^ >]+)" _file ${FILE})
  51. if ("${_file}" STREQUAL "")
  52. sanitizer_lang_of_source(${FILE} LANG)
  53. if (LANG)
  54. list(APPEND BUFFER ${CMAKE_${LANG}_COMPILER_ID})
  55. endif ()
  56. endif ()
  57. endforeach ()
  58. list(REMOVE_DUPLICATES BUFFER)
  59. set(${RETURN_VAR} "${BUFFER}" PARENT_SCOPE)
  60. endfunction ()