diff options
author | Christophe Giboudeaux <christophe@krop.fr> | 2021-05-17 11:44:44 +0200 |
---|---|---|
committer | Christophe Giboudeaux <christophe@krop.fr> | 2021-05-25 08:07:34 +0000 |
commit | c6e575539a4c0f370df65d15001e7f1b942b7e91 (patch) | |
tree | 5a472c6d8ff4b74b0ff7c74caa742fb00c80d03d | |
parent | 1312c40ca85e2e5bab6781897b4224cfd04f805a (diff) | |
download | extra-cmake-modules-c6e575539a4c0f370df65d15001e7f1b942b7e91.tar.gz extra-cmake-modules-c6e575539a4c0f370df65d15001e7f1b942b7e91.tar.bz2 |
Clean ECM files after the minimum version change
- Remove deprecated version checks
- Use VERSION_GREATER_EQUAL
-rw-r--r-- | docs/manual/ecm-developer.7.rst | 8 | ||||
-rw-r--r-- | find-modules/FindKF5.cmake | 2 | ||||
-rw-r--r-- | kde-modules/KDECMakeSettings.cmake | 10 | ||||
-rw-r--r-- | kde-modules/KDECompilerSettings.cmake | 14 | ||||
-rw-r--r-- | kde-modules/KDEFrameworkCompilerSettings.cmake | 8 | ||||
-rw-r--r-- | kde-modules/KDEInstallDirs.cmake | 7 | ||||
-rw-r--r-- | kde-modules/KDEPackageAppTemplates.cmake | 16 | ||||
-rw-r--r-- | modules/ECMAddQtDesignerPlugin.cmake | 2 | ||||
-rw-r--r-- | modules/ECMFindModuleHelpers.cmake | 8 | ||||
-rw-r--r-- | modules/ECMGenerateExportHeader.cmake | 27 | ||||
-rw-r--r-- | modules/ECMGeneratePkgConfigFile.cmake | 3 | ||||
-rw-r--r-- | modules/ECMGeneratePriFile.cmake | 2 | ||||
-rw-r--r-- | modules/ECMPackageConfigHelpers.cmake | 4 | ||||
-rw-r--r-- | modules/ECMSetupQtPluginMacroNames.cmake | 112 | ||||
-rw-r--r-- | modules/ECMSetupVersion.cmake | 9 | ||||
-rw-r--r-- | tests/ECMGenerateExportHeaderTest/consumer/testAPI_DISABLE_DEPRECATED_BEFORE_AND_AT.cmake | 4 | ||||
-rw-r--r-- | tests/ECMGenerateExportHeaderTest/format_version/CMakeLists.txt | 18 | ||||
-rw-r--r-- | tests/ECMSetupVersionTest/version_helpers.cmake | 2 |
18 files changed, 97 insertions, 159 deletions
diff --git a/docs/manual/ecm-developer.7.rst b/docs/manual/ecm-developer.7.rst index b12cc83d..0d3108c2 100644 --- a/docs/manual/ecm-developer.7.rst +++ b/docs/manual/ecm-developer.7.rst @@ -132,11 +132,11 @@ used is not high enough. This can be done with: .. code-block:: cmake - if(CMAKE_VERSION VERSION_LESS 2.8.12) - message(FATAL_ERROR "CMake 2.8.12 is required by FindFoo.cmake") + if(CMAKE_VERSION VERSION_LESS 3.16.0) + message(FATAL_ERROR "CMake 3.16.0 is required by FindFoo.cmake") endif() - if(CMAKE_MINIMUM_REQUIRED_VERSION VERSION_LESS 2.8.12) - message(AUTHOR_WARNING "Your project should require at least CMake 2.8.12 to use FindFoo.cmake") + if(CMAKE_MINIMUM_REQUIRED_VERSION VERSION_LESS 3.16.0) + message(AUTHOR_WARNING "Your project should require at least CMake 3.16.0 to use FindFoo.cmake") endif() The :module:`ECMFindModuleHelpers` module has several useful functions and diff --git a/find-modules/FindKF5.cmake b/find-modules/FindKF5.cmake index 42c55bab..ed7215c8 100644 --- a/find-modules/FindKF5.cmake +++ b/find-modules/FindKF5.cmake @@ -55,7 +55,7 @@ foreach(_module ${KF5_FIND_COMPONENTS}) ) # CMake >= 3.17 wants to be explicitly told we are fine with name mismatch here set(_name_mismatched_arg) - if(NOT CMAKE_VERSION VERSION_LESS 3.17) + if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.17) set(_name_mismatched_arg NAME_MISMATCHED) endif() find_package_handle_standard_args(KF5${_module} CONFIG_MODE ${_name_mismatched_arg}) diff --git a/kde-modules/KDECMakeSettings.cmake b/kde-modules/KDECMakeSettings.cmake index d33daa7a..251f7cff 100644 --- a/kde-modules/KDECMakeSettings.cmake +++ b/kde-modules/KDECMakeSettings.cmake @@ -220,9 +220,7 @@ if(NOT KDE_SKIP_BUILD_SETTINGS) # Since CMake 3.0 # TODO KF6: discuss enabling AUTOUIC and note porting requirements. autouic # acts on all #include "ui_*.h" assuming *.ui exists - if(NOT CMAKE_VERSION VERSION_LESS 3.0) - set(CMAKE_AUTORCC ON) - endif() + set(CMAKE_AUTORCC ON) # By default, create 'GUI' executables. This can be reverted on a per-target basis # using ECMMarkNonGuiExecutable @@ -246,7 +244,7 @@ if(NOT KDE_SKIP_BUILD_SETTINGS) # even without installation. # We do the same under Unix to make it possible to run tests and apps without installing - if (WIN32 OR NOT ("${ECM_GLOBAL_FIND_VERSION}" VERSION_LESS "5.38.0")) + if (WIN32 OR ECM_GLOBAL_FIND_VERSION VERSION_GREATER_EQUAL 5.38.0) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib") set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") @@ -342,9 +340,7 @@ if(NOT EXISTS ${CMAKE_SOURCE_DIR}/po AND NOT TARGET fetch-translations) set(_l10n_po_dir "${CMAKE_BINARY_DIR}/po") set(_l10n_poqm_dir "${CMAKE_BINARY_DIR}/poqm") - if(CMAKE_VERSION VERSION_GREATER 3.2) - set(extra BYPRODUCTS ${_l10n_po_dir} ${_l10n_poqm_dir}) - endif() + set(extra BYPRODUCTS ${_l10n_po_dir} ${_l10n_poqm_dir}) set(fetch_commands COMMAND ruby "${CMAKE_BINARY_DIR}/releaseme/fetchpo.rb" diff --git a/kde-modules/KDECompilerSettings.cmake b/kde-modules/KDECompilerSettings.cmake index 7fd905cf..aa5b3e15 100644 --- a/kde-modules/KDECompilerSettings.cmake +++ b/kde-modules/KDECompilerSettings.cmake @@ -75,7 +75,7 @@ endif() ############################################################ macro(_kde_compiler_min_version min_version) - if ("${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS "${min_version}") + if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${min_version}) message(WARNING "Version ${CMAKE_CXX_COMPILER_VERSION} of the ${CMAKE_CXX_COMPILER_ID} C++ compiler is not supported. Please use version ${min_version} or later.") endif() endmacro() @@ -368,12 +368,12 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=return-type") endif() if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR - (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.5)) + (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 3.5)) # -Wvla: use of variable-length arrays (an extension to C++) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wvla") endif() -if ((CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0) OR - (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.5)) +if ((CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 5.0) OR + (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 3.5)) include(CheckCXXCompilerFlag) check_cxx_compiler_flag(-Wdate-time HAVE_DATE_TIME) if (HAVE_DATE_TIME) @@ -383,7 +383,7 @@ if ((CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_CXX_COMPILER_VERSION VER endif() if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "5.0.0") + if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 5.0.0) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wsuggest-override -Wlogical-op" ) endif() endif() @@ -461,8 +461,8 @@ if (MINGW AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU") endif() if (CMAKE_GENERATOR STREQUAL "Ninja" AND - ((CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9) OR - (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.5))) + ((CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 4.9) OR + (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 3.5))) # Force colored warnings in Ninja's output, if the compiler has -fdiagnostics-color support. # Rationale in https://github.com/ninja-build/ninja/issues/814 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color=always") diff --git a/kde-modules/KDEFrameworkCompilerSettings.cmake b/kde-modules/KDEFrameworkCompilerSettings.cmake index fca643d4..7459594e 100644 --- a/kde-modules/KDEFrameworkCompilerSettings.cmake +++ b/kde-modules/KDEFrameworkCompilerSettings.cmake @@ -45,7 +45,7 @@ endif() # Some non-KF projects make (ab)use of KDEFrameworkCompilerSettings currently, # let them only hit this as well when bumping their min. ECM requirement to a newer version. -if (NOT "${ECM_GLOBAL_FIND_VERSION}" VERSION_LESS "5.79.0") +if (ECM_GLOBAL_FIND_VERSION VERSION_GREATER_EQUAL 5.79.0) add_definitions( -DQT_NO_KEYWORDS -DQT_NO_FOREACH @@ -64,18 +64,18 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang endif() if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "5.0.0") + if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 5.0.0) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wzero-as-null-pointer-constant" ) endif() endif() if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") - if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "5.0.0") + if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 5.0.0) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wzero-as-null-pointer-constant" ) endif() endif() -if (NOT ("${ECM_GLOBAL_FIND_VERSION}" VERSION_LESS "5.80.0")) +if (ECM_GLOBAL_FIND_VERSION VERSION_GREATER_EQUAL 5.80.0) include(KDEClangFormat) # add clang-format target file(GLOB_RECURSE ALL_CLANG_FORMAT_SOURCE_FILES *.cpp *.h *.c) diff --git a/kde-modules/KDEInstallDirs.cmake b/kde-modules/KDEInstallDirs.cmake index 628baa06..db987f23 100644 --- a/kde-modules/KDEInstallDirs.cmake +++ b/kde-modules/KDEInstallDirs.cmake @@ -334,9 +334,7 @@ macro(_define_relative varname parent subdir docstring) PROPERTY TYPE PATH) endif() elseif(${_oldstylename}) - if(NOT CMAKE_VERSION VERSION_LESS 3.0.0) - message(DEPRECATION "${_oldstylename} is deprecated, use KDE_INSTALL_${varname} instead.") - endif() + message(DEPRECATION "${_oldstylename} is deprecated, use KDE_INSTALL_${varname} instead.") # The old name was given (probably on the command line): move # it to the new name set(KDE_INSTALL_${varname} "${${_oldstylename}}" @@ -344,7 +342,7 @@ macro(_define_relative varname parent subdir docstring) "${docstring} (${_docpath})" FORCE) elseif(${_cmakename}) - if(_cmakename_is_deprecated AND NOT CMAKE_VERSION VERSION_LESS 3.0.0) + if(_cmakename_is_deprecated) message(DEPRECATION "${_cmakename} is deprecated, use KDE_INSTALL_${varname} instead.") endif() # The CMAKE_ name was given (probably on the command line): move @@ -417,7 +415,6 @@ if(APPLE) BUNDLE_INSTALL_DIR) endif() -# Only supported since cmake 3.7 if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${ECM_PREFIX}" CACHE PATH "Install path prefix" FORCE) endif() diff --git a/kde-modules/KDEPackageAppTemplates.cmake b/kde-modules/KDEPackageAppTemplates.cmake index 951fcee1..aa8111ac 100644 --- a/kde-modules/KDEPackageAppTemplates.cmake +++ b/kde-modules/KDEPackageAppTemplates.cmake @@ -107,19 +107,9 @@ function(kde_package_app_templates) get_filename_component(_baseName ${_tmp_file} NAME_WE) set(_template ${CMAKE_CURRENT_BINARY_DIR}/${_baseName}.tar.bz2) - # CONFIGURE_DEPENDS is only available for cmake >= 3.12 - if(NOT CMAKE_VERSION VERSION_LESS "3.12.0") - # also enlist directories as deps to catch file removals - file(GLOB_RECURSE _subdirs_entries LIST_DIRECTORIES true CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${_templateName}/*") - else() - file(GLOB_RECURSE _subdirs_entries LIST_DIRECTORIES true "${CMAKE_CURRENT_SOURCE_DIR}/${_templateName}/*") - # custom code to implement CONFIGURE_DEPENDS - foreach(_direntry ${_subdirs_entries}) - if(IS_DIRECTORY ${_direntry}) - set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${_direntry}) - endif() - endforeach() - endif() + # also enlist directories as deps to catch file removals + file(GLOB_RECURSE _subdirs_entries LIST_DIRECTORIES true CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${_templateName}/*") + add_custom_target(${_baseName} ALL DEPENDS ${_template}) if(GNU_TAR_FOUND) diff --git a/modules/ECMAddQtDesignerPlugin.cmake b/modules/ECMAddQtDesignerPlugin.cmake index eaf3660f..7d3dfb69 100644 --- a/modules/ECMAddQtDesignerPlugin.cmake +++ b/modules/ECMAddQtDesignerPlugin.cmake @@ -618,7 +618,7 @@ QList<QDesignerCustomWidgetInterface*> ${_collection_classname}::customWidgets() # setup plugin binary add_library(${target} MODULE ${_srcs}) - if(Qt5UiPlugin_VERSION AND NOT Qt5UiPlugin_VERSION VERSION_LESS "5.9.0") + if(Qt5UiPlugin_VERSION AND Qt5UiPlugin_VERSION VERSION_GREATER_EQUAL 5.9.0) list(APPEND ARGS_LINK_LIBRARIES Qt5::UiPlugin) else() # For Qt <5.9 include dir variables needed diff --git a/modules/ECMFindModuleHelpers.cmake b/modules/ECMFindModuleHelpers.cmake index 1d9b8eea..aec2abb4 100644 --- a/modules/ECMFindModuleHelpers.cmake +++ b/modules/ECMFindModuleHelpers.cmake @@ -105,11 +105,11 @@ Since pre-1.0.0. include(CMakeParseArguments) macro(ecm_find_package_version_check module_name) - if(CMAKE_VERSION VERSION_LESS 2.8.12) - message(FATAL_ERROR "CMake 2.8.12 is required by Find${module_name}.cmake") + if(CMAKE_VERSION VERSION_LESS 3.16.0) + message(FATAL_ERROR "CMake 3.16.0 is required by Find${module_name}.cmake") endif() - if(CMAKE_MINIMUM_REQUIRED_VERSION VERSION_LESS 2.8.12) - message(AUTHOR_WARNING "Your project should require at least CMake 2.8.12 to use Find${module_name}.cmake") + if(CMAKE_MINIMUM_REQUIRED_VERSION VERSION_LESS 3.16.0) + message(AUTHOR_WARNING "Your project should require at least CMake 3.16.0 to use Find${module_name}.cmake") endif() endmacro() diff --git a/modules/ECMGenerateExportHeader.cmake b/modules/ECMGenerateExportHeader.cmake index 7cd1418e..7b05e6fc 100644 --- a/modules/ECMGenerateExportHeader.cmake +++ b/modules/ECMGenerateExportHeader.cmake @@ -394,9 +394,7 @@ function(_ecm_geh_generate_hex_number _var_name _version) string(REGEX REPLACE ${version_regex} "\\2" _version_minor "${_version}") string(REGEX REPLACE ${version_regex} "\\3" _version_patch "${_version}") set(_outputformat) - if (NOT CMAKE_VERSION VERSION_LESS 3.13) - set(_outputformat OUTPUT_FORMAT HEXADECIMAL) - endif() + set(_outputformat OUTPUT_FORMAT HEXADECIMAL) math(EXPR _hexnumber "${_version_major}*65536 + ${_version_minor}*256 + ${_version_patch}" ${_outputformat}) set(${_var_name} ${_hexnumber} PARENT_SCOPE) endfunction() @@ -471,9 +469,6 @@ function(ecm_generate_export_header target) elseif(NOT ARGS_VERSION MATCHES ${_version_triple_regexp}) message(FATAL_ERROR "VERSION expected to be in x.y.z format when calling ecm_generate_export_header().") endif() - if (ARGS_INCLUDE_GUARD_NAME AND CMAKE_VERSION VERSION_LESS 3.11) - message(FATAL_ERROR "Argument INCLUDE_GUARD_NAME needs at least CMake 3.11 when calling ecm_generate_export_header().") - endif() if (NOT ARGS_EXCLUDE_DEPRECATED_BEFORE_AND_AT) set(ARGS_EXCLUDE_DEPRECATED_BEFORE_AND_AT 0) elseif(ARGS_EXCLUDE_DEPRECATED_BEFORE_AND_AT STREQUAL "CURRENT") @@ -771,9 +766,7 @@ function(ecm_generate_export_header target) # for older cmake verions we have to manually append our generated content # for newer we use CUSTOM_CONTENT_FROM_VARIABLE set(_custom_content_args) - if (NOT CMAKE_VERSION VERSION_LESS 3.7) - set(_custom_content_args CUSTOM_CONTENT_FROM_VARIABLE _output) - endif() + set(_custom_content_args CUSTOM_CONTENT_FROM_VARIABLE _output) generate_export_header(${target} BASE_NAME ${ARGS_BASE_NAME} DEPRECATED_MACRO_NAME "${_macro_base_name}_DECL_DEPRECATED" @@ -786,14 +779,13 @@ function(ecm_generate_export_header target) ${_custom_content_args} ) - if (CMAKE_VERSION VERSION_LESS 3.7) - if (ARGS_INCLUDE_GUARD_NAME) - set(_include_guard "ECM_GENERATEEXPORTHEADER_${ARGS_INCLUDE_GUARD_NAME}") - else() - set(_include_guard "ECM_GENERATEEXPORTHEADER_${_upper_base_name}_EXPORT_H") - endif() + if (ARGS_INCLUDE_GUARD_NAME) + set(_include_guard "ECM_GENERATEEXPORTHEADER_${ARGS_INCLUDE_GUARD_NAME}") + else() + set(_include_guard "ECM_GENERATEEXPORTHEADER_${_upper_base_name}_EXPORT_H") + endif() - file(APPEND ${_header_work_file} " + file(APPEND ${_header_work_file} " #ifndef ${_include_guard} #define ${_include_guard} @@ -802,8 +794,7 @@ ${_output} #endif /* ${_include_guard} */ " - ) - endif() + ) # avoid rebuilding if there was no change execute_process( diff --git a/modules/ECMGeneratePkgConfigFile.cmake b/modules/ECMGeneratePkgConfigFile.cmake index fde6e5d9..2fb45c83 100644 --- a/modules/ECMGeneratePkgConfigFile.cmake +++ b/modules/ECMGeneratePkgConfigFile.cmake @@ -61,8 +61,7 @@ subsequent calls. To properly use this macro a version needs to be set. To retrieve it, ``ECM_PKGCONFIG_INSTALL_DIR`` uses ``PROJECT_VERSION``. To set it, use the -project() command (only available since CMake 3.0) or the ecm_setup_version() -macro. +project() command or the ecm_setup_version() macro Example usage: diff --git a/modules/ECMGeneratePriFile.cmake b/modules/ECMGeneratePriFile.cmake index c679cbd9..63139aef 100644 --- a/modules/ECMGeneratePriFile.cmake +++ b/modules/ECMGeneratePriFile.cmake @@ -122,7 +122,7 @@ function(ECM_GENERATE_PRI_FILE) message(FATAL_ERROR "Unknown keywords given to ECM_GENERATE_PRI_FILE(): \"${EGPF_UNPARSED_ARGUMENTS}\"") endif() - if("${ECM_GLOBAL_FIND_VERSION}" VERSION_LESS "5.83.0") + if(ECM_GLOBAL_FIND_VERSION VERSION_LESS 5.83.0) set(_support_backward_compat_version_string_var TRUE) else() set(_support_backward_compat_version_string_var FALSE) diff --git a/modules/ECMPackageConfigHelpers.cmake b/modules/ECMPackageConfigHelpers.cmake index 6bff6927..f320ebc2 100644 --- a/modules/ECMPackageConfigHelpers.cmake +++ b/modules/ECMPackageConfigHelpers.cmake @@ -59,9 +59,7 @@ include(${CMAKE_ROOT}/Modules/CMakePackageConfigHelpers.cmake) set(_ecm_package_config_helpers_included TRUE) -if(NOT CMAKE_MINIMUM_REQUIRED_VERSION VERSION_LESS 2.8.13) - message(AUTHOR_WARNING "Your project already requires a version of CMake that includes the find_dependency macro via the CMakeFindDependencyMacro module. You should use CMakePackageConfigHelpers instead of ECMPackageConfigHelpers.") -endif() +message(AUTHOR_WARNING "Your project already requires a version of CMake that includes the find_dependency macro via the CMakeFindDependencyMacro module. You should use CMakePackageConfigHelpers instead of ECMPackageConfigHelpers.") function(ECM_CONFIGURE_PACKAGE_CONFIG_FILE _inputFile _outputFile) set(options NO_SET_AND_CHECK_MACRO NO_CHECK_REQUIRED_COMPONENTS_MACRO) diff --git a/modules/ECMSetupQtPluginMacroNames.cmake b/modules/ECMSetupQtPluginMacroNames.cmake index 632149ca..348ad38e 100644 --- a/modules/ECMSetupQtPluginMacroNames.cmake +++ b/modules/ECMSetupQtPluginMacroNames.cmake @@ -111,42 +111,34 @@ macro(ecm_setup_qtplugin_macro_names) endif() # CMAKE_AUTOMOC_MACRO_NAMES - if(NOT CMAKE_VERSION VERSION_LESS "3.10.0") - # CMake 3.9+ warns about automoc on files without Q_OBJECT, and doesn't know about other macros. - # 3.10+ lets us provide more macro names that require automoc. - list(APPEND CMAKE_AUTOMOC_MACRO_NAMES - ${ESQMN_JSON_NONE} - ${ESQMN_JSON_ARG1} - ${ESQMN_JSON_ARG2} - ${ESQMN_JSON_ARG3} - ) - endif() + list(APPEND CMAKE_AUTOMOC_MACRO_NAMES + ${ESQMN_JSON_NONE} + ${ESQMN_JSON_ARG1} + ${ESQMN_JSON_ARG2} + ${ESQMN_JSON_ARG3} + ) # CMAKE_AUTOMOC_DEPEND_FILTERS - if(NOT CMAKE_VERSION VERSION_LESS "3.9.0") - # CMake's automoc needs help to find names of plugin metadata files in case Q_PLUGIN_METADATA - # is indirectly used via other C++ preprocessor macros - # 3.9+ lets us provide some filter rule pairs (keyword, regexp) to match the names of such files - # in the plain text of the sources. See AUTOMOC_DEPEND_FILTERS docs for details. - foreach(macro_name ${ESQMN_JSON_ARG1}) - list(APPEND CMAKE_AUTOMOC_DEPEND_FILTERS - "${macro_name}" - "[\n^][ \t]*${macro_name}[ \t\n]*\\([ \t\n]*\"([^\"]+)\"" - ) - endforeach() - foreach(macro_name ${ESQMN_JSON_ARG2}) - list(APPEND CMAKE_AUTOMOC_DEPEND_FILTERS - "${macro_name}" - "[\n^][ \t]*${macro_name}[ \t\n]*\\([^,]*,[ \t\n]*\"([^\"]+)\"" - ) - endforeach() - foreach(macro_name ${ESQMN_JSON_ARG3}) - list(APPEND CMAKE_AUTOMOC_DEPEND_FILTERS - "${macro_name}" - "[\n^][ \t]*${macro_name}[ \t\n]*\\([^,]*,[^,]*,[ \t\n]*\"([^\"]+)\"" - ) - endforeach() - endif() + # CMake's automoc needs help to find names of plugin metadata files in case Q_PLUGIN_METADATA + # is indirectly used via other C++ preprocessor macros + foreach(macro_name ${ESQMN_JSON_ARG1}) + list(APPEND CMAKE_AUTOMOC_DEPEND_FILTERS + "${macro_name}" + "[\n^][ \t]*${macro_name}[ \t\n]*\\([ \t\n]*\"([^\"]+)\"" + ) + endforeach() + foreach(macro_name ${ESQMN_JSON_ARG2}) + list(APPEND CMAKE_AUTOMOC_DEPEND_FILTERS + "${macro_name}" + "[\n^][ \t]*${macro_name}[ \t\n]*\\([^,]*,[ \t\n]*\"([^\"]+)\"" + ) + endforeach() + foreach(macro_name ${ESQMN_JSON_ARG3}) + list(APPEND CMAKE_AUTOMOC_DEPEND_FILTERS + "${macro_name}" + "[\n^][ \t]*${macro_name}[ \t\n]*\\([^,]*,[^,]*,[ \t\n]*\"([^\"]+)\"" + ) + endforeach() if (ESQMN_CONFIG_CODE_VARIABLE) set(_content @@ -160,52 +152,46 @@ macro(ecm_setup_qtplugin_macro_names) ${ESQMN_JSON_ARG3} ) string(APPEND _content " -if(NOT CMAKE_VERSION VERSION_LESS \"3.10.0\") - # CMake 3.9+ warns about automoc on files without Q_OBJECT, and doesn't know about other macros. - # 3.10+ lets us provide more macro names that require automoc. - list(APPEND CMAKE_AUTOMOC_MACRO_NAMES ${_all_macro_names}) -endif() +# CMake 3.9+ warns about automoc on files without Q_OBJECT, and doesn't know about other macros. +# 3.10+ lets us provide more macro names that require automoc. +list(APPEND CMAKE_AUTOMOC_MACRO_NAMES ${_all_macro_names}) ") if(ESQMN_JSON_ARG1 OR ESQMN_JSON_ARG2 OR ESQMN_JSON_ARG3) string(APPEND _content " -if(NOT CMAKE_VERSION VERSION_LESS \"3.9.0\") - # CMake's automoc needs help to find names of plugin metadata files in case Q_PLUGIN_METADATA - # is indirectly used via other C++ preprocessor macros - # 3.9+ lets us provide some filter rule pairs (keyword, regexp) to match the names of such files - # in the plain text of the sources. See AUTOMOC_DEPEND_FILTERS docs for details. +# CMake's automoc needs help to find names of plugin metadata files in case Q_PLUGIN_METADATA +# is indirectly used via other C++ preprocessor macros ") if(ESQMN_JSON_ARG1) string(APPEND _content -" foreach(macro_name ${ESQMN_JSON_ARG1}) - list(APPEND CMAKE_AUTOMOC_DEPEND_FILTERS - \"\${macro_name}\" - \"[\\n^][ \\t]*\${macro_name}[ \\t\\n]*\\\\([ \\t\\n]*\\\"([^\\\"]+)\\\"\" - ) - endforeach() +"foreach(macro_name ${ESQMN_JSON_ARG1}) + list(APPEND CMAKE_AUTOMOC_DEPEND_FILTERS + \"\${macro_name}\" + \"[\\n^][ \\t]*\${macro_name}[ \\t\\n]*\\\\([ \\t\\n]*\\\"([^\\\"]+)\\\"\" + ) +endforeach() ") endif() if(ESQMN_JSON_ARG2) string(APPEND _content -" foreach(macro_name ${ESQMN_JSON_ARG2}) - list(APPEND CMAKE_AUTOMOC_DEPEND_FILTERS - \"\${macro_name}\" - \"[\\n^][ \\t]*\${macro_name}[ \\t\\n]*\\\\([^,]*,[ \\t\\n]*\\\"([^\\\"]+)\\\"\" - ) - endforeach() +"foreach(macro_name ${ESQMN_JSON_ARG2}) + list(APPEND CMAKE_AUTOMOC_DEPEND_FILTERS + \"\${macro_name}\" + \"[\\n^][ \\t]*\${macro_name}[ \\t\\n]*\\\\([^,]*,[ \\t\\n]*\\\"([^\\\"]+)\\\"\" + ) +endforeach() ") endif() if(ESQMN_JSON_ARG3) string(APPEND _content -" foreach(macro_name ${ESQMN_JSON_ARG3}) - list(APPEND CMAKE_AUTOMOC_DEPEND_FILTERS - \"\${macro_name}\" - \"[\\n^][ \\t]*\${macro_name}[ \\t\\n]*\\\\([^,]*,[^,]*,[ \\t\\n]*\\\"([^\\\"]+)\\\"\" - ) - endforeach() +"foreach(macro_name ${ESQMN_JSON_ARG3}) + list(APPEND CMAKE_AUTOMOC_DEPEND_FILTERS + \"\${macro_name}\" + \"[\\n^][ \\t]*\${macro_name}[ \\t\\n]*\\\\([^,]*,[^,]*,[ \\t\\n]*\\\"([^\\\"]+)\\\"\" + ) +endforeach() ") endif() - string(APPEND _content "endif()") endif() string(APPEND _content " ####################################################################################" diff --git a/modules/ECMSetupVersion.cmake b/modules/ECMSetupVersion.cmake index b67ed0d0..f4b2e700 100644 --- a/modules/ECMSetupVersion.cmake +++ b/modules/ECMSetupVersion.cmake @@ -110,12 +110,7 @@ function(ecm_setup_version _version) set(project_manages_version FALSE) set(use_project_version FALSE) - # CMP0048 only exists in CMake 3.0.0 and later - if(CMAKE_VERSION VERSION_LESS 3.0.0) - set(project_version_policy "OLD") - else() - cmake_policy(GET CMP0048 project_version_policy) - endif() + cmake_policy(GET CMP0048 project_version_policy) if(project_version_policy STREQUAL "NEW") set(project_manages_version TRUE) if(_version STREQUAL "PROJECT") @@ -150,7 +145,7 @@ function(ecm_setup_version _version) set(ESV_SOVERSION ${_major}) endif() - if("${ECM_GLOBAL_FIND_VERSION}" VERSION_LESS "5.83.0") + if(ECM_GLOBAL_FIND_VERSION VERSION_LESS 5.83.0) set(_set_backward_compat_version_string_vars TRUE) else() set(_set_backward_compat_version_string_vars FALSE) diff --git a/tests/ECMGenerateExportHeaderTest/consumer/testAPI_DISABLE_DEPRECATED_BEFORE_AND_AT.cmake b/tests/ECMGenerateExportHeaderTest/consumer/testAPI_DISABLE_DEPRECATED_BEFORE_AND_AT.cmake index 48f8a52e..1f95999c 100644 --- a/tests/ECMGenerateExportHeaderTest/consumer/testAPI_DISABLE_DEPRECATED_BEFORE_AND_AT.cmake +++ b/tests/ECMGenerateExportHeaderTest/consumer/testAPI_DISABLE_DEPRECATED_BEFORE_AND_AT.cmake @@ -6,9 +6,7 @@ function(generate_hex_number _var_name _version) string(REGEX REPLACE ${version_regex} "\\2" _version_minor "${_version}") string(REGEX REPLACE ${version_regex} "\\3" _version_patch "${_version}") set(_outputformat) - if (NOT CMAKE_VERSION VERSION_LESS 3.13) - set(_outputformat OUTPUT_FORMAT HEXADECIMAL) - endif() + set(_outputformat OUTPUT_FORMAT HEXADECIMAL) math(EXPR _hexnumber "${_version_major}*65536 + ${_version_minor}*256 + ${_version_patch}" ${_outputformat}) set(${_var_name} ${_hexnumber} PARENT_SCOPE) endfunction() diff --git a/tests/ECMGenerateExportHeaderTest/format_version/CMakeLists.txt b/tests/ECMGenerateExportHeaderTest/format_version/CMakeLists.txt index bcb681d2..428a372a 100644 --- a/tests/ECMGenerateExportHeaderTest/format_version/CMakeLists.txt +++ b/tests/ECMGenerateExportHeaderTest/format_version/CMakeLists.txt @@ -36,11 +36,7 @@ ecm_export_header_format_version(1.2.3 ) assert_var_str_value(_versionstring "1.2.3") -if (NOT CMAKE_VERSION VERSION_LESS 3.13) - assert_var_str_value(_hexnumber "0x10203") -else() - assert_var_str_value(_hexnumber "66051") -endif() +assert_var_str_value(_hexnumber "0x10203") # check some version: no CURRENT_VERSION ecm_export_header_format_version(1.2.3 @@ -49,11 +45,7 @@ ecm_export_header_format_version(1.2.3 ) assert_var_str_value(_versionstring "1.2.3") -if (NOT CMAKE_VERSION VERSION_LESS 3.13) - assert_var_str_value(_hexnumber "0x10203") -else() - assert_var_str_value(_hexnumber "66051") -endif() +assert_var_str_value(_hexnumber "0x10203") # check CURRENT ecm_export_header_format_version(CURRENT @@ -63,10 +55,6 @@ ecm_export_header_format_version(CURRENT ) assert_var_str_value(_versionstring "4.5.6") -if (NOT CMAKE_VERSION VERSION_LESS 3.13) - assert_var_str_value(_hexnumber "0x40506") -else() - assert_var_str_value(_hexnumber "263430") -endif() +assert_var_str_value(_hexnumber "0x40506") add_executable(dummy main.cpp) diff --git a/tests/ECMSetupVersionTest/version_helpers.cmake b/tests/ECMSetupVersionTest/version_helpers.cmake index 6254322f..d8497c9f 100644 --- a/tests/ECMSetupVersionTest/version_helpers.cmake +++ b/tests/ECMSetupVersionTest/version_helpers.cmake @@ -43,7 +43,7 @@ endmacro() macro(version_var_checks prefix version) assert_var_str_value(${prefix}_VERSION "${version}") - if("${ECM_GLOBAL_FIND_VERSION}" VERSION_LESS "5.83.0") + if(ECM_GLOBAL_FIND_VERSION VERSION_LESS 5.83.0) assert_var_str_value(${prefix}_VERSION_STRING "${version}") endif() if("${version}" MATCHES "^([0-9]+)") |