Чистка

This commit is contained in:
Andrei Astafev 2021-06-12 12:59:31 +03:00
parent cfad412b21
commit b3ad740ab8
14 changed files with 49 additions and 47 deletions

View File

@ -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_]+'

View File

@ -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}")

View File

@ -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 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include> $<INSTALL_INTERFACE:include/${target}>)
@ -22,7 +21,7 @@ function(add_common_library target)
# cmake-format: off
if(BUILD_SHARED_LIBS)
add_library(${target}_shared SHARED $<TARGET_OBJECTS:${target}>)
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 $<TARGET_OBJECTS:${target}>)
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()

View File

@ -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()

View File

@ -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)

View File

@ -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

View File

@ -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()

View File

@ -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:")

View File

@ -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.

View File

@ -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()

View File

@ -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()

View File

@ -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()

View File

@ -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")

View File

@ -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 "<file alias=\"${_qm}\">${CMAKE_BINARY_DIR}/${_qm}</file>\n")
list(APPEND _l10n_names_list "${_base_name}_l10n_${lang}")
string(APPEND _l10n_qrc_body "<file alias=\"${_qm}\">${CMAKE_BINARY_DIR}/${_qm}</file>\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()