diff options
| author | Christoph Cullmann <cullmann@kde.org> | 2021-01-17 20:25:11 +0100 | 
|---|---|---|
| committer | Alexander Lohnau <alexander.lohnau@gmx.de> | 2021-01-18 20:53:46 +0000 | 
| commit | 765360a0de2e5bd2f00c49c1c68e0958c3978e77 (patch) | |
| tree | d3dd812f30020fa0edfe0a556c6ce9a25ae4c0dd | |
| parent | 7b835ca4d837f22c49f88dabc256569a80692c6d (diff) | |
| download | extra-cmake-modules-765360a0de2e5bd2f00c49c1c68e0958c3978e77.tar.gz extra-cmake-modules-765360a0de2e5bd2f00c49c1c68e0958c3978e77.tar.bz2  | |
fix issues with too long command line length
| -rw-r--r-- | kde-modules/KDEClangFormat.cmake | 36 | 
1 files changed, 19 insertions, 17 deletions
diff --git a/kde-modules/KDEClangFormat.cmake b/kde-modules/KDEClangFormat.cmake index 057433c8..6d4ef0f4 100644 --- a/kde-modules/KDEClangFormat.cmake +++ b/kde-modules/KDEClangFormat.cmake @@ -40,24 +40,26 @@ endif()  # formatting target  function(KDE_CLANG_FORMAT) -    # add target only if clang-format available +    # 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}...") + +    # run clang-format only if available, else signal the user what is missing      if(KDE_CLANG_FORMAT_EXECUTABLE) -        add_custom_target(clang-format -        COMMAND -            ${KDE_CLANG_FORMAT_EXECUTABLE} -            -style=file -            -i -            ${ARGV} -        WORKING_DIRECTORY -            ${CMAKE_CURRENT_SOURCE_DIR} -        COMMENT -            "Formatting sources in ${CMAKE_CURRENT_SOURCE_DIR} with ${KDE_CLANG_FORMAT_EXECUTABLE}..." -        ) +        foreach(_file ${ARGV}) +            add_custom_command(TARGET clang-format +                COMMAND +                    ${KDE_CLANG_FORMAT_EXECUTABLE} +                    -style=file +                    -i +                    ${_file} +                WORKING_DIRECTORY +                    ${CMAKE_CURRENT_SOURCE_DIR} +                ) +        endforeach()      else() -        add_custom_target(clang-format -        COMMAND -            ${CMAKE_COMMAND} -E echo -            "Could not set up the clang-format target as the clang-format executable is missing." -        ) +        add_custom_command(TARGET clang-format +            COMMAND +                ${CMAKE_COMMAND} -E echo "Could not set up the clang-format target as the clang-format executable is missing." +            )      endif()  endfunction()  | 
