summaryrefslogtreecommitdiffstats
path: root/Source/Checks/cm_cxx_features.cmake
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2016-06-27 14:40:35 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2016-06-27 14:40:35 (GMT)
commitd3544d023b7b118f5f9fcb70808546d7b3724f50 (patch)
tree95c008ea092df8c3e1666c4a4d900148bfcd0319 /Source/Checks/cm_cxx_features.cmake
parent4adab7093a2a30caf053b149a3b57565235b05ca (diff)
parent7647f6afa46b6b5020cc1d93b3f75d3358a28f8a (diff)
downloadCMake-d3544d023b7b118f5f9fcb70808546d7b3724f50.zip
CMake-d3544d023b7b118f5f9fcb70808546d7b3724f50.tar.gz
CMake-d3544d023b7b118f5f9fcb70808546d7b3724f50.tar.bz2
Merge topic 'compiler-features'
7647f6af Add CM_OVERRIDE to some functions 5286110d cxx features: add check for override 09aa2c94 Use <unordered_set> where available ea5477e4 Make C++ feature checks extensible
Diffstat (limited to 'Source/Checks/cm_cxx_features.cmake')
-rw-r--r--Source/Checks/cm_cxx_features.cmake38
1 files changed, 38 insertions, 0 deletions
diff --git a/Source/Checks/cm_cxx_features.cmake b/Source/Checks/cm_cxx_features.cmake
new file mode 100644
index 0000000..18dbaf8
--- /dev/null
+++ b/Source/Checks/cm_cxx_features.cmake
@@ -0,0 +1,38 @@
+
+function(cm_check_cxx_feature name)
+ string(TOUPPER ${name} FEATURE)
+ if(NOT DEFINED CMake_HAVE_CXX_${FEATURE})
+ message(STATUS "Checking if compiler supports C++ ${name}")
+ try_compile(CMake_HAVE_CXX_${FEATURE}
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${CMAKE_CURRENT_LIST_DIR}/cm_cxx_${name}.cxx
+ CMAKE_FLAGS -DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}
+ OUTPUT_VARIABLE OUTPUT
+ )
+ # If using the feature causes warnings, treat it as broken/unavailable.
+ if(OUTPUT MATCHES "warning")
+ set(CMake_HAVE_CXX_${FEATURE} OFF CACHE INTERNAL "TRY_COMPILE" FORCE)
+ endif()
+ if(CMake_HAVE_CXX_${FEATURE})
+ message(STATUS "Checking if compiler supports C++ ${name} - yes")
+ file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
+ "Determining if compiler supports C++ ${name} passed with the following output:\n"
+ "${OUTPUT}\n"
+ "\n"
+ )
+ else()
+ message(STATUS "Checking if compiler supports C++ ${name} - no")
+ file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
+ "Determining if compiler supports C++ ${name} failed with the following output:\n"
+ "${OUTPUT}\n"
+ "\n"
+ )
+ endif()
+ endif()
+endfunction()
+
+if(CMAKE_CXX_STANDARD)
+ cm_check_cxx_feature(override)
+ cm_check_cxx_feature(unordered_map)
+ cm_check_cxx_feature(unordered_set)
+endif()