1.99.50
This commit is contained in:
parent
87efaa095d
commit
57de097d2d
@ -29,6 +29,8 @@ include(${MYX_CMAKE_LIB_DIR}/AddLibrary.cmake)
|
||||
include(${MYX_CMAKE_LIB_DIR}/TargetSetup.cmake)
|
||||
include(${MYX_CMAKE_LIB_DIR}/Qt5TargetSetup.cmake)
|
||||
|
||||
include(${MYX_CMAKE_LIB_DIR}/Uncrustify.cmake)
|
||||
|
||||
unset(MYX_CMAKE_SOURCE_DIR)
|
||||
unset(MYX_CMAKE_BACKPORTS_DIR)
|
||||
unset(MYX_CMAKE_LIB_DIR)
|
||||
|
@ -1,4 +1,4 @@
|
||||
set(MYX_CMAKE_PACKAGE_VERSION "1.99.44")
|
||||
set(MYX_CMAKE_PACKAGE_VERSION "1.99.50")
|
||||
if(MYX_CMAKE_PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)
|
||||
set(PACKAGE_VERSION_COMPATIBLE FALSE)
|
||||
else()
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
```cmake
|
||||
if(MYX_CMAKE_USE_SYSTEM)
|
||||
find_package(MyxCMake 1.99.44 REQUIRED)
|
||||
find_package(MyxCMake 1.99.50 REQUIRED)
|
||||
else()
|
||||
include(${PROJECT_SOURCE_DIR}/cmake/myx/MyxCMakeConfig.cmake)
|
||||
endif()
|
||||
|
@ -1 +1 @@
|
||||
1.99.44
|
||||
1.99.50
|
||||
|
104
lib/Uncrustify.cmake
Normal file
104
lib/Uncrustify.cmake
Normal file
@ -0,0 +1,104 @@
|
||||
include_guard(GLOBAL)
|
||||
|
||||
find_program(UNCRUSTIFY_EXE NAMES uncrustify)
|
||||
|
||||
if(UNCRUSTIFY_EXE)
|
||||
if(NOT EXISTS ${PROJECT_BINARY_DIR}/uncrustify-classheader.txt)
|
||||
file(GENERATE OUTPUT ${PROJECT_BINARY_DIR}/uncrustify-classheader.txt CONTENT
|
||||
"/**
|
||||
* @class $(fclass)
|
||||
* @brief TODO
|
||||
* @details TODO
|
||||
*/")
|
||||
endif()
|
||||
|
||||
if(NOT EXISTS ${PROJECT_BINARY_DIR}/uncrustify-filefooter.txt)
|
||||
file(GENERATE OUTPUT ${PROJECT_BINARY_DIR}/uncrustify-filefooter.txt CONTENT
|
||||
"// EOF $(filename)")
|
||||
endif()
|
||||
|
||||
if(NOT EXISTS ${PROJECT_BINARY_DIR}/uncrustify-fileheader.txt)
|
||||
file(GENERATE OUTPUT ${PROJECT_BINARY_DIR}/uncrustify-fileheader.txt CONTENT
|
||||
"/**
|
||||
* @file $(filename)
|
||||
* @brief TODO
|
||||
* @details TODO
|
||||
*/")
|
||||
endif()
|
||||
|
||||
if(NOT EXISTS ${PROJECT_BINARY_DIR}/uncrustify-funcheader.txt)
|
||||
file(GENERATE OUTPUT ${PROJECT_BINARY_DIR}/uncrustify-funcheader.txt CONTENT
|
||||
"/**
|
||||
* @fn $(fclass)::$(function)
|
||||
* $(javaparam)
|
||||
* @details TODO
|
||||
*/")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
function(myx_uncrustify target)
|
||||
set(options)
|
||||
set(oneValueArgs CONFIG)
|
||||
set(multiValueArgs)
|
||||
|
||||
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
|
||||
if(NOT ARG_CONFIG)
|
||||
set(ARG_CONFIG "${PROJECT_SOURCE_DIR}/.uncrustify.cfg")
|
||||
endif()
|
||||
|
||||
if(NOT UNCRUSTIFY_EXE)
|
||||
myx_message_notify("MyxCMake: uncrustify executable is not found")
|
||||
return()
|
||||
endif()
|
||||
|
||||
if(NOT EXISTS ${ARG_CONFIG})
|
||||
myx_message_notify("MyxCMake: uncrustify config is not found")
|
||||
return()
|
||||
endif()
|
||||
|
||||
if(NOT TARGET myx-uncrustify)
|
||||
add_custom_target(myx-uncrustify)
|
||||
endif()
|
||||
if(NOT TARGET myx-uncrustify-check)
|
||||
add_custom_target(myx-uncrustify-check)
|
||||
endif()
|
||||
if(NOT TARGET myx-uncrustify-append-comments)
|
||||
add_custom_target(myx-uncrustify-append-comments)
|
||||
endif()
|
||||
|
||||
get_target_property(__sources ${target} SOURCES)
|
||||
list(FILTER __sources EXCLUDE REGEX "qrc_.*\\.cpp$")
|
||||
list(FILTER __sources EXCLUDE REGEX "moc_.*\\.cpp$")
|
||||
list(FILTER __sources EXCLUDE REGEX "ui_.*\\.h$")
|
||||
|
||||
add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/uncrustify-${target}.cfg
|
||||
COMMAND ${UNCRUSTIFY_EXE} --update-config-with-doc
|
||||
-c ${ARG_CONFIG}
|
||||
-o ${PROJECT_BINARY_DIR}/uncrustify-${target}.cfg)
|
||||
list(APPEND UNCRUSTIFY_OPTS -c ${PROJECT_BINARY_DIR}/uncrustify-${target}.cfg)
|
||||
# cmake-format: off
|
||||
add_custom_target(${target}-uncrustify-check
|
||||
DEPENDS ${PROJECT_BINARY_DIR}/uncrustify-${target}.cfg
|
||||
COMMAND ${UNCRUSTIFY_EXE} ${UNCRUSTIFY_OPTS} --check ${__sources})
|
||||
|
||||
list(APPEND UNCRUSTIFY_OPTS --replace --no-backup)
|
||||
add_custom_target(${target}-uncrustify
|
||||
DEPENDS ${PROJECT_BINARY_DIR}/uncrustify-${target}.cfg
|
||||
COMMAND ${UNCRUSTIFY_EXE} ${UNCRUSTIFY_OPTS} --mtime ${__sources})
|
||||
|
||||
add_custom_target(${target}-uncrustify-append-comments
|
||||
DEPENDS ${PROJECT_BINARY_DIR}/uncrustify-${target}.cfg
|
||||
COMMAND ${UNCRUSTIFY_EXE} ${UNCRUSTIFY_OPTS}
|
||||
--set cmt_insert_class_header=${PROJECT_BINARY_DIR}/uncrustify-classheader.txt
|
||||
--set cmt_insert_file_footer=${PROJECT_BINARY_DIR}/uncrustify-filefooter.txt
|
||||
--set cmt_insert_file_header=${PROJECT_BINARY_DIR}/uncrustify-fileheader.txt
|
||||
--set cmt_insert_func_header=${PROJECT_BINARY_DIR}/uncrustify-funcheader.txt
|
||||
--set cmt_insert_before_ctor_dtor=true --mtime ${__sources})
|
||||
# cmake-format: on
|
||||
|
||||
add_dependencies(myx-uncrustify ${target}-uncrustify)
|
||||
add_dependencies(myx-uncrustify-check ${target}-uncrustify-check)
|
||||
add_dependencies(myx-uncrustify-append-comments ${target}-uncrustify-append-comments)
|
||||
endfunction()
|
Loading…
Reference in New Issue
Block a user