diff --git a/CMLibCPackSources.cmake b/CMLibCPackSources.cmake index 5ac412c..cec023f 100644 --- a/CMLibCPackSources.cmake +++ b/CMLibCPackSources.cmake @@ -3,7 +3,9 @@ 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/CMLibCommonLibraryTarget.cmake b/CMLibCommonLibraryTarget.cmake index 7056c62..ae5190a 100644 --- a/CMLibCommonLibraryTarget.cmake +++ b/CMLibCommonLibraryTarget.cmake @@ -1,25 +1,28 @@ # Создание статической и динамической библиотеки из одинаковых объектных файлов function(add_common_library LIBNAME SOURCES) add_library(${LIBNAME} OBJECT ${SOURCES}) - target_include_directories(${LIBNAME} PUBLIC - $ - $ - $) + target_include_directories( + ${LIBNAME} + PUBLIC $ + $ + $) set_target_properties(${LIBNAME} PROPERTIES POSITION_INDEPENDENT_CODE ON) add_library(${LIBNAME}_shared SHARED $) get_property(_ver GLOBAL PROPERTY VERSION_STR) get_property(_sover GLOBAL PROPERTY VERSION_MAJOR) - set_target_properties(${LIBNAME}_shared PROPERTIES - VERSION ${_ver} - SOVERSION ${_sover} - OUTPUT_NAME ${LIBNAME} - LIBRARY_OUTPUT_DIRECTORY ${CMAKE_INSTALL_LIBDIR}) + set_target_properties(${LIBNAME}_shared + PROPERTIES VERSION ${_ver} + SOVERSION ${_sover} + OUTPUT_NAME ${LIBNAME} + LIBRARY_OUTPUT_DIRECTORY ${CMAKE_INSTALL_LIBDIR}) add_library(${LIBNAME}_static STATIC $) - set_target_properties(${LIBNAME}_static PROPERTIES - OUTPUT_NAME ${LIBNAME} - ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_INSTALL_LIBDIR}) - configure_file(${CMLIB_MODULE_DIR}/pc/lib.pc.in ${CMAKE_BINARY_DIR}/${LIBNAME}.pc) + set_target_properties(${LIBNAME}_static + PROPERTIES OUTPUT_NAME ${LIBNAME} + ARCHIVE_OUTPUT_DIRECTORY + ${CMAKE_INSTALL_LIBDIR}) + configure_file(${CMLIB_MODULE_DIR}/pc/lib.pc.in + ${CMAKE_BINARY_DIR}/${LIBNAME}.pc) endfunction() diff --git a/CMLibCommonTargetProperties.cmake b/CMLibCommonTargetProperties.cmake index d5026e6..592476a 100644 --- a/CMLibCommonTargetProperties.cmake +++ b/CMLibCommonTargetProperties.cmake @@ -1,5 +1,4 @@ -set(COMMON_CXX_FEATURES - cxx_alias_templates cxx_nullptr cxx_override) +set(COMMON_CXX_FEATURES cxx_alias_templates cxx_nullptr cxx_override) function(common_target_properties Name) get_target_property(__type ${Name} TYPE) @@ -9,24 +8,29 @@ function(common_target_properties Name) set(__visibility INTERFACE) endif() target_compile_features(${Name} ${__visibility} ${COMMON_CXX_FEATURES}) - 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) - target_compile_options(${Name} PUBLIC "${Qt5Core_EXECUTABLE_COMPILE_FLAGS}") + target_compile_options(${Name} + PUBLIC "${Qt5Core_EXECUTABLE_COMPILE_FLAGS}") 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 - $) + if(CMAKE_VERSION VERSION_LESS 3.7.99) + target_include_directories( + ${Name} + PUBLIC + $ + ) endif() endif() if(CMAKE_CXX_COMPILER_IS_GCC AND NOT APPLE) diff --git a/CMLibCompiler.cmake b/CMLibCompiler.cmake index 87ea801..61b415e 100644 --- a/CMLibCompiler.cmake +++ b/CMLibCompiler.cmake @@ -1,8 +1,8 @@ # 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,8 +13,8 @@ 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) diff --git a/CMLibCompilerFlags.cmake b/CMLibCompilerFlags.cmake index 4b7c42a..9747726 100644 --- a/CMLibCompilerFlags.cmake +++ b/CMLibCompilerFlags.cmake @@ -18,93 +18,98 @@ 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) if(CMAKE_BUILD_TYPE STREQUAL "Debug") - CHECK_ENABLE_CXX_FLAG(-Wall) - CHECK_ENABLE_CXX_FLAG(-Wextra) - CHECK_ENABLE_CXX_FLAG(-Wnon-virtual-dtor) - CHECK_ENABLE_CXX_FLAG(-Wnoexcept) - CHECK_ENABLE_CXX_FLAG(-Wlogical-op) - CHECK_ENABLE_CXX_FLAG(-Wconversion) - CHECK_ENABLE_CXX_FLAG(-Wdeprecated) + check_enable_cxx_flag(-Wall) + check_enable_cxx_flag(-Wextra) + check_enable_cxx_flag(-Wnon-virtual-dtor) + check_enable_cxx_flag(-Wnoexcept) + check_enable_cxx_flag(-Wlogical-op) + check_enable_cxx_flag(-Wconversion) + check_enable_cxx_flag(-Wdeprecated) # This limit is supposed to be at least 1024 in C++11, but for some reason # clang sets this to 256, and gcc to 900. - CHECK_ENABLE_CXX_FLAG(-ftemplate-depth=1024) - CHECK_ENABLE_CXX_FLAG(-Wold-style-cast) - CHECK_ENABLE_CXX_FLAG(-Wdisabled-optimization) - # This is useful when the compiler decides the template backtrace is too verbose. - CHECK_ENABLE_CXX_FLAG(-ftemplate-backtrace-limit=0) - CHECK_ENABLE_CXX_FLAG(-fstack-protector-all) + check_enable_cxx_flag(-ftemplate-depth=1024) + check_enable_cxx_flag(-Wold-style-cast) + check_enable_cxx_flag(-Wdisabled-optimization) + # This is useful when the compiler decides the template backtrace is too + # verbose. + check_enable_cxx_flag(-ftemplate-backtrace-limit=0) + check_enable_cxx_flag(-fstack-protector-all) # A few suggestion flags. - CHECK_ENABLE_CXX_FLAG(-Wsuggest-attribute=pure) - CHECK_ENABLE_CXX_FLAG(-Wsuggest-attribute=const) - CHECK_ENABLE_CXX_FLAG(-Wsuggest-attribute=noreturn) - CHECK_ENABLE_CXX_FLAG(-Wsuggest-attribute=format) + check_enable_cxx_flag(-Wsuggest-attribute=pure) + check_enable_cxx_flag(-Wsuggest-attribute=const) + check_enable_cxx_flag(-Wsuggest-attribute=noreturn) + check_enable_cxx_flag(-Wsuggest-attribute=format) # From GCC 5. - CHECK_ENABLE_CXX_FLAG(-Wodr) - CHECK_ENABLE_CXX_FLAG(-Wsuggest-final-types) - CHECK_ENABLE_CXX_FLAG(-Wsuggest-final-methods) - CHECK_ENABLE_CXX_FLAG(-Wsuggest-override) + check_enable_cxx_flag(-Wodr) + check_enable_cxx_flag(-Wsuggest-final-types) + check_enable_cxx_flag(-Wsuggest-final-methods) + check_enable_cxx_flag(-Wsuggest-override) # From GCC 6. - CHECK_ENABLE_CXX_FLAG(-Wshift-negative-value) - CHECK_ENABLE_CXX_FLAG(-Wshift-overflow=2) - CHECK_ENABLE_CXX_FLAG(-Wduplicated-cond) - CHECK_ENABLE_CXX_FLAG(-Wnull-dereference) + check_enable_cxx_flag(-Wshift-negative-value) + check_enable_cxx_flag(-Wshift-overflow=2) + check_enable_cxx_flag(-Wduplicated-cond) + check_enable_cxx_flag(-Wnull-dereference) # From GCC 7. - CHECK_ENABLE_CXX_FLAG(-Wrestrict) - CHECK_ENABLE_CXX_FLAG(-Waligned-new) + check_enable_cxx_flag(-Wrestrict) + check_enable_cxx_flag(-Waligned-new) # From GCC 8. - CHECK_ENABLE_CXX_FLAG(-Wcast-align=strict) - # This is supposed to produce a nice graphical visualization - # of mismatching template errors. - CHECK_ENABLE_CXX_FLAG(-fdiagnostics-show-template-tree) - CHECK_ENABLE_CXX_FLAG(-fdiagnostics-show-option) + check_enable_cxx_flag(-Wcast-align=strict) + # This is supposed to produce a nice graphical visualization of mismatching + # template errors. + check_enable_cxx_flag(-fdiagnostics-show-template-tree) + check_enable_cxx_flag(-fdiagnostics-show-option) - CHECK_ENABLE_CXX_FLAG(-pedantic) - CHECK_ENABLE_CXX_FLAG(-Wcast-align) - CHECK_ENABLE_CXX_FLAG(-Wcast-qual) - CHECK_ENABLE_CXX_FLAG(-Wctor-dtor-privacy) - CHECK_ENABLE_CXX_FLAG(-Wdisabled-optimization) - CHECK_ENABLE_CXX_FLAG(-Wformat=2) - CHECK_ENABLE_CXX_FLAG(-Winit-self) - CHECK_ENABLE_CXX_FLAG(-Wmissing-include-dirs) - CHECK_ENABLE_CXX_FLAG(-Woverloaded-virtual) - CHECK_ENABLE_CXX_FLAG(-Wredundant-decls) - CHECK_ENABLE_CXX_FLAG(-Wsign-promo) - CHECK_ENABLE_CXX_FLAG(-Wstrict-overflow=5) - CHECK_ENABLE_CXX_FLAG(-Wundef) - CHECK_ENABLE_CXX_FLAG(-Wno-unused) - CHECK_ENABLE_CXX_FLAG(-Wno-variadic-macros) - CHECK_ENABLE_CXX_FLAG(-Wno-parentheses) - CHECK_ENABLE_CXX_FLAG(-Wstrict-null-sentinel) - CHECK_ENABLE_CXX_FLAG(-Wshadow) - CHECK_ENABLE_CXX_FLAG(-Wshadow-all) + check_enable_cxx_flag(-pedantic) + check_enable_cxx_flag(-Wcast-align) + check_enable_cxx_flag(-Wcast-qual) + check_enable_cxx_flag(-Wctor-dtor-privacy) + check_enable_cxx_flag(-Wdisabled-optimization) + check_enable_cxx_flag(-Wformat=2) + check_enable_cxx_flag(-Winit-self) + check_enable_cxx_flag(-Wmissing-include-dirs) + check_enable_cxx_flag(-Woverloaded-virtual) + check_enable_cxx_flag(-Wredundant-decls) + check_enable_cxx_flag(-Wsign-promo) + check_enable_cxx_flag(-Wstrict-overflow=5) + check_enable_cxx_flag(-Wundef) + check_enable_cxx_flag(-Wno-unused) + check_enable_cxx_flag(-Wno-variadic-macros) + check_enable_cxx_flag(-Wno-parentheses) + check_enable_cxx_flag(-Wstrict-null-sentinel) + check_enable_cxx_flag(-Wshadow) + check_enable_cxx_flag(-Wshadow-all) endif() if(CMAKE_BUILD_TYPE STREQUAL "Release") - CHECK_ENABLE_CXX_FLAG(-flto) - if(CMAKE_CXX_COMPILER_IS_GCC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "4.8") + check_enable_cxx_flag(-flto) + if(CMAKE_CXX_COMPILER_IS_GCC + AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "4.8") # Doesn't work with GCC 4.7.2 in Astra Linux 1.5 - CHECK_ENABLE_CXX_FLAG(-fno-fat-lto-objects) + check_enable_cxx_flag(-fno-fat-lto-objects) endif() endif() endif() -if (CMAKE_CXX_COMPILER_IS_GCC) - CHECK_ENABLE_CXX_FLAG(-fdiagnostics-color=auto) - # The -Wmaybe-uninitialized flag is enabled by -Wall, but it is known - # to emit a lot of possibly spurious warnings. Let's just disable it. - CHECK_ENABLE_CXX_FLAG(-Wno-maybe-uninitialized) +if(CMAKE_CXX_COMPILER_IS_GCC) + check_enable_cxx_flag(-fdiagnostics-color=auto) + # The -Wmaybe-uninitialized flag is enabled by -Wall, + # but it is known to emit a lot of possibly spurious warnings. + # Let's just disable it. + check_enable_cxx_flag(-Wno-maybe-uninitialized) if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "5.999") # NOTE: GCC >= 6 seems to be wrongly warning about visibility attributes # in some situations: # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80947 # Let's just disable the warning for now. - CHECK_ENABLE_CXX_FLAG(-Wno-attributes) + check_enable_cxx_flag(-Wno-attributes) endif() endif() diff --git a/CMLibConfigHPPGenerate.cmake b/CMLibConfigHPPGenerate.cmake index 2ba7b31..b5f42c3 100644 --- a/CMLibConfigHPPGenerate.cmake +++ b/CMLibConfigHPPGenerate.cmake @@ -5,5 +5,6 @@ function(cmlib_config_hpp_generate) get_property(VERSION_INT GLOBAL PROPERTY VERSION_INT) get_property(VERSION_STR GLOBAL PROPERTY VERSION_STR) get_property(ORGANIZATION_NAME GLOBAL PROPERTY ORGANIZATION_NAME) - configure_file(${CMLIB_MODULE_DIR}/hpp/config.hpp.in ${CMAKE_BINARY_DIR}/include/config.hpp) + configure_file(${CMLIB_MODULE_DIR}/hpp/config.hpp.in + ${CMAKE_BINARY_DIR}/include/config.hpp) endfunction() diff --git a/CMLibDisableInSourceBuild.cmake b/CMLibDisableInSourceBuild.cmake index 4e7f2df..1110a55 100644 --- a/CMLibDisableInSourceBuild.cmake +++ b/CMLibDisableInSourceBuild.cmake @@ -9,7 +9,7 @@ get_filename_component(_source_realpath "${CMAKE_SOURCE_DIR}" REALPATH) get_filename_component(_binary_realpath "${CMAKE_BINARY_DIR}" REALPATH) if(${_source_realpath} STREQUAL ${_binary_realpath}) - message(FATAL_ERROR "In-source builds are not allowed.") + message(FATAL_ERROR "In-source builds are not allowed.") endif() # Очистка от сгенерированных файлов @@ -17,13 +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/CMLibFlagRemove.cmake b/CMLibFlagRemove.cmake index ee68552..b416768 100644 --- a/CMLibFlagRemove.cmake +++ b/CMLibFlagRemove.cmake @@ -7,14 +7,14 @@ # Pre: apply_global_cxx_flags_to_all_targets() must be invoked. # 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}") - endif() + 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}") + endif() endmacro() - # # Removes the specified compiler flag from the specified file. # _target - The target that _file belongs to @@ -24,48 +24,57 @@ endmacro() # Pre: apply_global_cxx_flags_to_all_targets() must be invoked. # 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) - unset(_cached_${_target}_cxx_flags CACHE) - unset(_cached_${_target}_${_file}_cxx_flags CACHE) - endif() - get_target_property(_${_target}_cxx_flags ${_target} COMPILE_OPTIONS) - # On first entry, cache the target compile flags and apply them to each source file - # in the target. - if(NOT _cached_${_target}_cxx_flags) - # Obtain and cache the target compiler options, then clear them. - get_target_property(_target_cxx_flags ${_target} COMPILE_OPTIONS) - set(_cached_${_target}_cxx_flags "${_target_cxx_flags}" CACHE INTERNAL "") - set_target_properties(${_target} PROPERTIES COMPILE_OPTIONS "") - # 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) - if(_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 "${_source_file_cxx_flags}") - set_source_files_properties(${_source_file} PROPERTIES COMPILE_FLAGS "${_source_file_cxx_flags_string}") - endforeach() - endif() - list(FIND _target_sources ${_file} _file_found_at) - if(_file_found_at GREATER -1) - if(NOT _cached_${_target}_${_file}_cxx_flags) - # 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 "") - 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 "${_cached_${_target}_${_file}_cxx_flags}") - set_source_files_properties(${_file} PROPERTIES COMPILE_FLAGS "${_cached_${_target}_${_file}_cxx_flags_string}") + 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) + unset(_cached_${_target}_cxx_flags CACHE) + unset(_cached_${_target}_${_file}_cxx_flags CACHE) + endif() + get_target_property(_${_target}_cxx_flags ${_target} COMPILE_OPTIONS) + # On first entry, cache the target compile flags and apply them to each source file + # in the target. + if(NOT _cached_${_target}_cxx_flags) + # Obtain and cache the target compiler options, then clear them. + get_target_property(_target_cxx_flags ${_target} COMPILE_OPTIONS) + set(_cached_${_target}_cxx_flags "${_target_cxx_flags}" CACHE INTERNAL "") + set_target_properties(${_target} PROPERTIES COMPILE_OPTIONS "") + # 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) + if(_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 + "${_source_file_cxx_flags}") + set_source_files_properties(${_source_file} PROPERTIES COMPILE_FLAGS + "${_source_file_cxx_flags_string}") + endforeach() + endif() + list(FIND _target_sources ${_file} _file_found_at) + if(_file_found_at GREATER -1) + if(NOT _cached_${_target}_${_file}_cxx_flags) + # 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 "") 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 + "${_cached_${_target}_${_file}_cxx_flags}") + set_source_files_properties( + ${_file} PROPERTIES COMPILE_FLAGS + "${_cached_${_target}_${_file}_cxx_flags_string}") + endif() endmacro() diff --git a/CMLibLSBInfo.cmake b/CMLibLSBInfo.cmake index 7bca79f..604fe26 100644 --- a/CMLibLSBInfo.cmake +++ b/CMLibLSBInfo.cmake @@ -6,13 +6,16 @@ find_program(_lsb_release_executable lsb_release) if(_lsb_release_executable) execute_process(COMMAND ${_lsb_release_executable} -sc - OUTPUT_VARIABLE LSB_CODENAME OUTPUT_STRIP_TRAILING_WHITESPACE) + OUTPUT_VARIABLE LSB_CODENAME + OUTPUT_STRIP_TRAILING_WHITESPACE) execute_process(COMMAND ${_lsb_release_executable} -sr - OUTPUT_VARIABLE LSB_RELEASE OUTPUT_STRIP_TRAILING_WHITESPACE) + OUTPUT_VARIABLE LSB_RELEASE + OUTPUT_STRIP_TRAILING_WHITESPACE) execute_process(COMMAND ${_lsb_release_executable} -si - OUTPUT_VARIABLE LSB_DISTRIBUTOR_ID OUTPUT_STRIP_TRAILING_WHITESPACE) + OUTPUT_VARIABLE LSB_DISTRIBUTOR_ID + OUTPUT_STRIP_TRAILING_WHITESPACE) else() set(LSB_DISTRIBUTOR_ID "unknown") set(LSB_RELEASE "unknown") diff --git a/CMLibOrganizationName.cmake b/CMLibOrganizationName.cmake index 6c56f61..234e53f 100644 --- a/CMLibOrganizationName.cmake +++ b/CMLibOrganizationName.cmake @@ -6,7 +6,9 @@ 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") diff --git a/CMLibProjectVersion.cmake b/CMLibProjectVersion.cmake index e8e4c56..245cf14 100644 --- a/CMLibProjectVersion.cmake +++ b/CMLibProjectVersion.cmake @@ -7,7 +7,9 @@ function(set_project_version) message(FATAL_ERROR "File ${_version_file} doesn't exists") endif() file(READ "${_version_file}" _version) - set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${_version_file}) + set_property(DIRECTORY + APPEND + PROPERTY CMAKE_CONFIGURE_DEPENDS ${_version_file}) if(NOT "${_version}" MATCHES "^([0-9]+)\\.([0-9]+)\\.([0-9]+)\n") message(FATAL_ERROR "${_version_file} has wrong format") @@ -18,8 +20,11 @@ function(set_project_version) set_property(GLOBAL PROPERTY VERSION_MAJOR ${CMAKE_MATCH_1}) set_property(GLOBAL PROPERTY VERSION_MINOR ${CMAKE_MATCH_2}) set_property(GLOBAL PROPERTY VERSION_PATCH ${CMAKE_MATCH_3}) - math(EXPR _version_int "(${CMAKE_MATCH_1} << 16) + (${CMAKE_MATCH_2} << 8) + ${CMAKE_MATCH_3}") + math(EXPR _version_int + "(${CMAKE_MATCH_1} << 16) + (${CMAKE_MATCH_2} << 8) + ${CMAKE_MATCH_3}") set_property(GLOBAL PROPERTY VERSION_INT ${_version_int}) - set_property(GLOBAL PROPERTY VERSION_STR "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}.${CMAKE_MATCH_3}") + set_property(GLOBAL + PROPERTY VERSION_STR + "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}.${CMAKE_MATCH_3}") endfunction() diff --git a/CMLibQtTranslation.cmake b/CMLibQtTranslation.cmake index 65e980b..fdd33e0 100644 --- a/CMLibQtTranslation.cmake +++ b/CMLibQtTranslation.cmake @@ -29,18 +29,23 @@ function(qt_translation) ") endif() - string(APPEND L10N_QRC_BODY "${CMAKE_BINARY_DIR}/${_qm}\n") + string(APPEND L10N_QRC_BODY + "${CMAKE_BINARY_DIR}/${_qm}\n") add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/${_qm} - COMMAND ${Qt5_LRELEASE_EXECUTABLE} ARGS ${_ts_dir}/${_ts} -qm ${CMAKE_BINARY_DIR}/${_qm} - DEPENDS ${_ts_dir}/${_ts}) + COMMAND ${Qt5_LRELEASE_EXECUTABLE} + ARGS ${_ts_dir}/${_ts} -qm + ${CMAKE_BINARY_DIR}/${_qm} + DEPENDS ${_ts_dir}/${_ts}) endforeach() add_custom_command(OUTPUT ${_ts_list} - COMMAND ${Qt5_LUPDATE_EXECUTABLE} ARGS ${_sources_list} -ts ${_ts_list} - DEPENDS ${_sources_list}) + COMMAND ${Qt5_LUPDATE_EXECUTABLE} + ARGS ${_sources_list} -ts ${_ts_list} + DEPENDS ${_sources_list}) - 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(_qrc_target DEPENDS ${_qrc}) diff --git a/CMLibUninstall.cmake b/CMLibUninstall.cmake index 78ec366..ba15774 100644 --- a/CMLibUninstall.cmake +++ b/CMLibUninstall.cmake @@ -1,9 +1,8 @@ if(NOT TARGET uninstall) - configure_file( - "${CMLIB_MODULE_DIR}/CMLibUninstall.cmake.in" - "${CMAKE_BINARY_DIR}/cmake_uninstall.cmake" - IMMEDIATE @ONLY) + configure_file("${CMLIB_MODULE_DIR}/CMLibUninstall.cmake.in" + "${CMAKE_BINARY_DIR}/cmake_uninstall.cmake" IMMEDIATE @ONLY) add_custom_target(uninstall - COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/cmake_uninstall.cmake) + COMMAND ${CMAKE_COMMAND} -P + ${CMAKE_BINARY_DIR}/cmake_uninstall.cmake) endif()