Skip to content

Commit

Permalink
Guard formatting targets behind a custom option.
Browse files Browse the repository at this point in the history
  • Loading branch information
breyerml committed Nov 12, 2024
1 parent e7bf0f1 commit 122e7cc
Showing 1 changed file with 29 additions and 19 deletions.
48 changes: 29 additions & 19 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 ##
########################################################################################################################
Expand Down

0 comments on commit 122e7cc

Please sign in to comment.