You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.9 KiB

  1. function(cm_check_cxx_feature name)
  2. string(TOUPPER ${name} FEATURE)
  3. if(NOT DEFINED CMake_HAVE_CXX_${FEATURE})
  4. message(STATUS "Checking if compiler supports C++ ${name}")
  5. if(CMAKE_CXX_STANDARD)
  6. set(maybe_cxx_standard -DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD})
  7. else()
  8. set(maybe_cxx_standard "")
  9. endif()
  10. try_compile(CMake_HAVE_CXX_${FEATURE}
  11. ${CMAKE_CURRENT_BINARY_DIR}
  12. ${CMAKE_CURRENT_LIST_DIR}/cm_cxx_${name}.cxx
  13. CMAKE_FLAGS ${maybe_cxx_standard}
  14. OUTPUT_VARIABLE OUTPUT
  15. )
  16. # Filter out MSBuild output that looks like a warning.
  17. string(REGEX REPLACE " +0 Warning\\(s\\)" "" check_output "${OUTPUT}")
  18. # If using the feature causes warnings, treat it as broken/unavailable.
  19. if(check_output MATCHES "[Ww]arning")
  20. set(CMake_HAVE_CXX_${FEATURE} OFF CACHE INTERNAL "TRY_COMPILE" FORCE)
  21. endif()
  22. if(CMake_HAVE_CXX_${FEATURE})
  23. message(STATUS "Checking if compiler supports C++ ${name} - yes")
  24. file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
  25. "Determining if compiler supports C++ ${name} passed with the following output:\n"
  26. "${OUTPUT}\n"
  27. "\n"
  28. )
  29. else()
  30. message(STATUS "Checking if compiler supports C++ ${name} - no")
  31. file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
  32. "Determining if compiler supports C++ ${name} failed with the following output:\n"
  33. "${OUTPUT}\n"
  34. "\n"
  35. )
  36. endif()
  37. endif()
  38. endfunction()
  39. cm_check_cxx_feature(auto_ptr)
  40. cm_check_cxx_feature(eq_delete)
  41. cm_check_cxx_feature(fallthrough)
  42. if(NOT CMake_HAVE_CXX_FALLTHROUGH)
  43. cm_check_cxx_feature(gnu_fallthrough)
  44. if(NOT CMake_HAVE_CXX_GNU_FALLTHROUGH)
  45. cm_check_cxx_feature(attribute_fallthrough)
  46. endif()
  47. endif()
  48. cm_check_cxx_feature(make_unique)
  49. if(CMake_HAVE_CXX_MAKE_UNIQUE)
  50. set(CMake_HAVE_CXX_UNIQUE_PTR 1)
  51. endif()
  52. cm_check_cxx_feature(unique_ptr)