Форматирование кода

This commit is contained in:
Andrei Astafev 2021-12-12 23:11:20 +03:00
parent f156a614aa
commit e81a491606
5 changed files with 28 additions and 41 deletions

View File

@ -83,7 +83,7 @@ function(myx_cmake_doc_breathe)
COMPONENT doc OPTIONAL COMPONENT doc OPTIONAL
DESTINATION ${CMAKE_INSTALL_DATADIR}/doc/breathe) DESTINATION ${CMAKE_INSTALL_DATADIR}/doc/breathe)
else() else()
message(STATUS "CMLIB warning:") message(STATUS "MyxCMake:")
add_custom_target(${target} VERBATIM COMMENT " Breathe is not found. Skipping target ${target} build") add_custom_target(${target} VERBATIM COMMENT " Breathe is not found. Skipping target ${target} build")
endif() endif()
endfunction() endfunction()

View File

@ -7,9 +7,8 @@ function(myx_cmake_add_shared_library target)
endif() endif()
get_target_property(__target_type ${target} TYPE) get_target_property(__target_type ${target} TYPE)
if(NOT __target_type STREQUAL OBJECT_LIBRARY) if(NOT __target_type STREQUAL OBJECT_LIBRARY)
message( message(FATAL_ERROR
FATAL_ERROR "MyxCMake: myx_cmake_add_shared_library needs target of type OBJECT_LIBRARY")
"MyxCMake: myx_cmake_add_shared_library needs target of type OBJECT_LIBRARY")
return() return()
endif() endif()

View File

@ -7,9 +7,8 @@ function(myx_cmake_add_static_library target)
endif() endif()
get_target_property(__target_type ${target} TYPE) get_target_property(__target_type ${target} TYPE)
if(NOT __target_type STREQUAL OBJECT_LIBRARY) if(NOT __target_type STREQUAL OBJECT_LIBRARY)
message( message(FATAL_ERROR
FATAL_ERROR "MyxCMake: myx_cmake_add_static_library needs target of type OBJECT_LIBRARY")
"MyxCMake: myx_cmake_add_static_library needs target of type OBJECT_LIBRARY")
return() return()
endif() endif()

View File

