diff --git a/MyxCMake/MyxCMakeConfig.cmake b/MyxCMake/MyxCMakeConfig.cmake index 13e1632..73b80d5 100644 --- a/MyxCMake/MyxCMakeConfig.cmake +++ b/MyxCMake/MyxCMakeConfig.cmake @@ -24,7 +24,7 @@ set(MYX_CMAKE_LIB_DIR "${MYX_CMAKE_SOURCE_DIR}/lib") # Модули для обеспечения обратной совместимости со старыми версиями CMake include(${MYX_CMAKE_BACKPORTS_DIR}/IncludeGuard.cmake) -if(${CMAKE_VERSION} VERSION_LESS "3.11.0") +if(${CMAKE_VERSION} VERSION_LESS 3.11) include(${MYX_CMAKE_BACKPORTS_DIR}/FetchContent.cmake) else() include(FetchContent) diff --git a/MyxCMake/lib/AddExecutable.cmake b/MyxCMake/lib/AddExecutable.cmake index 5d78070..d384ade 100644 --- a/MyxCMake/lib/AddExecutable.cmake +++ b/MyxCMake/lib/AddExecutable.cmake @@ -14,7 +14,7 @@ myx_add_executable include_guard(GLOBAL) function(myx_add_executable TARGET_NAME) - if(${CMAKE_VERSION} VERSION_LESS "3.11.0") + if(${CMAKE_VERSION} VERSION_LESS 3.11.0) add_executable(${TARGET_NAME} ${ARGN} "") else() add_executable(${TARGET_NAME} ${ARGN}) diff --git a/MyxCMake/lib/AddInterfaceLibrary.cmake b/MyxCMake/lib/AddInterfaceLibrary.cmake index a5298ea..98fb9fd 100644 --- a/MyxCMake/lib/AddInterfaceLibrary.cmake +++ b/MyxCMake/lib/AddInterfaceLibrary.cmake @@ -20,12 +20,12 @@ include_guard(GLOBAL) include(CMakePackageConfigHelpers) -if(${CMAKE_VERSION} VERSION_LESS "3.17.0") +if(${CMAKE_VERSION} VERSION_LESS 3.17) set(MYX_CMAKE_LIB_DIR_BACKPORT "${CMAKE_CURRENT_LIST_DIR}") endif() function(myx_add_interface_library TARGET_NAME) - if(${CMAKE_VERSION} VERSION_LESS "3.17.0") + if(${CMAKE_VERSION} VERSION_LESS 3.17) set(CMAKE_CURRENT_FUNCTION_LIST_DIR ${MYX_CMAKE_LIB_DIR_BACKPORT}) endif() @@ -43,7 +43,7 @@ function(myx_add_interface_library TARGET_NAME) endif() # Вызов стандартной функции `add_library()` - if(${CMAKE_VERSION} VERSION_LESS "3.19.0") + if(${CMAKE_VERSION} VERSION_LESS 3.19) add_library(${TARGET_NAME} INTERFACE) target_sources(${TARGET_NAME} INTERFACE $) else() @@ -66,7 +66,7 @@ function(myx_add_interface_library TARGET_NAME) target_include_directories(${TARGET_NAME} INTERFACE ${include_dirs}) endif() endif() - if(${CMAKE_VERSION} VERSION_GREATER "3.13.0") + if(${CMAKE_VERSION} VERSION_GREATER 3.13) install(TARGETS ${lib} EXPORT ${TARGET_NAME}Targets COMPONENT DEV) @@ -97,7 +97,7 @@ function(myx_add_interface_library TARGET_NAME) # При этом сама цель `${TARGET_NAME}` может участвовать в сборке, # если окажется в перечне зависимостей. if(NOT PROJECT_IS_TOP_LEVEL) - if(${CMAKE_VERSION} VERSION_GREATER "3.17.0") + if(${CMAKE_VERSION} VERSION_GREATER 3.17) set_target_properties(${TARGET_NAME} PROPERTIES EXCLUDE_FROM_ALL True) else() set_target_properties(${TARGET_NAME} PROPERTIES INTERFACE_EXCLUDE_FROM_ALL True) @@ -122,7 +122,7 @@ function(myx_add_interface_library TARGET_NAME) NO_CHECK_REQUIRED_COMPONENTS_MACRO ) - if(${CMAKE_VERSION} VERSION_GREATER "3.13.0") + if(${CMAKE_VERSION} VERSION_GREATER 3.13) install( EXPORT ${TARGET_NAME}Targets DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${TARGET_NAME} @@ -157,7 +157,7 @@ function(myx_add_interface_library TARGET_NAME) # Установка библиотеки из заголовочных файлов target_include_directories(${TARGET_NAME} SYSTEM INTERFACE $) - if(${CMAKE_VERSION} VERSION_GREATER "3.13.0") + if(${CMAKE_VERSION} VERSION_GREATER 3.13) install( TARGETS ${TARGET_NAME} EXPORT ${TARGET_NAME}Targets diff --git a/MyxCMake/lib/AddObjectLibrary.cmake b/MyxCMake/lib/AddObjectLibrary.cmake index 0005f6c..1d43ee5 100644 --- a/MyxCMake/lib/AddObjectLibrary.cmake +++ b/MyxCMake/lib/AddObjectLibrary.cmake @@ -21,12 +21,12 @@ myx_add_object_library include_guard(GLOBAL) -if(${CMAKE_VERSION} VERSION_LESS "3.17.0") +if(${CMAKE_VERSION} VERSION_LESS 3.17) set(MYX_CMAKE_LIB_DIR_BACKPORT "${CMAKE_CURRENT_LIST_DIR}") endif() function(myx_add_object_library TARGET_NAME) - if(${CMAKE_VERSION} VERSION_LESS "3.17.0") + if(${CMAKE_VERSION} VERSION_LESS 3.17) set(CMAKE_CURRENT_FUNCTION_LIST_DIR ${MYX_CMAKE_LIB_DIR_BACKPORT}) endif() diff --git a/MyxCMake/lib/NinjaGeneratorWarning.cmake b/MyxCMake/lib/NinjaGeneratorWarning.cmake index a07ee69..7ef9ddd 100644 --- a/MyxCMake/lib/NinjaGeneratorWarning.cmake +++ b/MyxCMake/lib/NinjaGeneratorWarning.cmake @@ -1,8 +1,7 @@ -# Версии CMake, как минимум до 3.8.0, генерируют некорректные -# правила для ninja. +# Версии CMake, как минимум до 3.8, генерируют некорректные правила для ninja. include_guard(GLOBAL) -if(${CMAKE_VERSION} VERSION_LESS "3.8.0" AND CMAKE_GENERATOR MATCHES Ninja) +if(${CMAKE_VERSION} VERSION_LESS 3.8 AND CMAKE_GENERATOR MATCHES Ninja) myx_message_send_error("Myx: Old CMake versions should use Makefile generator") endif() diff --git a/MyxCMake/lib/TargetSetup.cmake b/MyxCMake/lib/TargetSetup.cmake index c7dd3e7..11f3d7c 100644 --- a/MyxCMake/lib/TargetSetup.cmake +++ b/MyxCMake/lib/TargetSetup.cmake @@ -88,29 +88,29 @@ function(myx_target_setup TARGET_NAME) (NOT ${target_type} STREQUAL "EXECUTABLE")) target_link_libraries(${TARGET_NAME} PRIVATE ${ARG_LINK_LIBRARIES}) else() - foreach(__link_library ${ARG_LINK_LIBRARIES}) - if(TARGET ${__link_library}) - get_target_property(__lib_type ${__link_library} TYPE) - if(__lib_type) - get_target_property(__include_dirs ${__link_library} INTERFACE_INCLUDE_DIRECTORIES) - if(__include_dirs) - target_include_directories(${TARGET_NAME} PUBLIC ${__include_dirs}) + foreach(link_library ${ARG_LINK_LIBRARIES}) + if(TARGET ${link_library}) + get_target_property(library_type ${link_library} TYPE) + if(library_type) + get_target_property(include_dirs ${link_library} INTERFACE_INCLUDE_DIRECTORIES) + if(include_dirs) + target_include_directories(${TARGET_NAME} PUBLIC ${include_dirs}) endif() if(${target_type} STREQUAL "EXECUTABLE") - if(${__lib_type} STREQUAL "OBJECT_LIBRARY") - if(TARGET ${__link_library}_static) - target_link_libraries(${TARGET_NAME} PRIVATE ${__link_library}_static) + if(${library_type} STREQUAL "OBJECT_LIBRARY") + if(TARGET ${link_library}_static) + target_link_libraries(${TARGET_NAME} PRIVATE ${link_library}_static) else() - target_link_libraries(${TARGET_NAME} PRIVATE ${__link_library}_shared) - endif() + target_link_libraries(${TARGET_NAME} PRIVATE ${link_library}_shared) + endif() else() - target_link_libraries(${TARGET_NAME} PRIVATE ${__link_library}) + target_link_libraries(${TARGET_NAME} PRIVATE ${link_library}) endif() endif() endif() else() if((${CMAKE_VERSION} VERSION_GREATER "3.7.99") OR (NOT target_type STREQUAL "OBJECT_LIBRARY")) - target_link_libraries(${TARGET_NAME} PRIVATE ${__link_library}) + target_link_libraries(${TARGET_NAME} PRIVATE ${link_library}) endif() endif() endforeach() diff --git a/MyxCMake/lib/TargetSetupQt.cmake b/MyxCMake/lib/TargetSetupQt.cmake index 1838e74..6ff2163 100644 --- a/MyxCMake/lib/TargetSetupQt.cmake +++ b/MyxCMake/lib/TargetSetupQt.cmake @@ -30,7 +30,7 @@ function(myx_target_setup_qt TARGET_NAME) if(target_type STREQUAL "SHARED_LIBRARY") target_link_libraries(${TARGET_NAME} PUBLIC Qt${myx_qt_ver}::${iter}) endif() - if((${CMAKE_VERSION} VERSION_GREATER "3.8.0") AND (target_type STREQUAL "OBJECT_LIBRARY")) + if((${CMAKE_VERSION} VERSION_GREATER 3.8.0) AND (target_type STREQUAL "OBJECT_LIBRARY")) target_link_libraries(${TARGET_NAME} PUBLIC Qt${myx_qt_ver}::${iter}) else() target_include_directories(${TARGET_NAME} PUBLIC ${Qt${myx_qt_ver}${iter}_INCLUDE_DIRS}) diff --git a/MyxCMake/lib/doc/Doxygen.cmake b/MyxCMake/lib/doc/Doxygen.cmake index abc3072..0abd9f4 100644 --- a/MyxCMake/lib/doc/Doxygen.cmake +++ b/MyxCMake/lib/doc/Doxygen.cmake @@ -1,11 +1,11 @@ -if(${CMAKE_VERSION} VERSION_LESS "3.17.0") +if(${CMAKE_VERSION} VERSION_LESS 3.17) set(MYX_CMAKE_LIB_DOC_DIR_BACKPORT "${CMAKE_CURRENT_LIST_DIR}") endif() find_package(Doxygen QUIET) function(myx_doc_doxygen TARGET_NAME) - if(${CMAKE_VERSION} VERSION_LESS "3.17.0") + if(${CMAKE_VERSION} VERSION_LESS 3.17) set(CMAKE_CURRENT_FUNCTION_LIST_DIR ${MYX_CMAKE_LIB_DOC_DIR_BACKPORT}) endif() diff --git a/MyxCMake/lib/generators/GitInfoHeader.cmake b/MyxCMake/lib/generators/GitInfoHeader.cmake index 9fd35a3..1c812e9 100644 --- a/MyxCMake/lib/generators/GitInfoHeader.cmake +++ b/MyxCMake/lib/generators/GitInfoHeader.cmake @@ -17,12 +17,12 @@ myx_generate_git_info_header include_guard(GLOBAL) -if(${CMAKE_VERSION} VERSION_LESS "3.17.0") +if(${CMAKE_VERSION} VERSION_LESS 3.17.0) set(MYX_CMAKE_LIB_GENERATORS_DIR_BACKPORT "${CMAKE_CURRENT_LIST_DIR}") endif() function(myx_generate_git_info_header TARGET_NAME BASE_FILENAME) - if(${CMAKE_VERSION} VERSION_LESS "3.17.0") + if(${CMAKE_VERSION} VERSION_LESS 3.17.0) set(CMAKE_CURRENT_FUNCTION_LIST_DIR ${MYX_CMAKE_LIB_GENERATORS_DIR_BACKPORT}) endif() diff --git a/MyxCMake/lib/generators/PrivateConfigHeader.cmake b/MyxCMake/lib/generators/PrivateConfigHeader.cmake index e9d3201..641b287 100644 --- a/MyxCMake/lib/generators/PrivateConfigHeader.cmake +++ b/MyxCMake/lib/generators/PrivateConfigHeader.cmake @@ -14,12 +14,12 @@ myx_generate_private_config_header include_guard(GLOBAL) -if(${CMAKE_VERSION} VERSION_LESS "3.17.0") +if(${CMAKE_VERSION} VERSION_LESS 3.17.0) set(MYX_CMAKE_LIB_GENERATORS_DIR_BACKPORT "${CMAKE_CURRENT_LIST_DIR}") endif() function(myx_generate_private_config_header TARGET_NAME BASE_FILENAME) - if(${CMAKE_VERSION} VERSION_LESS "3.17.0") + if(${CMAKE_VERSION} VERSION_LESS 3.17.0) set(CMAKE_CURRENT_FUNCTION_LIST_DIR ${MYX_CMAKE_LIB_GENERATORS_DIR_BACKPORT}) endif() @@ -27,14 +27,14 @@ function(myx_generate_private_config_header TARGET_NAME BASE_FILENAME) myx_project_version_int() get_property(PROJECT_VERSION_INT GLOBAL PROPERTY PROJECT_VERSION_INT) - set(__filename "${PROJECT_BINARY_DIR}/include/${BASE_FILENAME}") - configure_file("${CMAKE_CURRENT_FUNCTION_LIST_DIR}/PrivateConfig.hpp.in" ${__filename}) + set(filename "${PROJECT_BINARY_DIR}/include/${BASE_FILENAME}") + configure_file("${CMAKE_CURRENT_FUNCTION_LIST_DIR}/PrivateConfig.hpp.in" ${filename}) - set_property(TARGET ${TARGET_NAME} APPEND PROPERTY PRIVATE_HEADER_FILES ${__filename}) - get_target_property(__target_type ${TARGET_NAME} TYPE) - if(${__target_type} STREQUAL "INTERFACE_LIBRARY") - target_sources(${TARGET_NAME} INTERFACE ${__filename}) + set_property(TARGET ${TARGET_NAME} APPEND PROPERTY PRIVATE_HEADER_FILES ${filename}) + get_target_property(target_type ${TARGET_NAME} TYPE) + if(${target_type} STREQUAL "INTERFACE_LIBRARY") + target_sources(${TARGET_NAME} INTERFACE ${filename}) else() - target_sources(${TARGET_NAME} PRIVATE ${__filename}) + target_sources(${TARGET_NAME} PRIVATE ${filename}) endif() endfunction() diff --git a/MyxCMake/lib/macro/CheckEnableCxxCompilerFlag.cmake b/MyxCMake/lib/macro/CheckEnableCxxCompilerFlag.cmake index eb24c11..d5d398e 100644 --- a/MyxCMake/lib/macro/CheckEnableCxxCompilerFlag.cmake +++ b/MyxCMake/lib/macro/CheckEnableCxxCompilerFlag.cmake @@ -27,8 +27,8 @@ macro(check_enable_cxx_compiler_flag FLAG) endif() unset(check_cxx_flag CACHE) - foreach(__iter IN LISTS oneValueArgs multiValueArgs) - unset(ARG_${__iter}) + foreach(iter IN LISTS oneValueArgs multiValueArgs) + unset(ARG_${iter}) endforeach() unset(ARG_UNPARSED_ARGUMENTS) unset(multiValueArgs) diff --git a/MyxCMake/lib/macro/CreateSymlink.cmake b/MyxCMake/lib/macro/CreateSymlink.cmake index 15b7e44..0efd936 100644 --- a/MyxCMake/lib/macro/CreateSymlink.cmake +++ b/MyxCMake/lib/macro/CreateSymlink.cmake @@ -3,7 +3,7 @@ include_guard(GLOBAL) # Создание символических ссылок macro(myx_create_symlink ORIGINAL_FILENAME LINKNAME) if(UNIX AND (NOT EXISTS ${LINKNAME})) - if(${CMAKE_VERSION} VERSION_LESS "3.14.0") + if(${CMAKE_VERSION} VERSION_LESS 3.14.0) execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink ${ORIGINAL_FILENAME} ${LINKNAME}) else() diff --git a/MyxCMake/lib/macro/FindPackages.cmake b/MyxCMake/lib/macro/FindPackages.cmake index b18d17b..d28a187 100644 --- a/MyxCMake/lib/macro/FindPackages.cmake +++ b/MyxCMake/lib/macro/FindPackages.cmake @@ -52,8 +52,8 @@ macro(myx_find_packages) endforeach() endif() - foreach(__iter IN LISTS oneValueArgs multiValueArgs) - unset(ARG_${__iter}) + foreach(iter IN LISTS oneValueArgs multiValueArgs) + unset(ARG_${iter}) endforeach() unset(ARG_UNPARSED_ARGUMENTS) unset(multiValueArgs) diff --git a/MyxCMake/lib/macro/FindQt.cmake b/MyxCMake/lib/macro/FindQt.cmake index 27a5fb5..7e09d2d 100644 --- a/MyxCMake/lib/macro/FindQt.cmake +++ b/MyxCMake/lib/macro/FindQt.cmake @@ -30,8 +30,8 @@ macro(myx_find_qt) find_package("Qt${ARG_VERSION}${iter}" COMPONENTS Private ${ARG_REQUIRED}) endforeach() - foreach(__iter IN LISTS oneValueArgs multiValueArgs) - unset(ARG_${__iter}) + foreach(iter IN LISTS oneValueArgs multiValueArgs) + unset(ARG_${iter}) endforeach() unset(ARG_UNPARSED_ARGUMENTS) unset(multiValueArgs) diff --git a/MyxCMake/lib/macro/GTest.cmake b/MyxCMake/lib/macro/GTest.cmake index 9ff6b92..d7b7aae 100644 --- a/MyxCMake/lib/macro/GTest.cmake +++ b/MyxCMake/lib/macro/GTest.cmake @@ -19,8 +19,8 @@ macro(myx_add_gtest TARGET_NAME) endif() add_test(NAME ${TARGET_NAME} COMMAND ${TARGET_NAME}) - foreach(__iter IN LISTS oneValueArgs multiValueArgs) - unset(ARG_${__iter}) + foreach(iter IN LISTS oneValueArgs multiValueArgs) + unset(ARG_${iter}) endforeach() unset(ARG_UNPARSED_ARGUMENTS) unset(multiValueArgs) diff --git a/MyxCMake/lib/macro/QTest.cmake b/MyxCMake/lib/macro/QTest.cmake index 99478cd..2750443 100644 --- a/MyxCMake/lib/macro/QTest.cmake +++ b/MyxCMake/lib/macro/QTest.cmake @@ -29,8 +29,8 @@ macro(myx_add_qtest TARGET_NAME) unset(hpps) unset(moc) unset(mocs) - foreach(__iter IN LISTS oneValueArgs multiValueArgs) - unset(ARG_${__iter}) + foreach(iter IN LISTS oneValueArgs multiValueArgs) + unset(ARG_${iter}) endforeach() unset(ARG_UNPARSED_ARGUMENTS) unset(multiValueArgs) diff --git a/MyxCMake/lib/uncrustify/Uncrustify.cmake b/MyxCMake/lib/uncrustify/Uncrustify.cmake index 8cd9b88..c7b01da 100644 --- a/MyxCMake/lib/uncrustify/Uncrustify.cmake +++ b/MyxCMake/lib/uncrustify/Uncrustify.cmake @@ -1,11 +1,11 @@ -if(${CMAKE_VERSION} VERSION_LESS "3.17.0") +if(${CMAKE_VERSION} VERSION_LESS 3.17.0) set(MYX_CMAKE_LIB_UNCRUSTIFY_DIR_BACKPORT "${CMAKE_CURRENT_LIST_DIR}") endif() find_program(UNCRUSTIFY_EXE NAMES uncrustify) function(myx_uncrustify TARGET_NAME) - if(${CMAKE_VERSION} VERSION_LESS "3.17.0") + if(${CMAKE_VERSION} VERSION_LESS 3.17.0) set(CMAKE_CURRENT_FUNCTION_LIST_DIR ${MYX_CMAKE_LIB_UNCRUSTIFY_DIR_BACKPORT}) endif() @@ -45,50 +45,50 @@ function(myx_uncrustify TARGET_NAME) endif() # Динамически сгенерированные файлы исключаются - get_target_property(__target_type ${TARGET_NAME} TYPE) - if((${__target_type} STREQUAL "INTERFACE_LIBRARY") AND (${CMAKE_VERSION} VERSION_LESS "3.17.0")) - get_target_property(__s1 ${TARGET_NAME} INTERFACE_SOURCES) - if(__s1) - list(APPEND __all_sources ${__s1}) + get_target_property(target_type ${TARGET_NAME} TYPE) + if((${target_type} STREQUAL "INTERFACE_LIBRARY") AND (${CMAKE_VERSION} VERSION_LESS 3.17.0)) + get_target_property(target_sources ${TARGET_NAME} INTERFACE_SOURCES) + if(target_sources) + list(APPEND all_sources ${target_sources}) endif() else() - get_target_property(__s2 ${TARGET_NAME} SOURCES) - if(__s2) - list(APPEND __all_sources ${__s2}) + get_target_property(target_sources ${TARGET_NAME} SOURCES) + if(target_sources) + list(APPEND all_sources ${target_sources}) endif() endif() - foreach(iter ${__all_sources}) + foreach(iter ${all_sources}) string(FIND ${iter} ${CMAKE_BINARY_DIR} pos) if(pos EQUAL -1) - list(APPEND __sources ${iter}) + list(APPEND sources ${iter}) endif() endforeach() - set(__fixed_config ${PROJECT_BINARY_DIR}/uncrustify-${TARGET_NAME}.cfg) - add_custom_command(OUTPUT ${__fixed_config} + set(fixed_config ${PROJECT_BINARY_DIR}/uncrustify-${TARGET_NAME}.cfg) + add_custom_command(OUTPUT ${fixed_config} DEPENDS ${ARG_CONFIG} COMMAND ${UNCRUSTIFY_EXE} --update-config-with-doc - -c ${ARG_CONFIG} -o ${__fixed_config}) - list(APPEND __options -c ${__fixed_config}) + -c ${ARG_CONFIG} -o ${fixed_config}) + list(APPEND options -c ${fixed_config}) # cmake-format: off add_custom_target(${TARGET_NAME}-uncrustify-check - DEPENDS ${__fixed_config} - COMMAND ${UNCRUSTIFY_EXE} ${__options} --check ${__sources}) + DEPENDS ${fixed_config} + COMMAND ${UNCRUSTIFY_EXE} ${options} --check ${sources}) - list(APPEND __options --replace --no-backup) + list(APPEND options --replace --no-backup) add_custom_target(${TARGET_NAME}-uncrustify - DEPENDS ${__fixed_config} - COMMAND ${UNCRUSTIFY_EXE} ${__options} --mtime ${__sources}) + DEPENDS ${fixed_config} + COMMAND ${UNCRUSTIFY_EXE} ${options} --mtime ${sources}) add_custom_target(${TARGET_NAME}-uncrustify-append-comments - DEPENDS ${__fixed_config} - COMMAND ${UNCRUSTIFY_EXE} ${__options} + DEPENDS ${fixed_config} + COMMAND ${UNCRUSTIFY_EXE} ${options} --set cmt_insert_class_header=${CMAKE_CURRENT_FUNCTION_LIST_DIR}/classheader.txt --set cmt_insert_file_footer=${CMAKE_CURRENT_FUNCTION_LIST_DIR}/filefooter.txt --set cmt_insert_file_header=${CMAKE_CURRENT_FUNCTION_LIST_DIR}/fileheader.txt --set cmt_insert_func_header=${CMAKE_CURRENT_FUNCTION_LIST_DIR}/funcheader.txt - --set cmt_insert_before_ctor_dtor=true --mtime ${__sources}) + --set cmt_insert_before_ctor_dtor=true --mtime ${sources}) # cmake-format: on add_dependencies(myx-uncrustify ${TARGET_NAME}-uncrustify)