diff --git a/.github/actions/apply-style/entrypoint.sh b/.github/actions/apply-style/entrypoint.sh index 4d4452f294..2116f23d9f 100755 --- a/.github/actions/apply-style/entrypoint.sh +++ b/.github/actions/apply-style/entrypoint.sh @@ -56,7 +56,7 @@ git checkout $branch git submodule update --init --recursive mkdir build && cd build -cmake $CMAKE_ARGS .. +cmake $CMAKE_ARGS ../src make style cd .. diff --git a/.mailmap b/.mailmap index e366e891f9..18ba1fc677 100644 --- a/.mailmap +++ b/.mailmap @@ -25,6 +25,7 @@ Cyrus D. Harrison Cyrus Daniel Taller Danny Taller <66029857+dtaller@users.noreply.github.com> Esteban Pauli Esteban Pauli <40901502+estebanpauli@users.noreply.github.com> Evan Taylor Desantola Evan Taylor DeSantola +format-robot format-robot George Zagaris George Zagaris Jacob Spainhour jcs15c Jacob Spainhour Jacob Spainhour diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2eede4f9b1..490a7d4ab6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -129,6 +129,8 @@ if(AXOM_ENABLE_CUDA AND ${CMAKE_VERSION} VERSION_LESS 3.18.0) message(FATAL_ERROR "Axom requires CMake version 3.18.0+ when CUDA is enabled.") endif() +axom_add_code_checks() + #------------------------------------------------------------------------------ # Add source directories #------------------------------------------------------------------------------ diff --git a/src/axom/config.hpp.in b/src/axom/config.hpp.in index 59050667e1..4cbdee0e29 100644 --- a/src/axom/config.hpp.in +++ b/src/axom/config.hpp.in @@ -13,20 +13,18 @@ * since it might be included from a C file */ - /* * Axom Version Information */ #define AXOM_VERSION_MAJOR @AXOM_VERSION_MAJOR@ #define AXOM_VERSION_MINOR @AXOM_VERSION_MINOR@ #define AXOM_VERSION_PATCH @AXOM_VERSION_PATCH@ -#define AXOM_VERSION_FULL "@AXOM_VERSION_FULL@" +#define AXOM_VERSION_FULL "@AXOM_VERSION_FULL@" /*NOTE: Do not add AXOM_GIT_SHA here. This will force * full rebuild on all local changes. It is added in axom::getVersion() * and axom::about(), as well as accessible from axom::gitSha(). */ - /* * Axom source location */ @@ -34,7 +32,6 @@ #define AXOM_BIN_DIR "@AXOM_BIN_DIR@" #cmakedefine AXOM_DATA_DIR "@AXOM_DATA_DIR@" - /* * Platform specific definitions */ @@ -46,7 +43,6 @@ #cmakedefine AXOM_USE_64BIT_INDEXTYPE #endif - /* * Compiler tests */ @@ -62,7 +58,6 @@ #cmakedefine AXOM_USE_MPIF_HEADER #cmakedefine AXOM_USE_OPENMP - /* * Compiler defines for libraries (built-in and third party) */ @@ -97,7 +92,6 @@ #define NOMINMAX #endif - /* * Compiler defines for Axom components */ @@ -120,7 +114,6 @@ */ #cmakedefine AXOM_DEPRECATED_TYPES_N @AXOM_DEPRECATED_TYPES_N@ - /* * Compiler defines to configure the built-in fmt library */ @@ -133,11 +126,9 @@ #cmakedefine SPARSEHASH_HASHFUN_HEADER @SPARSEHASH_HASHFUN_HEADER@ #cmakedefine SPARSEHASH_HASHFUN_NAMESPACE @SPARSEHASH_HASHFUN_NAMESPACE@ - /* * Disable some MSVC warnings related to shared libraries, if applicable */ @AXOM_MSVC_PRAGMAS@ - -#endif /* AXOM_COMMON_CONFIG_HPP */ +#endif /* AXOM_COMMON_CONFIG_HPP */ diff --git a/src/axom/core/CMakeLists.txt b/src/axom/core/CMakeLists.txt index 7bb28fb085..fc4be76825 100644 --- a/src/axom/core/CMakeLists.txt +++ b/src/axom/core/CMakeLists.txt @@ -158,8 +158,3 @@ endif() if(AXOM_ENABLE_EXAMPLES) add_subdirectory(examples) endif() - -#------------------------------------------------------------------------------ -# Add code checks -#------------------------------------------------------------------------------ -axom_add_code_checks(PREFIX core) diff --git a/src/axom/inlet/CMakeLists.txt b/src/axom/inlet/CMakeLists.txt index e65d90b95d..9eb755634c 100644 --- a/src/axom/inlet/CMakeLists.txt +++ b/src/axom/inlet/CMakeLists.txt @@ -86,8 +86,3 @@ endif() if (AXOM_ENABLE_TESTS) add_subdirectory(tests) endif() - -#------------------------------------------------------------------------------ -# Add code checks -#------------------------------------------------------------------------------ -axom_add_code_checks(PREFIX inlet) diff --git a/src/axom/klee/CMakeLists.txt b/src/axom/klee/CMakeLists.txt index e49699aed9..7350aee9c2 100644 --- a/src/axom/klee/CMakeLists.txt +++ b/src/axom/klee/CMakeLists.txt @@ -61,9 +61,3 @@ axom_install_component( NAME klee if (AXOM_ENABLE_TESTS AND ENABLE_GMOCK) add_subdirectory(tests) endif() - -#------------------------------------------------------------------------------ -# Add code checks -#------------------------------------------------------------------------------ -axom_add_code_checks(PREFIX klee) - diff --git a/src/axom/lumberjack/CMakeLists.txt b/src/axom/lumberjack/CMakeLists.txt index 97c2cdcbb1..a685825fd7 100644 --- a/src/axom/lumberjack/CMakeLists.txt +++ b/src/axom/lumberjack/CMakeLists.txt @@ -61,8 +61,3 @@ endif() if (AXOM_ENABLE_TESTS) add_subdirectory(tests) endif() - -#------------------------------------------------------------------------------ -# Add code checks -#------------------------------------------------------------------------------ -axom_add_code_checks(PREFIX lumberjack) diff --git a/src/axom/mint/CMakeLists.txt b/src/axom/mint/CMakeLists.txt index bc8d49d77d..235361cf4d 100644 --- a/src/axom/mint/CMakeLists.txt +++ b/src/axom/mint/CMakeLists.txt @@ -161,8 +161,3 @@ endif() if (AXOM_ENABLE_TESTS) add_subdirectory(tests) endif() - -#------------------------------------------------------------------------------ -# Add code checks -#------------------------------------------------------------------------------ -axom_add_code_checks(PREFIX mint) diff --git a/src/axom/mint/core/config.hpp.in b/src/axom/mint/core/config.hpp.in index a429650685..4f7d6c5554 100644 --- a/src/axom/mint/core/config.hpp.in +++ b/src/axom/mint/core/config.hpp.in @@ -6,8 +6,8 @@ #ifndef MINT_CONFIG_HPP_ #define MINT_CONFIG_HPP_ -#include "axom/config.hpp"// for compile-time definitions -#include "axom/core/Types.hpp" // for fixed-width types +#include "axom/config.hpp" // for compile-time definitions +#include "axom/core/Types.hpp" // for fixed-width types #cmakedefine AXOM_MINT_USE_SIDRE @@ -22,6 +22,4 @@ using int64 = std::int64_t; } /* end namespace mint */ } /* end namespace axom */ - - #endif /* MINT_CONFIG_HPP_ */ diff --git a/src/axom/multimat/CMakeLists.txt b/src/axom/multimat/CMakeLists.txt index a26d66073a..41c6194330 100644 --- a/src/axom/multimat/CMakeLists.txt +++ b/src/axom/multimat/CMakeLists.txt @@ -62,11 +62,3 @@ endif() if (AXOM_ENABLE_EXAMPLES) add_subdirectory(examples) endif() - - -#------------------------------------------------------------------------------ -# Add docs and code checks -#------------------------------------------------------------------------------ -axom_add_code_checks( - PREFIX multimat - ) diff --git a/src/axom/primal/CMakeLists.txt b/src/axom/primal/CMakeLists.txt index a16b1d0236..329085b383 100644 --- a/src/axom/primal/CMakeLists.txt +++ b/src/axom/primal/CMakeLists.txt @@ -115,8 +115,3 @@ endif() if (AXOM_ENABLE_TESTS) add_subdirectory(tests) endif() - -#------------------------------------------------------------------------------ -# Add code checks -#------------------------------------------------------------------------------ -axom_add_code_checks(PREFIX primal) diff --git a/src/axom/quest/CMakeLists.txt b/src/axom/quest/CMakeLists.txt index d52d50f66c..079b8cbdd9 100644 --- a/src/axom/quest/CMakeLists.txt +++ b/src/axom/quest/CMakeLists.txt @@ -205,5 +205,3 @@ endif() if (AXOM_ENABLE_TESTS) add_subdirectory(tests) endif() - -axom_add_code_checks(PREFIX quest) diff --git a/src/axom/sidre/CMakeLists.txt b/src/axom/sidre/CMakeLists.txt index bddbaff2f4..fac6704b9f 100644 --- a/src/axom/sidre/CMakeLists.txt +++ b/src/axom/sidre/CMakeLists.txt @@ -146,9 +146,3 @@ endif() if(AXOM_ENABLE_EXAMPLES) add_subdirectory(examples) endif() - -#------------------------------------------------------------------------------ -# Add code checks -#------------------------------------------------------------------------------ -axom_add_code_checks(PREFIX sidre - EXCLUDES sidre/examples/lulesh2) diff --git a/src/axom/slam/CMakeLists.txt b/src/axom/slam/CMakeLists.txt index f25056ae2e..fb54c2abd4 100644 --- a/src/axom/slam/CMakeLists.txt +++ b/src/axom/slam/CMakeLists.txt @@ -112,14 +112,3 @@ endif() if (AXOM_ENABLE_EXAMPLES) add_subdirectory(examples) endif() - - -#------------------------------------------------------------------------------ -# Add code checks -#------------------------------------------------------------------------------ -axom_add_code_checks( - PREFIX slam - EXCLUDES - slam/examples/lulesh2.0.3 - slam/examples/tinyHydro ) - diff --git a/src/axom/slic/CMakeLists.txt b/src/axom/slic/CMakeLists.txt index 31a7d8f598..4f939be076 100644 --- a/src/axom/slic/CMakeLists.txt +++ b/src/axom/slic/CMakeLists.txt @@ -100,8 +100,3 @@ endif() if (AXOM_ENABLE_TESTS) add_subdirectory(tests) endif() - -#------------------------------------------------------------------------------ -# Add code checks -#------------------------------------------------------------------------------ -axom_add_code_checks(PREFIX slic) diff --git a/src/axom/spin/CMakeLists.txt b/src/axom/spin/CMakeLists.txt index 2eafefbcbc..9bbb089537 100644 --- a/src/axom/spin/CMakeLists.txt +++ b/src/axom/spin/CMakeLists.txt @@ -80,8 +80,3 @@ endif() if (AXOM_ENABLE_TESTS) add_subdirectory(tests) endif() - -#------------------------------------------------------------------------------ -# Add code checks -#------------------------------------------------------------------------------ -axom_add_code_checks(PREFIX spin) diff --git a/src/cmake/AxomMacros.cmake b/src/cmake/AxomMacros.cmake index 78979503ea..e78a1c5b7c 100644 --- a/src/cmake/AxomMacros.cmake +++ b/src/cmake/AxomMacros.cmake @@ -4,23 +4,23 @@ # SPDX-License-Identifier: (BSD-3-Clause) ##------------------------------------------------------------------------------ -## axom_add_code_checks( PREFIX -## EXCLUDES [path1 [path2 ...]]) +## axom_add_code_checks() ## -## Adds code checks to all source files under this directory. -## -## PREFIX is used in the creation of all the underlying targets. For example: -## _clangformat_check. -## -## EXCLUDES is used to exclude any files from the code checks. It is done with -## a simple CMake reg exp MATCHES check. +## Adds code checks for all source files recursively in the Axom repository. +## +## This creates the following parent build targets: +## check - Runs a non file changing style check and CppCheck +## style - In-place code formatting ## +## Creates various child build targets that follow this pattern: +## axom_ +## axom__ ##------------------------------------------------------------------------------ macro(axom_add_code_checks) set(options) - set(singleValueArgs PREFIX ) - set(multiValueArgs EXCLUDES ) + set(singleValueArgs) + set(multiValueArgs) # Parse the arguments to the macro cmake_parse_arguments(arg @@ -29,34 +29,36 @@ macro(axom_add_code_checks) # Only do code checks if building Axom by itself and not included in # another project if ("${PROJECT_SOURCE_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}") - set(_all_sources) - file(GLOB_RECURSE _all_sources - "*.cpp" "*.hpp" "*.cxx" "*.hxx" "*.cc" "*.c" "*.h" "*.hh" - "*.F" "*.f" "*.f90" "*.F90") - - # Check for excludes - if (NOT DEFINED arg_EXCLUDES) - set(_sources ${_all_sources}) - else() - set(_sources) - foreach(_source ${_all_sources}) - set(_to_be_excluded FALSE) - foreach(_exclude ${arg_EXCLUDES}) - if (${_source} MATCHES ${_exclude}) - set(_to_be_excluded TRUE) - break() - endif() - endforeach() - - if (NOT ${_to_be_excluded}) - list(APPEND _sources ${_source}) - endif() + # Create file globbing expressions that only include directories that contain source + set(_base_dirs "axom" "examples" "thirdparty/tests" "tools") + set(_ext_expressions "*.cpp" "*.hpp" "*.inl" + "*.cxx" "*.hxx" "*.cc" "*.c" "*.h" "*.hh" + "*.F" "*.f" "*.f90" "*.F90") + + set(_glob_expressions) + foreach(_exp ${_ext_expressions}) + foreach(_base_dir ${_base_dirs}) + list(APPEND _glob_expressions "${PROJECT_SOURCE_DIR}/${_base_dir}/${_exp}") endforeach() - endif() + endforeach() + + # Glob for list of files to run code checks on + set(_sources) + file(GLOB_RECURSE _sources ${_glob_expressions}) + + # Filter out exclusions + set(_exclude_expressions + "${PROJECT_SOURCE_DIR}/axom/sidre/examples/lulesh2/*" + "${PROJECT_SOURCE_DIR}/axom/slam/examples/lulesh2.0.3/*" + "${PROJECT_SOURCE_DIR}/axom/slam/examples/tinyHydro/*") + foreach(_exp ${_exclude_expressions}) + list(FILTER _sources EXCLUDE REGEX ${_exp}) + endforeach() - blt_add_code_checks(PREFIX ${arg_PREFIX} - SOURCES ${_sources} - CLANGFORMAT_CFG_FILE ${PROJECT_SOURCE_DIR}/.clang-format) + blt_add_code_checks(PREFIX axom + SOURCES ${_sources} + CLANGFORMAT_CFG_FILE ${PROJECT_SOURCE_DIR}/.clang-format + CPPCHECK_FLAGS --enable=all --inconclusive) # Set FOLDER property for code check targets foreach(_suffix clangformat_check clangformat_style clang_tidy_check clang_tidy_style) diff --git a/src/docs/sphinx/dev_guide/component_org.rst b/src/docs/sphinx/dev_guide/component_org.rst index b5bfeec236..6798ae1e34 100644 --- a/src/docs/sphinx/dev_guide/component_org.rst +++ b/src/docs/sphinx/dev_guide/component_org.rst @@ -169,20 +169,9 @@ The top-level component directory contains a ``CMakeLists.txt``, e.g., install(EXPORT -targets DESTINATION lib/cmake) - #. Code formatting and static analysis targets; e.g.,:: - - axom_add_code_checks(BASE_NAME ) - - - -.. note:: Each Axom component should use the common ``clang-format`` - configuration file defined for the project at ``src/.clang-format``. - The file is used to define source code formatting options that are - applied when the *clang-format* tool is run on the code. - Component src directory -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +^^^^^^^^^^^^^^^^^^^^^^^ The ``CMakeLists.txt`` file in the component ``src`` directory defines: diff --git a/src/examples/using-with-blt/example.cpp b/src/examples/using-with-blt/example.cpp index 816ddbf984..9be211114b 100644 --- a/src/examples/using-with-blt/example.cpp +++ b/src/examples/using-with-blt/example.cpp @@ -3,7 +3,6 @@ // // SPDX-License-Identifier: (BSD-3-Clause) - //----------------------------------------------------------------------------- /// /// file: example.cpp @@ -17,14 +16,15 @@ int main() { - // Using fmt library exported by axom - std::cout << axom::fmt::format( - "Example of using an installed version of Axom {}", - axom::getVersion()) << std::endl << std::endl; + // Using fmt library exported by axom + std::cout << axom::fmt::format( + "Example of using an installed version of Axom {}", + axom::getVersion()) + << std::endl + << std::endl; - // Uses installed axom library - axom::about(); + // Uses installed axom library + axom::about(); - return 0; + return 0; } - diff --git a/src/examples/using-with-cmake/example.cpp b/src/examples/using-with-cmake/example.cpp index 816ddbf984..9be211114b 100644 --- a/src/examples/using-with-cmake/example.cpp +++ b/src/examples/using-with-cmake/example.cpp @@ -3,7 +3,6 @@ // // SPDX-License-Identifier: (BSD-3-Clause) - //----------------------------------------------------------------------------- /// /// file: example.cpp @@ -17,14 +16,15 @@ int main() { - // Using fmt library exported by axom - std::cout << axom::fmt::format( - "Example of using an installed version of Axom {}", - axom::getVersion()) << std::endl << std::endl; + // Using fmt library exported by axom + std::cout << axom::fmt::format( + "Example of using an installed version of Axom {}", + axom::getVersion()) + << std::endl + << std::endl; - // Uses installed axom library - axom::about(); + // Uses installed axom library + axom::about(); - return 0; + return 0; } - diff --git a/src/examples/using-with-make/example.cpp b/src/examples/using-with-make/example.cpp index e2186c1a0c..b41310124c 100644 --- a/src/examples/using-with-make/example.cpp +++ b/src/examples/using-with-make/example.cpp @@ -3,7 +3,6 @@ // // SPDX-License-Identifier: (BSD-3-Clause) - //----------------------------------------------------------------------------- /// /// file: example.cpp @@ -14,8 +13,4 @@ #include "axom/core.hpp" -int main() -{ - axom::about(); -} - +int main() { axom::about(); } diff --git a/src/thirdparty/tests/CMakeLists.txt b/src/thirdparty/tests/CMakeLists.txt index 1ff63d7575..a9f57ee084 100644 --- a/src/thirdparty/tests/CMakeLists.txt +++ b/src/thirdparty/tests/CMakeLists.txt @@ -6,9 +6,6 @@ # Collection of tests for axom's built-in third party libraries #------------------------------------------------------------------------------ -# Create cmake targets for running the tests through axom's code checks -axom_add_code_checks(PREFIX thirdparty_tests) - #------------------------------------------------------------------------------ # Smoke test for Umpire third party library #------------------------------------------------------------------------------ diff --git a/src/tools/CMakeLists.txt b/src/tools/CMakeLists.txt index 448f653d53..98f9e32ad8 100644 --- a/src/tools/CMakeLists.txt +++ b/src/tools/CMakeLists.txt @@ -173,8 +173,3 @@ if( AXOM_ENABLE_SIDRE AND AXOM_ENABLE_PRIMAL AND ) endif() - -#------------------------------------------------------------------------------ -# Add code checks -#------------------------------------------------------------------------------ -axom_add_code_checks(PREFIX tools)