Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 2 additions & 20 deletions .github/workflows/clang-tidy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,6 @@ jobs:

- name: Install fftw3
run: sudo apt-get install -yq libfftw3-dev pkg-config

- name: Install Bear
run: sudo apt-get install -yq bear

- name: configure pcms
run : |
Expand All @@ -219,27 +216,12 @@ jobs:
-DKokkosKernels_DIR=${{ runner.temp }}/build-kokkos-kernels-openmpi/install/lib/cmake/KokkosKernels/ \
-DPCMS_TEST_DATA_DIR=$PWD/pcms_testcases

- name: Configure pcms with Bear
run: |
cd ${{ runner.temp }}/build-pcms
bear -- make

- name: Install clang-tidy
run: |
sudo apt-get update
sudo apt-get install -yq clang-tidy-18

# TODO need to capture the error code from this
- name: Run clang-tidy
run: |
EXIT_CODE=0
while read file; do
if ! clang-tidy -p ${{ runner.temp }}/build-pcms "$file" --quiet; then
echo "$file has clang-tidy issues"
EXIT_CODE=1
fi
done < <(find src -name "*.cpp" -o -name "*.hpp" -o -name "*.c" -o -name "*.h" -o -name "*.cc" -o -name "*.cxx" | grep -v 'src/pcms/capi/' | grep -v 'src/pcms/fortranapi/')
if [ $EXIT_CODE -eq 1 ]; then
echo "Some C/C++ files have clang-tidy issues. Please fix them with clang-tidy-18."
exit 1
fi
echo "All C/C++ files pass clang-tidy checks"
cmake --build ${{ runner.temp }}/build-pcms -t run-clang-tidy
22 changes: 22 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,28 @@ if(PCMS_ENABLE_ASAN AND CMAKE_COMPILER_IS_GNUCXX MATCHES 1)
set(PCMS_HAS_ASAN ON)
endif()

# based on Professional CMake: A Practical Guide
# this approach works around some issues with CMakes internal handling using co-compilation
# this approach affords a separate clang-tidy run step in the CI
if(PROJECT_IS_TOP_LEVEL)
set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE)

find_program(CLANG_TIDY_EXECUTABLE clang-tidy REQUIRED)
find_program(RUN_CLANG_TIDY_EXECUTABLE run-clang-tidy REQUIRED)

set(CLANG_TIDY_CONFIG_FILE ${CMAKE_CURRENT_LIST_DIR}/.clang-tidy)

message(STATUS "CLANG_TIDY_EXECUTABLE=${CLANG_TIDY_EXECUTABLE}")
message(STATUS "RUN_CLANG_TIDY_EXECUTABLE= ${RUN_CLANG_TIDY_EXECUTABLE}")
message(STATUS "CLANG_TIDY_CONFIG_FILE=${CLANG_TIDY_CONFIG_FILE}")
add_custom_target(run-clang-tidy
COMMAND ${RUN_CLANG_TIDY_EXECUTABLE}
-clang-tidy-binary ${CLANG_TIDY_EXECUTABLE}
-p ${CMAKE_BINARY_DIR}
-config-file ${CLANG_TIDY_CONFIG_FILE}
)
endif()

option(PCMS_ENABLE_SERVER "enable the coupling server implementation" ON)
option(PCMS_ENABLE_CLIENT "enable the coupling client implementation" ON)

Expand Down
Loading