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

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
DESTINATION ${CMAKE_INSTALL_DATADIR}/doc/breathe)
else()
message(STATUS "CMLIB warning:")
message(STATUS "MyxCMake:")
add_custom_target(${target} VERBATIM COMMENT " Breathe is not found. Skipping target ${target} build")
endif()
endfunction()

View File

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

View File

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

View File

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