Skip to content
Snippets Groups Projects
Commit 7b6da84e authored by René Fritze's avatar René Fritze
Browse files

Merge branch 'cmake_remove_clang_format' into 'master'

Remove clang-{format,tidy}

See merge request !87
parents abbcc523 dac0baae
No related branches found
No related tags found
1 merge request!87Remove clang-{format,tidy}
Pipeline #107013 passed
......@@ -93,8 +93,6 @@ add_subdirectory(dune)
add_subdirectory("cmake/modules")
add_subdirectory(doc/doxygen)
add_format(${CMAKE_CURRENT_SOURCE_DIR})
add_tidy(${CMAKE_CURRENT_SOURCE_DIR})
add_pylicense()
finalize_dune_project(GENERATE_CONFIG_H_CMAKE)
......
......@@ -18,8 +18,6 @@ install(FILES DuneTBB.cmake
DunePybindxiMacros.cmake
DunePybindxiUtils.cmake
FindPythonLibsNew.cmake
FindClangFormat.cmake
FindClangTidy.cmake
FindEigen3.cmake
FindFASP.cmake
FindLIKWID.cmake
......
# ~~~
# This file is part of the dune-xt project:
# https://zivgitlab.uni-muenster.de/ag-ohlberger/dune-community/dune-xt
# Copyright 2009-2021 dune-xt developers and contributors. All rights reserved.
# License: Dual licensed as BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause)
# or GPL-2.0+ (http://opensource.org/licenses/gpl-license)
# with "runtime exception" (http://www.dune-project.org/license.html)
# Authors:
# Felix Schindler (2017)
# René Fritze (2016 - 2019)
# Tobias Leibner (2017 - 2018, 2020)
#
# Use this module by invoking find_package with the form::
#
# find_package(ClangFormat
# [version] # Minimum version e.g. 3.7
# )
#
# optionally pass the minimal version you require like so find_package(ClangFormat 3.7)
# this module set ClangFormat_EXECUTABLE, ClangFormat_VERSION
# and ClangFormat_FOUND accordingly
# ~~~
find_program(ClangFormat_EXECUTABLE NAMES clang-format-8 clang-format-8.0)
if(NOT EXISTS ${ClangFormat_EXECUTABLE})
find_program(ClangFormat_EXECUTABLE NAMES clang-format)
endif(NOT EXISTS ${ClangFormat_EXECUTABLE})
if(EXISTS ${ClangFormat_EXECUTABLE})
execute_process(COMMAND ${ClangFormat_EXECUTABLE} -version OUTPUT_VARIABLE clang_out)
string(REGEX
REPLACE ".*clang-format version ([0-9]+\\.[0-9]+).*"
"\\1"
ClangFormat_VERSION
${clang_out})
endif(EXISTS ${ClangFormat_EXECUTABLE})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(ClangFormat REQUIRED_VARS ClangFormat_EXECUTABLE VERSION_VAR ClangFormat_VERSION)
# ~~~
# This file is part of the dune-xt project:
# https://zivgitlab.uni-muenster.de/ag-ohlberger/dune-community/dune-xt
# Copyright 2009-2021 dune-xt developers and contributors. All rights reserved.
# License: Dual licensed as BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause)
# or GPL-2.0+ (http://opensource.org/licenses/gpl-license)
# with "runtime exception" (http://www.dune-project.org/license.html)
# Authors:
# Felix Schindler (2017)
# René Fritze (2016, 2018 - 2020)
# Tobias Leibner (2020)
#
# Use this module by invoking find_package with the form::
#
# find_package(ClangTidy
# [version] # Minimum version e.g. 3.7
# )
#
# optionally pass the minimal version you require like so find_package(ClangTidy 3.7)
# this module set ClangTidy_EXECUTABLE, ClangTidy_VERSION
# and ClangTidy_FOUND accordingly
# ~~~
find_program(ClangTidy_EXECUTABLE
NAMES clang-tidy
clang-tidy-8
clang-tidy-9
clang-tidy-10
clang-tidy-11
clang-tidy-12
clang-tidy-13
clang-tidy-14)
if(EXISTS ${ClangTidy_EXECUTABLE})
execute_process(COMMAND ${ClangTidy_EXECUTABLE} -version OUTPUT_VARIABLE clang_out)
string(REGEX
REPLACE ".*LLVM version ([0-9]+)\.[0-9]+\.[0-9]*.*"
"\\1"
ClangTidy_VERSION
${clang_out})
endif()
find_program(RunTidy_EXECUTABLE NAMES run-clang-tidy-${ClangTidy_VERSION})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(ClangTidy REQUIRED_VARS ClangTidy_EXECUTABLE VERSION_VAR ClangTidy_VERSION)
......@@ -34,80 +34,13 @@ macro(add_analyze)
endif(EXISTS ${ANALYZER})
endmacro(add_analyze)
find_package(ClangFormat 8 EXACT)
macro(add_format glob_dir)
if(NOT TARGET format)
if(NOT ClangFormat_FOUND)
message(WARNING "clang-format not found, not adding format target")
else()
add_custom_target(format)
endif()
else()
if(NOT ClangFormat_FOUND)
message(FATAL "clang-format not found but format target already exists")
endif()
endif(NOT TARGET format)
string(REPLACE "/"
"_"
fn
${glob_dir})
message(STATUS "adding format target")
if(ClangFormat_FOUND)
file(GLOB_RECURSE _files
"${glob_dir}/*.hh"
"${glob_dir}/*.cc"
"${glob_dir}/*.cxx"
"${glob_dir}/*.hxx"
"${glob_dir}/*.cpp"
"${glob_dir}/*.hpp"
"${glob_dir}/*.h"
"${glob_dir}/*.c"
"${glob_dir}/*.pbh")
# Formatting gtest.h causes extremely high memory usage and takes a long time
list(FILTER _files EXCLUDE REGEX ".*gtest.h$")
add_custom_target("format_${fn}" ${ClangFormat_EXECUTABLE} -i -style=file -fallback-style=none ${_files})
add_dependencies(format "format_${fn}")
file(GLOB_RECURSE _pyfiles "${glob_dir}/*.py")
add_custom_target("pyformat_${fn}"
${CMAKE_CURRENT_BINARY_DIR}/run-in-dune-env
yapf
-i
--style=${CMAKE_CURRENT_SOURCE_DIR}/python/.style.yapf
${_pyfiles})
add_dependencies(format "pyformat_${fn}")
file(GLOB_RECURSE _files "${glob_dir}/*.cmake" "${glob_dir}/CMakeLists.txt")
file(GLOB_RECURSE _exclude_files "${glob_dir}/*builder_definitions.cmake")
list(REMOVE_ITEM _files "${glob_dir}/config.h.cmake")
list(REMOVE_ITEM _files "${_exclude_files}")
add_custom_target("format_${fn}_cmake"
${CMAKE_BINARY_DIR}/run-in-dune-env
cmake-format
-i
-c
${glob_dir}/.cmake_format.py
${_files})
add_dependencies(format "format_${fn}_cmake")
else()
message(WARNING "not adding format target because clang-format is missing or "
"wrong version: ${ClangFormat_EXECUTABLE} ${ClangFormat_VERSION}")
endif(ClangFormat_FOUND)
macro(add_format)
message(NOTICE clang-format support was moved to a `pre-commit` hook. See dune-xt/.pre-commit-config.yaml)
add_custom_target("format" echo 'clang-format is now a pre-commit hook' && false)
endmacro(add_format)
find_package(ClangTidy 8)
macro(add_tidy)
if(ClangTidy_FOUND)
dune_symlink_to_source_files(FILES .clang-tidy)
message(STATUS "adding tidy target")
add_custom_target(tidy)
add_custom_target(fix_tidy)
add_tidy_subdir(common)
add_tidy_subdir(grid)
add_tidy_subdir(la)
add_tidy_subdir(functions)
else()
message(WARNING "not adding tidy target because clang-tidy is missing or"
"wrong version: ${ClangTidy_EXECUTABLE} ${ClangTidy_VERSION}")
endif(ClangTidy_FOUND)
add_custom_target("tidy" echo 'clang-tidy support was removed' && false)
endmacro()
macro(add_tidy_subdir _dxt_subdir)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment