Начало

This commit is contained in:
Andrei Astafev 2022-10-05 17:12:28 +03:00
commit 23cffd49d3
14 changed files with 439 additions and 0 deletions

237
.gitignore vendored Normal file
View File

@ -0,0 +1,237 @@
# Каталог для результатов сборки проекта
_build
build
# Каталог для тестирования установки
_output
!.gitkeep
!.gitignore
###
### Общие настройки для C, C++, Fortran, Qt, CMake, Ninja, LaTeX и редакторов
###
###
### Временные файлы текстовых редакторов
###
*.bak
*.gho
*.tmp
*.dotdropbak
###
### LyX
###
*.lyx~
*.lyx#
###
### Vim
###
# Swap
[._]*.s[a-v][a-z]
!*.svg # comment out if you don't need vector files
[._]*.sw[a-p]
[._]s[a-rt-v][a-z]
[._]ss[a-gi-z]
[._]sw[a-p]
# Project
.vimprj
# Temporary
.netrwhist
*~
# Auto-generated tag files
tags
# Persistent undo
[._]*.un~
###
### C++
###
# Prerequisites
*.d
# Compiled Object files
*.slo
*.lo
*.o
*.obj
# Precompiled Headers
*.gch
*.pch
# Compiled Dynamic libraries
*.so
*.so.*
*.dylib
*.dll
# Fortran module files
*.mod
*.smod
# Compiled Static libraries
*.lai
*.la
*.a
*.lib
# Executables
*.exe
*.out
*.app
###
### CMake
###
CMakeLists.txt.user*
CMakeCache.txt
CMakeFiles
CMakeScripts
Testing
Makefile
cmake_install.cmake
install_manifest.txt
compile_commands.json
CTestTestfile.cmake
_deps
.cmake
### CMake Patch ###
# External projects
*-prefix/
###
### Ninja
###
.ninja_deps
.ninja_log
###
### GCC coverage testing tool files
###
*.gcno
*.gcda
*.gcov
###
### Qt
###
object_script.*.Release
object_script.*.Debug
*_plugin_import.cpp
/.qmake.cache
/.qmake.stash
*.pro.user
*.pro.user.*
*.qbs.user
*.qbs.user.*
*.moc
moc_*.cpp
moc_*.h
qrc_*.cpp
ui_*.h
*.qmlc
*.jsc
Makefile*
*build-*
*.qm
*.prl
# Qt unit tests
target_wrapper.*
# QtCreator
*.autosave
# QtCreator Qml
*.qmlproject.user
*.qmlproject.user.*
# QtCreator local machine specific files for imported projects
*creator.user*
*_qmlcache.qrc
### KDevelop4 ###
*.kdev4
.kdev4/
### vscode ###
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
*.code-workspace
### IDEA ###
.idea
### Eclipse ###
.metadata
.settings/
.recommenders/
# TeXlipse
.texlipse
# PyDev specific (Python IDE for Eclipse)
*.pydevproject
# CDT-specific (C/C++ Development Tooling)
.cproject
# CDT- autotools
.autotools
###
### Latex
###
*.acn
*.acr
*.alg
*.aux
*.bbl
*.blg
*.dvi
*.fdb_latexmk
*.fls
*.glg
*.glo
*.gls
*.idx
*.ilg
*.ind
*.ist
*.lof
*.log
*.lot
*.maf
*.mtc
*.mtc0
*.nav
*.nlo
*.out
*.pdfsync
*.ps
*.snm
*.synctex.gz
*.toc
*.vrb
*.xdv
*.xdy
*.tdo

34
Makefile Normal file
View File

