Clang-C.cmake 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. include(Compiler/Clang)
  2. __compiler_clang(C)
  3. cmake_policy(GET CMP0025 appleClangPolicy)
  4. if(WIN32 OR (APPLE AND NOT appleClangPolicy STREQUAL NEW))
  5. return()
  6. endif()
  7. if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.4)
  8. set(CMAKE_C90_STANDARD_COMPILE_OPTION "-std=c90")
  9. set(CMAKE_C90_EXTENSION_COMPILE_OPTION "-std=gnu90")
  10. set(CMAKE_C99_STANDARD_COMPILE_OPTION "-std=c99")
  11. set(CMAKE_C99_EXTENSION_COMPILE_OPTION "-std=gnu99")
  12. set(CMAKE_C11_STANDARD_COMPILE_OPTION "-std=c11")
  13. set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std=gnu11")
  14. endif()
  15. set(CMAKE_C_STANDARD_DEFAULT 90)
  16. macro(cmake_record_c_compile_features)
  17. macro(_get_clang_features std_version list)
  18. record_compiler_features(C "${std_version}" ${list})
  19. endmacro()
  20. if (UNIX AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.4)
  21. _get_clang_features(${CMAKE_C11_STANDARD_COMPILE_OPTION} CMAKE_C11_COMPILE_FEATURES)
  22. if (_result EQUAL 0)
  23. _get_clang_features(${CMAKE_C99_STANDARD_COMPILE_OPTION} CMAKE_C99_COMPILE_FEATURES)
  24. endif()
  25. if (_result EQUAL 0)
  26. _get_clang_features(${CMAKE_C90_STANDARD_COMPILE_OPTION} CMAKE_C90_COMPILE_FEATURES)
  27. endif()
  28. else()
  29. set(_result 0)
  30. endif()
  31. endmacro()