diff --git a/.clang-format b/.clang-format index 817b640..7922bb5 100644 --- a/.clang-format +++ b/.clang-format @@ -2,47 +2,114 @@ # SPDX-FileCopyrightText: 2016-2025 Knut Reinert & MPI für molekulare Genetik # SPDX-License-Identifier: CC0-1.0 -# Format all files -# find . -iname "*.hpp" | xargs clang-format-15 --style=file -i +# From top-level directory: +# Format all files +# find ${PWD} -iname "*.hpp" -not -path ${PWD}/build | xargs clang-format-20 --style=file -i +# Format staged file +# git diff --name-only HEAD --diff-filter=ACMRT | grep "\.hpp" | xargs clang-format-20 --style=file -i --- Language: Cpp AccessModifierOffset: -4 AlignAfterOpenBracket: Align AlignArrayOfStructures: None -AlignConsecutiveMacros: None -AlignConsecutiveAssignments: None -AlignConsecutiveBitFields: None -AlignConsecutiveDeclarations: None +AlignConsecutiveAssignments: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionDeclarations: false + AlignFunctionPointers: false + PadOperators: true +AlignConsecutiveBitFields: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionDeclarations: false + AlignFunctionPointers: false + PadOperators: true +AlignConsecutiveDeclarations: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionDeclarations: false + AlignFunctionPointers: false + PadOperators: true +AlignConsecutiveMacros: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionDeclarations: false + AlignFunctionPointers: false + PadOperators: true +AlignConsecutiveShortCaseStatements: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCaseArrows: false + AlignCaseColons: false +AlignConsecutiveTableGenBreakingDAGArgColons: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionDeclarations: false + AlignFunctionPointers: false + PadOperators: true +AlignConsecutiveTableGenCondOperatorColons: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionDeclarations: false + AlignFunctionPointers: false + PadOperators: true +AlignConsecutiveTableGenDefinitionColons: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionDeclarations: false + AlignFunctionPointers: false + PadOperators: true AlignEscapedNewlines: Right AlignOperands: AlignAfterOperator -AlignTrailingComments: true +AlignTrailingComments: + Kind: Always + OverEmptyLines: 0 AllowAllArgumentsOnNextLine: false AllowAllParametersOfDeclarationOnNextLine: false -AllowShortEnumsOnASingleLine: true +AllowBreakBeforeNoexceptSpecifier: Never AllowShortBlocksOnASingleLine: Never +AllowShortCaseExpressionOnASingleLine: true AllowShortCaseLabelsOnASingleLine: false +AllowShortCompoundRequirementOnASingleLine: true +AllowShortEnumsOnASingleLine: true AllowShortFunctionsOnASingleLine: None -AllowShortLambdasOnASingleLine: Empty AllowShortIfStatementsOnASingleLine: Never +AllowShortLambdasOnASingleLine: Empty AllowShortLoopsOnASingleLine: false +AllowShortNamespacesOnASingleLine: false AlwaysBreakAfterDefinitionReturnType: None -AlwaysBreakAfterReturnType: None AlwaysBreakBeforeMultilineStrings: false -AlwaysBreakTemplateDeclarations: Yes AttributeMacros: + - __capability BinPackArguments: false -BinPackParameters: false +BinPackParameters: OnePerLine +BitFieldColonSpacing: Both BraceWrapping: AfterCaseLabel: true AfterClass: true AfterControlStatement: Always AfterEnum: true + AfterExternBlock: true AfterFunction: true AfterNamespace: true AfterObjCDeclaration: false AfterStruct: true AfterUnion: true - AfterExternBlock: true BeforeCatch: true BeforeElse: true BeforeLambdaBody: true @@ -51,71 +118,84 @@ BraceWrapping: SplitEmptyFunction: false SplitEmptyRecord: false SplitEmptyNamespace: false +BreakAdjacentStringLiterals: true +BreakAfterAttributes: Leave +BreakAfterJavaFieldAnnotations: false +BreakAfterReturnType: None +BreakArrays: true BreakBeforeBinaryOperators: NonAssignment -BreakBeforeConceptDeclarations: true +BreakBeforeConceptDeclarations: Always BreakBeforeBraces: Custom -BreakBeforeInheritanceComma: false -BreakInheritanceList: AfterColon +BreakBeforeInlineASMColon: OnlyMultiline BreakBeforeTernaryOperators: true -BreakConstructorInitializersBeforeComma: false +BreakBinaryOperations: Never BreakConstructorInitializers: AfterColon -BreakAfterJavaFieldAnnotations: false +BreakFunctionDefinitionParameters: false +BreakInheritanceList: AfterColon BreakStringLiterals: true +BreakTemplateDeclarations: Yes ColumnLimit: 120 CommentPragmas: '^ IWYU pragma:' -QualifierAlignment: Custom -QualifierOrder: ['static', 'inline', 'constexpr', 'volatile', 'type', 'const'] CompactNamespaces: false ConstructorInitializerIndentWidth: 4 ContinuationIndentWidth: 4 Cpp11BracedListStyle: true -DeriveLineEnding: true DerivePointerAlignment: false DisableFormat: false EmptyLineAfterAccessModifier: Never EmptyLineBeforeAccessModifier: Always ExperimentalAutoDetectBinPacking: false -PackConstructorInitializers: CurrentLine -BasedOnStyle: '' -ConstructorInitializerAllOnOneLineOrOnePerLine: false -AllowAllConstructorInitializersOnNextLine: true FixNamespaceComments: true ForEachMacros: + - foreach + - Q_FOREACH + - BOOST_FOREACH IfMacros: + - KJ_IF_MAYBE IncludeBlocks: Regroup IncludeCategories: - - Regex: '(' Priority: 1 - - Regex: '(<[[:alnum:]._]+>|)' - Priority: 2 - - Regex: ' "seqan-std/all_view.hpp" +set (generator_relative_path "$") +# For each list item, prepend with "#include <" +# "seqan-std/all_view.hpp" -> "#include ") +# Join the list, use ">\n" as separator. "$" must be used for ">" +# "#include "#include " +set (generator_join_list "$\n>") +# Generate file. The last item in the list is missing ">", so we add another ">". +file (GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/header_test.cpp" + CONTENT "${generator_join_list}$\n\nint main() { return 0; }") +add_executable (header_test ${CMAKE_CURRENT_BINARY_DIR}/header_test.cpp) +target_link_libraries (header_test seqan-std_test) +add_test (NAME "header_test" COMMAND header_test) + foreach (absolute_header_path ${header_files}) file (RELATIVE_PATH header "${include_dir}" "${absolute_header_path}") get_filename_component (header_test_name "${absolute_header_path}" NAME_WE) foreach (header_sub_test "header-guard" "no-self-include") set (header_target "${header_test_name}-${header_sub_test}") - set (header_target_source "${CMAKE_CURRENT_BINARY_DIR}/${target}_files/${header_target}.cpp") + set (header_target_source "${CMAKE_CURRENT_BINARY_DIR}/header_test_files/${header_target}.cpp") # we use add_custom_command to detect changes to a header file, which will update the generated source file add_custom_command (OUTPUT "${header_target_source}" @@ -54,6 +69,16 @@ foreach (absolute_header_path ${header_files}) add_library (${header_target} OBJECT "${header_target_source}") target_link_libraries (${header_target} seqan-std_test) - target_sources (${target} PRIVATE $) + target_sources (header_test PRIVATE $) endforeach () endforeach () + +################################################################################ +############################ FILE_SET HEADERS check ############################ +################################################################################ +add_test (NAME "file_set_check" + COMMAND ${CMAKE_COMMAND} "-DHEADER_SET=$" + "-DINCLUDE_DIRECTORY=${include_dir}" + -P "${CMAKE_CURRENT_SOURCE_DIR}/check_file_set.cmake") + +set_tests_properties (header_test PROPERTIES DEPENDS file_set_check) diff --git a/test/check_file_set.cmake b/test/check_file_set.cmake new file mode 100644 index 0000000..d26d453 --- /dev/null +++ b/test/check_file_set.cmake @@ -0,0 +1,45 @@ +# SPDX-FileCopyrightText: 2006-2025, Knut Reinert & Freie Universität Berlin +# SPDX-FileCopyrightText: 2016-2025, Knut Reinert & MPI für molekulare Genetik +# SPDX-License-Identifier: BSD-3-Clause + +cmake_minimum_required (VERSION 3.25) + +option (INCLUDE_DIRECTORY "") +option (HEADER_SET "") + +if (NOT INCLUDE_DIRECTORY) + message (FATAL_ERROR "INCLUDE_DIRECTORY must be set.") +endif () +if (NOT HEADER_SET) + message (FATAL_ERROR "HEADER_SET must be set.") +endif () + +file (GLOB_RECURSE header_files + LIST_DIRECTORIES FALSE + "${INCLUDE_DIRECTORY}/*") + +foreach (header_file IN LISTS header_files) + if (NOT header_file IN_LIST HEADER_SET) + list (APPEND missing_headers "${header_file}") + endif () +endforeach () + +foreach (header_file IN LISTS HEADER_SET) + if (NOT header_file IN_LIST header_files) + list (APPEND non_existing_headers "${header_file}") + endif () +endforeach () + +if (missing_headers) + string (REPLACE ";" " " missing_headers "${missing_headers}") + set (error_message "Missing from FILE_SET HEADERS: ${missing_headers}\n") +endif () + +if (non_existing_headers) + string (REPLACE ";" " " non_existing_headers "${non_existing_headers}") + set (error_message "${error_message}Non-existing headers in FILE_SET HEADERS: ${non_existing_headers}") +endif () + +if (error_message) + message (FATAL_ERROR "${error_message}") +endif () diff --git a/test/generate_header_source.cmake b/test/generate_header_source.cmake index 8fdbbc0..e41cce8 100644 --- a/test/generate_header_source.cmake +++ b/test/generate_header_source.cmake @@ -2,6 +2,8 @@ # SPDX-FileCopyrightText: 2016-2025, Knut Reinert & MPI für molekulare Genetik # SPDX-License-Identifier: BSD-3-Clause +cmake_minimum_required (VERSION 3.25) + option (HEADER_FILE_ABSOLUTE "") option (HEADER_FILE_INCLUDE "") option (HEADER_TARGET_SOURCE "")