@ -0,0 +1,34 @@
V:=$(shell cat VERSION)
TOP_DIR:=$(shell pwd)
BUILD_DIR:=$(TOP_DIR)/build
DEB_DIR:=$(BUILD_DIR)/deb/myxx-cmake-$(V)
all: update_version deb pack
update_version:
sed -i "s/CMake.*REQUIRED/CMake $V REQUIRED/" $(TOP_DIR)/README.md
sed -i "s/VERSION \".*\"/VERSION \"$V\"/" $(TOP_DIR)/MyxxCMake/MyxxCMakeConfigVersion.cmake
sed -i "s/VERSION .* LANG/VERSION $V LANG/" $(TOP_DIR)/debian/CMakeLists.txt
sed -i "s/(.*)/($(V))/" $(TOP_DIR)/debian/changelog
deb:
rm -rf $(DEB_DIR)
mkdir -p $(DEB_DIR)
cp -ap "$(TOP_DIR)/MyxxCMake" "$(TOP_DIR)/debian" "$(DEB_DIR)"
cd $(DEB_DIR); debuild
mv $(BUILD_DIR)/deb/*deb $(BUILD_DIR)
mv $(BUILD_DIR)/deb/*dsc $(BUILD_DIR)
mv $(BUILD_DIR)/deb/*xz $(BUILD_DIR)
pack:
tar acf $(BUILD_DIR)/myxx-cmake-local-$(V).tar.xz MyxxCMake
upload:
git tag $(V)
tea r c --repo cmake/myxx -t $(V) --tag $(V) \
-a $(BUILD_DIR)/myxx-cmake_$(V).dsc \
-a $(BUILD_DIR)/myxx-cmake_$(V).tar.xz \
-a $(BUILD_DIR)/myxx-cmake_$(V)_all.deb \
-a $(BUILD_DIR)/myxx-cmake-local-$(V).tar.xz
git tag -d $(V)
git push

View File

@ -0,0 +1,25 @@
cmake_policy(PUSH)
cmake_policy(SET CMP0057 NEW) # IN_LIST operator
get_filename_component(MYXX_CMAKE_SOURCE_DIR "${CMAKE_CURRENT_LIST_FILE}" DIRECTORY)
if(NOT MyxCMake_DIR)
message(FATAL_ERROR "MyxxCMake library required MyxCMake to work")
endif()
set(MYXX_CMAKE_LIB_DIR "${MYXX_CMAKE_SOURCE_DIR}/lib" CACHE PATH "")
include(${MYXX_CMAKE_LIB_DIR}/CodeAnalyzeClangTidy.cmake)
function(myxx)
get_property(targets DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} PROPERTY BUILDSYSTEM_TARGETS)
foreach(iter ${targets})
get_target_property(target_type ${iter} TYPE)
if(NOT ${target_type} STREQUAL "UTILITY")
myxx_analyze_clang_tidy(${iter})
endif()
endforeach()
endfunction(myxx)
cmake_policy(POP)

View File

@ -0,0 +1,9 @@
set(MYXX_CMAKE_PACKAGE_VERSION "2.0.1")
if(MYXX_CMAKE_PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)
set(PACKAGE_VERSION_COMPATIBLE FALSE)
else()
set(PACKAGE_VERSION_COMPATIBLE TRUE)
if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION)
set(PACKAGE_VERSION_EXACT TRUE)
endif()
endif()

View File

@ -0,0 +1,52 @@
include_guard(GLOBAL)
if(NOT CLANG_TIDY_NAME)
set(CLANG_TIDY_NAMES clang-tidy)
foreach(V RANGE 9 18)
list(INSERT CLANG_TIDY_NAMES 0 "clang-tidy-${V}")
endforeach()
unset(V)
else()
set(CLANG_TIDY_NAMES ${CLANG_TIDY_NAME})
endif()
find_program(CLANG_TIDY_EXE NAMES ${CLANG_TIDY_NAMES})
unset(CLANG_TIDY_NAMES)
function(myxx_analyze_clang_tidy target)
if(NOT CLANG_TIDY_EXE)
message(STATUS "MyxxCMake: Clang Tidy analyzer is not found")
return()
endif()
if(TARGET ${target}-analyze-clang-tidy)
message(STATUS "MyxxCMake: target ${target}-analyze-clang-tidy already exists")
return()
endif()
set(options FIX)
set(oneValueArgs)
set(multiValueArgs EXTRA_ARGS)
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
set(args -extra-arg="-Wno-unknown-warning-option ${ARG_EXTRA_ARGS}")
get_target_property(sources ${target} SOURCES)
foreach(iter ${sources})
string(FIND ${iter} ${CMAKE_BINARY_DIR} pos)
if(pos EQUAL -1)
list(APPEND srcs ${iter})
endif()
endforeach()
if(ARG_FIX)
list(APPEND args "-fix-errors")
endif()
if(NOT TARGET myxx-analyze-clang-tidy)
add_custom_target(myxx-analyze-clang-tidy)
endif()
add_custom_target(${target}-analyze-clang-tidy
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMAND ${CLANG_TIDY_EXE} ${args} -p ${CMAKE_BINARY_DIR} ${srcs})
add_dependencies(${target}-analyze-clang-tidy ${target})
add_dependencies(myxx-analyze-clang-tidy ${target}-analyze-clang-tidy)
endfunction()

23
README.md Normal file
View File

@ -0,0 +1,23 @@
# Библиотека дополнительных фукций для CMake
## Установка
Скачать [здесь](../../../releases) пакет для Debian и установить
его или архив `myxx-cmake-local` и распаковать его в каталог
`$HOME/.local/share/cmake`.
## Использование
Для работы в программном проекте должна использоваться библиотека
[myx-cmake](../../../../myx), которая автоматически находит
эту библиотеку.
Для подключения функций необходимо в конце описания проекта
(после описания целей, для которых нужно применить правила)
добавить строки:
```cmake
if(MyxxCMake_DIR)
myxx()
endif()
```

1
VERSION Normal file
View File

@ -0,0 +1 @@
2.0.0

18
debian/CMakeLists.txt vendored Normal file
View File

@ -0,0 +1,18 @@
cmake_minimum_required(VERSION 3.6 FATAL_ERROR)
project(myxx-cmake VERSION 2.0.1 LANGUAGES)
include(GNUInstallDirs)
file(WRITE ${CMAKE_SOURCE_DIR}/MyxxCMake/MyxxCMakeConfigVersion.cmake
"set(MYXX_CMAKE_PACKAGE_VERSION \"${PROJECT_VERSION}\")\n"
"if(MYXX_CMAKE_PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)\n"
" set(PACKAGE_VERSION_COMPATIBLE FALSE)\n"
"else()\n"
" set(PACKAGE_VERSION_COMPATIBLE TRUE)\n"
" if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION)\n"
" set(PACKAGE_VERSION_EXACT TRUE)\n"
" endif()\n"
"endif()\n"
)
install(DIRECTORY MyxxCMake DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake")

6
debian/changelog vendored Normal file
View File

@ -0,0 +1,6 @@
myxx-cmake (2.0.1) unstable; urgency=medium
* New version.
-- Andrey Astafyev <dpkg@246060.ru> Wed, 08 Dec 2021 14:23:03 +0300

1
debian/compat vendored Normal file
View File

@ -0,0 +1 @@
9

15
debian/control vendored Normal file
View File

@ -0,0 +1,15 @@
Source: myxx-cmake
Section: utils
Priority: optional
Maintainer: Andrey Astafyev <dev@246060.ru>
Build-Depends: debhelper (>= 9), cmake
Standards-Version: 4.2.0
Package: myxx-cmake
Architecture: all
Section: utils
Depends: cmake
Recommends: cmake-format
Description: CMake functions library: development assistance functions
CMake functions library: development assistance functions

13
debian/rules vendored Executable file
View File

@ -0,0 +1,13 @@
#!/usr/bin/make -f
%:
dh $@ --buildsystem=cmake
override_dh_auto_configure:
cp -f debian/CMakeLists.txt CMakeLists.txt
dh_auto_configure
override_dh_fixperms:
dh_fixperms
# find debian -name asan-wrapper -print0 | xargs -0 chmod +x

1
debian/source/format vendored Normal file
View File

@ -0,0 +1 @@
3.0 (native)

4
debian/source/options vendored Normal file
View File

@ -0,0 +1,4 @@
compression = "xz"
compression-level = 9
extend-diff-ignore = "(^l10n\/.*ts)$"