@ -2,9 +2,8 @@ cmake_policy(PUSH)
cmake_policy(SET CMP0057 NEW) # IN_LIST operator cmake_policy(SET CMP0057 NEW) # IN_LIST operator
option(MYX_CMAKE_ENABLE_WARNING_FLAGS "Enable autodetected warning flags" ON) option(MYX_CMAKE_ENABLE_WARNING_FLAGS "Enable autodetected warning flags" ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE BOOL
ON "Enable generation of compile_commands.json." FORCE)
CACHE BOOL "Enable generation of compile_commands.json." FORCE)
# Добавление конфигурации для профилирования # Добавление конфигурации для профилирования
if(CMAKE_CONFIGURATION_TYPES) if(CMAKE_CONFIGURATION_TYPES)
@ -15,9 +14,7 @@ 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}) set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS ${_allowed_build_types})
if(NOT CMAKE_BUILD_TYPE) if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE set(CMAKE_BUILD_TYPE Debug CACHE STRING "" FORCE)
Debug
CACHE STRING "" FORCE)
elseif(NOT "${CMAKE_BUILD_TYPE}" IN_LIST _allowed_build_types) elseif(NOT "${CMAKE_BUILD_TYPE}" IN_LIST _allowed_build_types)
message(FATAL_ERROR "Invalid build type: ${CMAKE_BUILD_TYPE}") message(FATAL_ERROR "Invalid build type: ${CMAKE_BUILD_TYPE}")
endif() endif()
@ -52,20 +49,15 @@ if(CMAKE_BUILD_TYPE STREQUAL Profile)
elseif(CMAKE_CXX_COMPILER_IS_MSVC) elseif(CMAKE_CXX_COMPILER_IS_MSVC)
message("Set options for profiling with Visual Studio C++") message("Set options for profiling with Visual Studio C++")
endif() endif()
set(CMAKE_VERBOSE_MAKEFILE set(CMAKE_VERBOSE_MAKEFILE ON CACHE BOOL
ON "Enable generation of verbose build scripts." FORCE)
CACHE BOOL "Enable generation of verbose build scripts." FORCE)
elseif(CMAKE_BUILD_TYPE STREQUAL Debug) elseif(CMAKE_BUILD_TYPE STREQUAL Debug)
# В режиме отладки подробный вывод сообщений компилятора # В режиме отладки подробный вывод сообщений компилятора
if(CMAKE_CXX_COMPILER_IS_CLANG OR CMAKE_CXX_COMPILER_IS_GCC) if(CMAKE_CXX_COMPILER_IS_CLANG OR CMAKE_CXX_COMPILER_IS_GCC)
string(REPLACE " ${_gcc_debug_flags}" "" CMAKE_C_FLAGS_DEBUG string(REPLACE " ${_gcc_debug_flags}" "" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}")
"${CMAKE_C_FLAGS_DEBUG}") set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${_gcc_debug_flags}" CACHE STRING "" FORCE)
set(CMAKE_C_FLAGS_DEBUG
"${CMAKE_C_FLAGS_DEBUG} ${_gcc_debug_flags}"
CACHE STRING "" FORCE)
string(REPLACE " ${_gcc_debug_flags}" "" CMAKE_CXX_FLAGS_DEBUG string(REPLACE " ${_gcc_debug_flags}" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
"${CMAKE_CXX_FLAGS_DEBUG}")
if(MYX_CMAKE_ENABLE_WARNING_FLAGS) if(MYX_CMAKE_ENABLE_WARNING_FLAGS)
set(CMAKE_CXX_FLAGS_DEBUG set(CMAKE_CXX_FLAGS_DEBUG
"${CMAKE_CXX_FLAGS_DEBUG} ${MYX_CMAKE_DETECTED_CXX_FLAGS_DEBUG} ${_gcc_debug_flags}" "${CMAKE_CXX_FLAGS_DEBUG} ${MYX_CMAKE_DETECTED_CXX_FLAGS_DEBUG} ${_gcc_debug_flags}"
@ -76,18 +68,15 @@ elseif(CMAKE_BUILD_TYPE STREQUAL Debug)
CACHE STRING "" FORCE) CACHE STRING "" FORCE)
endif() endif()
endif() endif()
set(CMAKE_VERBOSE_MAKEFILE set(CMAKE_VERBOSE_MAKEFILE ON CACHE BOOL
ON "Enable generation of verbose build scripts." FORCE)
CACHE BOOL "Enable generation of verbose build scripts." FORCE)
elseif(CMAKE_BUILD_TYPE STREQUAL Release) elseif(CMAKE_BUILD_TYPE STREQUAL Release)
set(CMAKE_CXX_FLAGS_RELEASE set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${MYX_CMAKE_DETECTED_CXX_FLAGS}"
"${CMAKE_CXX_FLAGS_RELEASE} ${MYX_CMAKE_DETECTED_CXX_FLAGS}"
CACHE STRING "" FORCE) CACHE STRING "" FORCE)
elseif(CMAKE_BUILD_TYPE STREQUAL None) elseif(CMAKE_BUILD_TYPE STREQUAL None)
# Режим None используется для статического анализа кода # Режим None используется для статического анализа кода
set(CMAKE_VERBOSE_MAKEFILE set(CMAKE_VERBOSE_MAKEFILE ON CACHE BOOL
ON "Enable generation of verbose build scripts." FORCE)
CACHE BOOL "Enable generation of verbose build scripts." FORCE)
endif() endif()
unset(_gcc_debug_flags) unset(_gcc_debug_flags)

View File

@ -40,16 +40,16 @@ option(MYX_CMAKE_COMPACT_SOURCE_PACKAGE "Make compact source package" ON)
if(MYX_CMAKE_COMPACT_SOURCE_PACKAGE) if(MYX_CMAKE_COMPACT_SOURCE_PACKAGE)
# Список масок для исключения из архива исходных текстов для более компактного архива # Список масок для исключения из архива исходных текстов для более компактного архива
set(CPACK_SOURCE_IGNORE_FILES set(CPACK_SOURCE_IGNORE_FILES
"${CPACK_SOURCE_IGNORE_FILES}" "${CPACK_SOURCE_IGNORE_FILES}"
"\\\\.git" "\\\\.git"
"/\\\\.git/" "/\\\\.git/"
"/\\\\.gitlab-ci/" "/\\\\.gitlab-ci/"
"\\\\.clang-tidy$" "\\\\.clang-tidy$"
"\\\\.cmake-format$" "\\\\.cmake-format$"
"\\\\.gitignore$" "\\\\.gitignore$"
"\\\\.gitattributes$" "\\\\.gitattributes$"
"\\\\.gitmodules$" "\\\\.gitmodules$"
"\\\\.gitlab-ci.yml$") "\\\\.gitlab-ci.yml$")
endif() endif()
set(CPACK_PROJECT_CONFIG_FILE ${CMAKE_CURRENT_LIST_DIR}/MyxCMakeCPackProject.cmake) set(CPACK_PROJECT_CONFIG_FILE ${CMAKE_CURRENT_LIST_DIR}/MyxCMakeCPackProject.cmake)