Skip to content
Snippets Groups Projects
Commit bd88304b authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

Add clang-format target to cmake

If `clang-format` is found the 'clang-format' target is defined. To build this
target, clang format is run on pastis sources (c++) omitting 'packages' sources.

It is better to configure editors to use clang-format than running this on the
whole sources before pushing...
parent 8b0e50ae
Branches
Tags
1 merge request!13Feature/clang format
......@@ -121,6 +121,21 @@ endif()
set(PASTIS_HAS_MPI ${MPI_FOUND})
#------------------------------------------------------
# search for clang-format
find_program(CLANG_FORMAT clang-format)
if (CLANG_FORMAT)
add_custom_target(clang-format
COMMAND echo "running ${CLANG_FORMAT} ..."
COMMAND ${CMAKE_COMMAND}
-DPASTIS_SOURCE_DIR="${PASTIS_SOURCE_DIR}"
-DCLANG_FORMAT="${CLANG_FORMAT}"
-P ${PASTIS_SOURCE_DIR}/cmake/ClangFormatProcess.cmake)
else ()
message(WARNING "clang-format no found!")
endif()
#------------------------------------------------------
# setting Kokkos defaults to OpenMP when available
......
# --------------- runs clang-format in place using the style file ---------------
if(PASTIS_SOURCE_DIR AND CLANG_FORMAT)
# get C++ sources file list (ignoring packages)
file(GLOB_RECURSE ALL_SOURCE_FILES
${PASTIS_SOURCE_DIR}/src/**.[hc]pp
${PASTIS_SOURCE_DIR}/tests/**.[hc]pp)
# apply style to the file list
foreach(SOURCE_FILE ${ALL_SOURCE_FILES})
execute_process(COMMAND "${CLANG_FORMAT}" -style=file -verbose -i "${SOURCE_FILE}")
endforeach()
endif()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment