Compare commits
31 Commits
4768c5efc7
...
197e5b3939
Author | SHA1 | Date | |
---|---|---|---|
197e5b3939 | |||
8ca93d3115 | |||
a52a9e7b8a | |||
83a9e94e31 | |||
4bd8ab0ced | |||
e5fbb90235 | |||
2909f5a9d4 | |||
6449929719 | |||
d1685694ed | |||
b513e9b15b | |||
8a09a61d52 | |||
8defb4fbb4 | |||
0dbfda298f | |||
81b3a19a55 | |||
a1765526f8 | |||
48fff012d0 | |||
3ebfdf81a8 | |||
f97349f404 | |||
f0a7996d26 | |||
8d2809a772 | |||
afa8b1e295 | |||
255f0f432b | |||
d709a6d555 | |||
9c6148ab82 | |||
0b69005b7a | |||
cebdb82bfa | |||
b5ed0303a1 | |||
3e8511da71 | |||
3c0fd214b9 | |||
8730aba9bf | |||
f168386296 |
@ -1,3 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ----------------------------------
|
||||
# Options affecting listfile parsing
|
||||
# ----------------------------------
|
||||
@ -5,15 +7,21 @@ with section("parse"):
|
||||
|
||||
# Specify structure for custom cmake functions
|
||||
additional_commands = {
|
||||
'add_doxygen': { 'flags' : [],
|
||||
'kwargs': { 'LATEX': 1,
|
||||
'HTML': 1,
|
||||
'COMMENT': 1}},
|
||||
'add_breathe': { 'flags' : [],
|
||||
'kwargs': { 'COMMENT': 1}},
|
||||
'add_common_library': { 'flags' : [],
|
||||
'kwargs': { 'OUTPUT_NAME': '*',
|
||||
'kwargs': { 'OUTPUT_NAME': 1,
|
||||
'SOURCES': '*',
|
||||
'TARGET': '1'}},
|
||||
'TARGET': 1}},
|
||||
'qt5_translation': { 'flags' : [],
|
||||
'kwargs': { 'TS_DIR': '1',
|
||||
'kwargs': { 'OUTPUT_DIR': 1,
|
||||
'LANGUAGES': '*',
|
||||
'SOURCES': '*',
|
||||
'TARGET': '1'}},
|
||||
'BASE_NAME': 1}},
|
||||
'pvs_studio_add_target': { 'flags' : [ 'COMPILE_COMMANDS',
|
||||
'OUTPUT',
|
||||
'HIDE_HELP'],
|
||||
@ -22,7 +30,7 @@ with section("parse"):
|
||||
'DEPENDS': '*',
|
||||
'FORMAT': '*',
|
||||
'MODE': '*',
|
||||
'TARGET': '*'}},
|
||||
'TARGET': 1}},
|
||||
'write_compiler_detection_header': { 'flags' : [],
|
||||
'kwargs': { 'COMPILERS': '*',
|
||||
'FEATURES': '*',
|
||||
@ -48,11 +56,11 @@ with section("format"):
|
||||
|
||||
# If an argument group contains more than this many sub-groups (parg or kwarg
|
||||
# groups) then force it to a vertical layout.
|
||||
max_subgroups_hwrap = 2
|
||||
max_subgroups_hwrap = 3
|
||||
|
||||
# If a positional argument group contains more than this many arguments, then
|
||||
# force it to a vertical layout.
|
||||
max_pargs_hwrap = 6
|
||||
max_pargs_hwrap = 5
|
||||
|
||||
# If a cmdline positional group consumes more than this many lines without
|
||||
# nesting, then invalidate the layout (and nest)
|
||||
|
@ -24,37 +24,36 @@ 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} -ggdb -pg" CACHE STRING "")
|
||||
set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE} -ggdb -pg" CACHE STRING "")
|
||||
set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -pg" CACHE STRING "")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} -pg" CACHE STRING "")
|
||||
set(CMAKE_STATIC_LINKER_FLAGS_PROFILE "${CMAKE_STATIC_LINKER_FLAGS_RELEASE} -pg" CACHE STRING "")
|
||||
set(CMAKE_MODULE_LINKER_FLAGS_PROFILE "${CMAKE_MODULE_LINKER_FLAGS_RELEASE} -pg" CACHE STRING "")
|
||||
set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE} -ggdb -pg -fno-omit-frame-pointer" CACHE STRING ""
|
||||
FORCE)
|
||||
set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE} -ggdb -pg -fno-omit-frame-pointer" CACHE STRING
|
||||
"" FORCE)
|
||||
set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -pg" CACHE STRING "" FORCE)
|
||||
set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} -pg" CACHE STRING "" FORCE)
|
||||
set(CMAKE_STATIC_LINKER_FLAGS_PROFILE "${CMAKE_STATIC_LINKER_FLAGS_RELEASE} -pg" CACHE STRING "" FORCE)
|
||||
set(CMAKE_MODULE_LINKER_FLAGS_PROFILE "${CMAKE_MODULE_LINKER_FLAGS_RELEASE} -pg" CACHE STRING "" FORCE)
|
||||
elseif(CMAKE_CXX_COMPILER_IS_Intel)
|
||||
message("Set options for profiling with Intel C++")
|
||||
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_EXPORT_COMPILE_COMMANDS ON CACHE BOOL "Enable generation of compile_commands.json." FORCE)
|
||||
set(PROFILE 1)
|
||||
elseif(CMAKE_BUILD_TYPE STREQUAL Debug)
|
||||
# В режиме отладки подробный вывод сообщений компилятора
|
||||
if(CMAKE_CXX_COMPILER_IS_Clang OR CMAKE_CXX_COMPILER_IS_GCC)
|
||||
string(APPEND CMAKE_C_FLAGS_DEBUG " -ggdb")
|
||||
string(APPEND CMAKE_CXX_FLAGS_DEBUG " -ggdb")
|
||||
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -ggdb -fno-omit-frame-pointer" CACHE STRING "" FORCE)
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -ggdb -fno-omit-frame-pointer" CACHE STRING "" FORCE)
|
||||
endif()
|
||||
set(CMAKE_VERBOSE_MAKEFILE ON CACHE BOOL "Enable verbose build file generation." FORCE)
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE BOOL "Enable output of compile commands during generation."
|
||||
FORCE)
|
||||
set(CMAKE_VERBOSE_MAKEFILE ON CACHE BOOL "Enable generation of verbose build scripts." FORCE)
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE BOOL "Enable generation of compile_commands.json." FORCE)
|
||||
set(DEBUG 1)
|
||||
elseif(CMAKE_BUILD_TYPE STREQUAL Release)
|
||||
set(RELEASE 1)
|
||||
elseif(CMAKE_BUILD_TYPE STREQUAL None)
|
||||
# Режим None используется для статического анализа кода
|
||||
set(CMAKE_VERBOSE_MAKEFILE ON CACHE BOOL "Enable generation of verbose build scripts." FORCE)
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE BOOL "Enable generation of compile_commands.json." FORCE)
|
||||
set(ANALYSIS 1)
|
||||
set(CMAKE_VERBOSE_MAKEFILE ON CACHE BOOL "Enable verbose build file generation." FORCE)
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE BOOL "Enable output of compile commands during generation."
|
||||
FORCE)
|
||||
# set(USE_CLANG_TIDY ON CACHE BOOL "Use clang-tidy")
|
||||
# set(USE_CPPCHECK ON CACHE BOOL "Use cppcheck")
|
||||
set(USE_PVS_STUDIO ON CACHE BOOL "Use PVS-Studio")
|
||||
endif()
|
||||
|
@ -4,9 +4,16 @@ set(CPACK_PACKAGE_NAME ${CMLIB_PROJECT_NAME_LOWER})
|
||||
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
|
||||
|
||||
# Параметры для архива исходных текстов
|
||||
set(CPACK_SOURCE_GENERATOR TXZ)
|
||||
if(NOT CPACK_SOURCE_GENERATOR)
|
||||
set(CPACK_SOURCE_GENERATOR "TXZ")
|
||||
endif()
|
||||
set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CMLIB_PROJECT_NAME_LOWER}-${CPACK_PACKAGE_VERSION}")
|
||||
|
||||
# Типы генераторов для бинарных архивов
|
||||
if(NOT CPACK_GENERATOR)
|
||||
set(CPACK_GENERATOR "TXZ" "DEB")
|
||||
endif()
|
||||
|
||||
# Параметры для архива собранного проекта
|
||||
set(CPACK_TARGET_ARCH ${CMAKE_SYSTEM_PROCESSOR})
|
||||
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
|
||||
@ -15,6 +22,34 @@ endif()
|
||||
set(CPACK_PACKAGE_FILE_NAME "${CMLIB_PROJECT_NAME_LOWER}_${CPACK_TARGET_ARCH}_${CPACK_PACKAGE_VERSION}")
|
||||
set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CMLIB_PROJECT_NAME_LOWER}-${CPACK_PACKAGE_VERSION}")
|
||||
|
||||
# Список масок для исключения из архива исходных текстов
|
||||
set(CPACK_SOURCE_IGNORE_FILES
|
||||
"${CPACK_SOURCE_IGNORE_FILES}"
|
||||
"${CMAKE_BINARY_DIR}"
|
||||
"^${CMAKE_SOURCE_DIR}/.?build.?/"
|
||||
"^${CMAKE_SOURCE_DIR}/.?output.?/"
|
||||
"^${CMAKE_SOURCE_DIR}/files/lib"
|
||||
"^${CMAKE_SOURCE_DIR}/files/log"
|
||||
"CMakeLists.txt.user.*"
|
||||
".*.autosave"
|
||||
"~$"
|
||||
"\\\\.swp$")
|
||||
|
||||
option(CMLIB_COMPACT_SOURCE_PACKAGE "Make compact source package" ON)
|
||||
if(CMLIB_COMPACT_SOURCE_PACKAGE)
|
||||
# Список масок для исключения из архива исходных текстов для более компактного архива
|
||||
set(CPACK_SOURCE_IGNORE_FILES
|
||||
"${CPACK_SOURCE_IGNORE_FILES}"
|
||||
"/\\\\.git/"
|
||||
"/\\\\.gitlab-ci/"
|
||||
"\\\\.clang-tidy$"
|
||||
"\\\\.cmake-format$"
|
||||
"\\\\.gitignore$"
|
||||
"\\\\.gitattributes$"
|
||||
"\\\\.gitmodules$"
|
||||
"\\\\.gitlab-ci.yml$")
|
||||
endif()
|
||||
|
||||
set(CPACK_PROJECT_CONFIG_FILE ${CMAKE_CURRENT_LIST_DIR}/CMLibCPackProject.cmake)
|
||||
|
||||
# Правила для сборки пакетов для Debian
|
||||
|
@ -3,6 +3,14 @@ if(NOT DEBIAN_PACKAGE_TYPE)
|
||||
set(DEBIAN_PACKAGE_TYPE "unstable")
|
||||
endif()
|
||||
|
||||
if(NOT CPACK_DEBIAN_PACKAGE_SECTION)
|
||||
set(CPACK_DEBIAN_PACKAGE_SECTION "misc")
|
||||
endif()
|
||||
|
||||
if(NOT CPACK_DEBIAN_PACKAGE_PRIORITY)
|
||||
set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
|
||||
endif()
|
||||
|
||||
# По умолчанию пакет для Debian делится на компоненты
|
||||
if(NOT CPACK_DEB_COMPONENT_INSTALL)
|
||||
set(CPACK_DEB_COMPONENT_INSTALL ON)
|
||||
|
@ -1,30 +1,21 @@
|
||||
find_program(
|
||||
CLANG_CHECK_EXE
|
||||
NAMES
|
||||
clang-check-10
|
||||
clang-check-9
|
||||
clang-check-8
|
||||
clang-check-7
|
||||
clang-check-6.0
|
||||
clang-check)
|
||||
find_program(CLANG_CHECK_EXE NAMES clang-check-10 clang-check-9 clang-check)
|
||||
if(CLANG_CHECK_EXE)
|
||||
option(CLANG_ANALYZE_FIX "Perform fixes for Clang-Check" OFF)
|
||||
option(CMLIB_CLANG_ANALYZE_FIX "Perform fixes for Clang-Check" OFF)
|
||||
endif()
|
||||
|
||||
function(add_clang_analyze_check target)
|
||||
set(_sources ${ARGN})
|
||||
set(_args -analyze -extra-arg="-Wno-unknown-warning-option")
|
||||
|
||||
if(CLANG_CHECK_EXE)
|
||||
if(CLANG_CHECK_FIX)
|
||||
list(APPEND _args "-fix")
|
||||
if(CMLIB_CLANG_ANALYZE_FIX)
|
||||
list(APPEND _args "--fixit")
|
||||
endif()
|
||||
if(NOT TARGET 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})
|
||||
add_custom_target(clang-analyze-check-${target} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
COMMAND ${CLANG_CHECK_EXE} ${_args} -p ${CMAKE_BINARY_DIR} ${_sources})
|
||||
add_dependencies(clang-analyze-check-${target} ${target})
|
||||
add_dependencies(clang-analyze-check clang-analyze-check-${target})
|
||||
else()
|
||||
|
@ -1,29 +1,21 @@
|
||||
find_program(
|
||||
CLANG_TIDY_EXE
|
||||
NAMES
|
||||
clang-tidy-10
|
||||
clang-tidy-9
|
||||
clang-tidy-8
|
||||
clang-tidy-7
|
||||
clang-tidy-6.0
|
||||
clang-tidy)
|
||||
find_program(CLANG_TIDY_EXE NAMES clang-tidy-10 clang-tidy-9 clang-tidy)
|
||||
if(CLANG_TIDY_EXE)
|
||||
option(CLANG_TIDY_FIX "Perform fixes for Clang-Tidy" OFF)
|
||||
if(CLANG_TIDY_FIX)
|
||||
list(APPEND _args "-fix")
|
||||
endif()
|
||||
option(CMLIB_CLANG_TIDY_FIX "Perform fixes for Clang-Tidy" OFF)
|
||||
endif()
|
||||
|
||||
function(add_clang_tidy_check target)
|
||||
set(_sources ${ARGN})
|
||||
set(_args -extra-arg="-Wno-unknown-warning-option")
|
||||
|
||||
if(CLANG_TIDY_EXE)
|
||||
if(CMLIB_CLANG_TIDY_FIX)
|
||||
list(APPEND _args "--fix")
|
||||
endif()
|
||||
if(NOT TARGET 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})
|
||||
add_custom_target(clang-tidy-check-${target} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
COMMAND ${CLANG_TIDY_EXE} ${_args} -p ${CMAKE_BINARY_DIR} ${_sources})
|
||||
add_dependencies(clang-tidy-check-${target} ${target})
|
||||
add_dependencies(clang-tidy-check clang-tidy-check-${target})
|
||||
else()
|
||||
|
@ -1,23 +1,46 @@
|
||||
set(clazy_checks
|
||||
container-inside-loop,heap-allocated-small-trivial-type,inefficient-qlist,isempty-vs-count,qt-keywords,unneeded-cast
|
||||
)
|
||||
find_program(CLANG_APPLY_REPLACEMENTS_EXE NAMES clang-apply-replacements-10 clang-apply-replacements-9
|
||||
clang-apply-replacements)
|
||||
|
||||
find_program(CLAZY_EXE NAMES clazy-standalone)
|
||||
|
||||
if(CLAZY_EXE AND CLANG_APPLY_REPLACEMENTS_EXE)
|
||||
option(CMLIB_CLAZY_FIX "Perform fixes for Clazy" OFF)
|
||||
endif()
|
||||
|
||||
function(add_clazy_check target)
|
||||
set(_sources ${ARGN})
|
||||
set(options)
|
||||
set(oneValueArgs CHECKS)
|
||||
set(multiValueArgs)
|
||||
|
||||
cmake_parse_arguments(_CLAZY "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
|
||||
set(_sources ${_CLAZY_UNPARSED_ARGUMENTS})
|
||||
if(NOT _CLAZY_CHECKS)
|
||||
set(_CLAZY_CHECKS
|
||||
"level2,container-inside-loop,heap-allocated-small-trivial-type,inefficient-qlist,isempty-vs-count,qt-keywords,unneeded-cast"
|
||||
)
|
||||
endif()
|
||||
set(_args -checks=${_CLAZY_CHECKS} -extra-arg="-Wno-unknown-warning-option"
|
||||
-export-fixes=clazy-fixes-file.yaml)
|
||||
|
||||
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,${clazy_checks} -extra-arg="-Wno-unknown-warning-option" -p
|
||||
${CMAKE_BINARY_DIR} ${_sources})
|
||||
if(CMLIB_CLAZY_FIX)
|
||||
add_custom_target(
|
||||
clazy-check-${target}
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
COMMAND ${CLAZY_EXE} ${_args} -p ${CMAKE_BINARY_DIR} ${_sources}
|
||||
COMMAND ${CLANG_APPLY_REPLACEMENTS_EXE} ${CMAKE_BINARY_DIR})
|
||||
else()
|
||||
add_custom_target(clazy-check-${target} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
COMMAND ${CLAZY_EXE} ${_args} -p ${CMAKE_BINARY_DIR} ${_sources})
|
||||
endif()
|
||||
add_dependencies(clazy-check-${target} ${target})
|
||||
add_dependencies(clazy-check clazy-check-${target})
|
||||
else()
|
||||
message(STATUS "CMLIB warning:")
|
||||
message(STATUS " Clazy analyzer is not found")
|
||||
message(STATUS " Clazy standalone analyzer is not found")
|
||||
endif()
|
||||
endfunction()
|
||||
|
@ -1,10 +1,10 @@
|
||||
option(ENABLE_CODE_COVERAGE "Enable code coverage support" OFF)
|
||||
option(CMLIB_ENABLE_CODE_COVERAGE "Enable code coverage support" OFF)
|
||||
find_program(LCOV_EXE NAMES lcov)
|
||||
find_program(GENHTML_EXE NAMES genhtml)
|
||||
|
||||
function(add_code_coverage target)
|
||||
|
||||
if(ENABLE_CODE_COVERAGE)
|
||||
if(CMLIB_ENABLE_CODE_COVERAGE)
|
||||
if(CMAKE_CXX_COMPILER_IS_GCC)
|
||||
target_compile_options(${target} PUBLIC "--coverage")
|
||||
get_target_property(LF ${target} LINK_FLAGS)
|
||||
|
@ -27,6 +27,7 @@ include(CMLibCompilerFlags)
|
||||
include(CMLibDistCC)
|
||||
include(CMLibCompilerFeaturesHPPGenerate)
|
||||
include(CMLibFlagRemove)
|
||||
include(CMLibCotire)
|
||||
include(CMLibBuildTypes)
|
||||
include(CMLibCommonTargetProperties)
|
||||
include(CMLibCommonLibraryTarget)
|
||||
@ -36,7 +37,6 @@ include(CMLibCodeAnalysisClangTidy)
|
||||
include(CMLibCodeAnalysisClazy)
|
||||
include(CMLibCodeCoverage)
|
||||
include(CMLibSanitizers)
|
||||
include(cotire)
|
||||
|
||||
include(CMLibFormatSources)
|
||||
include(CMLibDocDoxygen)
|
||||
@ -45,5 +45,6 @@ include(CMLibQtTranslation)
|
||||
include(CMLibToday)
|
||||
include(CMLibAuxilarySymlinks)
|
||||
include(CMLibConfigHPPGenerate)
|
||||
include(CMLibNinjaGeneratorHelper)
|
||||
include(CMLibCPack)
|
||||
include(CMLibUninstall)
|
||||
|
@ -19,21 +19,22 @@ function(add_common_library target)
|
||||
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include> $<INSTALL_INTERFACE:include/${target}>)
|
||||
set_target_properties(${target} PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
||||
|
||||
# cmake-format: off
|
||||
if(BUILD_SHARED_LIBS)
|
||||
add_library(${target}_shared SHARED $<TARGET_OBJECTS:${target}>)
|
||||
set_target_properties(
|
||||
${target}_shared
|
||||
PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR} OUTPUT_NAME ${OUTNAME}
|
||||
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_INSTALL_LIBDIR})
|
||||
set_target_properties(${target}_shared PROPERTIES OUTPUT_NAME ${OUTNAME}
|
||||
VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR}
|
||||
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
|
||||
install(TARGETS ${target}_shared LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
endif()
|
||||
|
||||
if(NOT SKIP_STATIC_LIBS)
|
||||
add_library(${target}_static STATIC $<TARGET_OBJECTS:${target}>)
|
||||
set_target_properties(${target}_static PROPERTIES OUTPUT_NAME ${OUTNAME} ARCHIVE_OUTPUT_DIRECTORY
|
||||
${CMAKE_INSTALL_LIBDIR})
|
||||
set_target_properties(${target}_static PROPERTIES OUTPUT_NAME ${OUTNAME}
|
||||
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
|
||||
install(TARGETS ${target}_static ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
endif()
|
||||
# cmake-format: on
|
||||
|
||||
configure_file(${CMLIB_MODULE_DIR}/pc/lib.pc.in ${CMAKE_BINARY_DIR}/${target}.pc)
|
||||
install(FILES ${CMAKE_BINARY_DIR}/${target}.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
|
||||
|
@ -11,15 +11,19 @@ function(common_target_properties target)
|
||||
get_target_property(__sources ${target} SOURCES)
|
||||
foreach(__src IN LISTS __sources)
|
||||
string(REGEX MATCH ".*/qrc_.*\\.cpp$" __qrc ${__src})
|
||||
if (__qrc)
|
||||
if(__qrc)
|
||||
set_property(SOURCE ${__qrc} PROPERTY COTIRE_EXCLUDED ON)
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
target_compile_features(${target} ${__visibility} ${COMMON_CXX_FEATURES})
|
||||
get_target_property(_targetType ${target} TYPE)
|
||||
if(_targetType STREQUAL "EXECUTABLE" AND CMAKE_CXX_COMPILE_OPTIONS_PIE)
|
||||
target_compile_options(${target} PUBLIC "${CMAKE_CXX_COMPILE_OPTIONS_PIE}")
|
||||
if(_targetType STREQUAL "EXECUTABLE")
|
||||
set_target_properties(${target} PROPERTIES RUNTIME_OUTPUT_DIRECTORY
|
||||
${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR})
|
||||
if(CMAKE_CXX_COMPILE_OPTIONS_PIE)
|
||||
target_compile_options(${target} PUBLIC "${CMAKE_CXX_COMPILE_OPTIONS_PIE}")
|
||||
endif()
|
||||
endif()
|
||||
target_include_directories(
|
||||
${target}
|
||||
@ -33,18 +37,6 @@ function(common_target_properties target)
|
||||
if(_targetType STREQUAL "EXECUTABLE")
|
||||
target_compile_options(${target} PUBLIC "${Qt5Core_EXECUTABLE_COMPILE_FLAGS}")
|
||||
endif()
|
||||
# set_target_properties(${target} PROPERTIES AUTOMOC TRUE)
|
||||
# set_target_properties(${target} PROPERTIES AUTORCC TRUE)
|
||||
endif()
|
||||
if(TARGET Qt5::Widgets)
|
||||
# set_target_properties(${target} PROPERTIES AUTOUIC TRUE)
|
||||
# if(CMAKE_VERSION VERSION_LESS 3.7.99)
|
||||
# target_include_directories(
|
||||
# ${target}
|
||||
# PUBLIC
|
||||
# $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/${target}_autogen/include>
|
||||
# )
|
||||
# endif()
|
||||
endif()
|
||||
if(CMAKE_CXX_COMPILER_IS_GCC AND NOT APPLE)
|
||||
set_target_properties(${target} PROPERTIES LINK_FLAGS "-Wl,--no-as-needed")
|
||||
@ -81,6 +73,10 @@ function(common_target_properties target)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set_target_properties(${target} PROPERTIES COTIRE_ENABLE_PRECOMPILED_HEADER
|
||||
${CMLIB_COTIRE_ENABLE_PRECOMPILED_HEADER})
|
||||
set_target_properties(${target} PROPERTIES COTIRE_ADD_UNITY_BUILD ${CMLIB_COTIRE_ADD_UNITY_BUILD})
|
||||
|
||||
if(CMAKE_BUILD_TYPE STREQUAL Profile)
|
||||
target_compile_definitions(${target} ${__visibility} PROFILE)
|
||||
elseif(CMAKE_BUILD_TYPE STREQUAL Debug)
|
||||
|
@ -1,7 +1,12 @@
|
||||
include(WriteCompilerDetectionHeader)
|
||||
|
||||
set(OUTPUT_FILE ${CMAKE_BINARY_DIR}/include/compiler_features.hpp)
|
||||
if(CMLIB_GENERATED_HEADERS_PATH)
|
||||
set(OUTPUT_FILE ${CMLIB_GENERATED_HEADERS_PATH}/compiler_features.hpp)
|
||||
endif()
|
||||
|
||||
write_compiler_detection_header(
|
||||
FILE include/compiler_features.hpp
|
||||
FILE ${OUTPUT_FILE}
|
||||
PREFIX ${CMLIB_PROJECT_NAME_CANONICAL}
|
||||
COMPILERS GNU Clang MSVC Intel
|
||||
FEATURES
|
||||
@ -14,3 +19,5 @@ write_compiler_detection_header(
|
||||
cxx_constexpr
|
||||
cxx_digit_separators
|
||||
cxx_range_for)
|
||||
|
||||
unset(OUTPUT_FILE)
|
||||
|
@ -1,5 +1,7 @@
|
||||
# based on https://github.com/bluescarni/yacma
|
||||
|
||||
option(CMLIB_WARNING_FLAGS "Enable warning flags" ON)
|
||||
|
||||
include(CheckCXXCompilerFlag)
|
||||
|
||||
macro(CHECK_ENABLE_CXX_FLAG flag)
|
||||
@ -35,7 +37,7 @@ if(CMAKE_CXX_COMPILER_IS_CLANG OR CMAKE_CXX_COMPILER_IS_INTEL OR CMAKE_CXX_COMPI
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED YES)
|
||||
set(CMAKE_CXX_EXTENSIONS YES)
|
||||
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
if(CMLIB_WARNING_FLAGS AND CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
check_enable_cxx_flag(-Wall)
|
||||
check_enable_cxx_flag(-Wextra)
|
||||
check_enable_cxx_flag(-Wnon-virtual-dtor)
|
||||
|
@ -2,7 +2,13 @@ function(cmlib_config_hpp_generate)
|
||||
include(CMLibLargeFiles)
|
||||
cmlib_test_large_files(HAVE_LARGEFILES)
|
||||
|
||||
set(OUTPUT_FILE ${CMAKE_BINARY_DIR}/include/cmlib_private_config.hpp)
|
||||
if(CMLIB_GENERATED_HEADERS_PATH)
|
||||
set(OUTPUT_FILE ${CMLIB_GENERATED_HEADERS_PATH}/cmlib_private_config.hpp)
|
||||
elseif(ARGV0)
|
||||
set(OUTPUT_FILE ${ARGV0})
|
||||
endif()
|
||||
|
||||
get_property(PROJECT_VERSION_INT GLOBAL PROPERTY PROJECT_VERSION_INT)
|
||||
configure_file(${CMLIB_MODULE_DIR}/hpp/cmlib_private_config.hpp.in
|
||||
${CMAKE_BINARY_DIR}/include/cmlib_private_config.hpp)
|
||||
configure_file(${CMLIB_MODULE_DIR}/hpp/cmlib_private_config.hpp.in ${OUTPUT_FILE})
|
||||
endfunction()
|
||||
|
6
CMLibCotire.cmake
Normal file
6
CMLibCotire.cmake
Normal file
@ -0,0 +1,6 @@
|
||||
include(cotire)
|
||||
|
||||
if(COMMAND cotire)
|
||||
option(CMLIB_COTIRE_ENABLE_PRECOMPILED_HEADER "Enable precompiled headers" OFF)
|
||||
option(CMLIB_COTIRE_ADD_UNITY_BUILD "Enable unity build" OFF)
|
||||
endif()
|
@ -54,8 +54,8 @@ function(add_breathe target)
|
||||
configure_file(${INDEX_MD_FILE} ${WORK_DIR}/index.md @ONLY)
|
||||
file(GLOB MD_FILES ${CMAKE_SOURCE_DIR}/doc/breathe/*.md)
|
||||
if(MD_FILES)
|
||||
add_custom_command(TARGET ${target} PRE_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${MD_FILES} ${WORK_DIR})
|
||||
add_custom_command(TARGET ${target} PRE_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
${MD_FILES} ${WORK_DIR})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@ -64,13 +64,12 @@ function(add_breathe target)
|
||||
configure_file(${INDEX_RST_FILE} ${WORK_DIR}/index.rst @ONLY)
|
||||
file(GLOB RST_FILES ${CMAKE_SOURCE_DIR}/doc/breathe/*.rst)
|
||||
if(RST_FILES)
|
||||
add_custom_command(TARGET ${target} PRE_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${RST_FILES} ${WORK_DIR})
|
||||
add_custom_command(TARGET ${target} PRE_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
${RST_FILES} ${WORK_DIR})
|
||||
endif()
|
||||
endif()
|
||||
else()
|
||||
message(STATUS "CMLIB warning:")
|
||||
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()
|
||||
endfunction()
|
||||
|
@ -37,7 +37,6 @@ function(add_doxygen target)
|
||||
COMMENT "Generating API documentation with Doxygen")
|
||||
else()
|
||||
message(STATUS "CMLIB warning:")
|
||||
add_custom_target(${target} VERBATIM
|
||||
COMMENT " Doxygen is not found. Skipping target ${target} build")
|
||||
add_custom_target(${target} VERBATIM COMMENT " Doxygen is not found. Skipping target ${target} build")
|
||||
endif()
|
||||
endfunction()
|
||||
|
@ -4,22 +4,28 @@ function(add_format_sources target)
|
||||
if(NOT TARGET format-sources)
|
||||
add_custom_target(format-sources)
|
||||
endif()
|
||||
if(NOT TARGET doc-add-comments)
|
||||
add_custom_target(doc-add-comments)
|
||||
endif()
|
||||
|
||||
find_program(UNCRUSTIFY_EXE NAMES uncrustify)
|
||||
if(UNCRUSTIFY_EXE)
|
||||
list(
|
||||
APPEND
|
||||
UNCRUSTIFY_OPTS
|
||||
-lCPP
|
||||
--replace
|
||||
--no-backup
|
||||
--mtime)
|
||||
list(APPEND UNCRUSTIFY_OPTS -lCPP --replace --no-backup)
|
||||
if(EXISTS ${CMAKE_SOURCE_DIR}/cmake/etc/uncrustify/default.cfg)
|
||||
list(APPEND UNCRUSTIFY_OPTS -c ${CMAKE_SOURCE_DIR}/cmake/etc/uncrustify/default.cfg)
|
||||
endif()
|
||||
# cmake-format: off
|
||||
add_custom_target(format-sources-uncrustify-${target} COMMAND ${UNCRUSTIFY_EXE} ${UNCRUSTIFY_OPTS}
|
||||
${_sources})
|
||||
--mtime ${_sources})
|
||||
add_custom_target(doc-add-comments-uncrustify-${target} COMMAND ${UNCRUSTIFY_EXE} ${UNCRUSTIFY_OPTS}
|
||||
--set cmt_insert_file_header=fileheader.txt
|
||||
--set cmt_insert_file_footer=filefooter.txt
|
||||
--set cmt_insert_func_header=funcheader.txt
|
||||
--set cmt_insert_class_header=classheader.txt
|
||||
--set cmt_insert_before_ctor_dtor=true ${_sources})
|
||||
# cmake-format: on
|
||||
add_dependencies(format-sources format-sources-uncrustify-${target})
|
||||
add_dependencies(doc-add-comments doc-add-comments-uncrustify-${target})
|
||||
else()
|
||||
message(STATUS "CMLIB warning:")
|
||||
message(STATUS " uncrustify executable is not found")
|
||||
|
9
CMLibNinjaGeneratorHelper.cmake
Normal file
9
CMLibNinjaGeneratorHelper.cmake
Normal file
@ -0,0 +1,9 @@
|
||||
# Если выбран генератор Ninja, то в основном сборочном каталоге
|
||||
# создаётся файл Makefile, который обрабатывается командой make и
|
||||
# передаёт исполнение системе сборки ninja.
|
||||
# Таким образом можно выполнять команду make, даже если правила
|
||||
# сборки проекта сгенерированы для ninja.
|
||||
|
||||
if("${CMAKE_GENERATOR}" MATCHES "Ninja")
|
||||
file(WRITE ${CMAKE_BINARY_DIR}/Makefile ".PHONY: build\n%:\n\t@ninja \$@\nbuild:\n\t@ninja\n")
|
||||
endif()
|
@ -18,12 +18,12 @@ function(qt5_translation outfiles)
|
||||
set(_ts "${_base_name}_${_lang}.ts")
|
||||
set(_qm "${_base_name}_${_lang}.qm")
|
||||
list(APPEND _ts_list ${_output_dir}/${_ts})
|
||||
list(APPEND _l10n_names "${_base_name}_l10n_${_lang}")
|
||||
list(APPEND _l10n_names_list "${_base_name}_l10n_${_lang}")
|
||||
string(APPEND L10N_QRC_BODY "<file alias=\"${_qm}\">${CMAKE_BINARY_DIR}/${_qm}</file>\n")
|
||||
|
||||
add_custom_target(
|
||||
${_base_name}_l10n_${_lang} COMMAND ${Qt5_LUPDATE_EXECUTABLE} ${_sources} -ts ${_output_dir}/${_ts}
|
||||
-target-language ${_lang} DEPENDS ${_sources})
|
||||
-target-language ${_lang} DEPENDS ${_sources})
|
||||
|
||||
if(NOT EXISTS "${_output_dir}/${_ts}")
|
||||
add_custom_target(${_ts} DEPENDS ${_base_name}_l10n_${_lang})
|
||||
@ -39,7 +39,7 @@ function(qt5_translation outfiles)
|
||||
configure_file(${CMLIB_MODULE_DIR}/qrc/l10n.qrc.in ${CMAKE_BINARY_DIR}/${_base_name}_l10n.qrc)
|
||||
qt5_add_resources(${outfiles} ${CMAKE_BINARY_DIR}/${_base_name}_l10n.qrc)
|
||||
add_custom_target(${_base_name}_qrc DEPENDS ${_qrc})
|
||||
add_custom_target(${_base_name}_l10n DEPENDS ${_l10n_targets})
|
||||
add_custom_target(${_base_name}_l10n DEPENDS ${_l10n_names_list})
|
||||
if(NOT TARGET l10n)
|
||||
add_custom_target(l10n)
|
||||
endif()
|
||||
|
@ -10,10 +10,6 @@ endif()
|
||||
|
||||
set(CPACK_PACKAGE_VENDOR ${ORGANIZATION_NAME})
|
||||
|
||||
if(NOT CPACK_GENERATOR)
|
||||
message(FATAL_ERROR "Required variable CPACK_GENERATOR is not defined")
|
||||
endif()
|
||||
|
||||
if(NOT CPACK_PACKAGE_CONTACT)
|
||||
message(FATAL_ERROR "Required variable CPACK_PACKAGE_CONTACT is not defined")
|
||||
endif()
|
||||
@ -21,15 +17,3 @@ endif()
|
||||
if(NOT CPACK_PACKAGE_DESCRIPTION_SUMMARY)
|
||||
message(FATAL_ERROR "Required variable CPACK_PACKAGE_DESCRIPTION_SUMMARY is not defined")
|
||||
endif()
|
||||
|
||||
if(NOT CPACK_DEBIAN_PACKAGE_SECTION)
|
||||
message(FATAL_ERROR "Required variable CPACK_DEBIAN_PACKAGE_SECTION is not defined")
|
||||
endif()
|
||||
|
||||
if(NOT CPACK_DEBIAN_PACKAGE_PRIORITY)
|
||||
message(FATAL_ERROR "Required variable CPACK_DEBIAN_PACKAGE_PRIORITY is not defined")
|
||||
endif()
|
||||
|
||||
if(NOT CPACK_SOURCE_IGNORE_FILES)
|
||||
message(FATAL_ERROR "Required variable CPACK_SOURCE_IGNORE_FILES is not defined")
|
||||
endif()
|
||||
|
8
thirdparty/cotire.cmake
vendored
8
thirdparty/cotire.cmake
vendored
@ -931,7 +931,13 @@ function (cotire_add_includes_to_cmd _cmdVar _language _includesVar _systemInclu
|
||||
list (FIND ${_systemIncludesVar} "${_include}" _index)
|
||||
endif()
|
||||
if (_index GREATER -1)
|
||||
list (APPEND ${_cmdVar} "${CMAKE_INCLUDE_SYSTEM_FLAG_${_language}}${CMAKE_INCLUDE_FLAG_SEP_${_language}}${_include}")
|
||||
if (CMAKE_${_language}_COMPILER_ID MATCHES "GNU|Clang")
|
||||
string(REPLACE " " "" _flag ${CMAKE_INCLUDE_SYSTEM_FLAG_${_language}})
|
||||
list (APPEND ${_cmdVar} "${_flag}")
|
||||
list (APPEND ${_cmdVar} "${_include}")
|
||||
else()
|
||||
list (APPEND ${_cmdVar} "${CMAKE_INCLUDE_SYSTEM_FLAG_${_language}}${CMAKE_INCLUDE_FLAG_SEP_${_language}}${_include}")
|
||||
endif()
|
||||
else()
|
||||
list (APPEND ${_cmdVar} "${CMAKE_INCLUDE_FLAG_${_language}}${CMAKE_INCLUDE_FLAG_SEP_${_language}}${_include}")
|
||||
endif()
|
||||
|
Reference in New Issue
Block a user