#=============================================================================== # @file AkantuCleaning.cmake # # @author Nicolas Richart # # @date creation: Thu Jun 1, 2017 # # @brief set of tools to clean the code # # @section LICENSE # # Copyright (©) 2010-2012, 2014, 2015 EPFL (Ecole Polytechnique Fédérale de # Lausanne) Laboratory (LSMS - Laboratoire de Simulation en Mécanique des # Solides) # # Akantu is free software: you can redistribute it and/or modify it under the # terms of the GNU Lesser General Public License as published by the Free # Software Foundation, either version 3 of the License, or (at your option) any # later version. # # Akantu is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR # A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # details. # # You should have received a copy of the GNU Lesser General Public License # along with Akantu. If not, see . #=============================================================================== # Adding clang-format target if executable is found find_program(CLANG_FORMAT "clang-format") mark_as_advanced(CLANG_FORMAT) macro(register_code_to_format) if(CLANG_FORMAT) add_custom_target( clang-format-all COMMAND ${CLANG_FORMAT} -i -style=file ${ARGN} ) endif() endmacro() # Adding clang-tidy target if executable is found find_program(CLANG_TIDY "clang-tidy") mark_as_advanced(CLANG_TIDY) macro(register_target_to_tidy target) if(CLANG_TIDY) get_target_property(_sources ${target} SOURCES) set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE BOOL "Enable/Disable output of compile commands during generation" FORCE) add_custom_target( clang-tidy-${target} COMMAND ${CLANG_TIDY} -quiet -p=${PROJECT_BINARY_DIR} -export-fixes=${PROJECT_BINARY_DIR}/clang-tidy-${target}.yaml ${_sources} COMMENT "Tidying ${target}" WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ) endif() endmacro()