diff options
32 files changed, 179 insertions, 168 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 1bc4b4e..a5702e1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -66,12 +66,8 @@ if(NOT CMake_TEST_EXTERNAL_CMAKE) include(${CMake_SOURCE_DIR}/Source/Checks/cm_cxx_features.cmake) endif() -# option to set the internal encoding of CMake to UTF-8 -option(CMAKE_ENCODING_UTF8 "Use UTF-8 encoding internally." ON) -mark_as_advanced(CMAKE_ENCODING_UTF8) -if(CMAKE_ENCODING_UTF8) - set(KWSYS_ENCODING_DEFAULT_CODEPAGE CP_UTF8) -endif() +# set the internal encoding of CMake to UTF-8 +set(KWSYS_ENCODING_DEFAULT_CODEPAGE CP_UTF8) # option to use COMPONENT with install command option(CMake_INSTALL_COMPONENTS "Using components when installing" OFF) diff --git a/Help/manual/cmake-compile-features.7.rst b/Help/manual/cmake-compile-features.7.rst index 9862d4a..13f7d16 100644 --- a/Help/manual/cmake-compile-features.7.rst +++ b/Help/manual/cmake-compile-features.7.rst @@ -84,6 +84,33 @@ Feature requirements are evaluated transitively by consuming the link implementation. See :manual:`cmake-buildsystem(7)` for more on transitive behavior of build properties and usage requirements. +Requiring Language Standards +---------------------------- + +In projects that use a large number of commonly available features from +a particular language standard (e.g. C++ 11) one may specify a +meta-feature (e.g. ``cxx_std_11``) that requires use of a compiler mode +aware of that standard. This is simpler than specifying all the +features individually, but does not guarantee the existence of any +particular feature. Diagnosis of use of unsupported features will be +delayed until compile time. + +For example, if C++ 11 features are used extensively in a project's +header files, then clients must use a compiler mode aware of C++ 11 +or above. This can be requested with the code: + +.. code-block:: cmake + + target_compile_features(mylib PUBLIC cxx_std_11) + +In this example, CMake will ensure the compiler is invoked in a mode +that is aware of C++ 11 (or above), adding flags such as +``-std=gnu++11`` if necessary. This applies to sources within ``mylib`` +as well as any dependents (that may include headers from ``mylib``). + +Availability of Compiler Extensions +----------------------------------- + Because the :prop_tgt:`CXX_EXTENSIONS` target property is ``ON`` by default, CMake uses extended variants of language dialects by default, such as ``-std=gnu++11`` instead of ``-std=c++11``. That target property may be diff --git a/Help/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.rst b/Help/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.rst index e8f4d2a..00a5104 100644 --- a/Help/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.rst +++ b/Help/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.rst @@ -14,6 +14,15 @@ compile features and a list of supported compilers. The features known to this version of CMake are: +``cxx_std_98`` + Compiler mode is aware of C++ 98. + +``cxx_std_11`` + Compiler mode is aware of C++ 11. + +``cxx_std_14`` + Compiler mode is aware of C++ 14. + ``cxx_aggregate_default_initializers`` Aggregate default initializers, as defined in N3605_. diff --git a/Help/prop_gbl/CMAKE_C_KNOWN_FEATURES.rst b/Help/prop_gbl/CMAKE_C_KNOWN_FEATURES.rst index a08af00..3707fef 100644 --- a/Help/prop_gbl/CMAKE_C_KNOWN_FEATURES.rst +++ b/Help/prop_gbl/CMAKE_C_KNOWN_FEATURES.rst @@ -13,6 +13,15 @@ compile features and a list of supported compilers. The features known to this version of CMake are: +``c_std_90`` + Compiler mode is aware of C 90. + +``c_std_99`` + Compiler mode is aware of C 99. + +``c_std_11`` + Compiler mode is aware of C 11. + ``c_function_prototypes`` Function prototypes, as defined in ``ISO/IEC 9899:1990``. diff --git a/Help/release/dev/compile-features-for-language-standards.rst b/Help/release/dev/compile-features-for-language-standards.rst new file mode 100644 index 0000000..20473b7 --- /dev/null +++ b/Help/release/dev/compile-features-for-language-standards.rst @@ -0,0 +1,7 @@ +compile-features-for-language-standards +--------------------------------------- + +* The :manual:`Compile Features <cmake-compile-features(7)>` functionality + now offers meta-features that request compiler modes for specific language + standard levels. See :prop_gbl:`CMAKE_C_KNOWN_FEATURES` and + :prop_gbl:`CMAKE_CXX_KNOWN_FEATURES`. diff --git a/Modules/CPackIFW.cmake b/Modules/CPackIFW.cmake index 6c93ddb..08078cb 100644 --- a/Modules/CPackIFW.cmake +++ b/Modules/CPackIFW.cmake @@ -433,11 +433,15 @@ # Default path -set(_CPACK_IFW_PATHS - "${QTIFWDIR}" - "$ENV{QTIFWDIR}" - "${QTDIR}" - "$ENV{QTIFWDIR}") +foreach(_CPACK_IFW_PATH_VAR "QTIFWDIR" "QTDIR") + if(DEFINED ${_CPACK_IFW_PATH_VAR} + AND NOT "${${_CPACK_IFW_PATH_VAR}}" STREQUAL "") + list(APPEND _CPACK_IFW_PATHS "${${_CPACK_IFW_PATH_VAR}}") + endif() + if(NOT "$ENV{${_CPACK_IFW_PATH_VAR}}" STREQUAL "") + list(APPEND _CPACK_IFW_PATHS "$ENV{${_CPACK_IFW_PATH_VAR}}") + endif() +endforeach() if(WIN32) list(APPEND _CPACK_IFW_PATHS "$ENV{HOMEDRIVE}/Qt" @@ -447,22 +451,44 @@ else() "$ENV{HOME}/Qt" "/opt/Qt") endif() - -set(_CPACK_IFW_SUFFIXES -# Common - "bin" -# Second branch - "QtIFW2.3.0/bin" - "QtIFW2.2.0/bin" - "QtIFW2.1.0/bin" - "QtIFW2.0.3/bin" - "QtIFW2.0.1/bin" - "QtIFW2.0.0/bin" -# First branch - "QtIFW-1.6.0/bin" - "QtIFW-1.5.0/bin" - "QtIFW-1.4.0/bin" - "QtIFW-1.3.0/bin") +list(REMOVE_DUPLICATES _CPACK_IFW_PATHS) + +set(_CPACK_IFW_PREFIXES + # QtSDK + "Tools/QtInstallerFramework/" + # Second branch + "QtIFW" + # First branch + "QtIFW-") + +set(_CPACK_IFW_VERSIONS + "2.3" + "2.3.0" + "2.2" + "2.2.0" + "2.1" + "2.1.0" + "2.0" + "2.0.3" + "2.0.2" + "2.0.1" + "2.0.0" + "1.6" + "1.6.0" + "1.5" + "1.5.0" + "1.4" + "1.4.0" + "1.3" + "1.3.0") + +set(_CPACK_IFW_SUFFIXES "bin") +foreach(_CPACK_IFW_PREFIX ${_CPACK_IFW_PREFIXES}) + foreach(_CPACK_IFW_VERSION ${_CPACK_IFW_VERSIONS}) + list(APPEND + _CPACK_IFW_SUFFIXES "${_CPACK_IFW_PREFIX}${_CPACK_IFW_VERSION}/bin") + endforeach() +endforeach() # Look for 'binarycreator' diff --git a/Modules/Compiler/AppleClang-C.cmake b/Modules/Compiler/AppleClang-C.cmake index 1cc72c0..fe39b3b 100644 --- a/Modules/Compiler/AppleClang-C.cmake +++ b/Modules/Compiler/AppleClang-C.cmake @@ -25,18 +25,14 @@ if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.0) endif() macro(cmake_record_c_compile_features) - macro(_get_appleclang_features std_version list) - record_compiler_features(C "${std_version}" ${list}) - endmacro() - set(_result 0) if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.0) - _get_appleclang_features(${CMAKE_C11_STANDARD_COMPILE_OPTION} CMAKE_C11_COMPILE_FEATURES) + _record_compiler_features_c(11) if (_result EQUAL 0) - _get_appleclang_features(${CMAKE_C99_STANDARD_COMPILE_OPTION} CMAKE_C99_COMPILE_FEATURES) + _record_compiler_features_c(99) endif() if (_result EQUAL 0) - _get_appleclang_features(${CMAKE_C90_STANDARD_COMPILE_OPTION} CMAKE_C90_COMPILE_FEATURES) + _record_compiler_features_c(90) endif() endif() endmacro() diff --git a/Modules/Compiler/AppleClang-CXX.cmake b/Modules/Compiler/AppleClang-CXX.cmake index 95bc79a..8dd6278 100644 --- a/Modules/Compiler/AppleClang-CXX.cmake +++ b/Modules/Compiler/AppleClang-CXX.cmake @@ -36,21 +36,17 @@ endif() macro(cmake_record_cxx_compile_features) - macro(_get_appleclang_features std_version list) - record_compiler_features(CXX "${std_version}" ${list}) - endmacro() - set(_result 0) if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.0) set(_result 0) if(CMAKE_CXX14_STANDARD_COMPILE_OPTION) - _get_appleclang_features(${CMAKE_CXX14_STANDARD_COMPILE_OPTION} CMAKE_CXX14_COMPILE_FEATURES) + _record_compiler_features_cxx(14) endif() if (_result EQUAL 0) - _get_appleclang_features(${CMAKE_CXX11_STANDARD_COMPILE_OPTION} CMAKE_CXX11_COMPILE_FEATURES) + _record_compiler_features_cxx(11) endif() if (_result EQUAL 0) - _get_appleclang_features(${CMAKE_CXX98_STANDARD_COMPILE_OPTION} CMAKE_CXX98_COMPILE_FEATURES) + _record_compiler_features_cxx(98) endif() endif() endmacro() diff --git a/Modules/Compiler/Clang-C.cmake b/Modules/Compiler/Clang-C.cmake index d8b7743..b3f3805 100644 --- a/Modules/Compiler/Clang-C.cmake +++ b/Modules/Compiler/Clang-C.cmake @@ -34,18 +34,14 @@ if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 3.4) endif() macro(cmake_record_c_compile_features) - macro(_get_clang_features std_version list) - record_compiler_features(C "${std_version}" ${list}) - endmacro() - set(_result 0) if (UNIX AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 3.4) - _get_clang_features(${CMAKE_C11_STANDARD_COMPILE_OPTION} CMAKE_C11_COMPILE_FEATURES) + _record_compiler_features_c(11) if (_result EQUAL 0) - _get_clang_features(${CMAKE_C99_STANDARD_COMPILE_OPTION} CMAKE_C99_COMPILE_FEATURES) + _record_compiler_features_c(99) endif() if (_result EQUAL 0) - _get_clang_features(${CMAKE_C90_STANDARD_COMPILE_OPTION} CMAKE_C90_COMPILE_FEATURES) + _record_compiler_features_c(90) endif() endif() endmacro() diff --git a/Modules/Compiler/Clang-CXX.cmake b/Modules/Compiler/Clang-CXX.cmake index dc62711..dfe0628 100644 --- a/Modules/Compiler/Clang-CXX.cmake +++ b/Modules/Compiler/Clang-CXX.cmake @@ -44,18 +44,14 @@ if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.4) endif() macro(cmake_record_cxx_compile_features) - macro(_get_clang_features std_version list) - record_compiler_features(CXX "${std_version}" ${list}) - endmacro() - set(_result 0) if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.4) - _get_clang_features(${CMAKE_CXX14_STANDARD_COMPILE_OPTION} CMAKE_CXX14_COMPILE_FEATURES) + _record_compiler_features_cxx(14) if (_result EQUAL 0) - _get_clang_features(${CMAKE_CXX11_STANDARD_COMPILE_OPTION} CMAKE_CXX11_COMPILE_FEATURES) + _record_compiler_features_cxx(11) endif() if (_result EQUAL 0) - _get_clang_features(${CMAKE_CXX98_STANDARD_COMPILE_OPTION} CMAKE_CXX98_COMPILE_FEATURES) + _record_compiler_features_cxx(98) endif() endif() endmacro() diff --git a/Modules/Compiler/GNU-C.cmake b/Modules/Compiler/GNU-C.cmake index 2c478da..4dbf6ef 100644 --- a/Modules/Compiler/GNU-C.cmake +++ b/Modules/Compiler/GNU-C.cmake @@ -40,20 +40,16 @@ endif() macro(cmake_record_c_compile_features) - macro(_get_gcc_features std_version list) - record_compiler_features(C "${std_version}" ${list}) - endmacro() - set(_result 0) if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.6) - _get_gcc_features(${CMAKE_C11_STANDARD_COMPILE_OPTION} CMAKE_C11_COMPILE_FEATURES) + _record_compiler_features_c(11) endif() if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.4) if (_result EQUAL 0) - _get_gcc_features(${CMAKE_C99_STANDARD_COMPILE_OPTION} CMAKE_C99_COMPILE_FEATURES) + _record_compiler_features_c(99) endif() if (_result EQUAL 0) - _get_gcc_features(${CMAKE_C90_STANDARD_COMPILE_OPTION} CMAKE_C90_COMPILE_FEATURES) + _record_compiler_features_c(90) endif() endif() endmacro() diff --git a/Modules/Compiler/GNU-CXX.cmake b/Modules/Compiler/GNU-CXX.cmake index e1c555b..936f62b 100644 --- a/Modules/Compiler/GNU-CXX.cmake +++ b/Modules/Compiler/GNU-CXX.cmake @@ -47,20 +47,16 @@ if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.4) endif() macro(cmake_record_cxx_compile_features) - macro(_get_gcc_features std_version list) - record_compiler_features(CXX "${std_version}" ${list}) - endmacro() - set(_result 0) if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8) - _get_gcc_features(${CMAKE_CXX14_STANDARD_COMPILE_OPTION} CMAKE_CXX14_COMPILE_FEATURES) + _record_compiler_features_cxx(14) endif() if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.4) if (_result EQUAL 0) - _get_gcc_features(${CMAKE_CXX11_STANDARD_COMPILE_OPTION} CMAKE_CXX11_COMPILE_FEATURES) + _record_compiler_features_cxx(11) endif() if (_result EQUAL 0) - _get_gcc_features(${CMAKE_CXX98_STANDARD_COMPILE_OPTION} CMAKE_CXX98_COMPILE_FEATURES) + _record_compiler_features_cxx(98) endif() endif() endmacro() diff --git a/Modules/Compiler/Intel-C.cmake b/Modules/Compiler/Intel-C.cmake index 5815857..5a79452 100644 --- a/Modules/Compiler/Intel-C.cmake +++ b/Modules/Compiler/Intel-C.cmake @@ -47,20 +47,16 @@ unset(_std) unset(_ext) macro(cmake_record_c_compile_features) - macro(_get_intel_c_features std_version list) - record_compiler_features(C "${std_version}" ${list}) - endmacro() - set(_result 0) if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 12.1) if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 15.0.0) - _get_intel_c_features(${CMAKE_C11_STANDARD_COMPILE_OPTION} CMAKE_C11_COMPILE_FEATURES) + _record_compiler_features_C(11) endif() if (_result EQUAL 0) - _get_intel_c_features(${CMAKE_C99_STANDARD_COMPILE_OPTION} CMAKE_C99_COMPILE_FEATURES) + _record_compiler_features_C(99) endif() if (_result EQUAL 0) - _get_intel_c_features(${CMAKE_C90_STANDARD_COMPILE_OPTION} CMAKE_C90_COMPILE_FEATURES) + _record_compiler_features_C(90) endif() endif() endmacro() diff --git a/Modules/Compiler/Intel-CXX-FeatureTests.cmake b/Modules/Compiler/Intel-CXX-FeatureTests.cmake index 5b74fab..d1a3433 100644 --- a/Modules/Compiler/Intel-CXX-FeatureTests.cmake +++ b/Modules/Compiler/Intel-CXX-FeatureTests.cmake @@ -88,7 +88,7 @@ set(_cmake_feature_test_cxx_variadic_templates "(__cpp_variadic_templates >= 200 set(_cmake_feature_test_cxx_alias_templates "${Intel121_CXX11}") set(_cmake_feature_test_cxx_nullptr "${Intel121_CXX11}") set(_cmake_feature_test_cxx_trailing_return_types "${Intel121_CXX11}") -set(_cmake_feature_test_cxx_attributes "__cpp_attributes >= 200809 || ${Intel121}") +set(_cmake_feature_test_cxx_attributes "(__cpp_attributes >= 200809 || ${Intel121}) && ${DETECT_CXX11}") # [1] set(_cmake_feature_test_cxx_default_function_template_args "${Intel121_CXX11}") set(_cmake_feature_test_cxx_extended_friend_declarations "${Intel121_CXX11}") set(_cmake_feature_test_cxx_rvalue_references "(__cpp_rvalue_references >= 200610 || ${Intel121}) && ${DETECT_CXX11}") # [1] diff --git a/Modules/Compiler/Intel-CXX.cmake b/Modules/Compiler/Intel-CXX.cmake index b6bc2ee..6673a2d 100644 --- a/Modules/Compiler/Intel-CXX.cmake +++ b/Modules/Compiler/Intel-CXX.cmake @@ -60,20 +60,16 @@ unset(_std) unset(_ext) macro(cmake_record_cxx_compile_features) - macro(_get_intel_features std_version list) - record_compiler_features(CXX "${std_version}" ${list}) - endmacro() - set(_result 0) if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 12.1) if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 15.0) - _get_intel_features("${CMAKE_CXX14_STANDARD_COMPILE_OPTION}" CMAKE_CXX14_COMPILE_FEATURES) + _record_compiler_features_cxx(14) endif() if (_result EQUAL 0) - _get_intel_features("${CMAKE_CXX11_STANDARD_COMPILE_OPTION}" CMAKE_CXX11_COMPILE_FEATURES) + _record_compiler_features_cxx(11) endif() if (_result EQUAL 0) - _get_intel_features("${CMAKE_CXX98_STANDARD_COMPILE_OPTION}" CMAKE_CXX98_COMPILE_FEATURES) + _record_compiler_features_cxx(98) endif() endif() endmacro() diff --git a/Modules/Compiler/MSVC-CXX.cmake b/Modules/Compiler/MSVC-CXX.cmake index 82ce069..f103832 100644 --- a/Modules/Compiler/MSVC-CXX.cmake +++ b/Modules/Compiler/MSVC-CXX.cmake @@ -5,5 +5,12 @@ if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 16.0) endif() macro(cmake_record_cxx_compile_features) - record_compiler_features(CXX "" CMAKE_CXX_COMPILE_FEATURES) + if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 16.0) + list(APPEND CMAKE_CXX_COMPILE_FEATURES + cxx_std_98 + cxx_std_11 + cxx_std_14 + ) + _record_compiler_features(CXX "" CMAKE_CXX_COMPILE_FEATURES) + endif() endmacro() diff --git a/Modules/Compiler/SunPro-CXX.cmake b/Modules/Compiler/SunPro-CXX.cmake index ce01cdd..e83c896 100644 --- a/Modules/Compiler/SunPro-CXX.cmake +++ b/Modules/Compiler/SunPro-CXX.cmake @@ -32,6 +32,8 @@ set(CMAKE_CXX_CREATE_STATIC_LIBRARY "<CMAKE_RANLIB> <TARGET> ") if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.13) + set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "") + set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "") set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++11") set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=c++11") endif() @@ -49,15 +51,11 @@ if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.13) endif() macro(cmake_record_cxx_compile_features) - macro(_get_solaris_studio_features std_version list) - record_compiler_features(CXX "${std_version}" ${list}) - endmacro() - set(_result 0) if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.13) - _get_solaris_studio_features(${CMAKE_CXX11_STANDARD_COMPILE_OPTION} CMAKE_CXX11_COMPILE_FEATURES) + _record_compiler_features_cxx(11) if (_result EQUAL 0) - _get_solaris_studio_features("" CMAKE_CXX98_COMPILE_FEATURES) + _record_compiler_features_cxx(98) endif() endif() endmacro() diff --git a/Modules/FindHDF5.cmake b/Modules/FindHDF5.cmake index 1c2c443..16764e0 100644 --- a/Modules/FindHDF5.cmake +++ b/Modules/FindHDF5.cmake @@ -100,18 +100,10 @@ include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) set(HDF5_VALID_LANGUAGE_BINDINGS C CXX Fortran) # Validate the list of find components. -set(HDF5_LANGUAGE_BINDINGS) if(NOT HDF5_FIND_COMPONENTS) - get_property(__langs GLOBAL PROPERTY ENABLED_LANGUAGES) - foreach(__lang IN LISTS __langs) - if(__lang MATCHES "^(C|CXX|Fortran)$") - list(APPEND HDF5_LANGUAGE_BINDINGS ${__lang}) - set(HDF5_FIND_REQUIRED_${__lang} True) - endif() - endforeach() - set(FIND_HL ON) - set(HDF5_FIND_REQUIRED_HL True) + set(HDF5_LANGUAGE_BINDINGS "C") else() + set(HDF5_LANGUAGE_BINDINGS) # add the extra specified components, ensuring that they are valid. set(FIND_HL OFF) foreach(component IN LISTS HDF5_FIND_COMPONENTS) diff --git a/Modules/Internal/FeatureTesting.cmake b/Modules/Internal/FeatureTesting.cmake index 86b89b2..50b8526 100644 --- a/Modules/Internal/FeatureTesting.cmake +++ b/Modules/Internal/FeatureTesting.cmake @@ -1,5 +1,5 @@ -macro(record_compiler_features lang compile_flags feature_list) +macro(_record_compiler_features lang compile_flags feature_list) include("${CMAKE_ROOT}/Modules/Compiler/${CMAKE_${lang}_COMPILER_ID}-${lang}-FeatureTests.cmake" OPTIONAL) string(TOLOWER ${lang} lang_lc) @@ -58,3 +58,13 @@ macro(record_compiler_features lang compile_flags feature_list) "Detecting ${lang} [${compile_flags}] compiler features failed to compile with the following output:\n${_output}\n${_copy_error}\n\n") endif() endmacro() + +macro(_record_compiler_features_c std) + list(APPEND CMAKE_C${std}_COMPILE_FEATURES c_std_${std}) + _record_compiler_features(C "${CMAKE_C${std}_STANDARD_COMPILE_OPTION}" CMAKE_C${std}_COMPILE_FEATURES) +endmacro() + +macro(_record_compiler_features_cxx std) + list(APPEND CMAKE_CXX${std}_COMPILE_FEATURES cxx_std_${std}) + _record_compiler_features(CXX "${CMAKE_CXX${std}_STANDARD_COMPILE_OPTION}" CMAKE_CXX${std}_COMPILE_FEATURES) +endmacro() diff --git a/Modules/WriteCompilerDetectionHeader.cmake b/Modules/WriteCompilerDetectionHeader.cmake index 82e8fba..a390f4b 100644 --- a/Modules/WriteCompilerDetectionHeader.cmake +++ b/Modules/WriteCompilerDetectionHeader.cmake @@ -76,6 +76,7 @@ # Available features in this version of CMake are listed in the # :prop_gbl:`CMAKE_C_KNOWN_FEATURES` and # :prop_gbl:`CMAKE_CXX_KNOWN_FEATURES` global properties. +# The ``{c,cxx}_std_*`` meta-features are ignored if requested. # # See the :manual:`cmake-compile-features(7)` manual for information on # compile features. @@ -358,7 +359,11 @@ function(write_compiler_detection_header endif() foreach(feature ${_WCD_FEATURES}) - if (feature MATCHES "^cxx_") + if (feature MATCHES "^c_std_") + # ignored + elseif (feature MATCHES "^cxx_std_") + # ignored + elseif (feature MATCHES "^cxx_") list(APPEND _langs CXX) list(APPEND CXX_features ${feature}) elseif (feature MATCHES "^c_") diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 891a011..b3cff47 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 7) -set(CMake_VERSION_PATCH 20161102) +set(CMake_VERSION_PATCH 20161104) #set(CMake_VERSION_RC 1) diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.cxx b/Source/CPack/WiX/cmCPackWIXGenerator.cxx index 5320449..4c8abd9 100644 --- a/Source/CPack/WiX/cmCPackWIXGenerator.cxx +++ b/Source/CPack/WiX/cmCPackWIXGenerator.cxx @@ -410,8 +410,7 @@ void cmCPackWIXGenerator::AddDefinition(cmWIXSourceWriter& source, std::ostringstream tmp; tmp << name << "=\"" << value << '"'; - source.AddProcessingInstruction( - "define", cmWIXSourceWriter::CMakeEncodingToUtf8(tmp.str())); + source.AddProcessingInstruction("define", tmp.str()); } bool cmCPackWIXGenerator::CreateWiXSourceFiles() diff --git a/Source/CPack/WiX/cmWIXSourceWriter.cxx b/Source/CPack/WiX/cmWIXSourceWriter.cxx index a8b0d7c..b434334 100644 --- a/Source/CPack/WiX/cmWIXSourceWriter.cxx +++ b/Source/CPack/WiX/cmWIXSourceWriter.cxx @@ -117,9 +117,7 @@ void cmWIXSourceWriter::AddProcessingInstruction(std::string const& target, void cmWIXSourceWriter::AddAttribute(std::string const& key, std::string const& value) { - std::string utf8 = CMakeEncodingToUtf8(value); - - File << " " << key << "=\"" << EscapeAttributeValue(utf8) << '"'; + File << " " << key << "=\"" << EscapeAttributeValue(value) << '"'; } void cmWIXSourceWriter::AddAttributeUnlessEmpty(std::string const& key, @@ -130,43 +128,6 @@ void cmWIXSourceWriter::AddAttributeUnlessEmpty(std::string const& key, } } -std::string cmWIXSourceWriter::CMakeEncodingToUtf8(std::string const& value) -{ -#ifdef CMAKE_ENCODING_UTF8 - return value; -#else - if (value.empty()) { - return std::string(); - } - - int characterCount = MultiByteToWideChar( - CP_ACP, 0, value.c_str(), static_cast<int>(value.size()), 0, 0); - - if (characterCount == 0) { - return std::string(); - } - - std::vector<wchar_t> utf16(characterCount); - - MultiByteToWideChar(CP_ACP, 0, value.c_str(), static_cast<int>(value.size()), - &utf16[0], static_cast<int>(utf16.size())); - - int utf8ByteCount = WideCharToMultiByte( - CP_UTF8, 0, &utf16[0], static_cast<int>(utf16.size()), 0, 0, 0, 0); - - if (utf8ByteCount == 0) { - return std::string(); - } - - std::vector<char> utf8(utf8ByteCount); - - WideCharToMultiByte(CP_UTF8, 0, &utf16[0], static_cast<int>(utf16.size()), - &utf8[0], static_cast<int>(utf8.size()), 0, 0); - - return std::string(&utf8[0], utf8.size()); -#endif -} - std::string cmWIXSourceWriter::CreateGuidFromComponentId( std::string const& componentId) { diff --git a/Source/CPack/WiX/cmWIXSourceWriter.h b/Source/CPack/WiX/cmWIXSourceWriter.h index b5c06ab..45aefe5 100644 --- a/Source/CPack/WiX/cmWIXSourceWriter.h +++ b/Source/CPack/WiX/cmWIXSourceWriter.h @@ -50,8 +50,6 @@ public: std::string CreateGuidFromComponentId(std::string const& componentId); - static std::string CMakeEncodingToUtf8(std::string const& value); - protected: cmCPackLog* Logger; diff --git a/Source/QtDialog/CMakeSetup.cxx b/Source/QtDialog/CMakeSetup.cxx index fad8075..9038469 100644 --- a/Source/QtDialog/CMakeSetup.cxx +++ b/Source/QtDialog/CMakeSetup.cxx @@ -95,10 +95,8 @@ int main(int argc, char** argv) setlocale(LC_NUMERIC, "C"); -#if defined(CMAKE_ENCODING_UTF8) QTextCodec* utf8_codec = QTextCodec::codecForName("UTF-8"); QTextCodec::setCodecForLocale(utf8_codec); -#endif #if QT_VERSION < 0x050000 // clean out standard Qt paths for plugins, which we don't use anyway diff --git a/Source/cmConfigure.cmake.h.in b/Source/cmConfigure.cmake.h.in index 057c6c0..26f1df2 100644 --- a/Source/cmConfigure.cmake.h.in +++ b/Source/cmConfigure.cmake.h.in @@ -20,7 +20,6 @@ #cmakedefine CMAKE_USE_ELF_PARSER #cmakedefine CMAKE_USE_MACH_PARSER #cmakedefine CMAKE_USE_LIBUV -#cmakedefine CMAKE_ENCODING_UTF8 #cmakedefine CMake_HAVE_CXX_AUTO_PTR #cmakedefine CMake_HAVE_CXX_MAKE_UNIQUE #cmakedefine CMake_HAVE_CXX_NULLPTR diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index ac76191..1bade57 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -59,7 +59,7 @@ static mode_t mode_setuid = S_ISUID; static mode_t mode_setgid = S_ISGID; #endif -#if defined(_WIN32) && defined(CMAKE_ENCODING_UTF8) +#if defined(_WIN32) // libcurl doesn't support file:// urls for unicode filenames on Windows. // Convert string from UTF-8 to ACP if this is a file:// URL. static std::string fix_file_url_windows(const std::string& url) @@ -2642,7 +2642,7 @@ bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args) return false; } -#if defined(_WIN32) && defined(CMAKE_ENCODING_UTF8) +#if defined(_WIN32) url = fix_file_url_windows(url); #endif @@ -2902,7 +2902,7 @@ bool cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args) unsigned long file_size = cmsys::SystemTools::FileLength(filename); -#if defined(_WIN32) && defined(CMAKE_ENCODING_UTF8) +#if defined(_WIN32) url = fix_file_url_windows(url); #endif diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index 773f8a0..c60a1ff 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -731,11 +731,5 @@ bool cmGlobalVisualStudio7Generator::IsDependedOn( std::string cmGlobalVisualStudio7Generator::Encoding() { - std::ostringstream encoding; -#ifdef CMAKE_ENCODING_UTF8 - encoding << "UTF-8"; -#else - encoding << "Windows-1252"; -#endif - return encoding.str(); + return "UTF-8"; } diff --git a/Source/cmake.h b/Source/cmake.h index cd00c61..6e8d9c8 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -535,12 +535,18 @@ private: } #define FOR_EACH_C_FEATURE(F) \ + F(c_std_90) \ + F(c_std_99) \ + F(c_std_11) \ F(c_function_prototypes) \ F(c_restrict) \ F(c_static_assert) \ F(c_variadic_macros) #define FOR_EACH_CXX_FEATURE(F) \ + F(cxx_std_98) \ + F(cxx_std_11) \ + F(cxx_std_14) \ F(cxx_aggregate_default_initializers) \ F(cxx_alias_templates) \ F(cxx_alignas) \ diff --git a/Tests/CompileFeatures/CMakeLists.txt b/Tests/CompileFeatures/CMakeLists.txt index 9f08523..9f61186 100644 --- a/Tests/CompileFeatures/CMakeLists.txt +++ b/Tests/CompileFeatures/CMakeLists.txt @@ -23,10 +23,12 @@ macro(run_test feature lang) endmacro() get_property(c_features GLOBAL PROPERTY CMAKE_C_KNOWN_FEATURES) +list(REMOVE_ITEM c_features c_std_90 c_std_99 c_std_11) foreach(feature ${c_features}) run_test(${feature} C) endforeach() get_property(cxx_features GLOBAL PROPERTY CMAKE_CXX_KNOWN_FEATURES) +list(REMOVE_ITEM cxx_features cxx_std_98 cxx_std_11 cxx_std_14) foreach(feature ${cxx_features}) run_test(${feature} CXX) endforeach() @@ -396,7 +398,7 @@ if (CMAKE_CXX_COMPILE_FEATURES) ) add_executable(CompileFeaturesGenex2 genex_test.cpp) - target_compile_features(CompileFeaturesGenex2 PRIVATE cxx_static_assert) + target_compile_features(CompileFeaturesGenex2 PRIVATE cxx_std_11) target_compile_definitions(CompileFeaturesGenex2 PRIVATE HAVE_OVERRIDE_CONTROL=$<COMPILE_FEATURES:cxx_final,cxx_override> HAVE_AUTO_TYPE=$<COMPILE_FEATURES:cxx_auto_type> @@ -405,10 +407,10 @@ if (CMAKE_CXX_COMPILE_FEATURES) HAVE_INHERITING_CONSTRUCTORS_AND_FINAL=$<COMPILE_FEATURES:cxx_inheriting_constructors,cxx_final> ) - add_library(static_assert_iface INTERFACE) - target_compile_features(static_assert_iface INTERFACE cxx_static_assert) + add_library(std_11_iface INTERFACE) + target_compile_features(std_11_iface INTERFACE cxx_std_11) add_executable(CompileFeaturesGenex3 genex_test.cpp) - target_link_libraries(CompileFeaturesGenex3 PRIVATE static_assert_iface) + target_link_libraries(CompileFeaturesGenex3 PRIVATE std_11_iface) target_compile_definitions(CompileFeaturesGenex3 PRIVATE HAVE_OVERRIDE_CONTROL=$<COMPILE_FEATURES:cxx_final,cxx_override> HAVE_AUTO_TYPE=$<COMPILE_FEATURES:cxx_auto_type> diff --git a/Tests/RunCMake/CompileFeatures/LinkImplementationFeatureCycle.cmake b/Tests/RunCMake/CompileFeatures/LinkImplementationFeatureCycle.cmake index 09594bd..2d14a9e 100644 --- a/Tests/RunCMake/CompileFeatures/LinkImplementationFeatureCycle.cmake +++ b/Tests/RunCMake/CompileFeatures/LinkImplementationFeatureCycle.cmake @@ -3,13 +3,13 @@ add_library(empty1 empty.cpp) add_library(empty2 INTERFACE) add_library(empty3 INTERFACE) -target_compile_features(empty3 INTERFACE cxx_static_assert) +target_compile_features(empty3 INTERFACE cxx_std_11) target_link_libraries(empty1 # When starting, $<COMPILE_FEATURES:cxx_auto_type> is '0', so 'freeze' the # CXX_STANDARD at 98 during computation. $<$<COMPILE_FEATURES:cxx_auto_type>:empty2> - # This would add cxx_static_assert, but that would require CXX_STANDARD = 11, + # This would add cxx_std_11, but that would require CXX_STANDARD = 11, # which is not allowed after freeze. Report an error. empty3 ) diff --git a/Tests/RunCMake/CompileFeatures/LinkImplementationFeatureCycleSolved.cmake b/Tests/RunCMake/CompileFeatures/LinkImplementationFeatureCycleSolved.cmake index bbcf4e0..a04dcec 100644 --- a/Tests/RunCMake/CompileFeatures/LinkImplementationFeatureCycleSolved.cmake +++ b/Tests/RunCMake/CompileFeatures/LinkImplementationFeatureCycleSolved.cmake @@ -3,7 +3,7 @@ add_library(empty1 empty.cpp) add_library(empty2 INTERFACE) add_library(empty3 INTERFACE) -target_compile_features(empty3 INTERFACE cxx_static_assert) +target_compile_features(empty3 INTERFACE cxx_std_11) target_link_libraries(empty1 $<$<COMPILE_FEATURES:cxx_nullptr>:empty2> |