From da06fa05d8a20edab7c684a516d4a676889cc83b Mon Sep 17 00:00:00 2001 From: Alexander Lohnau Date: Sat, 16 Jan 2021 13:27:05 +0100 Subject: Add clang-format target by default in KDEFrameworkCompilerSettings To prevent cmake errors with exiting usages it is checked if the target already exists. --- kde-modules/KDEClangFormat.cmake | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'kde-modules/KDEClangFormat.cmake') diff --git a/kde-modules/KDEClangFormat.cmake b/kde-modules/KDEClangFormat.cmake index b662b275..7889fde0 100644 --- a/kde-modules/KDEClangFormat.cmake +++ b/kde-modules/KDEClangFormat.cmake @@ -22,6 +22,8 @@ # added to version control. It is recommended to add it to the ``.gitignore`` file: ``/.clang-format``. # # Since 5.79: If the source folder already contains a .clang-format file it is not overwritten. +# Since version 5.80 this function is called by default in KDEFrameworkCompilerSettings. If directories should be excluded from +# the formatting a .clang-format file with "DisableFormat: true" and "SortIncludes: false" should be created. # # Example usage: # @@ -43,6 +45,7 @@ #============================================================================= # SPDX-FileCopyrightText: 2019 Christoph Cullmann +# SPDX-FileCopyrightText: 2021 Alexander Lohnau # # SPDX-License-Identifier: BSD-3-Clause @@ -67,6 +70,11 @@ endif() # formatting target function(KDE_CLANG_FORMAT) + if (TARGET clang-format) + message(WARNING "the kde_clang_format function was already called") + return() + endif() + # add target without specific commands first, we add the real calls file-per-file to avoid command line length issues add_custom_target(clang-format COMMENT "Formatting sources in ${CMAKE_CURRENT_SOURCE_DIR} with ${KDE_CLANG_FORMAT_EXECUTABLE}...") -- cgit v1.2.1