Compare commits
3 Commits
36073091bc
...
9002b99e3e
Author | SHA1 | Date | |
---|---|---|---|
9002b99e3e | |||
dbcf484006 | |||
28e7c7ffa2 |
@@ -1,24 +1,37 @@
|
||||
function(add_uncrustify_format)
|
||||
function(add_format_sources)
|
||||
list(GET ARGN 0 _target)
|
||||
set(_sources ${ARGN})
|
||||
list(REMOVE_AT _sources 0)
|
||||
|
||||
if(NOT TARGET format-sources)
|
||||
add_custom_target(format-sources)
|
||||
endif()
|
||||
|
||||
find_program(UNCRUSTIFY_EXE NAMES uncrustify)
|
||||
if(UNCRUSTIFY_EXE)
|
||||
if(NOT TARGET uncrustify-format)
|
||||
add_custom_target(uncrustify-format)
|
||||
endif()
|
||||
list(APPEND OPTS
|
||||
list(APPEND UNCRUSTIFY_OPTS
|
||||
-lCPP
|
||||
--replace
|
||||
--no-backup)
|
||||
if(EXISTS ${CMAKE_SOURCE_DIR}/cmake/etc/uncrustify/default.cfg)
|
||||
list(APPEND OPTS -c ${CMAKE_SOURCE_DIR}/cmake/etc/uncrustify/default.cfg)
|
||||
list(APPEND UNCRUSTIFY_OPTS -c ${CMAKE_SOURCE_DIR}/cmake/etc/uncrustify/default.cfg)
|
||||
endif()
|
||||
add_custom_target(uncrustify-format-${_target} COMMAND ${UNCRUSTIFY_EXE} ${OPTS} ${_sources})
|
||||
add_dependencies(uncrustify-format uncrustify-format-${_target})
|
||||
add_custom_target(format-sources-uncrustify-${_target} COMMAND ${UNCRUSTIFY_EXE} ${UNCRUSTIFY_OPTS} ${_sources})
|
||||
add_dependencies(format-sources format-sources-uncrustify-${_target})
|
||||
else()
|
||||
message(STATUS "CMLIB warning:")
|
||||
message(STATUS " Uncrustify is not found")
|
||||
message(STATUS " uncrustify executable is not found")
|
||||
endif()
|
||||
|
||||
find_program(DOS2UNIX_EXE NAMES dos2unix)
|
||||
if(DOS2UNIX_EXE)
|
||||
list(APPEND DOS2UNIX_OPTS
|
||||
-k
|
||||
-r)
|
||||
add_custom_target(format-sources-dos2unix-${_target} COMMAND ${DOS2UNIX_EXE} ${OPTS} ${_sources})
|
||||
add_dependencies(format-sources format-sources-dos2unix-${_target})
|
||||
else()
|
||||
message(STATUS "CMLIB warning:")
|
||||
message(STATUS " dos2unix executable is not found")
|
||||
endif()
|
||||
endfunction()
|
||||
|
47
README.md
47
README.md
@@ -7,11 +7,19 @@
|
||||
В каталоге проекта выполнить команду
|
||||
|
||||
```sh
|
||||
git submodule add ssh://git@host/user/cmlib cmake/cmlib
|
||||
git submodule add git@host:user/cmlib cmake/cmlib
|
||||
```
|
||||
|
||||
заменив `host` и `user` на нужные значения.
|
||||
|
||||
Кроме того желательно установить библиотеки `find` и `generators`.
|
||||
|
||||
```sh
|
||||
git submodule add git@host:user/cmake-find cmake/find
|
||||
git submodule add git@host:user/cmake-generators cmake/generators
|
||||
```
|
||||
|
||||
|
||||
## Использование
|
||||
|
||||
В основном для проекта файле `CMakeLists.txt` добавить:
|
||||
@@ -26,25 +34,26 @@ endif()
|
||||
include(CMLibCommon)
|
||||
```
|
||||
|
||||
Создать файл `cmake/etc/version.txt`, в который нужно
|
||||
записать номер версии проекта, отвечающий стандарту
|
||||
[семантического версионирования](https://semver.org/lang/ru/).
|
||||
Создать файл `cmake/etc/Variable.cmake`, в котором нужно
|
||||
определить переменные, используемые в проекте, например:
|
||||
|
||||
В файле `cmake/etc/organization.txt` записать название
|
||||
организации, которой принадлежит проект.
|
||||
```cmake
|
||||
set(ORGANIZATION_NAME "org")
|
||||
|
||||
В файле `cmake/etc/cpack_ignore.txt` перечислить шаблоны
|
||||
для исключения из создаваемого целью `dist` архива. Например,
|
||||
|
||||
```
|
||||
cmake/lib/.git$
|
||||
.git$
|
||||
files/var
|
||||
CMakeLists.txt.user
|
||||
~$
|
||||
\\\\..*\\\\.bak$
|
||||
\\\\..*\\\\.tmp$
|
||||
\\\\..*\\\\.swp$
|
||||
set(CPACK_GENERATOR "TXZ;DEB")
|
||||
set(CPACK_PACKAGE_CONTACT "John Doe <john.doe@example.com>")
|
||||
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Useful software")
|
||||
set(CPACK_DEBIAN_PACKAGE_SECTION "misc")
|
||||
set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
|
||||
set(CPACK_SOURCE_IGNORE_FILES
|
||||
.git$
|
||||
.swp$
|
||||
obj.*/
|
||||
_build/
|
||||
_output/
|
||||
files/var
|
||||
CMakeLists.txt.user
|
||||
~$
|
||||
\\\\..*\\\\.swp$)
|
||||
```
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user