Clang-C.cmake 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. include(Compiler/Clang)
  2. __compiler_clang(C)
  3. cmake_policy(GET CMP0025 appleClangPolicy)
  4. if(APPLE AND NOT appleClangPolicy STREQUAL NEW)
  5. return()
  6. endif()
  7. if("x${CMAKE_C_COMPILER_FRONTEND_VARIANT}" STREQUAL "xMSVC")
  8. set(CMAKE_C_COMPILE_OPTIONS_EXPLICIT_LANGUAGE -TC)
  9. set(CMAKE_C_CLANG_TIDY_DRIVER_MODE "cl")
  10. if((NOT DEFINED CMAKE_DEPENDS_USE_COMPILER OR CMAKE_DEPENDS_USE_COMPILER)
  11. AND CMAKE_GENERATOR MATCHES "Makefiles|WMake"
  12. AND CMAKE_DEPFILE_FLAGS_C)
  13. set(CMAKE_C_DEPENDS_USE_COMPILER TRUE)
  14. endif()
  15. elseif("x${CMAKE_C_COMPILER_FRONTEND_VARIANT}" STREQUAL "xGNU")
  16. set(CMAKE_C_COMPILE_OPTIONS_EXPLICIT_LANGUAGE -x c)
  17. if((NOT DEFINED CMAKE_DEPENDS_USE_COMPILER OR CMAKE_DEPENDS_USE_COMPILER)
  18. AND CMAKE_GENERATOR MATCHES "Makefiles|WMake"
  19. AND CMAKE_DEPFILE_FLAGS_C)
  20. # dependencies are computed by the compiler itself
  21. set(CMAKE_C_DEPFILE_FORMAT gcc)
  22. set(CMAKE_C_DEPENDS_USE_COMPILER TRUE)
  23. endif()
  24. endif()
  25. if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 3.4)
  26. if(NOT "x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC")
  27. set(CMAKE_C90_STANDARD_COMPILE_OPTION "-std=c90")
  28. set(CMAKE_C90_EXTENSION_COMPILE_OPTION "-std=gnu90")
  29. set(CMAKE_C90_STANDARD__HAS_FULL_SUPPORT ON)
  30. set(CMAKE_C99_STANDARD_COMPILE_OPTION "-std=c99")
  31. set(CMAKE_C99_EXTENSION_COMPILE_OPTION "-std=gnu99")
  32. set(CMAKE_C99_STANDARD__HAS_FULL_SUPPORT ON)
  33. set(CMAKE_C11_STANDARD_COMPILE_OPTION "-std=c11")
  34. set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std=gnu11")
  35. set(CMAKE_C11_STANDARD__HAS_FULL_SUPPORT ON)
  36. else()
  37. # clang-cl doesn't have any of these
  38. set(CMAKE_C90_STANDARD_COMPILE_OPTION "")
  39. set(CMAKE_C90_EXTENSION_COMPILE_OPTION "")
  40. set(CMAKE_C90_STANDARD__HAS_FULL_SUPPORT ON)
  41. set(CMAKE_C99_STANDARD_COMPILE_OPTION "")
  42. set(CMAKE_C99_EXTENSION_COMPILE_OPTION "")
  43. set(CMAKE_C99_STANDARD__HAS_FULL_SUPPORT ON)
  44. set(CMAKE_C11_STANDARD_COMPILE_OPTION "")
  45. set(CMAKE_C11_EXTENSION_COMPILE_OPTION "")
  46. set(CMAKE_C11_STANDARD__HAS_FULL_SUPPORT ON)
  47. endif()
  48. endif()
  49. if(NOT "x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC")
  50. __compiler_check_default_language_standard(C 3.4 99 3.6 11)
  51. else()
  52. set(CMAKE_C_STANDARD_DEFAULT "")
  53. endif()