diff options
| author | Alexander Lohnau <alexander.lohnau@gmx.de> | 2021-01-30 13:44:07 +0100 | 
|---|---|---|
| committer | Alexander Lohnau <alexander.lohnau@gmx.de> | 2021-01-30 15:22:03 +0100 | 
| commit | 0d5ed9bb9117f6526691b3572bf85090efbeed4a (patch) | |
| tree | 9f00039991baafee1b03d412f67aab7e520b9b65 | |
| parent | fddc956e62c8f4162edc3b7e810c43d3e50b4c1e (diff) | |
| download | extra-cmake-modules-0d5ed9bb9117f6526691b3572bf85090efbeed4a.tar.gz extra-cmake-modules-0d5ed9bb9117f6526691b3572bf85090efbeed4a.tar.bz2 | |
KDEClangFormat: Do not override custom clang-format files
| -rw-r--r-- | kde-modules/KDEClangFormat.cmake | 13 | 
1 files changed, 12 insertions, 1 deletions
| diff --git a/kde-modules/KDEClangFormat.cmake b/kde-modules/KDEClangFormat.cmake index 6cdbd2b5..995f03ad 100644 --- a/kde-modules/KDEClangFormat.cmake +++ b/kde-modules/KDEClangFormat.cmake @@ -35,7 +35,18 @@ find_program(KDE_CLANG_FORMAT_EXECUTABLE clang-format)  # instantiate our clang-format file, must be in source directory for tooling if we have the tool  if(KDE_CLANG_FORMAT_EXECUTABLE) -    configure_file(${CMAKE_CURRENT_LIST_DIR}/clang-format.cmake ${CMAKE_CURRENT_SOURCE_DIR}/.clang-format @ONLY) +    set(CLANG_FORMAT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/.clang-format) +    if (EXISTS ${CLANG_FORMAT_FILE}) +        file(READ ${CLANG_FORMAT_FILE} CLANG_FORMAT_CONTENTS LIMIT 128) +        string(FIND "${CLANG_FORMAT_CONTENTS}" "SPDX-FileCopyrightText: 2019 Christoph Cullmann" matchres) +        if(${matchres} EQUAL -1) +            message(WARNING "The .clang-format file already exists. Please remove it in order to use the file provided by ECM") +        else() +            configure_file(${CMAKE_CURRENT_LIST_DIR}/clang-format.cmake ${CLANG_FORMAT_FILE} @ONLY) +        endif() +    else() +        configure_file(${CMAKE_CURRENT_LIST_DIR}/clang-format.cmake ${CLANG_FORMAT_FILE} @ONLY) +    endif()  endif()  # formatting target | 
