MSVC-C.cmake 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. # MSVC has no specific options to set C language standards, but set them as
  2. # empty strings anyways so the feature test infrastructure can at least check
  3. # to see if they are defined.
  4. set(CMAKE_C90_STANDARD_COMPILE_OPTION "")
  5. set(CMAKE_C90_EXTENSION_COMPILE_OPTION "")
  6. set(CMAKE_C99_STANDARD_COMPILE_OPTION "")
  7. set(CMAKE_C99_EXTENSION_COMPILE_OPTION "")
  8. set(CMAKE_C11_STANDARD_COMPILE_OPTION "")
  9. set(CMAKE_C11_EXTENSION_COMPILE_OPTION "")
  10. # There is no meaningful default for this
  11. set(CMAKE_C_STANDARD_DEFAULT "")
  12. # There are no C compiler modes so we hard-code the known compiler supported
  13. # features. Override the default macro for this special case. Pretend that
  14. # all language standards are available so that at least compilation
  15. # can be attempted.
  16. macro(cmake_record_c_compile_features)
  17. list(APPEND CMAKE_C_COMPILE_FEATURES
  18. c_std_90
  19. c_std_99
  20. c_std_11
  21. c_function_prototypes
  22. )
  23. list(APPEND CMAKE_C90_COMPILE_FEATURES c_std_90 c_function_prototypes)
  24. list(APPEND CMAKE_C99_COMPILE_FEATURES c_std_99)
  25. list(APPEND CMAKE_C11_COMPILE_FEATURES c_std_11)
  26. if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 14.0)
  27. list(APPEND CMAKE_C_COMPILE_FEATURES c_variadic_macros)
  28. list(APPEND CMAKE_C99_COMPILE_FEATURES c_variadic_macros)
  29. endif()
  30. set(_result 0) # expected by cmake_determine_compile_features
  31. endmacro()
  32. # /JMC "Just My Code" is only supported by MSVC 19.05 onward.
  33. if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 19.05)
  34. set(CMAKE_C_COMPILE_OPTIONS_JMC "-JMC")
  35. endif()