From 122e7cc387f320a2af0249add39a74e629b05697 Mon Sep 17 00:00:00 2001 From: Marcel Breyer Date: Tue, 12 Nov 2024 14:31:56 +0100 Subject: [PATCH] Guard formatting targets behind a custom option. --- CMakeLists.txt | 48 +++++++++++++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 19 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f2f3fc61b..daeed246b 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -625,27 +625,37 @@ else () endif () target_link_libraries(${PLSSVM_BASE_LIBRARY_NAME} PUBLIC fmt::fmt) -## install library to add a clang-format target -set(PLSSVM_format_VERSION 1b43a3989de33e44e2a4f1766e9842be1744eef6) -find_package(format QUIET) -if (format_FOUND) - message(STATUS "Found package format.") -else () - message(STATUS "Couldn't find package format. Building version ${PLSSVM_format_VERSION} from source.") - set(FORMAT_SKIP_CMAKE ON CACHE INTERNAL "" FORCE) - set(FORMAT_SKIP_CLANG OFF CACHE INTERNAL "" FORCE) - # fetch clang-format library - # TODO: use original library after PR (HIP support) has been merged - FetchContent_Declare(format - GIT_REPOSITORY https://github.com/breyerml/Format.cmake.git - GIT_TAG ${PLSSVM_format_VERSION} - QUIET - ) - FetchContent_MakeAvailable(format) -endif () - list(POP_BACK CMAKE_MESSAGE_INDENT) +######################################################################################################################## +## enable automatic formatting using clang-format ## +######################################################################################################################## +option(PLSSVM_ENABLE_FORMATTING "Enable a formatting targets using clang-format." OFF) +if (PLSSVM_ENABLE_FORMAT) + list(APPEND CMAKE_MESSAGE_INDENT "Formatting: ") + + ## install library to add a clang-format target + set(PLSSVM_format_VERSION 1b43a3989de33e44e2a4f1766e9842be1744eef6) + find_package(format QUIET) + if (format_FOUND) + message(STATUS "Found package format.") + else () + message(STATUS "Couldn't find package format. Building version ${PLSSVM_format_VERSION} from source.") + set(FORMAT_SKIP_CMAKE ON CACHE INTERNAL "" FORCE) + set(FORMAT_SKIP_CLANG OFF CACHE INTERNAL "" FORCE) + # fetch clang-format library + # TODO: use original library after PR (HIP support) has been merged + FetchContent_Declare(format + GIT_REPOSITORY https://github.com/breyerml/Format.cmake.git + GIT_TAG ${PLSSVM_format_VERSION} + QUIET + ) + FetchContent_MakeAvailable(format) + endif () + + list(POP_BACK CMAKE_MESSAGE_INDENT) +endif () + ######################################################################################################################## ## enable documentation generation via doxygen ## ########################################################################################################################