From 97ccbf69ac97d1116976853d57a555ec5b40ff02 Mon Sep 17 00:00:00 2001 From: Andrey Astafyev Date: Mon, 7 Oct 2019 13:52:50 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A4=D0=BE=D1=80=D0=BC=D0=B0=D1=82=D0=B8?= =?UTF-8?q?=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20=D1=81=20=D0=BF?= =?UTF-8?q?=D0=BE=D0=BC=D0=BE=D1=89=D1=8C=D1=8E=20https://github.com/chesh?= =?UTF-8?q?irekow/cmake=5Fformat?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .cmake-format | 151 +++++++++++++++++++++++++ CMLibBuildTypes.cmake | 29 +++-- CMLibCPackSources.cmake | 5 +- CMLibCodeAnalysisClangAnalyze.cmake | 22 ++-- CMLibCodeAnalysisClangTidy.cmake | 21 ++-- CMLibCodeAnalysisClazy.cmake | 13 ++- CMLibCodeAnalysisPvsStudio.cmake | 17 +-- CMLibCommon.cmake | 1 - CMLibCommonLibraryTarget.cmake | 38 ++++--- CMLibCommonTargetProperties.cmake | 36 +++--- CMLibCompiler.cmake | 7 +- CMLibCompilerFeaturesHPPGenerate.cmake | 31 +++-- CMLibCompilerFlags.cmake | 21 ++-- CMLibDisableInSourceBuild.cmake | 14 +-- CMLibDistCC.cmake | 3 +- CMLibDocBreathe.cmake | 59 +++++++--- CMLibDocDoxygen.cmake | 36 ++++-- CMLibFlagRemove.cmake | 40 ++++--- CMLibFormatSources.cmake | 8 +- CMLibGlobalVariables.cmake | 7 +- CMLibLSBInfo.cmake | 3 +- CMLibLargeFiles.cmake | 74 ++++++------ CMLibOrganizationName.cmake | 10 +- CMLibProjectVersion.cmake | 4 +- CMLibQtTranslation.cmake | 24 ++-- CMLibSanitizers.cmake | 1 - CMLibToday.cmake | 6 +- CMLibUninstall.cmake | 8 +- 28 files changed, 461 insertions(+), 228 deletions(-) create mode 100644 .cmake-format diff --git a/.cmake-format b/.cmake-format new file mode 100644 index 0000000..437a153 --- /dev/null +++ b/.cmake-format @@ -0,0 +1,151 @@ + +# -------------------------- +# General Formatting Options +# -------------------------- +# How wide to allow formatted cmake files +line_width = 100 + +# How many spaces to tab for indent +tab_size = 2 + +# If arglists are longer than this, break them always +max_subargs_per_line = 3 + +# If true, separate flow control names from their parentheses with a space +separate_ctrl_name_with_space = False + +# If true, separate function names from parentheses with a space +separate_fn_name_with_space = False + +# If a statement is wrapped to more than one line, than dangle the closing +# parenthesis on it's own line +dangle_parens = False + +# If the statement spelling length (including space and parenthesis is larger +# than the tab width by more than this amoung, then force reject un-nested +# layouts. +max_prefix_chars = 2 + +# If a candidate layout is wrapped horizontally but it exceeds this many lines, +# then reject the layout. +max_lines_hwrap = 2 + +# What style line endings to use in the output. +line_ending = 'unix' + +# Format command names consistently as 'lower' or 'upper' case +command_case = 'canonical' + +# Format keywords consistently as 'lower' or 'upper' case +keyword_case = 'upper' + +# Specify structure for custom cmake functions +additional_commands = { + "foo": { + "flags": [ + "BAR", + "BAZ" + ], + "kwargs": { + "HEADERS": "*", + "SOURCES": "*", + "DEPENDS": "*" + } + }, + "pvs_studio_add_target" : { + "flags": [ + "COMPILE_COMMANDS", + "OUTPUT", + "HIDE_HELP" + ], + "kwargs": { + "TARGET": "*", + "DEPENDS": "*", + "FORMAT": "*", + "CONFIG": "*", + "ARGS": "*", + "MODE": "*" + } + }, + "write_compiler_detection_header" : { + "flags": [ ], + "kwargs": { + "FILE": "*", + "PREFIX": "*", + "COMPILERS": "*", + "FEATURES": "*" + } + } +} + +# A list of command names which should always be wrapped +always_wrap = [] + +# Specify the order of wrapping algorithms during successive reflow attempts +algorithm_order = [0, 1, 2, 3, 4] + +# If true, the argument lists which are known to be sortable will be sorted +# lexicographicall +enable_sort = True + +# If true, the parsers may infer whether or not an argument list is sortable +# (without annotation). +autosort = False + +# If a comment line starts with at least this many consecutive hash characters, +# then don't lstrip() them off. This allows for lazy hash rulers where the first +# hash char is not separated by space +hashruler_min_length = 10 + +# A dictionary containing any per-command configuration overrides. Currently +# only `command_case` is supported. +per_command = {} + + +# -------------------------- +# Comment Formatting Options +# -------------------------- +# What character to use for bulleted lists +bullet_char = '*' + +# What character to use as punctuation after numerals in an enumerated list +enum_char = '.' + +# enable comment markup parsing and reflow +enable_markup = False + +# If comment markup is enabled, don't reflow the first comment block in each +# listfile. Use this to preserve formatting of your copyright/license +# statements. +first_comment_is_literal = False + +# If comment markup is enabled, don't reflow any comment block which matches +# this (regex) pattern. Default is `None` (disabled). +literal_comment_pattern = None + +# Regular expression to match preformat fences in comments +# default=r'^\s*([`~]{3}[`~]*)(.*)$' +fence_pattern = '^\\s*([`~]{3}[`~]*)(.*)$' + +# Regular expression to match rulers in comments +# default=r'^\s*[^\w\s]{3}.*[^\w\s]{3}$' +ruler_pattern = '^\\s*[^\\w\\s]{3}.*[^\\w\\s]{3}$' + +# If true, then insert a space between the first hash char and remaining hash +# chars in a hash ruler, and normalize it's length to fill the column +canonicalize_hashrulers = True + + +# --------------------------------- +# Miscellaneous Options +# --------------------------------- +# If true, emit the unicode byte-order mark (BOM) at the start of the file +emit_byteorder_mark = False + +# Specify the encoding of the input file. Defaults to utf-8. +input_encoding = 'utf-8' + +# Specify the encoding of the output file. Defaults to utf-8. Note that cmake +# only claims to support utf-8 so be careful when using anything else +output_encoding = 'utf-8' + diff --git a/CMLibBuildTypes.cmake b/CMLibBuildTypes.cmake index 244285e..9a78bc7 100644 --- a/CMLibBuildTypes.cmake +++ b/CMLibBuildTypes.cmake @@ -6,7 +6,13 @@ if(CMAKE_CONFIGURATION_TYPES) list(APPEND CMAKE_CONFIGURATION_TYPES Profile) endif() else() - set(_allowed_build_types None Debug Release Profile RelWithDebInfo MinSizeRel) + set(_allowed_build_types + None + Debug + Release + Profile + RelWithDebInfo + MinSizeRel) set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS ${_allowed_build_types}) if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Debug CACHE STRING "" FORCE) @@ -17,16 +23,18 @@ endif() if(CMAKE_BUILD_TYPE STREQUAL Profile) # Ключи компиляции для режима профилирования в зависимости от типа компилятора - if (CMAKE_CXX_COMPILER_IS_Clang OR CMAKE_CXX_COMPILER_IS_GCC) - set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE} -g -p" CACHE STRING "") - set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE} -g -p" CACHE STRING "") - set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -g -p" CACHE STRING "") - set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}" CACHE STRING "") - set(CMAKE_STATIC_LINKER_FLAGS_PROFILE "${CMAKE_STATIC_LINKER_FLAGS_RELEASE}" CACHE STRING "") - set(CMAKE_MODULE_LINKER_FLAGS_PROFILE "${CMAKE_MODULE_LINKER_FLAGS_RELEASE} -g -p" CACHE STRING "") - elseif (CMAKE_CXX_COMPILER_IS_Intel) + if(CMAKE_CXX_COMPILER_IS_Clang OR CMAKE_CXX_COMPILER_IS_GCC) + set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE} -g -p" CACHE STRING "") + set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE} -g -p" CACHE STRING "") + set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -g -p" CACHE STRING "") + set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}" CACHE STRING "") + set(CMAKE_STATIC_LINKER_FLAGS_PROFILE "${CMAKE_STATIC_LINKER_FLAGS_RELEASE}" CACHE STRING "") + set(CMAKE_MODULE_LINKER_FLAGS_PROFILE + "${CMAKE_MODULE_LINKER_FLAGS_RELEASE} -g -p" + CACHE STRING "") + elseif(CMAKE_CXX_COMPILER_IS_Intel) message("Set options for profiling with Intel C++") - elseif (CMAKE_CXX_COMPILER_IS_MSVC) + elseif(CMAKE_CXX_COMPILER_IS_MSVC) message("Set options for profiling with Visual Studio C++") endif() set(PROFILE 1) @@ -46,4 +54,3 @@ elseif(CMAKE_BUILD_TYPE STREQUAL None) # set(USE_CPPCHECK ON CACHE BOOL "Use cppcheck") set(USE_PVS_STUDIO ON CACHE BOOL "Use PVS-Studio") endif() - diff --git a/CMLibCPackSources.cmake b/CMLibCPackSources.cmake index 03d4536..1b64724 100644 --- a/CMLibCPackSources.cmake +++ b/CMLibCPackSources.cmake @@ -3,9 +3,6 @@ set(CPACK_SOURCE_GENERATOR TXZ) set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${CPACK_PACKAGE_VERSION}") set(CPACK_IGNORE_FILE "cmake/etc/cpack_ignore.txt") file(STRINGS ${CPACK_IGNORE_FILE} CPACK_SOURCE_IGNORE_FILES) -set_property(DIRECTORY - APPEND - PROPERTY CMAKE_CONFIGURE_DEPENDS ${CPACK_IGNORE_FILE}) +set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${CPACK_IGNORE_FILE}) include(CPack) add_custom_target(dist COMMAND ${CMAKE_MAKE_PROGRAM} package_source) - diff --git a/CMLibCodeAnalysisClangAnalyze.cmake b/CMLibCodeAnalysisClangAnalyze.cmake index 1440ca1..bf911f1 100644 --- a/CMLibCodeAnalysisClangAnalyze.cmake +++ b/CMLibCodeAnalysisClangAnalyze.cmake @@ -5,12 +5,12 @@ function(add_clang_analyze_check) option(CLANG_ANALYZE_FIX "Perform fixes for Clang-Check" OFF) find_program(CLANG_CHECK_EXE - NAMES clang-check-10 - clang-check-9 - clang-check-8 - clang-check-7 - clang-check-6.0 - clang-check) + NAMES clang-check-10 + clang-check-9 + clang-check-8 + clang-check-7 + clang-check-6.0 + clang-check) if(CLANG_CHECK_EXE) if(CLANG_CHECK_FIX) list(APPEND _args "-fix") @@ -19,8 +19,13 @@ function(add_clang_analyze_check) add_custom_target(clang-analyze-check) endif() add_custom_target(clang-analyze-check-${_target} - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ${CLANG_CHECK_EXE} -analyze -extra-arg="-Wno-unknown-warning-option" -p ${CMAKE_BINARY_DIR} ${_sources}) + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + COMMAND ${CLANG_CHECK_EXE} + -analyze + -extra-arg="-Wno-unknown-warning-option" + -p + ${CMAKE_BINARY_DIR} + ${_sources}) add_dependencies(clang-analyze-check-${_target} ${_target}) add_dependencies(clang-analyze-check clang-analyze-check-${_target}) else() @@ -28,4 +33,3 @@ function(add_clang_analyze_check) message(STATUS " Clang-Check analyzer is not found") endif() endfunction() - diff --git a/CMLibCodeAnalysisClangTidy.cmake b/CMLibCodeAnalysisClangTidy.cmake index 8fc3ab3..02ba516 100644 --- a/CMLibCodeAnalysisClangTidy.cmake +++ b/CMLibCodeAnalysisClangTidy.cmake @@ -5,12 +5,12 @@ function(add_clang_tidy_check) option(CLANG_TIDY_FIX "Perform fixes for Clang-Tidy" OFF) find_program(CLANG_TIDY_EXE - NAMES clang-tidy-10 - clang-tidy-9 - clang-tidy-8 - clang-tidy-7 - clang-tidy-6.0 - clang-tidy) + NAMES clang-tidy-10 + clang-tidy-9 + clang-tidy-8 + clang-tidy-7 + clang-tidy-6.0 + clang-tidy) if(CLANG_TIDY_EXE) if(CLANG_TIDY_FIX) list(APPEND _args "-fix") @@ -19,8 +19,12 @@ function(add_clang_tidy_check) add_custom_target(clang-tidy-check) endif() add_custom_target(clang-tidy-check-${_target} - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ${CLANG_TIDY_EXE} -extra-arg="-Wno-unknown-warning-option" -p ${CMAKE_BINARY_DIR} ${_sources}) + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + COMMAND ${CLANG_TIDY_EXE} + -extra-arg="-Wno-unknown-warning-option" + -p + ${CMAKE_BINARY_DIR} + ${_sources}) add_dependencies(clang-tidy-check-${_target} ${_target}) add_dependencies(clang-tidy-check clang-tidy-check-${_target}) else() @@ -28,4 +32,3 @@ function(add_clang_tidy_check) message(STATUS " ClangTidy analyzer is not found") endif() endfunction() - diff --git a/CMLibCodeAnalysisClazy.cmake b/CMLibCodeAnalysisClazy.cmake index 664a144..77d1264 100644 --- a/CMLibCodeAnalysisClazy.cmake +++ b/CMLibCodeAnalysisClazy.cmake @@ -3,15 +3,19 @@ function(add_clazy_check) set(_sources ${ARGN}) list(REMOVE_AT _sources 0) - find_program(CLAZY_EXE - NAMES clazy-standalone) + find_program(CLAZY_EXE NAMES clazy-standalone) if(CLAZY_EXE) if(NOT TARGET clazy-check) add_custom_target(clazy-check) endif() add_custom_target(clazy-check-${_target} - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ${CLAZY_EXE} -checks=level2 -extra-arg="-Wno-unknown-warning-option" -p ${CMAKE_BINARY_DIR} ${_sources}) + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + COMMAND ${CLAZY_EXE} + -checks=level2 + -extra-arg="-Wno-unknown-warning-option" + -p + ${CMAKE_BINARY_DIR} + ${_sources}) add_dependencies(clazy-check-${_target} ${_target}) add_dependencies(clazy-check clazy-check-${_target}) else() @@ -19,4 +23,3 @@ function(add_clazy_check) message(STATUS " Clazy analyzer is not found") endif() endfunction() - diff --git a/CMLibCodeAnalysisPvsStudio.cmake b/CMLibCodeAnalysisPvsStudio.cmake index a8e9e09..221814a 100644 --- a/CMLibCodeAnalysisPvsStudio.cmake +++ b/CMLibCodeAnalysisPvsStudio.cmake @@ -1,7 +1,7 @@ function(add_pvs_check) list(GET ARGN 0 _target) - if (CMAKE_EXPORT_COMPILE_COMMANDS) + if(CMAKE_EXPORT_COMPILE_COMMANDS) include(PVS-Studio) find_program(PVS_STUDIO_ANALYZER_EXE NAMES pvs-studio-analyzer) if(PVS_STUDIO_ANALYZER_EXE) @@ -10,12 +10,13 @@ function(add_pvs_check) endif() pvs_studio_add_target(TARGET pvs-check-${_target} DEPENDS ${_target} - COMPILE_COMMANDS - HIDE_HELP - OUTPUT FORMAT errorfile + COMPILE_COMMANDS HIDE_HELP OUTPUT + FORMAT errorfile CONFIG "${CMAKE_BINARY_DIR}/PVS-Studio-${_target}.cfg" - ARGS --analysis-mode 29 - --exclude-path ${CMAKE_CURRENT_BINARY_DIR}/${_target}_autogen + ARGS --analysis-mode + 29 + --exclude-path + ${CMAKE_CURRENT_BINARY_DIR}/${_target}_autogen MODE GA:1,2,3;64:1;OP:1,2;CS:1,2) add_dependencies(pvs-check pvs-check-${_target}) else() @@ -24,7 +25,7 @@ function(add_pvs_check) endif() else() message(STATUS "CMLIB warning:") - message(STATUS " Option CMAKE_EXPORT_COMPILE_COMMANDS is not set. PVS checks will be disabled.") + message( + STATUS " Option CMAKE_EXPORT_COMPILE_COMMANDS is not set. PVS checks will be disabled.") endif() endfunction() - diff --git a/CMLibCommon.cmake b/CMLibCommon.cmake index 04342ab..af70438 100644 --- a/CMLibCommon.cmake +++ b/CMLibCommon.cmake @@ -46,4 +46,3 @@ include(CMLibToday) include(CMLibConfigHPPGenerate) include(CMLibCPackSources) include(CMLibUninstall) - diff --git a/CMLibCommonLibraryTarget.cmake b/CMLibCommonLibraryTarget.cmake index 35c997c..ad751f4 100644 --- a/CMLibCommonLibraryTarget.cmake +++ b/CMLibCommonLibraryTarget.cmake @@ -4,45 +4,51 @@ function(add_common_library) set(oneValueArgs TARGET OUTPUT_NAME) set(multiValueArgs SOURCES) - cmake_parse_arguments(_LOCAL "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + cmake_parse_arguments(_LOCAL + "${options}" + "${oneValueArgs}" + "${multiValueArgs}" + ${ARGN}) set(LIBNAME ${_LOCAL_TARGET}) set(SOURCES ${_LOCAL_SOURCES}) - if (_LOCAL_OUTPUT_NAME) + if(_LOCAL_OUTPUT_NAME) set(OUTNAME ${_LOCAL_OUTPUT_NAME}) else() set(OUTNAME ${LIBNAME}) endif() add_library(${LIBNAME} OBJECT ${SOURCES}) - target_include_directories( - ${LIBNAME} - PUBLIC $ - $ - $) + target_include_directories(${LIBNAME} + PUBLIC $ + $ + $) set_target_properties(${LIBNAME} PROPERTIES POSITION_INDEPENDENT_CODE ON) if(BUILD_SHARED_LIBS) add_library(${LIBNAME}_shared SHARED $) set_target_properties(${LIBNAME}_shared - PROPERTIES - VERSION ${PROJECT_VERSION} - SOVERSION ${PROJECT_VERSION_MAJOR} - OUTPUT_NAME ${OUTNAME} - LIBRARY_OUTPUT_DIRECTORY ${CMAKE_INSTALL_LIBDIR}) + PROPERTIES VERSION + ${PROJECT_VERSION} + SOVERSION + ${PROJECT_VERSION_MAJOR} + OUTPUT_NAME + ${OUTNAME} + LIBRARY_OUTPUT_DIRECTORY + ${CMAKE_INSTALL_LIBDIR}) install(TARGETS ${LIBNAME}_shared LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() if(NOT SKIP_STATIC_LIBS) add_library(${LIBNAME}_static STATIC $) set_target_properties(${LIBNAME}_static - PROPERTIES - OUTPUT_NAME ${OUTNAME} - ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_INSTALL_LIBDIR}) + PROPERTIES OUTPUT_NAME + ${OUTNAME} + ARCHIVE_OUTPUT_DIRECTORY + ${CMAKE_INSTALL_LIBDIR}) install(TARGETS ${LIBNAME}_static ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() configure_file(${CMLIB_MODULE_DIR}/pc/lib.pc.in ${CMAKE_BINARY_DIR}/${LIBNAME}.pc) install(FILES ${CMAKE_BINARY_DIR}/${LIBNAME}.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) endfunction() - diff --git a/CMLibCommonTargetProperties.cmake b/CMLibCommonTargetProperties.cmake index 680898a..c157e77 100644 --- a/CMLibCommonTargetProperties.cmake +++ b/CMLibCommonTargetProperties.cmake @@ -9,34 +9,37 @@ function(common_target_properties Name) endif() target_compile_features(${Name} ${__visibility} ${COMMON_CXX_FEATURES}) get_target_property(_targetType ${Name} TYPE) - if (_targetType STREQUAL "EXECUTABLE" AND CMAKE_CXX_COMPILE_OPTIONS_PIE) + if(_targetType STREQUAL "EXECUTABLE" AND CMAKE_CXX_COMPILE_OPTIONS_PIE) target_compile_options(${Name} PUBLIC "${CMAKE_CXX_COMPILE_OPTIONS_PIE}") endif() - target_include_directories( - ${Name} - PUBLIC $ - $ - $ - $) + target_include_directories(${Name} + PUBLIC $ + $ + $ + $) if(APPLE) target_compile_definitions(${Name} ${__visibility} Darwin) endif() if(NOT __interface) if(TARGET Qt5::Core) - if (_targetType STREQUAL "EXECUTABLE") + if(_targetType STREQUAL "EXECUTABLE") target_compile_options(${Name} PUBLIC "${Qt5Core_EXECUTABLE_COMPILE_FLAGS}") endif() - set_target_properties(${Name} PROPERTIES AUTOMOC TRUE AUTORCC TRUE) + set_target_properties(${Name} + PROPERTIES AUTOMOC + TRUE + AUTORCC + TRUE) endif() if(TARGET Qt5::Widgets) set_target_properties(${Name} PROPERTIES AUTOUIC TRUE) -# if(CMAKE_VERSION VERSION_LESS 3.7.99) -# target_include_directories( -# ${Name} -# PUBLIC -# $ -# ) -# endif() + # if(CMAKE_VERSION VERSION_LESS 3.7.99) + # target_include_directories( + # ${Name} + # PUBLIC + # $ + # ) + # endif() endif() if(CMAKE_CXX_COMPILER_IS_GCC AND NOT APPLE) set_target_properties(${Name} PROPERTIES LINK_FLAGS "-Wl,--no-as-needed") @@ -44,4 +47,3 @@ function(common_target_properties Name) endif() endfunction() - diff --git a/CMLibCompiler.cmake b/CMLibCompiler.cmake index 61b415e..0c13007 100644 --- a/CMLibCompiler.cmake +++ b/CMLibCompiler.cmake @@ -1,8 +1,7 @@ # C compiler name if(CMAKE_C_COMPILER_ID STREQUAL "Intel") set(CMAKE_C_COMPILER_IS_INTEL ON) -elseif(CMAKE_C_COMPILER_ID STREQUAL "Clang" - OR CMAKE_C_COMPILER_ID STREQUAL "AppleClang") +elseif(CMAKE_C_COMPILER_ID STREQUAL "Clang" OR CMAKE_C_COMPILER_ID STREQUAL "AppleClang") set(CMAKE_C_COMPILER_IS_CLANG ON) elseif(CMAKE_C_COMPILER_ID STREQUAL "GNU") set(CMAKE_C_COMPILER_IS_GCC ON) @@ -13,12 +12,10 @@ endif() # C++ compiler name if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel") set(CMAKE_CXX_COMPILER_IS_INTEL ON) -elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" - OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") +elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") set(CMAKE_CXX_COMPILER_IS_CLANG ON) elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") set(CMAKE_CXX_COMPILER_IS_GCC ON) elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") set(CMAKE_CXX_COMPILER_IS_MSVC ON) endif() - diff --git a/CMLibCompilerFeaturesHPPGenerate.cmake b/CMLibCompilerFeaturesHPPGenerate.cmake index b4bfd3f..379799e 100644 --- a/CMLibCompilerFeaturesHPPGenerate.cmake +++ b/CMLibCompilerFeaturesHPPGenerate.cmake @@ -1,18 +1,17 @@ include(WriteCompilerDetectionHeader) -write_compiler_detection_header( - FILE include/compiler_features.hpp - PREFIX ${CMLIB_PROJECT_NAME_CANONICAL} - COMPILERS GNU Clang MSVC Intel - FEATURES - cxx_nullptr - cxx_override - cxx_alignas - cxx_alignof - cxx_attributes - cxx_auto_type - cxx_constexpr - cxx_digit_separators - cxx_range_for - ) - +write_compiler_detection_header(FILE include/compiler_features.hpp + PREFIX ${CMLIB_PROJECT_NAME_CANONICAL} + COMPILERS GNU + Clang + MSVC + Intel + FEATURES cxx_nullptr + cxx_override + cxx_alignas + cxx_alignof + cxx_attributes + cxx_auto_type + cxx_constexpr + cxx_digit_separators + cxx_range_for) diff --git a/CMLibCompilerFlags.cmake b/CMLibCompilerFlags.cmake index 24db8a4..40af045 100644 --- a/CMLibCompilerFlags.cmake +++ b/CMLibCompilerFlags.cmake @@ -18,9 +18,7 @@ macro(CHECK_ENABLE_CXX_FLAG flag) endmacro() # Common configuration for GCC, clang and Intel. -if(CMAKE_CXX_COMPILER_IS_CLANG - OR CMAKE_CXX_COMPILER_IS_INTEL - OR CMAKE_CXX_COMPILER_IS_GCC) +if(CMAKE_CXX_COMPILER_IS_CLANG OR CMAKE_CXX_COMPILER_IS_INTEL OR CMAKE_CXX_COMPILER_IS_GCC) set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED YES) set(CMAKE_CXX_EXTENSIONS YES) @@ -91,9 +89,15 @@ if(CMAKE_CXX_COMPILER_IS_CLANG check_cxx_compiler_flag(-flto CXX_HAS_LTO_FLAG) check_cxx_compiler_flag(-fno-fat-lto-objects CXX_HAS_NO_FAT_LTO_FLAG) if(CMAKE_CXX_COMPILER_IS_GCC AND CXX_HAS_LTO_FLAG) - find_program(CMAKE_GCC_AR NAMES ${_CMAKE_TOOLCHAIN_PREFIX}gcc-ar${_CMAKE_TOOLCHAIN_SUFFIX} HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) - find_program(CMAKE_GCC_NM NAMES ${_CMAKE_TOOLCHAIN_PREFIX}gcc-nm HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) - find_program(CMAKE_GCC_RANLIB NAMES ${_CMAKE_TOOLCHAIN_PREFIX}gcc-ranlib HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) + find_program(CMAKE_GCC_AR + NAMES ${_CMAKE_TOOLCHAIN_PREFIX}gcc-ar${_CMAKE_TOOLCHAIN_SUFFIX} + HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) + find_program(CMAKE_GCC_NM + NAMES ${_CMAKE_TOOLCHAIN_PREFIX}gcc-nm + HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) + find_program(CMAKE_GCC_RANLIB + NAMES ${_CMAKE_TOOLCHAIN_PREFIX}gcc-ranlib + HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) if(CMAKE_GCC_AR AND CMAKE_GCC_NM AND CMAKE_GCC_RANLIB) set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -flto") if(CXX_HAS_NO_FAT_LTO_FLAG) @@ -103,7 +107,9 @@ if(CMAKE_CXX_COMPILER_IS_CLANG set(CMAKE_NM "${CMAKE_GCC_NM}") set(CMAKE_RANLIB "${CMAKE_GCC_RANLIB}") else() - message(WARNING "GCC indicates LTO support, but binutils wrappers could not be found. Disabling LTO.") + message( + WARNING + "GCC indicates LTO support, but binutils wrappers could not be found. Disabling LTO.") endif() else() check_enable_compiler_flag(-flto) @@ -136,4 +142,3 @@ if(CMAKE_SYSTEM_PROCESSOR STREQUAL "e2k") add_definitions(-DQT_NO_VERSION_TAGGING) list(APPEND CMAKE_LIBRARY_PATH "/usr/lib/e2k-linux-gnu") endif() - diff --git a/CMLibDisableInSourceBuild.cmake b/CMLibDisableInSourceBuild.cmake index 1110a55..27112bd 100644 --- a/CMLibDisableInSourceBuild.cmake +++ b/CMLibDisableInSourceBuild.cmake @@ -17,11 +17,11 @@ file(GLOB_RECURSE _cmakelists_files RELATIVE ${_source_realpath} CMakeLists.txt) foreach(_it ${_cmakelists_files}) get_filename_component(_file ${_it} REALPATH) get_filename_component(_dir ${_file} DIRECTORY) - file(REMOVE_RECURSE ${_dir}/CMakeFiles - ${_dir}/CMakeCache.txt - ${_dir}/cmake_install.cmake - ${_dir}/Makefile - ${_dir}/build.ninja - ${_dir}/rules.ninja) + file(REMOVE_RECURSE + ${_dir}/CMakeFiles + ${_dir}/CMakeCache.txt + ${_dir}/cmake_install.cmake + ${_dir}/Makefile + ${_dir}/build.ninja + ${_dir}/rules.ninja) endforeach() - diff --git a/CMLibDistCC.cmake b/CMLibDistCC.cmake index cbce913..67ac2ad 100644 --- a/CMLibDistCC.cmake +++ b/CMLibDistCC.cmake @@ -2,7 +2,8 @@ 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$") + 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() diff --git a/CMLibDocBreathe.cmake b/CMLibDocBreathe.cmake index 75b90f1..68ad6cc 100644 --- a/CMLibDocBreathe.cmake +++ b/CMLibDocBreathe.cmake @@ -1,16 +1,31 @@ set(BREATHE_FOUND AUTO CACHE STRING "Enable Breathe documentation generator") -set_property(CACHE BREATHE_FOUND PROPERTY STRINGS ON OFF AUTO) +set_property(CACHE BREATHE_FOUND + PROPERTY STRINGS + ON + OFF + AUTO) find_package(Doxygen) find_package(Perl) -set(Python_ADDITIONAL_VERSIONS 3.7 3.6 3.5 3.4 3.3 3.2) +set(Python_ADDITIONAL_VERSIONS + 3.7 + 3.6 + 3.5 + 3.4 + 3.3 + 3.2) find_package(PythonInterp) -if (PYTHONINTERP_FOUND) +if(PYTHONINTERP_FOUND) find_package(Sphinx) include(FindPythonModule) find_python_module(breathe) find_python_module(recommonmark) - if(DOXYGEN_FOUND AND PERL_FOUND AND PYTHONINTERP_FOUND AND SPHINX_EXECUTABLE AND breathe AND recommonmark) + if(DOXYGEN_FOUND + AND PERL_FOUND + AND PYTHONINTERP_FOUND + AND SPHINX_EXECUTABLE + AND breathe + AND recommonmark) set(BREATHE_FOUND ON CACHE STRING "Breathe documentation generator enabled" FORCE) else() set(BREATHE_FOUND OFF CACHE STRING "Breathe documentation generator disabled" FORCE) @@ -19,13 +34,24 @@ else() set(BREATHE_FOUND OFF CACHE STRING "Breathe documentation generator disabled" FORCE) endif() - function(add_breathe_target) set(options) - set(oneValueArgs SOURCE_DIR BUILD_DIR CACHE_DIR HTML_DIR DOXY_FILE CONF_FILE TARGET_NAME COMMENT) + set(oneValueArgs + SOURCE_DIR + BUILD_DIR + CACHE_DIR + HTML_DIR + DOXY_FILE + CONF_FILE + TARGET_NAME + COMMENT) set(multiValueArgs) - cmake_parse_arguments(_BREATHE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + cmake_parse_arguments(_BREATHE + "${options}" + "${oneValueArgs}" + "${multiValueArgs}" + ${ARGN}) if(BREATHE_FOUND) set(BREATHE_DOCS_BUILD_DIR ${_BREATHE_BUILD_DIR}) set(GENERATE_XML YES) @@ -37,14 +63,19 @@ function(add_breathe_target) configure_file(${_BREATHE_DOXY_FILE} ${_BREATHE_BUILD_DIR}/Doxyfile @ONLY) add_custom_target(${_BREATHE_TARGET_NAME} VERBATIM - COMMAND ${SPHINX_EXECUTABLE} -q -b html -c ${_BREATHE_BUILD_DIR} - -d ${_BREATHE_CACHE_DIR} - ${_BREATHE_SOURCE_DIR} - ${_BREATHE_HTML_DIR} - COMMENT "Building ${_BREATHE_TARGET_NAME} documentation with Breathe" - ) + COMMAND ${SPHINX_EXECUTABLE} + -q + -b + html + -c + ${_BREATHE_BUILD_DIR} + -d + ${_BREATHE_CACHE_DIR} + ${_BREATHE_SOURCE_DIR} + ${_BREATHE_HTML_DIR} + COMMENT "Building ${_BREATHE_TARGET_NAME} documentation with Breathe") else() add_custom_target(${_BREATHE_TARGET_NAME} VERBATIM - COMMENT "Breathe is not found. Skipping target ${_BREATHE_TARGET_NAME} build") + COMMENT "Breathe is not found. Skipping target ${_BREATHE_TARGET_NAME} build") endif() endfunction() diff --git a/CMLibDocDoxygen.cmake b/CMLibDocDoxygen.cmake index 0cc5d3b..acb2b02 100644 --- a/CMLibDocDoxygen.cmake +++ b/CMLibDocDoxygen.cmake @@ -1,28 +1,40 @@ set(DOXYGEN_FOUND AUTO CACHE STRING "Enable Doxygen documentation generator") -set_property(CACHE DOXYGEN_FOUND PROPERTY STRINGS ON OFF AUTO) +set_property(CACHE DOXYGEN_FOUND + PROPERTY STRINGS + ON + OFF + AUTO) find_package(Doxygen) -if (DOXYGEN_FOUND) +if(DOXYGEN_FOUND) set(DOXYGEN_FOUND ON CACHE STRING "Doxygen documentation generator enabled" FORCE) else() set(DOXYGEN_FOUND OFF CACHE STRING "Doxygen documentation generator disabled" FORCE) endif() - function(add_doxygen_target) set(options) - set(oneValueArgs TARGET_NAME DOXY_FILE OUTPUT_DIRECTORY LATEX HTML) + set(oneValueArgs + TARGET_NAME + DOXY_FILE + OUTPUT_DIRECTORY + LATEX + HTML) set(multiValueArgs) - cmake_parse_arguments(_DOXYGEN "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - if (DOXYGEN_FOUND) + cmake_parse_arguments(_DOXYGEN + "${options}" + "${oneValueArgs}" + "${multiValueArgs}" + ${ARGN}) + if(DOXYGEN_FOUND) set(GENERATE_XML NO) set(GENERATE_HTML NO) set(GENERATE_LATEX NO) - if (_DOXYGEN_HTML) + if(_DOXYGEN_HTML) set(GENERATE_HTML YES) endif() - if (_DOXYGEN_LATEX) + if(_DOXYGEN_LATEX) set(GENERATE_LATEX YES) endif() @@ -30,11 +42,11 @@ function(add_doxygen_target) message("Doxygen build started") add_custom_target(${_DOXYGEN_TARGET_NAME} VERBATIM - COMMAND ${DOXYGEN_EXECUTABLE} ${_DOXYGEN_OUTPUT_DIRECTORY}/Doxyfile - WORKING_DIRECTORY ${_DOXYGEN_OUTPUT_DIRECTORY} - COMMENT "Generating API documentation with Doxygen") + COMMAND ${DOXYGEN_EXECUTABLE} ${_DOXYGEN_OUTPUT_DIRECTORY}/Doxyfile + WORKING_DIRECTORY ${_DOXYGEN_OUTPUT_DIRECTORY} + COMMENT "Generating API documentation with Doxygen") else() add_custom_target(${_DOXYGEN_TARGET_NAME} VERBATIM - COMMENT "Doxygen is not found. Skipping target ${_DOXYGEN_TARGET_NAME} build") + COMMENT "Doxygen is not found. Skipping target ${_DOXYGEN_TARGET_NAME} build") endif() endfunction() diff --git a/CMLibFlagRemove.cmake b/CMLibFlagRemove.cmake index b416768..d420e31 100644 --- a/CMLibFlagRemove.cmake +++ b/CMLibFlagRemove.cmake @@ -10,8 +10,7 @@ macro(remove_flag_from_target _target _flag) get_target_property(_target_cxx_flags ${_target} COMPILE_OPTIONS) if(_target_cxx_flags) list(REMOVE_ITEM _target_cxx_flags ${_flag}) - set_target_properties(${_target} - PROPERTIES COMPILE_OPTIONS "${_target_cxx_flags}") + set_target_properties(${_target} PROPERTIES COMPILE_OPTIONS "${_target_cxx_flags}") endif() endmacro() @@ -23,7 +22,10 @@ endmacro() # # Pre: apply_global_cxx_flags_to_all_targets() must be invoked. # -macro(remove_flag_from_file _target _file _flag) +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. if(_flag_sync_required) @@ -41,19 +43,21 @@ macro(remove_flag_from_file _target _file _flag) # Apply the target compile flags to each source file. foreach(_source_file ${_target_sources}) # Check for pre-existing flags set by set_source_files_properties(). - get_source_file_property(_source_file_cxx_flags ${_source_file} - COMPILE_FLAGS) + get_source_file_property(_source_file_cxx_flags ${_source_file} COMPILE_FLAGS) if(_source_file_cxx_flags) - separate_arguments(_source_file_cxx_flags UNIX_COMMAND - ${_source_file_cxx_flags}) + separate_arguments(_source_file_cxx_flags UNIX_COMMAND ${_source_file_cxx_flags}) list(APPEND _source_file_cxx_flags "${_target_cxx_flags}") else() set(_source_file_cxx_flags "${_target_cxx_flags}") endif() # Apply the compile flags to the current source file. - string(REPLACE ";" " " _source_file_cxx_flags_string + string(REPLACE ";" + " " + _source_file_cxx_flags_string "${_source_file_cxx_flags}") - set_source_files_properties(${_source_file} PROPERTIES COMPILE_FLAGS + set_source_files_properties(${_source_file} + PROPERTIES + COMPILE_FLAGS "${_source_file_cxx_flags_string}") endforeach() endif() @@ -63,18 +67,18 @@ macro(remove_flag_from_file _target _file _flag) # Cache the compile flags for the specified file. # This is the list that we'll be removing flags from. get_source_file_property(_source_file_cxx_flags ${_file} COMPILE_FLAGS) - separate_arguments(_source_file_cxx_flags UNIX_COMMAND - ${_source_file_cxx_flags}) - set(_cached_${_target}_${_file}_cxx_flags ${_source_file_cxx_flags} - CACHE INTERNAL "") + separate_arguments(_source_file_cxx_flags UNIX_COMMAND ${_source_file_cxx_flags}) + set(_cached_${_target}_${_file}_cxx_flags ${_source_file_cxx_flags} CACHE INTERNAL "") endif() # Remove the specified flag, then re-apply the rest. list(REMOVE_ITEM _cached_${_target}_${_file}_cxx_flags ${_flag}) - string(REPLACE ";" " " _cached_${_target}_${_file}_cxx_flags_string + string(REPLACE ";" + " " + _cached_${_target}_${_file}_cxx_flags_string "${_cached_${_target}_${_file}_cxx_flags}") - set_source_files_properties( - ${_file} PROPERTIES COMPILE_FLAGS - "${_cached_${_target}_${_file}_cxx_flags_string}") + set_source_files_properties(${_file} + PROPERTIES + COMPILE_FLAGS + "${_cached_${_target}_${_file}_cxx_flags_string}") endif() endmacro() - diff --git a/CMLibFormatSources.cmake b/CMLibFormatSources.cmake index 9fa0edd..d9748b1 100644 --- a/CMLibFormatSources.cmake +++ b/CMLibFormatSources.cmake @@ -8,12 +8,14 @@ function(add_uncrustify_format) if(NOT TARGET uncrustify-format) add_custom_target(uncrustify-format) endif() - list(APPEND OPTS -lCPP --replace --no-backup) + list(APPEND OPTS + -lCPP + --replace + --no-backup) if(EXISTS ${CMAKE_SOURCE_DIR}/cmake/etc/uncrustify/default.cfg) list(APPEND OPTS -c ${CMAKE_SOURCE_DIR}/cmake/etc/uncrustify/default.cfg) endif() - add_custom_target(uncrustify-format-${_target} - COMMAND ${UNCRUSTIFY_EXE} ${OPTS} ${_sources}) + add_custom_target(uncrustify-format-${_target} COMMAND ${UNCRUSTIFY_EXE} ${OPTS} ${_sources}) add_dependencies(uncrustify-format uncrustify-format-${_target}) else() message(STATUS "CMLIB warning:") diff --git a/CMLibGlobalVariables.cmake b/CMLibGlobalVariables.cmake index 72ef17d..02413f4 100644 --- a/CMLibGlobalVariables.cmake +++ b/CMLibGlobalVariables.cmake @@ -1,6 +1,10 @@ # CMLIB_PROJECT_NAME_CANONICAL string(TOUPPER ${PROJECT_NAME} _project_name_uppercase) -string(REGEX REPLACE "[ -]" "_" _project_name_fixed ${_project_name_uppercase}) +string(REGEX + REPLACE "[ -]" + "_" + _project_name_fixed + ${_project_name_uppercase}) set(CMLIB_PROJECT_NAME_CANONICAL ${_project_name_fixed}) # CMLIB_MODULE_DIR @@ -19,4 +23,3 @@ if(IS_DIRECTORY "${CMLIB_MODULE_DIR}") else() message(FATAL_ERROR "CMLib directory not found.") endif() - diff --git a/CMLibLSBInfo.cmake b/CMLibLSBInfo.cmake index e61168c..c8c5e0c 100644 --- a/CMLibLSBInfo.cmake +++ b/CMLibLSBInfo.cmake @@ -10,7 +10,7 @@ set(LSB_DISTRIBUTOR_ID "unknown") set(LSB_CODENAME "unknown") set(LSB_RELEASE "unknown") -if (EXISTS /etc/mcst_version) +if(EXISTS /etc/mcst_version) set(LSB_DISTRIBUTOR_ID "ElbrusD") set(LSB_CODENAME "Jessie") execute_process(COMMAND cat /etc/mcst_version @@ -32,4 +32,3 @@ else() OUTPUT_STRIP_TRAILING_WHITESPACE) endif() endif() - diff --git a/CMLibLargeFiles.cmake b/CMLibLargeFiles.cmake index 18a15f0..e487fc2 100644 --- a/CMLibLargeFiles.cmake +++ b/CMLibLargeFiles.cmake @@ -51,79 +51,75 @@ include(CheckTypeSize) -MACRO(cmlib_test_large_files VARIABLE) - IF(NOT DEFINED ${VARIABLE}) +macro(cmlib_test_large_files VARIABLE) + if(NOT DEFINED ${VARIABLE}) # On most platforms it is probably overkill to first test the flags for 64-bit off_t, # and then separately fseeko. However, in the future we might have 128-bit filesystems # (ZFS), so it might be dangerous to indiscriminately set e.g. _FILE_OFFSET_BITS=64. - MESSAGE(STATUS "Checking for 64-bit off_t") + message(STATUS "Checking for 64-bit off_t") # First check without any special flags - TRY_COMPILE(FILE64_OK "${CMAKE_BINARY_DIR}" - "${CMLIB_MODULE_DIR}/tests/TestFileOffsetBits.c") + try_compile(FILE64_OK "${CMAKE_BINARY_DIR}" "${CMLIB_MODULE_DIR}/tests/TestFileOffsetBits.c") if(FILE64_OK) - MESSAGE(STATUS "Checking for 64-bit off_t - present") + message(STATUS "Checking for 64-bit off_t - present") endif() if(NOT FILE64_OK) # Test with _FILE_OFFSET_BITS=64 - TRY_COMPILE(FILE64_OK "${CMAKE_BINARY_DIR}" - "${CMLIB_MODULE_DIR}/tests/TestFileOffsetBits.c" - COMPILE_DEFINITIONS "-D_FILE_OFFSET_BITS=64" ) + try_compile(FILE64_OK "${CMAKE_BINARY_DIR}" "${CMLIB_MODULE_DIR}/tests/TestFileOffsetBits.c" + COMPILE_DEFINITIONS "-D_FILE_OFFSET_BITS=64") if(FILE64_OK) - MESSAGE(STATUS "Checking for 64-bit off_t - present with _FILE_OFFSET_BITS=64") + message(STATUS "Checking for 64-bit off_t - present with _FILE_OFFSET_BITS=64") set(_FILE_OFFSET_BITS 64 CACHE INTERNAL "64-bit off_t requires _FILE_OFFSET_BITS=64") endif() endif() if(NOT FILE64_OK) # Test with _LARGE_FILES - TRY_COMPILE(FILE64_OK "${CMAKE_BINARY_DIR}" - "${CMLIB_MODULE_DIR}/tests/TestFileOffsetBits.c" - COMPILE_DEFINITIONS "-D_LARGE_FILES" ) + try_compile(FILE64_OK "${CMAKE_BINARY_DIR}" "${CMLIB_MODULE_DIR}/tests/TestFileOffsetBits.c" + COMPILE_DEFINITIONS "-D_LARGE_FILES") if(FILE64_OK) - MESSAGE(STATUS "Checking for 64-bit off_t - present with _LARGE_FILES") + message(STATUS "Checking for 64-bit off_t - present with _LARGE_FILES") set(_LARGE_FILES 1 CACHE INTERNAL "64-bit off_t requires _LARGE_FILES") endif() endif() if(NOT FILE64_OK) # Test with _LARGEFILE_SOURCE - TRY_COMPILE(FILE64_OK "${CMAKE_BINARY_DIR}" - "${CMLIB_MODULE_DIR}/tests/TestFileOffsetBits.c" - COMPILE_DEFINITIONS "-D_LARGEFILE_SOURCE" ) + try_compile(FILE64_OK "${CMAKE_BINARY_DIR}" "${CMLIB_MODULE_DIR}/tests/TestFileOffsetBits.c" + COMPILE_DEFINITIONS "-D_LARGEFILE_SOURCE") if(FILE64_OK) - MESSAGE(STATUS "Checking for 64-bit off_t - present with _LARGEFILE_SOURCE") + message(STATUS "Checking for 64-bit off_t - present with _LARGEFILE_SOURCE") set(_LARGEFILE_SOURCE 1 CACHE INTERNAL "64-bit off_t requires _LARGEFILE_SOURCE") endif() endif() if(NOT FILE64_OK) - MESSAGE(STATUS "Checking for 64-bit off_t - not present") + message(STATUS "Checking for 64-bit off_t - not present") else() # 64-bit off_t found. Now check that ftello/fseeko is available. # Set the flags we might have determined to be required above configure_file("${CMLIB_MODULE_DIR}/tests/TestLargeFiles.c.in" - "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/TestLargeFiles.c") + "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/TestLargeFiles.c") - MESSAGE(STATUS "Checking for fseeko/ftello") + message(STATUS "Checking for fseeko/ftello") # Test if ftello/fseeko are available - TRY_COMPILE(FSEEKO_COMPILE_OK "${CMAKE_BINARY_DIR}" - "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/TestLargeFiles.c") + try_compile(FSEEKO_COMPILE_OK "${CMAKE_BINARY_DIR}" + "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/TestLargeFiles.c") if(FSEEKO_COMPILE_OK) - MESSAGE(STATUS "Checking for fseeko/ftello - present") + message(STATUS "Checking for fseeko/ftello - present") endif() if(NOT FSEEKO_COMPILE_OK) # glibc 2.2 neds _LARGEFILE_SOURCE for fseeko (but not 64-bit off_t...) - TRY_COMPILE(FSEEKO_COMPILE_OK "${CMAKE_BINARY_DIR}" - "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/TestLargeFiles.c" - COMPILE_DEFINITIONS "-D_LARGEFILE_SOURCE" ) + try_compile(FSEEKO_COMPILE_OK "${CMAKE_BINARY_DIR}" + "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/TestLargeFiles.c" + COMPILE_DEFINITIONS "-D_LARGEFILE_SOURCE") if(FSEEKO_COMPILE_OK) - MESSAGE(STATUS "Checking for fseeko/ftello - present with _LARGEFILE_SOURCE") + message(STATUS "Checking for fseeko/ftello - present with _LARGEFILE_SOURCE") set(_LARGEFILE_SOURCE 1 CACHE INTERNAL "64-bit fseeko requires _LARGEFILE_SOURCE") else() set(FILE64_OK 0) @@ -134,29 +130,27 @@ MACRO(cmlib_test_large_files VARIABLE) if(NOT FILE64_OK) # now check for Windows stuff - TRY_COMPILE(FILE64_OK "${CMAKE_BINARY_DIR}" - "${CMLIB_MODULE_DIR}/tests/TestWindowsFSeek.c") + try_compile(FILE64_OK "${CMAKE_BINARY_DIR}" "${CMLIB_MODULE_DIR}/tests/TestWindowsFSeek.c") if(FILE64_OK) - MESSAGE(STATUS "Checking for 64-bit off_t - present with _fseeki64") + message(STATUS "Checking for 64-bit off_t - present with _fseeki64") set(HAVE__FSEEKI64 1 CACHE INTERNAL "64-bit off_t requires _fseeki64") endif() endif() if(FSEEKO_COMPILE_OK) - SET(${VARIABLE} 1 CACHE INTERNAL "Result of test for large file support" FORCE) + set(${VARIABLE} 1 CACHE INTERNAL "Result of test for large file support" FORCE) set(HAVE_FSEEKO 1 CACHE INTERNAL "64bit fseeko is available" FORCE) elseif(HAVE__FSEEKI64) - SET(${VARIABLE} 1 CACHE INTERNAL "Result of test for large file support" FORCE) - SET(HAVE__FSEEKI64 1 CACHE INTERNAL "Windows 64-bit fseek" FORCE) + set(${VARIABLE} 1 CACHE INTERNAL "Result of test for large file support" FORCE) + set(HAVE__FSEEKI64 1 CACHE INTERNAL "Windows 64-bit fseek" FORCE) else() - check_type_size("long int" SIZEOF_LONG_INT) + check_type_size("long int" SIZEOF_LONG_INT) if(SIZEOF_LONG_INT EQUAL 8) #standard fseek is OK for 64bit - SET(${VARIABLE} 1 CACHE INTERNAL "Result of test for large file support" FORCE) + set(${VARIABLE} 1 CACHE INTERNAL "Result of test for large file support" FORCE) else() - MESSAGE(FATAL_ERROR "Checking for 64bit file support failed.") + message(FATAL_ERROR "Checking for 64bit file support failed.") endif() endif() - ENDIF() -ENDMACRO(cmlib_test_large_files VARIABLE) - + endif() +endmacro(cmlib_test_large_files VARIABLE) diff --git a/CMLibOrganizationName.cmake b/CMLibOrganizationName.cmake index 234e53f..4ce3a3f 100644 --- a/CMLibOrganizationName.cmake +++ b/CMLibOrganizationName.cmake @@ -6,16 +6,16 @@ function(set_organization_name) message(FATAL_ERROR "File ${ORGANIZATION_FILE} doesn't exist") endif() file(READ "${_organization_file}" _org) - set_property(DIRECTORY - APPEND - PROPERTY CMAKE_CONFIGURE_DEPENDS ${_organization_file}) + set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${_organization_file}) if(NOT "${_org}" MATCHES "^([0-9A-Za-z ,.]+)\n") message(FATAL_ERROR "File ${_organization_file} has wrong format") endif() - string(REGEX MATCH "^([0-9A-Za-z ,.]+)\n" _ ${_org}) + string(REGEX MATCH + "^([0-9A-Za-z ,.]+)\n" + _ + ${_org}) set_property(GLOBAL PROPERTY ORGANIZATION_NAME ${CMAKE_MATCH_1}) endfunction() - diff --git a/CMLibProjectVersion.cmake b/CMLibProjectVersion.cmake index 3ef2204..6a53547 100644 --- a/CMLibProjectVersion.cmake +++ b/CMLibProjectVersion.cmake @@ -3,8 +3,8 @@ function(set_project_version) message(FATAL_ERROR "Please set project version in X.Y.Z format") endif() - math(EXPR _version_int + math( + EXPR _version_int "(${PROJECT_VERSION_MAJOR} << 16) + (${PROJECT_VERSION_MINOR} << 8) + ${PROJECT_VERSION_PATCH}") set_property(GLOBAL PROPERTY PROJECT_VERSION_INT ${_version_int}) endfunction() - diff --git a/CMLibQtTranslation.cmake b/CMLibQtTranslation.cmake index e174416..7f6f14c 100644 --- a/CMLibQtTranslation.cmake +++ b/CMLibQtTranslation.cmake @@ -5,7 +5,11 @@ function(qt_translation) set(oneValueArgs TARGET TS_DIR) set(multiValueArgs LANGUAGES) - cmake_parse_arguments(_QTTR "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + cmake_parse_arguments(_QTTR + "${options}" + "${oneValueArgs}" + "${multiValueArgs}" + ${ARGN}) set(_target ${_QTTR_TARGET}) set(_ts_dir ${_QTTR_TS_DIR}) set(_languages ${_QTTR_LANGUAGES}) @@ -22,8 +26,13 @@ function(qt_translation) string(APPEND L10N_QRC_BODY "${CMAKE_BINARY_DIR}/${_qm}\n") add_custom_target(${_target}_l10n_${_lang} - COMMAND ${Qt5_LUPDATE_EXECUTABLE} ${_sources} -ts ${_ts_dir}/${_ts} -target-language ${_lang} - DEPENDS ${_sources}) + COMMAND ${Qt5_LUPDATE_EXECUTABLE} + ${_sources} + -ts + ${_ts_dir}/${_ts} + -target-language + ${_lang} + DEPENDS ${_sources}) if(NOT EXISTS "${_ts_dir}/${_ts}") add_custom_target(${_ts} DEPENDS ${_target}_l10n_${_lang}) @@ -33,12 +42,14 @@ function(qt_translation) add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/${_qm} COMMAND ${Qt5_LRELEASE_EXECUTABLE} - ARGS ${_ts_dir}/${_ts} -qm ${CMAKE_BINARY_DIR}/${_qm} + ARGS + ${_ts_dir}/${_ts} + -qm + ${CMAKE_BINARY_DIR}/${_qm} DEPENDS ${_ts} ${_sources}) endforeach() - configure_file(${CMLIB_MODULE_DIR}/qrc/l10n.qrc.in - ${CMAKE_BINARY_DIR}/${_target}_l10n.qrc) + configure_file(${CMLIB_MODULE_DIR}/qrc/l10n.qrc.in ${CMAKE_BINARY_DIR}/${_target}_l10n.qrc) qt5_add_resources(_qrc ${CMAKE_BINARY_DIR}/${_target}_l10n.qrc) add_custom_target(${_target}_qrc DEPENDS ${_qrc}) add_custom_target(${_target}_l10n DEPENDS ${_l10n_targets}) @@ -50,4 +61,3 @@ function(qt_translation) add_dependencies(${_target} ${_target}_qrc) target_sources(${_target} PUBLIC ${_qrc}) endfunction() - diff --git a/CMLibSanitizers.cmake b/CMLibSanitizers.cmake index be3d883..776c348 100644 --- a/CMLibSanitizers.cmake +++ b/CMLibSanitizers.cmake @@ -10,4 +10,3 @@ if(IS_DIRECTORY "${CMLIB_MODULE_DIR}") else() message(FATAL_ERROR "CMLib directory not found.") endif() - diff --git a/CMLibToday.cmake b/CMLibToday.cmake index 10e7b7e..377050e 100644 --- a/CMLibToday.cmake +++ b/CMLibToday.cmake @@ -4,5 +4,9 @@ if(NOT TODAY) else() execute_process(COMMAND "date" "+%d/%m/%Y" OUTPUT_VARIABLE TODAY) endif() - string(REGEX REPLACE "(..)/(..)/(....).*" "\\3-\\2-\\1" TODAY ${TODAY}) + string(REGEX + REPLACE "(..)/(..)/(....).*" + "\\3-\\2-\\1" + TODAY + ${TODAY}) endif() diff --git a/CMLibUninstall.cmake b/CMLibUninstall.cmake index ba15774..7413496 100644 --- a/CMLibUninstall.cmake +++ b/CMLibUninstall.cmake @@ -1,8 +1,8 @@ if(NOT TARGET uninstall) configure_file("${CMLIB_MODULE_DIR}/CMLibUninstall.cmake.in" - "${CMAKE_BINARY_DIR}/cmake_uninstall.cmake" IMMEDIATE @ONLY) + "${CMAKE_BINARY_DIR}/cmake_uninstall.cmake" + IMMEDIATE + @ONLY) - add_custom_target(uninstall - COMMAND ${CMAKE_COMMAND} -P - ${CMAKE_BINARY_DIR}/cmake_uninstall.cmake) + add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/cmake_uninstall.cmake) endif()