diff options
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rw-r--r-- | Source/Checks/cm_cxx11_unordered_map.cmake | 25 | ||||
-rw-r--r-- | Source/Checks/cm_cxx_features.cmake | 36 | ||||
-rw-r--r-- | Source/Checks/cm_cxx_unordered_map.cxx (renamed from Source/Checks/cm_cxx11_unordered_map.cpp) | 0 | ||||
-rw-r--r-- | Source/cmConfigure.cmake.h.in | 2 | ||||
-rw-r--r-- | Source/cmDefinitions.h | 4 | ||||
-rw-r--r-- | Source/cmFileTimeComparison.cxx | 6 | ||||
-rw-r--r-- | Source/cmGlobalGenerator.h | 4 | ||||
-rw-r--r-- | Source/cmMakefile.h | 6 | ||||
-rw-r--r-- | Source/cmTarget.h | 4 |
10 files changed, 50 insertions, 39 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 5336208..ae5990e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -67,7 +67,7 @@ if(NOT DEFINED CMAKE_CXX_STANDARD AND NOT CMake_NO_CXX_STANDARD) endif() endif() if(NOT CMake_TEST_EXTERNAL_CMAKE) - include(${CMake_SOURCE_DIR}/Source/Checks/cm_cxx11_unordered_map.cmake) + include(${CMake_SOURCE_DIR}/Source/Checks/cm_cxx_features.cmake) endif() # option to set the internal encoding of CMake to UTF-8 diff --git a/Source/Checks/cm_cxx11_unordered_map.cmake b/Source/Checks/cm_cxx11_unordered_map.cmake deleted file mode 100644 index 80fe391..0000000 --- a/Source/Checks/cm_cxx11_unordered_map.cmake +++ /dev/null @@ -1,25 +0,0 @@ - -if(CMAKE_CXX_STANDARD AND NOT DEFINED CMake_HAVE_CXX11_UNORDERED_MAP) - message(STATUS "Checking if compiler supports C++11 unordered_map") - try_compile(CMake_HAVE_CXX11_UNORDERED_MAP - ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_CURRENT_LIST_DIR}/cm_cxx11_unordered_map.cpp - CMAKE_FLAGS -DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD} - OUTPUT_VARIABLE OUTPUT - ) - if(CMake_HAVE_CXX11_UNORDERED_MAP) - message(STATUS "Checking if compiler supports C++11 unordered_map - yes") - file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log - "Determining if compiler supports C++11 unordered_map passed with the following output:\n" - "${OUTPUT}\n" - "\n" - ) - else() - message(STATUS "Checking if compiler supports C++11 unordered_map - no") - file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log - "Determining if compiler supports C++11 unordered_map failed with the following output:\n" - "${OUTPUT}\n" - "\n" - ) - endif() -endif() diff --git a/Source/Checks/cm_cxx_features.cmake b/Source/Checks/cm_cxx_features.cmake new file mode 100644 index 0000000..b0ecc4c --- /dev/null +++ b/Source/Checks/cm_cxx_features.cmake @@ -0,0 +1,36 @@ + +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(unordered_map) +endif() diff --git a/Source/Checks/cm_cxx11_unordered_map.cpp b/Source/Checks/cm_cxx_unordered_map.cxx index be3de25..be3de25 100644 --- a/Source/Checks/cm_cxx11_unordered_map.cpp +++ b/Source/Checks/cm_cxx_unordered_map.cxx diff --git a/Source/cmConfigure.cmake.h.in b/Source/cmConfigure.cmake.h.in index 938b10e..4c5ad2a 100644 --- a/Source/cmConfigure.cmake.h.in +++ b/Source/cmConfigure.cmake.h.in @@ -29,7 +29,7 @@ #cmakedefine CMAKE_USE_ELF_PARSER #cmakedefine CMAKE_USE_MACH_PARSER #cmakedefine CMAKE_ENCODING_UTF8 -#cmakedefine CMake_HAVE_CXX11_UNORDERED_MAP +#cmakedefine CMake_HAVE_CXX_UNORDERED_MAP #define CMAKE_BIN_DIR "/@CMAKE_BIN_DIR@" #define CMAKE_DATA_DIR "/@CMAKE_DATA_DIR@" diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h index 7be0098..8f1813c 100644 --- a/Source/cmDefinitions.h +++ b/Source/cmDefinitions.h @@ -17,7 +17,7 @@ #include "cmLinkedTree.h" #if defined(CMAKE_BUILD_WITH_CMAKE) -#ifdef CMake_HAVE_CXX11_UNORDERED_MAP +#ifdef CMake_HAVE_CXX_UNORDERED_MAP #include <unordered_map> #else #include "cmsys/hash_map.hxx" @@ -92,7 +92,7 @@ private: static Def NoDef; #if defined(CMAKE_BUILD_WITH_CMAKE) -#ifdef CMake_HAVE_CXX11_UNORDERED_MAP +#ifdef CMake_HAVE_CXX_UNORDERED_MAP typedef std::unordered_map<std::string, Def> MapType; #else typedef cmsys::hash_map<std::string, Def> MapType; diff --git a/Source/cmFileTimeComparison.cxx b/Source/cmFileTimeComparison.cxx index 7efe194..9d63505 100644 --- a/Source/cmFileTimeComparison.cxx +++ b/Source/cmFileTimeComparison.cxx @@ -13,7 +13,7 @@ // Use a hash table to avoid duplicate file time checks from disk. #if defined(CMAKE_BUILD_WITH_CMAKE) -#ifdef CMake_HAVE_CXX11_UNORDERED_MAP +#ifdef CMake_HAVE_CXX_UNORDERED_MAP #include <unordered_map> #else #include <cmsys/hash_map.hxx> @@ -47,13 +47,13 @@ private: { public: size_t operator()(const std::string& s) const { return h(s.c_str()); } -#ifdef CMake_HAVE_CXX11_UNORDERED_MAP +#ifdef CMake_HAVE_CXX_UNORDERED_MAP std::hash<const char*> h; #else cmsys::hash<const char*> h; #endif }; -#ifdef CMake_HAVE_CXX11_UNORDERED_MAP +#ifdef CMake_HAVE_CXX_UNORDERED_MAP typedef std::unordered_map<std::string, #else typedef cmsys::hash_map<std::string, diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 68ff042..789e515 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -25,7 +25,7 @@ #if defined(CMAKE_BUILD_WITH_CMAKE) #include "cmFileLockPool.h" -#ifdef CMake_HAVE_CXX11_UNORDERED_MAP +#ifdef CMake_HAVE_CXX_UNORDERED_MAP #include <unordered_map> #else #include <cmsys/hash_map.hxx> @@ -433,7 +433,7 @@ protected: private: #if defined(CMAKE_BUILD_WITH_CMAKE) -#ifdef CMake_HAVE_CXX11_UNORDERED_MAP +#ifdef CMake_HAVE_CXX_UNORDERED_MAP typedef std::unordered_map<std::string, cmTarget*> TargetMap; typedef std::unordered_map<std::string, cmGeneratorTarget*> GeneratorTargetMap; diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 1680c6a..c68cd1c 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -31,7 +31,7 @@ #include <cmsys/RegularExpression.hxx> #include <cmsys/auto_ptr.hxx> #if defined(CMAKE_BUILD_WITH_CMAKE) -#ifdef CMake_HAVE_CXX11_UNORDERED_MAP +#ifdef CMake_HAVE_CXX_UNORDERED_MAP #include <unordered_map> #else #include <cmsys/hash_map.hxx> @@ -796,7 +796,7 @@ protected: // libraries, classes, and executables mutable cmTargets Targets; #if defined(CMAKE_BUILD_WITH_CMAKE) -#ifdef CMake_HAVE_CXX11_UNORDERED_MAP +#ifdef CMake_HAVE_CXX_UNORDERED_MAP typedef std::unordered_map<std::string, cmTarget*> TargetMap; #else typedef cmsys::hash_map<std::string, cmTarget*> TargetMap; @@ -915,7 +915,7 @@ private: // A map for fast output to input look up. #if defined(CMAKE_BUILD_WITH_CMAKE) -#ifdef CMake_HAVE_CXX11_UNORDERED_MAP +#ifdef CMake_HAVE_CXX_UNORDERED_MAP typedef std::unordered_map<std::string, cmSourceFile*> OutputToSourceMap; #else typedef cmsys::hash_map<std::string, cmSourceFile*> OutputToSourceMap; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index f91e5c6..9e095c2 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -21,7 +21,7 @@ #include <cmsys/auto_ptr.hxx> #if defined(CMAKE_BUILD_WITH_CMAKE) -#ifdef CMake_HAVE_CXX11_UNORDERED_MAP +#ifdef CMake_HAVE_CXX_UNORDERED_MAP #include <unordered_map> #else #include <cmsys/hash_map.hxx> @@ -331,7 +331,7 @@ private: }; #ifdef CMAKE_BUILD_WITH_CMAKE -#ifdef CMake_HAVE_CXX11_UNORDERED_MAP +#ifdef CMake_HAVE_CXX_UNORDERED_MAP typedef std::unordered_map<std::string, cmTarget> cmTargets; #else typedef cmsys::hash_map<std::string, cmTarget> cmTargets; |