GNU-C.cmake 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. include(Compiler/GNU)
  2. __compiler_gnu(C)
  3. if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.5)
  4. set(CMAKE_C90_STANDARD_COMPILE_OPTION "-std=c90")
  5. set(CMAKE_C90_EXTENSION_COMPILE_OPTION "-std=gnu90")
  6. elseif (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.4)
  7. set(CMAKE_C90_STANDARD_COMPILE_OPTION "-std=c89")
  8. set(CMAKE_C90_EXTENSION_COMPILE_OPTION "-std=gnu89")
  9. endif()
  10. if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.4)
  11. set(CMAKE_C99_STANDARD_COMPILE_OPTION "-std=c99")
  12. set(CMAKE_C99_EXTENSION_COMPILE_OPTION "-std=gnu99")
  13. endif()
  14. if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.7)
  15. set(CMAKE_C11_STANDARD_COMPILE_OPTION "-std=c11")
  16. set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std=gnu11")
  17. elseif (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.6)
  18. set(CMAKE_C11_STANDARD_COMPILE_OPTION "-std=c1x")
  19. set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std=gnu1x")
  20. endif()
  21. if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 5.0)
  22. set(CMAKE_C_STANDARD_DEFAULT 11)
  23. elseif(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.4)
  24. set(CMAKE_C_STANDARD_DEFAULT 90)
  25. endif()
  26. macro(cmake_record_c_compile_features)
  27. macro(_get_gcc_features std_version list)
  28. record_compiler_features(C "${std_version}" ${list})
  29. endmacro()
  30. set(_result 0)
  31. if (UNIX AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.6)
  32. _get_gcc_features(${CMAKE_C11_STANDARD_COMPILE_OPTION} CMAKE_C11_COMPILE_FEATURES)
  33. endif()
  34. if (UNIX AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.4)
  35. if (_result EQUAL 0)
  36. _get_gcc_features(${CMAKE_C99_STANDARD_COMPILE_OPTION} CMAKE_C99_COMPILE_FEATURES)
  37. endif()
  38. if (_result EQUAL 0)
  39. _get_gcc_features(${CMAKE_C90_STANDARD_COMPILE_OPTION} CMAKE_C90_COMPILE_FEATURES)
  40. endif()
  41. endif()
  42. endmacro()