MSVC-C.cmake 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. # file Copyright.txt or https://cmake.org/licensing for details.
  3. include(Compiler/CMakeCommonCompilerMacros)
  4. if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 19.27)
  5. set(CMAKE_C90_STANDARD_COMPILE_OPTION "")
  6. set(CMAKE_C90_EXTENSION_COMPILE_OPTION "")
  7. set(CMAKE_C99_STANDARD_COMPILE_OPTION "")
  8. set(CMAKE_C99_EXTENSION_COMPILE_OPTION "")
  9. set(CMAKE_C11_STANDARD_COMPILE_OPTION "-std:c11")
  10. set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std:c11")
  11. __compiler_check_default_language_standard(C 19.27 99)
  12. else()
  13. # MSVC has no specific options to set C language standards, but set them as
  14. # empty strings anyways so the feature test infrastructure can at least check
  15. # to see if they are defined.
  16. set(CMAKE_C90_STANDARD_COMPILE_OPTION "")
  17. set(CMAKE_C90_EXTENSION_COMPILE_OPTION "")
  18. set(CMAKE_C99_STANDARD_COMPILE_OPTION "")
  19. set(CMAKE_C99_EXTENSION_COMPILE_OPTION "")
  20. set(CMAKE_C11_STANDARD_COMPILE_OPTION "")
  21. set(CMAKE_C11_EXTENSION_COMPILE_OPTION "")
  22. # There is no meaningful default for this
  23. set(CMAKE_C_STANDARD_DEFAULT "")
  24. endif()
  25. set(CMAKE_C_COMPILE_OPTIONS_EXPLICIT_LANGUAGE -TC)
  26. set(CMAKE_C_CLANG_TIDY_DRIVER_MODE "cl")
  27. # There are no C compiler modes so we hard-code the known compiler supported
  28. # features. Override the default macro for this special case. Pretend that
  29. # all language standards are available so that at least compilation
  30. # can be attempted.
  31. macro(cmake_record_c_compile_features)
  32. list(APPEND CMAKE_C_COMPILE_FEATURES
  33. c_std_90
  34. c_std_99
  35. c_std_11
  36. c_function_prototypes
  37. )
  38. list(APPEND CMAKE_C90_COMPILE_FEATURES c_std_90 c_function_prototypes)
  39. list(APPEND CMAKE_C99_COMPILE_FEATURES c_std_99)
  40. list(APPEND CMAKE_C11_COMPILE_FEATURES c_std_11)
  41. if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 14.0)
  42. list(APPEND CMAKE_C_COMPILE_FEATURES c_variadic_macros)
  43. list(APPEND CMAKE_C99_COMPILE_FEATURES c_variadic_macros)
  44. endif()
  45. if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 19.27)
  46. list(APPEND CMAKE_C_COMPILE_FEATURES c_restrict)
  47. list(APPEND CMAKE_C99_COMPILE_FEATURES c_restrict)
  48. endif()
  49. if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 19.28)
  50. list(APPEND CMAKE_C_COMPILE_FEATURES c_static_assert)
  51. list(APPEND CMAKE_C11_COMPILE_FEATURES c_static_assert)
  52. endif()
  53. set(_result 0) # expected by cmake_determine_compile_features
  54. endmacro()
  55. # /JMC "Just My Code" is only supported by MSVC 19.05 onward.
  56. if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 19.05)
  57. set(CMAKE_C_COMPILE_OPTIONS_JMC "-JMC")
  58. endif()