diff --git a/.cmake-format b/.cmake-format.py similarity index 99% rename from .cmake-format rename to .cmake-format.py index e9fdda7..b86744c 100644 --- a/.cmake-format +++ b/.cmake-format.py @@ -175,7 +175,7 @@ with section("markup"): with section("lint"): # a list of lint codes to disable - disabled_codes = [] + disabled_codes = ['C0111','C0113'] # regular expression pattern describing valid function names function_pattern = '[0-9a-z_]+' diff --git a/CMLibCPackDeb.cmake b/CMLibCPackDeb.cmake index dffdb96..398f329 100644 --- a/CMLibCPackDeb.cmake +++ b/CMLibCPackDeb.cmake @@ -49,9 +49,9 @@ if(CMLIB_CPACK_DEFAULT_SCHEME) set(CPACK_DEBIAN_LIBS-DEV_PACKAGE_DEPENDS "lib${CMLIB_PROJECT_NAME_LOWER}-base-dev") - foreach(_C ${CPACK_COMPONENTS_ALL}) - string(TOLOWER ${_C} _cl) - string(TOUPPER ${_C} _cu) + foreach(component ${CPACK_COMPONENTS_ALL}) + string(TOLOWER ${component} _cl) + string(TOUPPER ${component} _cu) # Правила формирования имени пакета и файла для остальных компонентов if(NOT ${_cl} STREQUAL main AND NOT ${_cl} STREQUAL base-dev AND NOT ${_cl} STREQUAL libs-dev) set(CPACK_DEBIAN_${_cu}_PACKAGE_NAME "${CMLIB_PROJECT_NAME_LOWER}-${_cl}") diff --git a/CMLibCommonLibraryTarget.cmake b/CMLibCommonLibraryTarget.cmake index 7b4570e..e032738 100644 --- a/CMLibCommonLibraryTarget.cmake +++ b/CMLibCommonLibraryTarget.cmake @@ -5,15 +5,14 @@ function(add_common_library target) set(multiValueArgs SOURCES) cmake_parse_arguments(_LOCAL "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - set(SOURCES ${_LOCAL_SOURCES}) if(_LOCAL_OUTPUT_NAME) - set(OUTNAME ${_LOCAL_OUTPUT_NAME}) + set(output_name ${_LOCAL_OUTPUT_NAME}) else() - set(OUTNAME ${target}) + set(output_name ${target}) endif() - add_library(${target} OBJECT ${SOURCES}) + add_library(${target} OBJECT ${_LOCAL_SOURCES}) target_include_directories( ${target} PUBLIC $ $ $) @@ -22,7 +21,7 @@ function(add_common_library target) # cmake-format: off if(BUILD_SHARED_LIBS) add_library(${target}_shared SHARED $) - set_target_properties(${target}_shared PROPERTIES OUTPUT_NAME ${OUTNAME} + set_target_properties(${target}_shared PROPERTIES OUTPUT_NAME ${output_name} VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR} LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}) install(TARGETS ${target}_shared LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) @@ -30,7 +29,7 @@ function(add_common_library target) if(NOT SKIP_STATIC_LIBS) add_library(${target}_static STATIC $) - set_target_properties(${target}_static PROPERTIES OUTPUT_NAME ${OUTNAME} + set_target_properties(${target}_static PROPERTIES OUTPUT_NAME ${output_name} ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}) install(TARGETS ${target}_static ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() diff --git a/CMLibCommonTargetProperties.cmake b/CMLibCommonTargetProperties.cmake index e49b7b4..46db3e2 100644 --- a/CMLibCommonTargetProperties.cmake +++ b/CMLibCommonTargetProperties.cmake @@ -10,8 +10,8 @@ function(common_target_properties target) endif() get_target_property(__sources ${target} SOURCES) - foreach(__src IN LISTS __sources) - string(REGEX MATCH ".*/qrc_.*\\.cpp$" __qrc ${__src}) + foreach(src IN LISTS __sources) + string(REGEX MATCH ".*/qrc_.*\\.cpp$" __qrc ${src}) if(__qrc) set_property(SOURCE ${__qrc} PROPERTY COTIRE_EXCLUDED ON) endif() diff --git a/CMLibCompilerFlags.cmake b/CMLibCompilerFlags.cmake index 6ef5282..91d8eb9 100644 --- a/CMLibCompilerFlags.cmake +++ b/CMLibCompilerFlags.cmake @@ -68,9 +68,9 @@ if(LSB_DISTRIBUTOR_ID STREQUAL "AstraLinuxSE" AND # cmake-format: on cmlib_set_cxx_standard(11) - set(_CMAKE_TOOLCHAIN_PREFIX "x86_64-linux-gnu-") - set(_CMAKE_TOOLCHAIN_SUFFIX "-4.7") - set(_CMAKE_TOOLCHAIN_LOCATION "/usr/bin") + set(_CMAKE_TOOLCHAIN_PREFIX "x86_64-linux-gnu-" CACHE INTERNAL "" FORCE) + set(_CMAKE_TOOLCHAIN_SUFFIX "-4.7" CACHE INTERNAL "" FORCE) + set(_CMAKE_TOOLCHAIN_LOCATION "/usr/bin" CACHE INTERNAL "" FORCE) else() cmlib_set_cxx_standard(17) diff --git a/CMLibDisableInSourceBuild.cmake b/CMLibDisableInSourceBuild.cmake index d933ecc..180029f 100644 --- a/CMLibDisableInSourceBuild.cmake +++ b/CMLibDisableInSourceBuild.cmake @@ -14,8 +14,8 @@ endif() # Очистка от сгенерированных файлов file(GLOB_RECURSE _cmakelists_files RELATIVE ${_source_realpath} CMakeLists.txt) -foreach(_it ${_cmakelists_files}) - get_filename_component(_file ${_it} REALPATH) +foreach(it ${_cmakelists_files}) + get_filename_component(_file ${it} REALPATH) get_filename_component(_dir ${_file} DIRECTORY) file( REMOVE_RECURSE diff --git a/CMLibDistCC.cmake b/CMLibDistCC.cmake index cbce913..94c6476 100644 --- a/CMLibDistCC.cmake +++ b/CMLibDistCC.cmake @@ -1,10 +1,10 @@ find_program(DISTCC_EXECUTABLE distcc) mark_as_advanced(DISTCC_EXECUTABLE) if(DISTCC_EXECUTABLE) - foreach(LANG C CXX) - if(NOT DEFINED CMAKE_${LANG}_COMPILER_LAUNCHER AND NOT CMAKE_${LANG}_COMPILER MATCHES ".*/distcc$") - message(STATUS "Enabling distcc for ${LANG}") - set(CMAKE_${LANG}_COMPILER_LAUNCHER ${DISTCC_EXECUTABLE} CACHE STRING "") + foreach(lang C CXX) + if(NOT DEFINED CMAKE_${lang}_COMPILER_LAUNCHER AND NOT CMAKE_${lang}_COMPILER MATCHES ".*/distcc$") + message(STATUS "Enabling distcc for ${lang}") + set(CMAKE_${lang}_COMPILER_LAUNCHER ${DISTCC_EXECUTABLE} CACHE STRING "") endif() endforeach() endif() diff --git a/CMLibDocDoxygen.cmake b/CMLibDocDoxygen.cmake index 4ad62ef..31dcd2a 100644 --- a/CMLibDocDoxygen.cmake +++ b/CMLibDocDoxygen.cmake @@ -25,15 +25,15 @@ function(add_doxygen target) set(GENERATE_LATEX YES) endif() - set(WORK_DIR ${CMAKE_BINARY_DIR}/doc/doxygen) - configure_file(${CMAKE_SOURCE_DIR}/cmake/doc/Doxyfile.in ${WORK_DIR}/Doxyfile @ONLY) + set(work_dir ${CMAKE_BINARY_DIR}/doc/doxygen) + configure_file(${CMAKE_SOURCE_DIR}/cmake/doc/Doxyfile.in ${work_dir}/Doxyfile @ONLY) add_custom_target( ${target} VERBATIM - COMMAND "${CMAKE_COMMAND}" -E remove -f "${WORK_DIR}/doxygen_sqlite3.db" - COMMAND ${DOXYGEN_EXECUTABLE} ${WORK_DIR}/Doxyfile - WORKING_DIRECTORY ${WORK_DIR} + COMMAND "${CMAKE_COMMAND}" -E remove -f "${work_dir}/doxygen_sqlite3.db" + COMMAND ${DOXYGEN_EXECUTABLE} ${work_dir}/Doxyfile + WORKING_DIRECTORY ${work_dir} COMMENT "Generating API documentation with Doxygen") else() message(STATUS "CMLIB warning:") diff --git a/CMLibFlagRemove.cmake b/CMLibFlagRemove.cmake index f56caa2..43b7208 100644 --- a/CMLibFlagRemove.cmake +++ b/CMLibFlagRemove.cmake @@ -6,6 +6,7 @@ # # Pre: apply_global_cxx_flags_to_all_targets() must be invoked. # +# cmake-lint: disable=C0103 macro(remove_flag_from_target _target _flag) get_target_property(_target_cxx_flags ${_target} COMPILE_OPTIONS) if(_target_cxx_flags) @@ -22,6 +23,7 @@ endmacro() # # Pre: apply_global_cxx_flags_to_all_targets() must be invoked. # +# cmake-lint: disable=C0103 macro(remove_flag_from_file _target _file _flag) get_target_property(_target_sources ${_target} SOURCES) # Check if a sync is required, in which case we'll force a rewrite of the cache variables. diff --git a/CMLibGeneratePrivateConfigHPP.cmake b/CMLibGeneratePrivateConfigHPP.cmake index e5059c1..7348fc1 100644 --- a/CMLibGeneratePrivateConfigHPP.cmake +++ b/CMLibGeneratePrivateConfigHPP.cmake @@ -2,13 +2,13 @@ function(cmlib_generate_private_config_hpp) include(CMLibLargeFiles) cmlib_test_large_files(HAVE_LARGEFILES) - set(OUTPUT_FILE ${CMAKE_BINARY_DIR}/include/cmlib_private_config.hpp) + set(output_file ${CMAKE_BINARY_DIR}/include/cmlib_private_config.hpp) if(CMLIB_GENERATED_HEADERS_PATH) - set(OUTPUT_FILE ${CMLIB_GENERATED_HEADERS_PATH}/cmlib_private_config.hpp) + set(output_file ${CMLIB_GENERATED_HEADERS_PATH}/cmlib_private_config.hpp) elseif(ARGV0) - set(OUTPUT_FILE ${ARGV0}) + set(output_file ${ARGV0}) endif() get_property(PROJECT_VERSION_INT GLOBAL PROPERTY PROJECT_VERSION_INT) - configure_file(${CMLIB_MODULE_DIR}/hpp/cmlib_private_config.hpp.in ${OUTPUT_FILE}) + configure_file(${CMLIB_MODULE_DIR}/hpp/cmlib_private_config.hpp.in ${output_file}) endfunction() diff --git a/CMLibGlobalFunctions.cmake b/CMLibGlobalFunctions.cmake index 1852c00..2968ab9 100644 --- a/CMLibGlobalFunctions.cmake +++ b/CMLibGlobalFunctions.cmake @@ -1,14 +1,14 @@ -function(canonical_string INV OUTV) - string(TOUPPER ${INV} _arg_uppercase) +function(canonical_string in_string out_string) + string(TOUPPER ${in_string} _arg_uppercase) string(REGEX REPLACE "[ -]" "_" _arg_fixed ${_arg_uppercase}) - set(${OUTV} ${_arg_fixed} PARENT_SCOPE) + set(${out_string} ${_arg_fixed} PARENT_SCOPE) endfunction() # Добавление общего префикса ко всем переменным в списке function(list_transform_prepend var prefix) set(temp "") - foreach(f ${${var}}) - list(APPEND temp "${prefix}${f}") + foreach(filename ${${var}}) + list(APPEND temp "${prefix}${filename}") endforeach() set(${var} "${temp}" PARENT_SCOPE) endfunction() diff --git a/CMLibGlobalVariables.cmake b/CMLibGlobalVariables.cmake index d2d11b2..8e289e5 100644 --- a/CMLibGlobalVariables.cmake +++ b/CMLibGlobalVariables.cmake @@ -8,9 +8,9 @@ string(TOUPPER ${CMLIB_ORGANIZATION_NAME_CANONICAL} CMLIB_ORGANIZATION_NAME_UPPE string(TOUPPER ${CMLIB_PROJECT_NAME_CANONICAL} CMLIB_PROJECT_NAME_UPPER) # CMLIB_MODULE_DIR -foreach(_m ${CMAKE_MODULE_PATH}) - if(EXISTS ${_m}/CMLibCommon.cmake) - get_filename_component(CMLIB_MODULE_DIR ${_m}/CMLibCommon.cmake DIRECTORY) +foreach(module ${CMAKE_MODULE_PATH}) + if(EXISTS ${module}/CMLibCommon.cmake) + get_filename_component(CMLIB_MODULE_DIR ${module}/CMLibCommon.cmake DIRECTORY) break() endif() endforeach() diff --git a/CMLibLargeFiles.cmake b/CMLibLargeFiles.cmake index 446b171..31b51b5 100644 --- a/CMLibLargeFiles.cmake +++ b/CMLibLargeFiles.cmake @@ -129,6 +129,7 @@ macro(cmlib_test_large_files VARIABLE) endif() endif() + # cmake-lint: disable=C0103 if(NOT FILE64_OK) # now check for Windows stuff try_compile(FILE64_OK "${CMAKE_BINARY_DIR}" "${CMLIB_MODULE_DIR}/tests/TestWindowsFSeek.c") diff --git a/CMLibQtTranslation.cmake b/CMLibQtTranslation.cmake index ba213ff..23260a9 100644 --- a/CMLibQtTranslation.cmake +++ b/CMLibQtTranslation.cmake @@ -11,22 +11,22 @@ function(qt5_translation outfiles) set(_output_dir ${_QTTR_OUTPUT_DIR}) set(_languages ${_QTTR_LANGUAGES}) - set(L10N_QRC_BODY "") + set(_l10n_qrc_body "") make_directory(${_output_dir}) - foreach(_lang ${_languages}) - set(_ts "${_base_name}_${_lang}.ts") - set(_qm "${_base_name}_${_lang}.qm") + foreach(lang ${_languages}) + set(_ts "${_base_name}_${lang}.ts") + set(_qm "${_base_name}_${lang}.qm") list(APPEND _ts_list ${_output_dir}/${_ts}) - list(APPEND _l10n_names_list "${_base_name}_l10n_${_lang}") - string(APPEND L10N_QRC_BODY "${CMAKE_BINARY_DIR}/${_qm}\n") + list(APPEND _l10n_names_list "${_base_name}_l10n_${lang}") + string(APPEND _l10n_qrc_body "${CMAKE_BINARY_DIR}/${_qm}\n") add_custom_target( - ${_base_name}_l10n_${_lang} COMMAND ${Qt5_LUPDATE_EXECUTABLE} ${_sources} -ts ${_output_dir}/${_ts} - -target-language ${_lang} DEPENDS ${_sources}) + ${_base_name}_l10n_${lang} COMMAND ${Qt5_LUPDATE_EXECUTABLE} ${_sources} -ts ${_output_dir}/${_ts} + -target-language ${lang} DEPENDS ${_sources}) if(NOT EXISTS "${_output_dir}/${_ts}") - add_custom_target(${_ts} DEPENDS ${_base_name}_l10n_${_lang}) + add_custom_target(${_ts} DEPENDS ${_base_name}_l10n_${lang}) else() add_custom_target(${_ts} COMMAND echo "Skipping lupdate for ${_ts}") endif()