Compare commits
7 Commits
master
...
feature/ti
Author | SHA1 | Date |
---|---|---|
Martchus | f8934f979d | |
Martchus | 888ea56765 | |
Martchus | 6f46a18dc1 | |
Martchus | 2439ad6d38 | |
Martchus | 790660c711 | |
Martchus | 6c0f4d587d | |
Martchus | d2f0f2e511 |
|
@ -39,3 +39,6 @@ Makefile*
|
|||
|
||||
# tests
|
||||
testfiles/output.*
|
||||
|
||||
# clang-format
|
||||
/.clang-format
|
||||
|
|
|
@ -31,6 +31,7 @@ The library utilizes:
|
|||
* cppunit for unit tests (optional)
|
||||
* Doxygen for API documentation (optional)
|
||||
* Graphviz for diagrams in the API documentation (optional)
|
||||
* clang-format for tidying (optional)
|
||||
|
||||
#### Runtime dependencies
|
||||
* The c++utilities library itself only needs
|
||||
|
@ -43,6 +44,7 @@ Just run:
|
|||
```
|
||||
cd "path/to/build/directory"
|
||||
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="/final/install/location" "path/to/projectdirectory"
|
||||
make tidy # format source files (optional)
|
||||
make
|
||||
make check # build and run unit tests (optional)
|
||||
make apidoc # build API documentation (optional)
|
||||
|
|
|
@ -141,4 +141,68 @@ else()
|
|||
set(QUICK_GUI OFF)
|
||||
endif()
|
||||
|
||||
# find coding style (use style from c++utilities if none included in own project dir)
|
||||
set(CLANG_FORMAT_RULES "${CMAKE_CURRENT_SOURCE_DIR}/coding-style.clang-format")
|
||||
if(CPP_UTILITIES_SOURCE_DIR AND NOT EXISTS "${CLANG_FORMAT_RULES}")
|
||||
set(CLANG_FORMAT_RULES "${CPP_UTILITIES_SOURCE_DIR}/coding-style.clang-format")
|
||||
endif()
|
||||
if(NOT EXISTS "${CLANG_FORMAT_RULES}")
|
||||
set(CLANG_FORMAT_RULES "${CPP_UTILITIES_CONFIG_DIRS}/codingstyle.clang-format")
|
||||
endif()
|
||||
|
||||
# add autotools-style check target
|
||||
if(NOT TARGET check)
|
||||
set(CMAKE_CTEST_COMMAND ${CMAKE_CTEST_COMMAND} -V)
|
||||
add_custom_target(check
|
||||
COMMAND ${CMAKE_CTEST_COMMAND}
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
)
|
||||
endif()
|
||||
|
||||
# enable testing
|
||||
enable_testing()
|
||||
get_directory_property(HAS_PARENT PARENT_DIRECTORY)
|
||||
if(HAS_PARENT)
|
||||
message(STATUS "For the check target to work, it is required to call enable_testing() on the source directory root.")
|
||||
endif()
|
||||
|
||||
# add target for tidying with clang-format
|
||||
if(EXISTS "${CLANG_FORMAT_RULES}")
|
||||
find_program(CLANG_FORMAT_BIN clang-format)
|
||||
if(CLANG_FORMAT_BIN)
|
||||
set(FORMATABLE_FILES ${HEADER_FILES} ${SRC_FILES} ${WIDGETS_HEADER_FILES} ${WIDGETS_SRC_FILES} ${QML_HEADER_FILES} ${QML_SRC_FILES})
|
||||
if(FORMATABLE_FILES)
|
||||
list(REMOVE_ITEM FORMATABLE_FILES "")
|
||||
|
||||
add_custom_target("${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_tidy"
|
||||
COMMAND "${CLANG_FORMAT_BIN}" -style=file -i ${FORMATABLE_FILES}
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
COMMENT "Tidying ${META_PROJECT_NAME} sources using clang-format"
|
||||
)
|
||||
if(NOT TARGET tidy)
|
||||
add_custom_target(tidy)
|
||||
endif()
|
||||
add_dependencies(tidy "${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_tidy")
|
||||
add_custom_target("${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_link_codingstyle"
|
||||
COMMAND "${CMAKE_COMMAND}" -E create_symlink "${CLANG_FORMAT_RULES}" "${CMAKE_CURRENT_SOURCE_DIR}/.clang-format"
|
||||
COMMENT "Linking coding style from ${CLANG_FORMAT_RULES}"
|
||||
)
|
||||
add_dependencies("${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_tidy" "${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_link_codingstyle")
|
||||
|
||||
# also add a test to verify whether sources are tidy
|
||||
add_test(NAME "${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_tidy_test"
|
||||
COMMAND "${CLANG_FORMAT_BIN}" -output-replacements-xml -style=file ${FORMATABLE_FILES}
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
)
|
||||
set_tests_properties("${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_tidy_test" PROPERTIES
|
||||
FAIL_REGULAR_EXPRESSION "<replacement.*>.*</replacement>"
|
||||
)
|
||||
endif()
|
||||
else()
|
||||
message(WARNING "clang-format not found; unable to add tidy target")
|
||||
endif()
|
||||
else()
|
||||
message(WARNING "No rules to invoke clang-format for ${META_PROJECT_NAME} present")
|
||||
endif()
|
||||
|
||||
set(BASIC_PROJECT_CONFIG_DONE YES)
|
||||
|
|
|
@ -22,22 +22,6 @@ if(CPP_UNIT_LIB)
|
|||
set(META_PRIVATE_SHARED_LIB_COMPILE_DEFINITIONS ${META_PRIVATE_COMPILE_DEFINITIONS} ${META_ADDITIONAL_PRIVATE_SHARED_COMPILE_DEFINITIONS})
|
||||
endif()
|
||||
|
||||
# add autotools-style check target and enable testing
|
||||
if(NOT TARGET check)
|
||||
set(CMAKE_CTEST_COMMAND ctest -V)
|
||||
add_custom_target(check
|
||||
COMMAND ${CMAKE_CTEST_COMMAND}
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
)
|
||||
endif()
|
||||
|
||||
# enable testing
|
||||
enable_testing()
|
||||
get_directory_property(HAS_PARENT PARENT_DIRECTORY)
|
||||
if(HAS_PARENT)
|
||||
message(STATUS "For the check target to work, it is required to call enable_testing() on the source directory root.")
|
||||
endif()
|
||||
|
||||
# add target for test executable, but exclude it from the "all target" when EXCLUDE_TESTS_FROM_ALL is set
|
||||
if(EXCLUDE_TESTS_FROM_ALL)
|
||||
set(TESTS_EXCLUSION EXCLUDE_FROM_ALL)
|
||||
|
|
|
@ -7,11 +7,11 @@
|
|||
#include @GENERAL_GLOBAL_H_INCLUDE_PATH@
|
||||
|
||||
#ifdef @META_PROJECT_VARNAME_UPPER@_STATIC
|
||||
# define @META_PROJECT_VARNAME_UPPER@_EXPORT
|
||||
# define @META_PROJECT_VARNAME_UPPER@_IMPORT
|
||||
#define @META_PROJECT_VARNAME_UPPER@_EXPORT
|
||||
#define @META_PROJECT_VARNAME_UPPER@_IMPORT
|
||||
#else
|
||||
# define @META_PROJECT_VARNAME_UPPER@_EXPORT LIB_EXPORT
|
||||
# define @META_PROJECT_VARNAME_UPPER@_IMPORT LIB_IMPORT
|
||||
#define @META_PROJECT_VARNAME_UPPER@_EXPORT LIB_EXPORT
|
||||
#define @META_PROJECT_VARNAME_UPPER@_IMPORT LIB_IMPORT
|
||||
#endif
|
||||
|
||||
/*!
|
||||
|
|
|
@ -0,0 +1,95 @@
|
|||
---
|
||||
Language: Cpp
|
||||
# BasedOnStyle: WebKit
|
||||
AccessModifierOffset: -4
|
||||
AlignAfterOpenBracket: DontAlign
|
||||
AlignConsecutiveAssignments: false
|
||||
AlignConsecutiveDeclarations: false
|
||||
AlignEscapedNewlinesLeft: false
|
||||
AlignOperands: false
|
||||
AlignTrailingComments: false
|
||||
AllowAllParametersOfDeclarationOnNextLine: true
|
||||
AllowShortBlocksOnASingleLine: false
|
||||
AllowShortCaseLabelsOnASingleLine: false
|
||||
AllowShortFunctionsOnASingleLine: None
|
||||
AllowShortIfStatementsOnASingleLine: false
|
||||
AllowShortLoopsOnASingleLine: false
|
||||
AlwaysBreakAfterDefinitionReturnType: None
|
||||
AlwaysBreakAfterReturnType: None
|
||||
AlwaysBreakBeforeMultilineStrings: false
|
||||
AlwaysBreakTemplateDeclarations: false
|
||||
BinPackArguments: true
|
||||
BinPackParameters: true
|
||||
BraceWrapping:
|
||||
AfterClass: false
|
||||
AfterControlStatement: false
|
||||
AfterEnum: false
|
||||
AfterFunction: true
|
||||
AfterNamespace: false
|
||||
AfterObjCDeclaration: false
|
||||
AfterStruct: false
|
||||
AfterUnion: false
|
||||
BeforeCatch: false
|
||||
BeforeElse: false
|
||||
IndentBraces: false
|
||||
BreakBeforeBinaryOperators: All
|
||||
BreakBeforeBraces: WebKit
|
||||
BreakBeforeTernaryOperators: true
|
||||
BreakConstructorInitializersBeforeComma: true
|
||||
BreakAfterJavaFieldAnnotations: false
|
||||
BreakStringLiterals: true
|
||||
ColumnLimit: 150
|
||||
CommentPragmas: '^ IWYU pragma:'
|
||||
ConstructorInitializerAllOnOneLineOrOnePerLine: false
|
||||
ConstructorInitializerIndentWidth: 4
|
||||
ContinuationIndentWidth: 4
|
||||
Cpp11BracedListStyle: false
|
||||
DerivePointerAlignment: false
|
||||
DisableFormat: false
|
||||
ExperimentalAutoDetectBinPacking: false
|
||||
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
|
||||
IncludeCategories:
|
||||
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
|
||||
Priority: 2
|
||||
- Regex: '^(<|"(gtest|isl|json)/)'
|
||||
Priority: 3
|
||||
- Regex: '.*'
|
||||
Priority: 1
|
||||
IncludeIsMainRegex: '$'
|
||||
IndentCaseLabels: false
|
||||
IndentWidth: 4
|
||||
IndentWrappedFunctionNames: false
|
||||
JavaScriptQuotes: Leave
|
||||
JavaScriptWrapImports: true
|
||||
KeepEmptyLinesAtTheStartOfBlocks: true
|
||||
MacroBlockBegin: ''
|
||||
MacroBlockEnd: ''
|
||||
MaxEmptyLinesToKeep: 1
|
||||
NamespaceIndentation: None
|
||||
ObjCBlockIndentWidth: 4
|
||||
ObjCSpaceAfterProperty: true
|
||||
ObjCSpaceBeforeProtocolList: true
|
||||
PenaltyBreakBeforeFirstCallParameter: 19
|
||||
PenaltyBreakComment: 300
|
||||
PenaltyBreakFirstLessLess: 120
|
||||
PenaltyBreakString: 1000
|
||||
PenaltyExcessCharacter: 1000000
|
||||
PenaltyReturnTypeOnItsOwnLine: 60
|
||||
PointerAlignment: Right
|
||||
ReflowComments: false
|
||||
SortIncludes: true
|
||||
SpaceAfterCStyleCast: false
|
||||
SpaceBeforeAssignmentOperators: true
|
||||
SpaceBeforeParens: ControlStatements
|
||||
SpaceInEmptyParentheses: false
|
||||
SpacesBeforeTrailingComments: 1
|
||||
SpacesInAngles: false
|
||||
SpacesInContainerLiterals: true
|
||||
SpacesInCStyleCastParentheses: false
|
||||
SpacesInParentheses: false
|
||||
SpacesInSquareBrackets: false
|
||||
Standard: Cpp03
|
||||
TabWidth: 8
|
||||
UseTab: Never
|
||||
...
|
||||
|
8
global.h
8
global.h
|
@ -7,11 +7,11 @@
|
|||
#include "./application/global.h"
|
||||
|
||||
#ifdef CPP_UTILITIES_STATIC
|
||||
# define CPP_UTILITIES_EXPORT
|
||||
# define CPP_UTILITIES_IMPORT
|
||||
#define CPP_UTILITIES_EXPORT
|
||||
#define CPP_UTILITIES_IMPORT
|
||||
#else
|
||||
# define CPP_UTILITIES_EXPORT LIB_EXPORT
|
||||
# define CPP_UTILITIES_IMPORT LIB_IMPORT
|
||||
#define CPP_UTILITIES_EXPORT LIB_EXPORT
|
||||
#define CPP_UTILITIES_IMPORT LIB_IMPORT
|
||||
#endif
|
||||
|
||||
/*!
|
||||
|
|
Loading…
Reference in New Issue