From 5fe087286fb30b61660a205e21c7c484ab25446b Mon Sep 17 00:00:00 2001 From: Chris White Date: Wed, 17 Jul 2024 09:57:19 -0700 Subject: [PATCH 01/10] purposefully mess up style --- src/axom/inlet/Field.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/axom/inlet/Field.cpp b/src/axom/inlet/Field.cpp index 5455c211eb..f552512255 100644 --- a/src/axom/inlet/Field.cpp +++ b/src/axom/inlet/Field.cpp @@ -45,8 +45,7 @@ void Field::setDefaultValue(T value) if(m_docEnabled) { m_sidreGroup->createViewScalar("defaultValue", value); - } - if(!m_sidreGroup->hasView("value")) + }if(!m_sidreGroup->hasView("value")) { m_sidreGroup->createViewScalar("value", value); } From e1f6a3236d46d2f78f2d62842cdca307090090ec Mon Sep 17 00:00:00 2001 From: Chris White Date: Wed, 17 Jul 2024 10:04:45 -0700 Subject: [PATCH 02/10] fix path to base of cmake project --- .github/actions/apply-style/entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 .. From 192906dfcf8eb2de34ba408103a0aa36ef437020 Mon Sep 17 00:00:00 2001 From: Chris White Date: Wed, 17 Jul 2024 13:32:49 -0700 Subject: [PATCH 03/10] simplify code check macro to work across the whole repository and not per component --- src/CMakeLists.txt | 2 + src/axom/core/CMakeLists.txt | 5 -- src/axom/inlet/CMakeLists.txt | 5 -- src/axom/klee/CMakeLists.txt | 6 --- src/axom/lumberjack/CMakeLists.txt | 5 -- src/axom/mint/CMakeLists.txt | 5 -- src/axom/multimat/CMakeLists.txt | 8 --- src/axom/primal/CMakeLists.txt | 5 -- src/axom/quest/CMakeLists.txt | 2 - src/axom/sidre/CMakeLists.txt | 6 --- src/axom/slam/CMakeLists.txt | 11 ----- src/axom/slic/CMakeLists.txt | 5 -- src/axom/spin/CMakeLists.txt | 5 -- src/cmake/AxomMacros.cmake | 77 +++++++++++++++-------------- src/thirdparty/tests/CMakeLists.txt | 3 -- src/tools/CMakeLists.txt | 5 -- 16 files changed, 42 insertions(+), 113 deletions(-) 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/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/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..fcf890919c 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 cpp/hpp files recursively under the current directory. +## +## 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,37 @@ 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") + # Note: any extensions added here should also be added to BLT's lists in CMakeLists.txt + set(_ext_expressions "*.cpp" "*.hpp" "*.inl" "*.cuh" "*.cu" "*.cpp.in" "*.hpp.in" + "*.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/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) From 9335ff3bae66a539e19684609f58febcfce202e0 Mon Sep 17 00:00:00 2001 From: Chris White Date: Wed, 17 Jul 2024 13:42:30 -0700 Subject: [PATCH 04/10] fix extensions --- src/CMakeLists.txt | 5 +++++ src/cmake/AxomMacros.cmake | 8 +++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 490a7d4ab6..8c9033e401 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -129,6 +129,11 @@ 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() +# Add extra file extensions for code styling +# Note: Add them also to axom_add_code_checks in src/cmake/AxomMacros.cmake +# Configured C++ files +list(APPEND BLT_C_FILE_EXTS ".cpp.in" ".hpp.in") + axom_add_code_checks() #------------------------------------------------------------------------------ diff --git a/src/cmake/AxomMacros.cmake b/src/cmake/AxomMacros.cmake index fcf890919c..3a424e7abf 100644 --- a/src/cmake/AxomMacros.cmake +++ b/src/cmake/AxomMacros.cmake @@ -30,9 +30,11 @@ macro(axom_add_code_checks) # another project if ("${PROJECT_SOURCE_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}") # Create file globbing expressions that only include directories that contain source - set(_base_dirs "axom" "examples" "thirdparty/tests/" "tools") - # Note: any extensions added here should also be added to BLT's lists in CMakeLists.txt - set(_ext_expressions "*.cpp" "*.hpp" "*.inl" "*.cuh" "*.cu" "*.cpp.in" "*.hpp.in" + set(_base_dirs "axom" "examples" "thirdparty/tests" "tools") + + # Note: any extensions added here should also be added to BLT's lists + # in src/CMakeLists.txt + set(_ext_expressions "*.cpp" "*.hpp" "*.inl" "*.cpp.in" "*.hpp.in" "*.cxx" "*.hxx" "*.cc" "*.c" "*.h" "*.hh" "*.F" "*.f" "*.f90" "*.F90") From da0fe4102012479819478485e0c341369f619f67 Mon Sep 17 00:00:00 2001 From: format-robot Date: Wed, 17 Jul 2024 13:45:28 -0700 Subject: [PATCH 05/10] Apply style updates --- src/axom/config.hpp.in | 35 +++++++++-------------- src/axom/inlet/Field.cpp | 3 +- src/axom/mint/core/config.hpp.in | 6 ++-- src/examples/using-with-blt/example.cpp | 18 ++++++------ src/examples/using-with-cmake/example.cpp | 18 ++++++------ src/examples/using-with-make/example.cpp | 7 +---- 6 files changed, 36 insertions(+), 51 deletions(-) diff --git a/src/axom/config.hpp.in b/src/axom/config.hpp.in index 59050667e1..e82f27d22c 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_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@" /*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 */ @@ -43,10 +40,9 @@ #cmakedefine AXOM_NO_INT64_T #ifndef AXOM_NO_INT64_T -#cmakedefine AXOM_USE_64BIT_INDEXTYPE + #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) */ @@ -92,12 +87,11 @@ * Windows GDI geometry classes (NOGDI). */ #ifdef WIN32 -#define _USE_MATH_DEFINES -#define NOGDI -#define NOMINMAX + #define _USE_MATH_DEFINES + #define NOGDI + #define NOMINMAX #endif - /* * Compiler defines for Axom components */ @@ -118,8 +112,7 @@ * allow silently, and -1 to disallow. Corresponds to cmake variable * AXOM_DEPRECATED_TYPES values of WARN, ALLOW and ERROR. */ -#cmakedefine AXOM_DEPRECATED_TYPES_N @AXOM_DEPRECATED_TYPES_N@ - +#cmakedefine AXOM_DEPRECATED_TYPES_N @AXOM_DEPRECATED_TYPES_N @ /* * Compiler defines to configure the built-in fmt library @@ -130,14 +123,12 @@ /* * Compiler defines to configure the built-in sparsehash library */ -#cmakedefine SPARSEHASH_HASHFUN_HEADER @SPARSEHASH_HASHFUN_HEADER@ -#cmakedefine SPARSEHASH_HASHFUN_NAMESPACE @SPARSEHASH_HASHFUN_NAMESPACE@ - +#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@ - +@AXOM_MSVC_PRAGMAS @ -#endif /* AXOM_COMMON_CONFIG_HPP */ +#endif /* AXOM_COMMON_CONFIG_HPP */ diff --git a/src/axom/inlet/Field.cpp b/src/axom/inlet/Field.cpp index f552512255..5455c211eb 100644 --- a/src/axom/inlet/Field.cpp +++ b/src/axom/inlet/Field.cpp @@ -45,7 +45,8 @@ void Field::setDefaultValue(T value) if(m_docEnabled) { m_sidreGroup->createViewScalar("defaultValue", value); - }if(!m_sidreGroup->hasView("value")) + } + if(!m_sidreGroup->hasView("value")) { m_sidreGroup->createViewScalar("value", value); } 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/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(); } From be0c9674a6888563fb0f1fb564e059c93f5e5455 Mon Sep 17 00:00:00 2001 From: Chris White Date: Wed, 17 Jul 2024 13:53:26 -0700 Subject: [PATCH 06/10] mailmap update --- .mailmap | 1 + 1 file changed, 1 insertion(+) 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 From 1dd05bc8fdc15c226cde45b70715dce4bb25422d Mon Sep 17 00:00:00 2001 From: Chris White Date: Wed, 17 Jul 2024 14:25:18 -0700 Subject: [PATCH 07/10] fix formatting --- src/axom/config.hpp.in | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/axom/config.hpp.in b/src/axom/config.hpp.in index e82f27d22c..80d307af67 100644 --- a/src/axom/config.hpp.in +++ b/src/axom/config.hpp.in @@ -16,10 +16,12 @@ /* * Axom Version Information */ -#define AXOM_VERSION_MAJOR @AXOM_VERSION_MAJOR @ -#define AXOM_VERSION_MINOR @AXOM_VERSION_MINOR @ -#define AXOM_VERSION_PATCH @AXOM_VERSION_PATCH @ +// clang-format off +#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@" +// clang-format on /*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(). @@ -112,7 +114,9 @@ * allow silently, and -1 to disallow. Corresponds to cmake variable * AXOM_DEPRECATED_TYPES values of WARN, ALLOW and ERROR. */ -#cmakedefine AXOM_DEPRECATED_TYPES_N @AXOM_DEPRECATED_TYPES_N @ +// clang-format off +#cmakedefine AXOM_DEPRECATED_TYPES_N @AXOM_DEPRECATED_TYPES_N@ +// clang-format on /* * Compiler defines to configure the built-in fmt library @@ -123,12 +127,14 @@ /* * Compiler defines to configure the built-in sparsehash library */ -#cmakedefine SPARSEHASH_HASHFUN_HEADER @SPARSEHASH_HASHFUN_HEADER @ -#cmakedefine SPARSEHASH_HASHFUN_NAMESPACE @SPARSEHASH_HASHFUN_NAMESPACE @ +// clang-format off +#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 @ +@AXOM_MSVC_PRAGMAS@ +// clang-format on #endif /* AXOM_COMMON_CONFIG_HPP */ From 2190c71650a00c5d1ab983561862e50755cf375f Mon Sep 17 00:00:00 2001 From: Chris White Date: Wed, 17 Jul 2024 14:46:09 -0700 Subject: [PATCH 08/10] undo styling of configured C++ files --- src/CMakeLists.txt | 5 ----- src/axom/config.hpp.in | 6 ------ src/cmake/AxomMacros.cmake | 5 +---- 3 files changed, 1 insertion(+), 15 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8c9033e401..490a7d4ab6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -129,11 +129,6 @@ 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() -# Add extra file extensions for code styling -# Note: Add them also to axom_add_code_checks in src/cmake/AxomMacros.cmake -# Configured C++ files -list(APPEND BLT_C_FILE_EXTS ".cpp.in" ".hpp.in") - axom_add_code_checks() #------------------------------------------------------------------------------ diff --git a/src/axom/config.hpp.in b/src/axom/config.hpp.in index 80d307af67..f99a45f8d2 100644 --- a/src/axom/config.hpp.in +++ b/src/axom/config.hpp.in @@ -16,12 +16,10 @@ /* * Axom Version Information */ -// clang-format off #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@" -// clang-format on /*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(). @@ -114,9 +112,7 @@ * allow silently, and -1 to disallow. Corresponds to cmake variable * AXOM_DEPRECATED_TYPES values of WARN, ALLOW and ERROR. */ -// clang-format off #cmakedefine AXOM_DEPRECATED_TYPES_N @AXOM_DEPRECATED_TYPES_N@ -// clang-format on /* * Compiler defines to configure the built-in fmt library @@ -127,7 +123,6 @@ /* * Compiler defines to configure the built-in sparsehash library */ -// clang-format off #cmakedefine SPARSEHASH_HASHFUN_HEADER @SPARSEHASH_HASHFUN_HEADER@ #cmakedefine SPARSEHASH_HASHFUN_NAMESPACE @SPARSEHASH_HASHFUN_NAMESPACE@ @@ -135,6 +130,5 @@ * Disable some MSVC warnings related to shared libraries, if applicable */ @AXOM_MSVC_PRAGMAS@ -// clang-format on #endif /* AXOM_COMMON_CONFIG_HPP */ diff --git a/src/cmake/AxomMacros.cmake b/src/cmake/AxomMacros.cmake index 3a424e7abf..8354d0d964 100644 --- a/src/cmake/AxomMacros.cmake +++ b/src/cmake/AxomMacros.cmake @@ -31,10 +31,7 @@ macro(axom_add_code_checks) if ("${PROJECT_SOURCE_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}") # Create file globbing expressions that only include directories that contain source set(_base_dirs "axom" "examples" "thirdparty/tests" "tools") - - # Note: any extensions added here should also be added to BLT's lists - # in src/CMakeLists.txt - set(_ext_expressions "*.cpp" "*.hpp" "*.inl" "*.cpp.in" "*.hpp.in" + set(_ext_expressions "*.cpp" "*.hpp" "*.inl" "*.cxx" "*.hxx" "*.cc" "*.c" "*.h" "*.hh" "*.F" "*.f" "*.f90" "*.F90") From d1bfc4fe841476f3c9e21386af8637c027f0416f Mon Sep 17 00:00:00 2001 From: Chris White Date: Wed, 17 Jul 2024 14:50:41 -0700 Subject: [PATCH 09/10] clarify docs --- src/cmake/AxomMacros.cmake | 2 +- src/docs/sphinx/dev_guide/component_org.rst | 13 +------------ 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/src/cmake/AxomMacros.cmake b/src/cmake/AxomMacros.cmake index 8354d0d964..e78a1c5b7c 100644 --- a/src/cmake/AxomMacros.cmake +++ b/src/cmake/AxomMacros.cmake @@ -6,7 +6,7 @@ ##------------------------------------------------------------------------------ ## axom_add_code_checks() ## -## Adds code checks for all cpp/hpp files recursively under the current directory. +## 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 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: From 9b1ac61b96743243be6c8a7063f6cdc11a11acca Mon Sep 17 00:00:00 2001 From: Chris White Date: Wed, 17 Jul 2024 15:37:08 -0700 Subject: [PATCH 10/10] undo more formatting --- src/axom/config.hpp.in | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/axom/config.hpp.in b/src/axom/config.hpp.in index f99a45f8d2..4cbdee0e29 100644 --- a/src/axom/config.hpp.in +++ b/src/axom/config.hpp.in @@ -40,7 +40,7 @@ #cmakedefine AXOM_NO_INT64_T #ifndef AXOM_NO_INT64_T - #cmakedefine AXOM_USE_64BIT_INDEXTYPE +#cmakedefine AXOM_USE_64BIT_INDEXTYPE #endif /* @@ -87,9 +87,9 @@ * Windows GDI geometry classes (NOGDI). */ #ifdef WIN32 - #define _USE_MATH_DEFINES - #define NOGDI - #define NOMINMAX +#define _USE_MATH_DEFINES +#define NOGDI +#define NOMINMAX #endif /*