From 0a86e00b115cad9a25611ce7bd5e8e41706163a5 Mon Sep 17 00:00:00 2001 From: Randolph Settgast Date: Wed, 10 Sep 2025 22:57:01 +0900 Subject: [PATCH 01/12] add proper option for turning camp usage on/off --- CMakeLists.txt | 12 ++++++++---- cmake/CMakeBasics.cmake | 2 ++ docs/doxygen/ShivaConfig.hpp | 2 ++ src/ShivaConfig.hpp.in | 4 +++- src/common/types.hpp | 1 - 5 files changed, 15 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ab43b11..b4f8514 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -67,11 +67,15 @@ include( cmake/Config.cmake ) add_subdirectory( src ) -add_subdirectory( tpl/camp ) -target_compile_options( camp PRIVATE "-Wno-shadow") -configure_file(tpl/camp/include/camp/config.in.hpp - ${PROJECT_BINARY_DIR}/include/camp/config.hpp) +if( SHIVA_ENABLE_CAMP ) + add_subdirectory( tpl/camp ) + target_compile_options( camp PRIVATE "-Wno-shadow") + configure_file(tpl/camp/include/camp/config.in.hpp + ${PROJECT_BINARY_DIR}/include/camp/config.hpp) +endif() + + if( SHIVA_ENABLE_DOCS ) diff --git a/cmake/CMakeBasics.cmake b/cmake/CMakeBasics.cmake index cf3c275..00e4784 100644 --- a/cmake/CMakeBasics.cmake +++ b/cmake/CMakeBasics.cmake @@ -11,6 +11,8 @@ set( SHIVA_BUILD_OBJ_LIBS OFF CACHE BOOL "" ) option( SHIVA_ENABLE_BOUNDS_CHECK "Enable bounds checking in shiva::CArray" ON ) +option( SHIVA_ENABLE_CAMP "Enable CAMP usage" ON ) + if( CMAKE_CXX_STANDARD IN_LIST "98; 11; 14" ) MESSAGE(FATAL_ERROR "Shiva requires at least c++17") endif() diff --git a/docs/doxygen/ShivaConfig.hpp b/docs/doxygen/ShivaConfig.hpp index 390e74a..cd7b644 100644 --- a/docs/doxygen/ShivaConfig.hpp +++ b/docs/doxygen/ShivaConfig.hpp @@ -15,3 +15,5 @@ /* #undef SHIVA_USE_CALIPER */ #define SHIVA_USE_BOUNDS_CHECK + +/* #undef SHIVA_USE_CAMP */ diff --git a/src/ShivaConfig.hpp.in b/src/ShivaConfig.hpp.in index d7535f8..fc554ee 100644 --- a/src/ShivaConfig.hpp.in +++ b/src/ShivaConfig.hpp.in @@ -14,4 +14,6 @@ #cmakedefine SHIVA_USE_CALIPER -#cmakedefine SHIVA_USE_BOUNDS_CHECK \ No newline at end of file +#cmakedefine SHIVA_USE_BOUNDS_CHECK + +#cmakedefine SHIVA_USE_CAMP \ No newline at end of file diff --git a/src/common/types.hpp b/src/common/types.hpp index ff2afd0..26e22f7 100644 --- a/src/common/types.hpp +++ b/src/common/types.hpp @@ -20,7 +20,6 @@ #include "common/ShivaMacros.hpp" /// @brief Macro to define whether or not to use camp. -#define SHIVA_USE_CAMP #if defined(SHIVA_USE_CAMP) #include #else From 8f80a5ee0c51fb79b5256e05fae6ce03ad24cda3 Mon Sep 17 00:00:00 2001 From: Randolph Settgast Date: Sat, 13 Sep 2025 09:50:38 +0900 Subject: [PATCH 02/12] Top level CMAKE. keep BLT for stand alone, for submodule make it optional --- CMakeLists.txt | 37 +++++++++++++++++++++---------------- cmake/CMakeBasics.cmake | 3 --- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2ef5be6..a88d6d9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,10 +20,20 @@ else() set( SHIVA_IS_SUBMODULE OFF ) endif() + +option( SHIVA_ENABLE_CAMP "Enable CAMP usage" ON ) +option( CAMP_ENABLE_TESTS OFF ) +option( SHIVA_ENABLE_BLT "Enable BLT usage" ON ) + + if( NOT SHIVA_IS_SUBMODULE ) message( "not a submodule") project( Shiva LANGUAGES CXX C ) + if( NOT SHIVA_ENABLE_BLT ) + message( FATAL_ERROR "When building Shiva as a standalone project you must enable BLT support. Please set SHIVA_ENABLE_BLT to ON." ) + endif() + set( BLT_CXX_STD "c++17" CACHE STRING "Version of C++ standard" FORCE ) set( ENABLE_WARNINGS_AS_ERRORS "ON" CACHE PATH "" ) @@ -52,16 +62,17 @@ if( NOT SHIVA_IS_SUBMODULE ) include( ${BLT_SOURCE_DIR}/SetupBLT.cmake ) endif() - - include( cmake/CMakeBasics.cmake ) - #include( cmake/SetupTPL.cmake ) else() + if( SHIVA_ENABLE_BLT OR SHIVA_ENABLE_CAMP ) if( NOT BLT_LOADED ) - message( FATAL_ERROR "When using Shiva as a submodule you must have already loaded BLT." ) + message( FATAL_ERROR "When using Shiva as a submodule and are using BLT, you must have already loaded BLT. CAMP requires BLT" ) endif() - include( cmake/CMakeBasics.cmake ) + else() + + endif() endif() +include( cmake/CMakeBasics.cmake ) include( cmake/Macros.cmake ) include( cmake/Config.cmake ) @@ -69,22 +80,16 @@ include( cmake/Config.cmake ) set(SHIVA_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} ) set(SHIVA_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR} ) -message( STATUS "SHIVA_BINARY_DIR: ${SHIVA_BINARY_DIR}" ) -message( STATUS "SHIVA_SOURCE_DIR: ${SHIVA_SOURCE_DIR}" ) - - add_subdirectory( src ) if( SHIVA_ENABLE_CAMP ) - -if( SHIVA_ENABLE_CAMP ) + if( NOT SHIVA_ENABLE_BLT ) + message( FATAL_ERROR "CAMP support requires BLT. Please enable SHIVA_ENABLE_BLT." ) + endif() add_subdirectory( tpl/camp ) - target_compile_options( camp PRIVATE "-Wno-shadow") - configure_file(tpl/camp/include/camp/config.in.hpp ${PROJECT_BINARY_DIR}/include/camp/config.hpp) + target_compile_options( camp PRIVATE "-Wno-shadow") + configure_file(tpl/camp/include/camp/config.in.hpp ${PROJECT_BINARY_DIR}/include/camp/config.hpp) endif() -endif() - - if( SHIVA_ENABLE_DOCS ) diff --git a/cmake/CMakeBasics.cmake b/cmake/CMakeBasics.cmake index 332bae5..d5d710d 100644 --- a/cmake/CMakeBasics.cmake +++ b/cmake/CMakeBasics.cmake @@ -11,7 +11,6 @@ set( SHIVA_BUILD_OBJ_LIBS OFF CACHE BOOL "" ) option( SHIVA_ENABLE_BOUNDS_CHECK "Enable bounds checking in shiva::CArray" ON ) -option( SHIVA_ENABLE_CAMP "Enable CAMP usage" ON ) if( CMAKE_CXX_STANDARD IN_LIST "98; 11; 14" ) MESSAGE(FATAL_ERROR "Shiva requires at least c++17") @@ -29,8 +28,6 @@ blt_append_custom_compiler_flag( FLAGS_VAR CMAKE_CXX_FLAGS_DEBUG CLANG "-fstandalone-debug" ) -option( SHIVA_ENABLE_CAMP OFF ) -option( CAMP_ENABLE_TESTS OFF ) if( ENABLE_CUDA ) From 2c8d063e29d3cb5a89d1d25b911e9e7b04db3fbd Mon Sep 17 00:00:00 2001 From: Randolph Settgast Date: Sun, 14 Sep 2025 02:31:09 +0900 Subject: [PATCH 03/12] rearrange cmake for a single target and optional BLT --- CMakeLists.txt | 8 +++- cmake/CMakeBasics.cmake | 15 +++---- docs/doxygen/ShivaConfig.hpp | 2 +- src/CMakeLists.txt | 42 +++++++++++-------- src/common/CMakeLists.txt | 67 +++++++----------------------- src/discretizations/CMakeLists.txt | 27 ++---------- src/functions/CMakeLists.txt | 37 +++-------------- src/geometry/CMakeLists.txt | 47 ++++----------------- 8 files changed, 70 insertions(+), 175 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a88d6d9..ac1a9d3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,6 +20,8 @@ else() set( SHIVA_IS_SUBMODULE OFF ) endif() +message( "SHIVA_IS_SUBMODULE: ${SHIVA_IS_SUBMODULE}" ) + option( SHIVA_ENABLE_CAMP "Enable CAMP usage" ON ) option( CAMP_ENABLE_TESTS OFF ) @@ -27,7 +29,7 @@ option( SHIVA_ENABLE_BLT "Enable BLT usage" ON ) if( NOT SHIVA_IS_SUBMODULE ) - message( "not a submodule") + message( "Shiva is not a submodule") project( Shiva LANGUAGES CXX C ) if( NOT SHIVA_ENABLE_BLT ) @@ -63,6 +65,7 @@ if( NOT SHIVA_IS_SUBMODULE ) include( ${BLT_SOURCE_DIR}/SetupBLT.cmake ) endif() else() + message( "SHIVA is a submodule") if( SHIVA_ENABLE_BLT OR SHIVA_ENABLE_CAMP ) if( NOT BLT_LOADED ) message( FATAL_ERROR "When using Shiva as a submodule and are using BLT, you must have already loaded BLT. CAMP requires BLT" ) @@ -80,7 +83,6 @@ include( cmake/Config.cmake ) set(SHIVA_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} ) set(SHIVA_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR} ) -add_subdirectory( src ) if( SHIVA_ENABLE_CAMP ) if( NOT SHIVA_ENABLE_BLT ) @@ -91,6 +93,8 @@ if( SHIVA_ENABLE_CAMP ) configure_file(tpl/camp/include/camp/config.in.hpp ${PROJECT_BINARY_DIR}/include/camp/config.hpp) endif() +add_subdirectory( src ) + if( SHIVA_ENABLE_DOCS ) add_subdirectory( docs ) diff --git a/cmake/CMakeBasics.cmake b/cmake/CMakeBasics.cmake index d5d710d..caaf03e 100644 --- a/cmake/CMakeBasics.cmake +++ b/cmake/CMakeBasics.cmake @@ -17,16 +17,11 @@ if( CMAKE_CXX_STANDARD IN_LIST "98; 11; 14" ) endif() -blt_append_custom_compiler_flag( FLAGS_VAR CMAKE_CXX_FLAGS DEFAULT "${OpenMP_CXX_FLAGS}") -blt_append_custom_compiler_flag( FLAGS_VAR CMAKE_CXX_FLAGS - GNU "-Wpedantic -pedantic-errors -Wshadow -Wfloat-equal -Wcast-align -Wcast-qual" - CLANG "-Wpedantic -pedantic-errors -Wshadow -Wfloat-equal -Wcast-align -Wcast-qual" - ) - -blt_append_custom_compiler_flag( FLAGS_VAR CMAKE_CXX_FLAGS_DEBUG - GNU "" - CLANG "-fstandalone-debug" - ) +set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS} -Wpedantic -pedantic-errors -Wshadow -Wfloat-equal -Wcast-align -Wcast-qual" ) + +if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") # For Clang or AppleClang + set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fstandalone-debug" ) +endif() diff --git a/docs/doxygen/ShivaConfig.hpp b/docs/doxygen/ShivaConfig.hpp index 8e64b01..ce75a91 100644 --- a/docs/doxygen/ShivaConfig.hpp +++ b/docs/doxygen/ShivaConfig.hpp @@ -14,7 +14,7 @@ /* #undef SHIVA_USE_CALIPER */ -#define SHIVA_USE_CAMP +/* #undef SHIVA_USE_CAMP */ #define SHIVA_USE_BOUNDS_CHECK diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b680057..5c1d6d6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -3,29 +3,34 @@ set( shiva_headers Shiva.hpp ) -set( shiva_sources - ) +set( shiva_dependencies ) -set( shiva_dependencies - geometry - ) + +if( SHIVA_ENABLE_CAMP ) + list( APPEND shiva_dependencies camp ) +endif() + +if( SHIVA_ENABLE_BLT AND ENABLE_HIP ) + list( APPEND shiva_dependencies blt::hip ) +endif() + +if( ENABLE_CUDA ) + list( APPEND shiva_dependencies cuda ) +endif() add_subdirectory( common ) add_subdirectory( functions ) add_subdirectory( discretizations ) add_subdirectory( geometry ) -blt_add_library( NAME shiva -# SOURCES ${shiva_sources} - HEADERS ${shiva_headers} - DEPENDS_ON ${shiva_dependencies} - ) + + + +add_library( shiva INTERFACE ${shiva_headers} ) target_include_directories( shiva INTERFACE - $ - $ - $ ) + ${shiva_headers} ) install( FILES ${shiva_headers} DESTINATION include ) @@ -37,8 +42,11 @@ install( TARGETS shiva LIBRARY DESTINATION lib RUNTIME DESTINATION lib ) -install( EXPORT shiva - DESTINATION lib/cmake/shiva ) +if( SHIVA_ENABLE_BLT ) + + install( EXPORT shiva + DESTINATION lib/cmake/shiva ) -shiva_add_code_checks( PREFIX shiva - EXCLUDES "blt/*" ) + shiva_add_code_checks( PREFIX shiva + EXCLUDES "blt/*" ) +endif() \ No newline at end of file diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index bc450a1..da560d9 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -1,57 +1,18 @@ -set( common_headers - CArray.hpp - CArrayHelper.hpp - IndexTypes.hpp - LinearIndex.hpp - MathUtilities.hpp - MultiIndex.hpp - pmpl.hpp - SequenceUtilities.hpp - NestedSequenceUtilities.hpp - ShivaErrorHandling.hpp - ShivaMacros.hpp - types.hpp - ) - -set( common_sources - ) - -if( ENABLE_HIP ) - list( APPEND common_dependencies blt::hip camp ) -endif() - -if( ENABLE_CUDA ) - list( APPEND common_dependencies cuda ) -endif() - -blt_add_library( NAME common -# SOURCES ${common_sources} - HEADERS ${common_headers} - DEPENDS_ON ${common_dependencies} - ) - - - -target_include_directories( common - INTERFACE - $ - $ - $ ) - -target_include_directories( common - SYSTEM INTERFACE - $ - $ ) - -install( FILES ${common_headers} - DESTINATION include/common ) - -install( TARGETS common - EXPORT shiva - ARCHIVE DESTINATION lib - LIBRARY DESTINATION lib - RUNTIME DESTINATION lib ) +set( shiva_headers + common/CArray.hpp + common/CArrayHelper.hpp + common/IndexTypes.hpp + common/LinearIndex.hpp + common/MathUtilities.hpp + common/MultiIndex.hpp + common/pmpl.hpp + common/SequenceUtilities.hpp + common/NestedSequenceUtilities.hpp + common/ShivaErrorHandling.hpp + common/ShivaMacros.hpp + common/types.hpp + PARENT_SCOPE ) if( SHIVA_ENABLE_UNIT_TESTS ) add_subdirectory( unitTests ) diff --git a/src/discretizations/CMakeLists.txt b/src/discretizations/CMakeLists.txt index 03e3c80..2a7102a 100644 --- a/src/discretizations/CMakeLists.txt +++ b/src/discretizations/CMakeLists.txt @@ -1,31 +1,12 @@ -set( discretizations_headers - finiteElementMethod/parentElements/ParentElement.hpp +set( shiva_headers + discretizations/finiteElementMethod/parentElements/ParentElement.hpp + PARENT_SCOPE ) -set( discretizations_sources +set( shiva_sources ) -set( discretizations_dependencies - common - functions - ) - -blt_add_library( NAME discretizations -# SOURCES ${discretizations_sources} - HEADERS ${discretizations_headers} - DEPENDS_ON ${discretizations_dependencies} - ) - -install( FILES ${discretizations_headers} - DESTINATION include/discretizations ) - -install( TARGETS discretizations - EXPORT shiva - ARCHIVE DESTINATION lib - LIBRARY DESTINATION lib - RUNTIME DESTINATION lib ) - if( SHIVA_ENABLE_UNIT_TESTS ) add_subdirectory( unitTests ) endif() \ No newline at end of file diff --git a/src/functions/CMakeLists.txt b/src/functions/CMakeLists.txt index 0c4c2ff..2c2f34f 100644 --- a/src/functions/CMakeLists.txt +++ b/src/functions/CMakeLists.txt @@ -1,37 +1,12 @@ -set( functions_headers - bases/BasisProduct.hpp - bases/LagrangeBasis.hpp - quadrature/Quadrature.hpp - spacing/Spacing.hpp +set( shiva_headers + functions/bases/BasisProduct.hpp + functions/bases/LagrangeBasis.hpp + functions/quadrature/Quadrature.hpp + functions/spacing/Spacing.hpp + PARENT_SCOPE ) -set( functions_sources - ) - -set( functions_dependencies - common - ) - -blt_add_library( NAME functions -# SOURCES ${functions_sources} - HEADERS ${functions_headers} - DEPENDS_ON ${functions_dependencies} - ) - -foreach( _header ${functions_headers} ) - get_filename_component( _header_dir ${_header} DIRECTORY ) - install( FILES ${_header} - DESTINATION include/functions/${_header_dir} ) -endforeach() - -install( TARGETS functions - EXPORT shiva - ARCHIVE DESTINATION lib - LIBRARY DESTINATION lib - RUNTIME DESTINATION lib ) - - if( SHIVA_ENABLE_UNIT_TESTS ) add_subdirectory( unitTests ) endif() \ No newline at end of file diff --git a/src/geometry/CMakeLists.txt b/src/geometry/CMakeLists.txt index 31a2380..e6bd809 100644 --- a/src/geometry/CMakeLists.txt +++ b/src/geometry/CMakeLists.txt @@ -1,44 +1,15 @@ -set( geometry_headers - mapping/JacobianTransforms.hpp - mapping/LinearTransform.hpp - mapping/Scaling.hpp - mapping/UniformScaling.hpp - shapes/InterpolatedShape.hpp - shapes/NCube.hpp - shapes/NSimplex.hpp +set( shiva_headers + geometry/mapping/JacobianTransforms.hpp + geometry/mapping/LinearTransform.hpp + geometry/mapping/Scaling.hpp + geometry/mapping/UniformScaling.hpp + geometry/shapes/InterpolatedShape.hpp + geometry/shapes/NCube.hpp + geometry/shapes/NSimplex.hpp + PARENT_SCOPE ) -set( geometry_sources - ) - -set( geometry_dependencies - common - ) - - -blt_add_library( NAME geometry -# SOURCES ${geometry_sources} - HEADERS ${geometry_headers} - DEPENDS_ON ${geometry_dependencies} - ) - -foreach( _header ${geometry_headers} ) - get_filename_component( _header_dir ${_header} DIRECTORY ) - install( FILES ${_header} - DESTINATION include/geometry/${_header_dir} ) -endforeach() - -# install( FILES ${geometry_headers} -# DESTINATION include/geometry ) - -install( TARGETS geometry - EXPORT shiva - ARCHIVE DESTINATION lib - LIBRARY DESTINATION lib - RUNTIME DESTINATION lib ) - - if( SHIVA_ENABLE_UNIT_TESTS ) add_subdirectory( mapping/unitTests ) add_subdirectory( shapes/unitTests ) From 259fdb1c8a87b0dcc4abffd7cfc1c25e2ff8ee42 Mon Sep 17 00:00:00 2001 From: Randolph Settgast Date: Sun, 14 Sep 2025 21:41:39 -0700 Subject: [PATCH 04/12] restructure tree to more of a header only organization --- CMakeLists.txt | 229 ++++++++++++------ cmake/Config.cmake | 120 +++++---- docs/doxygen/ShivaConfig.hpp | 12 +- hostconfigs/apple/macOS_base.cmake | 2 - {src => include}/.clang-format | 0 {src => include}/CMakeLists.txt | 0 {src => include}/Shiva.hpp | 0 {src => include}/ShivaConfig.hpp.in | 2 - {src => include}/common/CArray.hpp | 0 {src => include}/common/CArrayHelper.hpp | 0 {src => include}/common/CMakeLists.txt | 6 +- {src => include}/common/IndexTypes.hpp | 0 {src => include}/common/LinearIndex.hpp | 0 {src => include}/common/MathUtilities.hpp | 0 {src => include}/common/MultiIndex.hpp | 0 .../common/NestedSequenceUtilities.hpp | 0 {src => include}/common/SequenceUtilities.hpp | 0 .../common/ShivaErrorHandling.hpp | 0 {src => include}/common/ShivaMacros.hpp | 0 {src => include}/common/pmpl.hpp | 0 {src => include}/common/types.hpp | 0 .../discretizations/CMakeLists.txt | 9 +- .../parentElements/ParentElement.hpp | 0 {src => include}/functions/CMakeLists.txt | 6 +- .../functions/bases/BasisProduct.hpp | 0 .../functions/bases/LagrangeBasis.hpp | 0 .../functions/quadrature/Quadrature.hpp | 0 .../functions/spacing/Spacing.hpp | 0 {src => include}/geometry/CMakeLists.txt | 7 +- .../geometry/mapping/JacobianTransforms.hpp | 0 .../geometry/mapping/LinearTransform.hpp | 0 {src => include}/geometry/mapping/Scaling.hpp | 0 .../geometry/mapping/UniformScaling.hpp | 0 .../geometry/shapes/InterpolatedShape.hpp | 0 {src => include}/geometry/shapes/NCube.hpp | 0 {src => include}/geometry/shapes/NSimplex.hpp | 0 {src => include}/namespaceDocumentation.hpp | 0 {src => include}/uncrustify.cfg | 0 tests/CMakeLists.txt | 54 +++++ .../unitTests => tests/common}/CMakeLists.txt | 0 .../unitTests => tests/common}/testCArray.cpp | 0 .../common}/testIndexTypes.cpp | 0 .../common}/testNestedSequenceUtilities.cpp | 0 .../common}/testSequenceUtilities.cpp | 0 .../common}/testShivaErrorHandling.cpp | 0 .../finiteElementMethod}/CMakeLists.txt | 0 .../testParentElement.cpp | 0 .../functions}/CMakeLists.txt | 0 .../functions}/testLagrangeBasis.cpp | 0 .../functions}/testQuadrature.cpp | 0 .../functions}/testSpacing.cpp | 0 .../geometry/mapping}/CMakeLists.txt | 0 .../mapping}/LinearTransformSolutions.nb | 0 .../geometry/mapping}/testGeometryHelpers.hpp | 0 .../geometry/mapping}/testLinearTransform.cpp | 0 .../geometry/mapping}/testScaling.cpp | 0 .../geometry/mapping}/testUniformScaling.cpp | 0 .../geometry/shapes}/CMakeLists.txt | 0 .../shapes}/testInterpolatedShape.cpp | 0 .../testInterpolatedShapeSolutions.hpp | 0 .../geometry/shapes}/testNCube.cpp | 0 .../geometry/shapes}/testNSimplex.cpp | 0 62 files changed, 286 insertions(+), 161 deletions(-) rename {src => include}/.clang-format (100%) rename {src => include}/CMakeLists.txt (100%) rename {src => include}/Shiva.hpp (100%) rename {src => include}/ShivaConfig.hpp.in (92%) rename {src => include}/common/CArray.hpp (100%) rename {src => include}/common/CArrayHelper.hpp (100%) rename {src => include}/common/CMakeLists.txt (79%) rename {src => include}/common/IndexTypes.hpp (100%) rename {src => include}/common/LinearIndex.hpp (100%) rename {src => include}/common/MathUtilities.hpp (100%) rename {src => include}/common/MultiIndex.hpp (100%) rename {src => include}/common/NestedSequenceUtilities.hpp (100%) rename {src => include}/common/SequenceUtilities.hpp (100%) rename {src => include}/common/ShivaErrorHandling.hpp (100%) rename {src => include}/common/ShivaMacros.hpp (100%) rename {src => include}/common/pmpl.hpp (100%) rename {src => include}/common/types.hpp (100%) rename {src => include}/discretizations/CMakeLists.txt (51%) rename {src => include}/discretizations/finiteElementMethod/parentElements/ParentElement.hpp (100%) rename {src => include}/functions/CMakeLists.txt (70%) rename {src => include}/functions/bases/BasisProduct.hpp (100%) rename {src => include}/functions/bases/LagrangeBasis.hpp (100%) rename {src => include}/functions/quadrature/Quadrature.hpp (100%) rename {src => include}/functions/spacing/Spacing.hpp (100%) rename {src => include}/geometry/CMakeLists.txt (70%) rename {src => include}/geometry/mapping/JacobianTransforms.hpp (100%) rename {src => include}/geometry/mapping/LinearTransform.hpp (100%) rename {src => include}/geometry/mapping/Scaling.hpp (100%) rename {src => include}/geometry/mapping/UniformScaling.hpp (100%) rename {src => include}/geometry/shapes/InterpolatedShape.hpp (100%) rename {src => include}/geometry/shapes/NCube.hpp (100%) rename {src => include}/geometry/shapes/NSimplex.hpp (100%) rename {src => include}/namespaceDocumentation.hpp (100%) rename {src => include}/uncrustify.cfg (100%) create mode 100644 tests/CMakeLists.txt rename {src/common/unitTests => tests/common}/CMakeLists.txt (100%) rename {src/common/unitTests => tests/common}/testCArray.cpp (100%) rename {src/common/unitTests => tests/common}/testIndexTypes.cpp (100%) rename {src/common/unitTests => tests/common}/testNestedSequenceUtilities.cpp (100%) rename {src/common/unitTests => tests/common}/testSequenceUtilities.cpp (100%) rename {src/common/unitTests => tests/common}/testShivaErrorHandling.cpp (100%) rename {src/discretizations/unitTests => tests/discretizations/finiteElementMethod}/CMakeLists.txt (100%) rename {src/discretizations/unitTests => tests/discretizations/finiteElementMethod}/testParentElement.cpp (100%) rename {src/functions/unitTests => tests/functions}/CMakeLists.txt (100%) rename {src/functions/unitTests => tests/functions}/testLagrangeBasis.cpp (100%) rename {src/functions/unitTests => tests/functions}/testQuadrature.cpp (100%) rename {src/functions/unitTests => tests/functions}/testSpacing.cpp (100%) rename {src/geometry/mapping/unitTests => tests/geometry/mapping}/CMakeLists.txt (100%) rename {src/geometry/mapping/unitTests => tests/geometry/mapping}/LinearTransformSolutions.nb (100%) rename {src/geometry/mapping/unitTests => tests/geometry/mapping}/testGeometryHelpers.hpp (100%) rename {src/geometry/mapping/unitTests => tests/geometry/mapping}/testLinearTransform.cpp (100%) rename {src/geometry/mapping/unitTests => tests/geometry/mapping}/testScaling.cpp (100%) rename {src/geometry/mapping/unitTests => tests/geometry/mapping}/testUniformScaling.cpp (100%) rename {src/geometry/shapes/unitTests => tests/geometry/shapes}/CMakeLists.txt (100%) rename {src/geometry/shapes/unitTests => tests/geometry/shapes}/testInterpolatedShape.cpp (100%) rename {src/geometry/shapes/unitTests => tests/geometry/shapes}/testInterpolatedShapeSolutions.hpp (100%) rename {src/geometry/shapes/unitTests => tests/geometry/shapes}/testNCube.cpp (100%) rename {src/geometry/shapes/unitTests => tests/geometry/shapes}/testNSimplex.cpp (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index ac1a9d3..d43b3f4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,103 +1,178 @@ -################################################################################################### -# Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. -# All rights reserved. -# See the LICENSE file for details. -# SPDX-License-Identifier: (BSD-3-Clause) -################################################################################################### - -cmake_minimum_required( VERSION 3.23.1 ) - -# Set version number -set( SHIVA_VERSION_MAJOR 0 ) -set( SHIVA_VERSION_MINOR 1 ) -set( SHIVA_VERSION_PATCHLEVEL 0 ) - -# check if Shiva is build as a submodule or a separate project -get_directory_property( parent_dir PARENT_DIRECTORY ) -if(parent_dir) - set( SHIVA_IS_SUBMODULE ON ) +cmake_minimum_required(VERSION 3.23.1) + +# Standalone project metadata +project(Shiva VERSION 0.1.0 ) + +# Are we the top-level project? +# (Reliable with CMake >= 3.21) +if (DEFINED PROJECT_IS_TOP_LEVEL) + set(SHIVA_IS_TOPLEVEL "${PROJECT_IS_TOP_LEVEL}") else() - set( SHIVA_IS_SUBMODULE OFF ) + # Fallback (shouldn’t be needed given min version) + if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) + set(SHIVA_IS_TOPLEVEL TRUE) + else() + set(SHIVA_IS_TOPLEVEL FALSE) + endif() endif() -message( "SHIVA_IS_SUBMODULE: ${SHIVA_IS_SUBMODULE}" ) +# Options +option( SHIVA_ENABLE_BLT "Enable BLT usage (standalone default ON)" ON ) +option( SHIVA_ENABLE_CAMP "Enable CAMP usage (requires BLT in this repo layout)" ON ) +option( CAMP_ENABLE_TESTS "Enable CAMP tests (if CAMP is added here)" OFF ) +# Shiva’s public config toggles (exported in INTERFACE) +option(SHIVA_ENABLE_UNIT_TESTS "Builds tests (standalone only)" ON) +option(SHIVA_ENABLE_EXAMPLES "Builds examples (standalone only)" ON) +option(SHIVA_ENABLE_BENCHMARKS "Builds benchmarks (standalone only)" ON) +option(SHIVA_ENABLE_DOCS "Builds documentation (standalone only)" ON) -option( SHIVA_ENABLE_CAMP "Enable CAMP usage" ON ) -option( CAMP_ENABLE_TESTS OFF ) -option( SHIVA_ENABLE_BLT "Enable BLT usage" ON ) +# Device toggles are *interface* concerns for consumers; we do not enable languages here. +option(SHIVA_USE_CUDA "Consumer intends to use CUDA with Shiva headers" OFF) +option(SHIVA_USE_HIP "Consumer intends to use HIP with Shiva headers" OFF) -if( NOT SHIVA_IS_SUBMODULE ) - message( "Shiva is not a submodule") - project( Shiva LANGUAGES CXX C ) - if( NOT SHIVA_ENABLE_BLT ) - message( FATAL_ERROR "When building Shiva as a standalone project you must enable BLT support. Please set SHIVA_ENABLE_BLT to ON." ) - endif() - set( BLT_CXX_STD "c++17" CACHE STRING "Version of C++ standard" FORCE ) - set( ENABLE_WARNINGS_AS_ERRORS "ON" CACHE PATH "" ) - - option( SHIVA_ENABLE_UNIT_TESTS "Builds tests" ON ) - option( SHIVA_ENABLE_EXAMPLES "Builds examples" ON ) - option( SHIVA_ENABLE_BENCHMARKS "Builds benchmarks" ON ) - option( SHIVA_ENABLE_DOCS "Builds documentation" ON ) - - option( ENABLE_CUDA "Build with CUDA" OFF ) - option( ENABLE_HIP "Build with HIP" OFF ) - - if( NOT BLT_LOADED ) - if( DEFINED BLT_SOURCE_DIR ) - if( NOT EXISTS ${BLT_SOURCE_DIR}/SetupBLT.cmake ) - message( FATAL_ERROR "Given BLT_SOURCE_DIR does not contain SetupBLT.cmake" ) - endif() - else () - set( BLT_SOURCE_DIR ${PROJECT_SOURCE_DIR}/cmake/blt CACHE PATH "" ) - - if( NOT EXISTS ${BLT_SOURCE_DIR}/SetupBLT.cmake ) - message( FATAL_ERROR "The BLT submodule is not present. If in git repository run the following two commands:\n \ - git submodule init\n \ - git submodule update" ) - endif () - endif () - - include( ${BLT_SOURCE_DIR}/SetupBLT.cmake ) - endif() + +# BLT (standalone mode only, and only if requested) +if (SHIVA_IS_TOPLEVEL) + message(STATUS "Building Shiva as a standalone project") + + enable_language(CXX) + if( SHIVA_USE_CUDA ) + enable_language(CUDA) + endif() + + set( SHIVA_ENABLE_BLT ON CACHE BOOL "Force ON in standalone mode" ) + set( SHIVA_ENABLE_CAMP ON CACHE BOOL "Force ON in standalone mode" ) + + # Where to find BLT if vendored + set(BLT_SOURCE_DIR "${PROJECT_SOURCE_DIR}/cmake/blt" CACHE PATH "Path to BLT") + if (NOT EXISTS "${BLT_SOURCE_DIR}/SetupBLT.cmake") + message(FATAL_ERROR + "BLT not found at '${BLT_SOURCE_DIR}'. If this repository vendors BLT as a submodule, run:\n" + " git submodule update --init --recursive\n" + "Or set -DBLT_SOURCE_DIR=/path/to/blt") + endif() + + # Standardized C++ level for BLT toolchains + set(BLT_CXX_STD "c++17" CACHE STRING "Version of C++ standard" FORCE) + include("${BLT_SOURCE_DIR}/SetupBLT.cmake") + message(STATUS "BLT loaded") else() - message( "SHIVA is a submodule") - if( SHIVA_ENABLE_BLT OR SHIVA_ENABLE_CAMP ) - if( NOT BLT_LOADED ) - message( FATAL_ERROR "When using Shiva as a submodule and are using BLT, you must have already loaded BLT. CAMP requires BLT" ) + message(STATUS "Using Shiva as a subproject/submodule") + if (SHIVA_ENABLE_CAMP OR SHIVA_ENABLE_BLT) + if (NOT BLT_LOADED) + message(FATAL_ERROR + "Parent requested BLT/CAMP features, but BLT is not loaded. " + "Please load BLT in the top-level project before adding Shiva.") endif() - else() - endif() endif() -include( cmake/CMakeBasics.cmake ) -include( cmake/Macros.cmake ) -include( cmake/Config.cmake ) +# Basic include paths (source + generated) +set(SHIVA_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") +set(SHIVA_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}") + +# Generate Shiva’s config header (your script) +include("${CMAKE_CURRENT_LIST_DIR}/cmake/Config.cmake") +# Create the header-only target unconditionally. +add_library(Shiva INTERFACE) +add_library(Shiva::shiva ALIAS Shiva) -set(SHIVA_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} ) -set(SHIVA_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR} ) +# Public include dirs (source + current binary for generated headers) +target_include_directories( Shiva + INTERFACE + "$" + "$" + "$" +) +# Public compile features and interface defines (but no language enable here) +target_compile_features(Shiva INTERFACE cxx_std_17) -if( SHIVA_ENABLE_CAMP ) - if( NOT SHIVA_ENABLE_BLT ) - message( FATAL_ERROR "CAMP support requires BLT. Please enable SHIVA_ENABLE_BLT." ) +# Device feature flags are exported as interface macros for consumers to react to in headers +if (SHIVA_USE_CUDA) + target_compile_definitions(Shiva INTERFACE SHIVA_USE_CUDA=1) +endif() +if (SHIVA_USE_HIP) + target_compile_definitions(Shiva INTERFACE SHIVA_USE_HIP=1) +endif() + +# CAMP (only wire it up here if explicitly requested) +if (SHIVA_ENABLE_CAMP) + # Option A (vendored via BLT/this repo): add_subdirectory + # Option B (preferred long-term): find_package(camp CONFIG REQUIRED) and link camp::camp + # Keeping your current approach but safer paths: + add_subdirectory(tpl/camp) + # Generated header into *current* binary dir to avoid collisions when subproject + configure_file( + tpl/camp/include/camp/config.in.hpp + "${SHIVA_BINARY_DIR}/include/camp/config.hpp" + @ONLY + ) + # The 'camp' target comes from the subdir. Be gentle with warnings: + if (TARGET camp) + # Example: silence -Wshadow on GCC/Clang only + target_compile_options(camp PRIVATE + $<$,$>:-Wno-shadow> + ) + # Export dependency to consumers + target_link_libraries(Shiva INTERFACE camp) endif() - add_subdirectory( tpl/camp ) - target_compile_options( camp PRIVATE "-Wno-shadow") - configure_file(tpl/camp/include/camp/config.in.hpp ${PROJECT_BINARY_DIR}/include/camp/config.hpp) endif() -add_subdirectory( src ) +# Put the rest of your target wiring (headers-only structure, subdirs) under src/ +# Keep 'src' responsible for populating the header tree and optional tests/examples/etc. +add_subdirectory(include) + +# Standalone-only extras +if (SHIVA_IS_TOPLEVEL) + if (SHIVA_ENABLE_DOCS) + add_subdirectory(docs) + endif() -if( SHIVA_ENABLE_DOCS ) - add_subdirectory( docs ) + # Minimal install/export so consumers can find_package(Shiva) + include(GNUInstallDirs) + install(TARGETS Shiva + EXPORT ShivaTargets + ) + install(DIRECTORY "${SHIVA_SOURCE_DIR}/src/" + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" + FILES_MATCHING PATTERN "*.hpp" PATTERN "*.h" + ) + # Also install generated headers if any + install(DIRECTORY "${SHIVA_BINARY_DIR}/include/" + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" + OPTIONAL + ) + + include(CMakePackageConfigHelpers) + write_basic_package_version_file( + "${CMAKE_CURRENT_BINARY_DIR}/ShivaConfigVersion.cmake" + VERSION "${PROJECT_VERSION}" + COMPATIBILITY SameMajorVersion + ) + configure_package_config_file( + "${CMAKE_CURRENT_LIST_DIR}/cmake/ShivaConfig.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/ShivaConfig.cmake" + INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/Shiva" + ) + install(FILES + "${CMAKE_CURRENT_BINARY_DIR}/ShivaConfig.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/ShivaConfigVersion.cmake" + DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/Shiva" + ) + install(EXPORT ShivaTargets + NAMESPACE Shiva:: + DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/Shiva" + ) endif() +if( SHIVA_ENABLE_UNIT_TESTS ) + add_subdirectory(tests) +endif() diff --git a/cmake/Config.cmake b/cmake/Config.cmake index 849955d..3c57dd7 100644 --- a/cmake/Config.cmake +++ b/cmake/Config.cmake @@ -1,65 +1,85 @@ -# -set( PREPROCESSOR_DEFINES CUDA - HIP - CAMP - BOUNDS_CHECK - ) +# cmake/Config.cmake +include_guard(DIRECTORY) -set( USE_CONFIGFILE ON CACHE BOOL "" ) -foreach( DEP in ${PREPROCESSOR_DEFINES}) - if( ${DEP}_FOUND OR ENABLE_${DEP} OR SHIVA_ENABLE_${DEP} ) - set( SHIVA_USE_${DEP} TRUE ) - endif() -endforeach() +# Expect these to be set by the parent CMakeLists: +# - SHIVA_SOURCE_DIR +# - SHIVA_BINARY_DIR -if( ENABLE_ADDR2LINE ) - if ( NOT DEFINED ADDR2LINE_EXEC ) - set( ADDR2LINE_EXEC /usr/bin/addr2line CACHE PATH "" ) - endif() +# ---------- Feature switches (normalize to SHIVA_USE_* booleans) ---------- +# Start from user options if you expose them; fall back to CMake signals. - if ( NOT EXISTS ${ADDR2LINE_EXEC} ) - message( FATAL_ERROR "The addr2line executable does not exist: ${ADDR2LINE_EXEC}" ) - endif() - - set( SHIVA_ADDR2LINE_EXEC ${ADDR2LINE_EXEC} ) +# CUDA +if (DEFINED SHIVA_USE_CUDA) + # keep as-is +elseif (CMAKE_CUDA_COMPILER) + set(SHIVA_USE_CUDA TRUE) +else() + set(SHIVA_USE_CUDA FALSE) endif() +# HIP +if (DEFINED SHIVA_USE_HIP) + # keep as-is +elseif (DEFINED HIP_FOUND OR CMAKE_HIP_COMPILER) + set(SHIVA_USE_HIP TRUE) +else() + set(SHIVA_USE_HIP FALSE) +endif() -configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/src/ShivaConfig.hpp.in - ${CMAKE_BINARY_DIR}/include/ShivaConfig.hpp ) +# CAMP +if (DEFINED SHIVA_USE_CAMP) + # keep as-is +elseif (DEFINED SHIVA_ENABLE_CAMP) + set(SHIVA_USE_CAMP "${SHIVA_ENABLE_CAMP}") +else() + set(SHIVA_USE_CAMP FALSE) +endif() -configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/src/ShivaConfig.hpp.in - ${CMAKE_CURRENT_SOURCE_DIR}/docs/doxygen/ShivaConfig.hpp ) +# BOUNDS_CHECK (provide an option upstream if you want this user-tunable) +if (NOT DEFINED SHIVA_USE_BOUNDS_CHECK) + set(SHIVA_USE_BOUNDS_CHECK FALSE) +endif() -# Install the generated header. -install( FILES ${CMAKE_BINARY_DIR}/include/ShivaConfig.hpp - DESTINATION include ) +# ---------- CUDA version numbers (if available) ---------- +set(SHIVA_CUDA_MAJOR 0) +set(SHIVA_CUDA_MINOR 0) +if (SHIVA_USE_CUDA AND DEFINED CMAKE_CUDA_COMPILER_VERSION) + # CMAKE_CUDA_COMPILER_VERSION like "12.4" + string(REPLACE "." ";" _cuda_ver_list "${CMAKE_CUDA_COMPILER_VERSION}") + list(GET _cuda_ver_list 0 SHIVA_CUDA_MAJOR) + list(LENGTH _cuda_ver_list _cuda_len) + if (_cuda_len GREATER 1) + list(GET _cuda_ver_list 1 SHIVA_CUDA_MINOR) + endif() +endif() -# Configure and install the CMake config +# ---------- Version numbers expected by the header ---------- +# Your header expects *_PATCHLEVEL; map from project() version. +set(SHIVA_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}") +set(SHIVA_VERSION_MINOR "${PROJECT_VERSION_MINOR}") +set(SHIVA_VERSION_PATCHLEVEL "${PROJECT_VERSION_PATCH}") -# Set up cmake package config file +# ---------- Emit the generated header(s) ---------- +set(_shiva_gen_inc "${SHIVA_BINARY_DIR}/include") +message( "SHIVA_BINARY_DIR = ${SHIVA_BINARY_DIR}" ) +file(MAKE_DIRECTORY "${_shiva_gen_inc}") -set(SHIVA_INSTALL_INCLUDE_DIR "include" CACHE STRING "") -set(SHIVA_INSTALL_CONFIG_DIR "lib" CACHE STRING "") -set(SHIVA_INSTALL_LIB_DIR "lib" CACHE STRING "") -set(SHIVA_INSTALL_BIN_DIR "bin" CACHE STRING "") -set(SHIVA_INSTALL_CMAKE_MODULE_DIR "${SHIVA_INSTALL_CONFIG_DIR}/cmake" CACHE STRING "") -set(SHIVA_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX} CACHE STRING "" FORCE) +configure_file( + "${SHIVA_SOURCE_DIR}/include/ShivaConfig.hpp.in" + "${_shiva_gen_inc}/ShivaConfig.hpp" +) +# Optional: a copy for Doxygen without touching the source tree +set(_shiva_gen_doc "${SHIVA_BINARY_DIR}/docs/doxygen") +file(MAKE_DIRECTORY "${_shiva_gen_doc}") +configure_file( + "${SHIVA_SOURCE_DIR}/include/ShivaConfig.hpp.in" + "${_shiva_gen_doc}/ShivaConfig.hpp" +) -include(CMakePackageConfigHelpers) -configure_package_config_file( - ${CMAKE_CURRENT_SOURCE_DIR}/cmake/shiva-config.cmake.in - ${CMAKE_CURRENT_BINARY_DIR}/shiva-config.cmake - INSTALL_DESTINATION - ${SHIVA_INSTALL_CONFIG_DIR} - PATH_VARS - SHIVA_INSTALL_INCLUDE_DIR - SHIVA_INSTALL_LIB_DIR - SHIVA_INSTALL_BIN_DIR - SHIVA_INSTALL_CMAKE_MODULE_DIR - ) +# Install the generated header (binary include tree) +install(FILES "${_shiva_gen_inc}/ShivaConfig.hpp" + DESTINATION include) -install( FILES ${CMAKE_CURRENT_BINARY_DIR}/shiva-config.cmake - DESTINATION share/shiva/cmake/) +message(STATUS "Shiva config header -> ${SHIVA_BINARY_DIR}/include/ShivaConfig.hpp") diff --git a/docs/doxygen/ShivaConfig.hpp b/docs/doxygen/ShivaConfig.hpp index ce75a91..222aa09 100644 --- a/docs/doxygen/ShivaConfig.hpp +++ b/docs/doxygen/ShivaConfig.hpp @@ -2,11 +2,11 @@ #pragma once -#define SHIVA_VERSION_MAJOR 0 +#define SHIVA_VERSION_MAJOR -#define SHIVA_VERSION_MINOR 1 +#define SHIVA_VERSION_MINOR -#define SHIVA_VERSION_PATCHLEVEL 0 +#define SHIVA_VERSION_PATCHLEVEL /* #undef SHIVA_USE_CUDA */ @@ -16,7 +16,7 @@ /* #undef SHIVA_USE_CAMP */ -#define SHIVA_USE_BOUNDS_CHECK +/* #undef SHIVA_USE_BOUNDS_CHECK */ -#define SHIVA_CUDA_MAJOR 0 -#define SHIVA_CUDA_MINOR 0 +#define SHIVA_CUDA_MAJOR +#define SHIVA_CUDA_MINOR diff --git a/hostconfigs/apple/macOS_base.cmake b/hostconfigs/apple/macOS_base.cmake index 50b7ab6..4206551 100644 --- a/hostconfigs/apple/macOS_base.cmake +++ b/hostconfigs/apple/macOS_base.cmake @@ -18,8 +18,6 @@ set(ENABLE_GTEST_DEATH_TESTS ON CACHE BOOL "" FORCE) set(ENABLE_CUDA "OFF" CACHE PATH "" FORCE) set(ENABLE_OPENMP "OFF" CACHE PATH "" FORCE) -set(ENABLE_CALIPER "OFF" CACHE PATH "" FORCE ) - set(ENABLE_DOXYGEN ON CACHE BOOL "" FORCE) set( DOXYGEN_EXECUTABLE "${HOMEBREW_DIR}/bin/doxygen" CACHE PATH "" FORCE) diff --git a/src/.clang-format b/include/.clang-format similarity index 100% rename from src/.clang-format rename to include/.clang-format diff --git a/src/CMakeLists.txt b/include/CMakeLists.txt similarity index 100% rename from src/CMakeLists.txt rename to include/CMakeLists.txt diff --git a/src/Shiva.hpp b/include/Shiva.hpp similarity index 100% rename from src/Shiva.hpp rename to include/Shiva.hpp diff --git a/src/ShivaConfig.hpp.in b/include/ShivaConfig.hpp.in similarity index 92% rename from src/ShivaConfig.hpp.in rename to include/ShivaConfig.hpp.in index 7103b82..2b9a173 100644 --- a/src/ShivaConfig.hpp.in +++ b/include/ShivaConfig.hpp.in @@ -12,8 +12,6 @@ #cmakedefine SHIVA_USE_HIP -#cmakedefine SHIVA_USE_CALIPER - #cmakedefine SHIVA_USE_CAMP #cmakedefine SHIVA_USE_BOUNDS_CHECK diff --git a/src/common/CArray.hpp b/include/common/CArray.hpp similarity index 100% rename from src/common/CArray.hpp rename to include/common/CArray.hpp diff --git a/src/common/CArrayHelper.hpp b/include/common/CArrayHelper.hpp similarity index 100% rename from src/common/CArrayHelper.hpp rename to include/common/CArrayHelper.hpp diff --git a/src/common/CMakeLists.txt b/include/common/CMakeLists.txt similarity index 79% rename from src/common/CMakeLists.txt rename to include/common/CMakeLists.txt index da560d9..a62a173 100644 --- a/src/common/CMakeLists.txt +++ b/include/common/CMakeLists.txt @@ -12,8 +12,4 @@ set( shiva_headers common/ShivaErrorHandling.hpp common/ShivaMacros.hpp common/types.hpp - PARENT_SCOPE ) - -if( SHIVA_ENABLE_UNIT_TESTS ) - add_subdirectory( unitTests ) -endif() \ No newline at end of file + PARENT_SCOPE ) \ No newline at end of file diff --git a/src/common/IndexTypes.hpp b/include/common/IndexTypes.hpp similarity index 100% rename from src/common/IndexTypes.hpp rename to include/common/IndexTypes.hpp diff --git a/src/common/LinearIndex.hpp b/include/common/LinearIndex.hpp similarity index 100% rename from src/common/LinearIndex.hpp rename to include/common/LinearIndex.hpp diff --git a/src/common/MathUtilities.hpp b/include/common/MathUtilities.hpp similarity index 100% rename from src/common/MathUtilities.hpp rename to include/common/MathUtilities.hpp diff --git a/src/common/MultiIndex.hpp b/include/common/MultiIndex.hpp similarity index 100% rename from src/common/MultiIndex.hpp rename to include/common/MultiIndex.hpp diff --git a/src/common/NestedSequenceUtilities.hpp b/include/common/NestedSequenceUtilities.hpp similarity index 100% rename from src/common/NestedSequenceUtilities.hpp rename to include/common/NestedSequenceUtilities.hpp diff --git a/src/common/SequenceUtilities.hpp b/include/common/SequenceUtilities.hpp similarity index 100% rename from src/common/SequenceUtilities.hpp rename to include/common/SequenceUtilities.hpp diff --git a/src/common/ShivaErrorHandling.hpp b/include/common/ShivaErrorHandling.hpp similarity index 100% rename from src/common/ShivaErrorHandling.hpp rename to include/common/ShivaErrorHandling.hpp diff --git a/src/common/ShivaMacros.hpp b/include/common/ShivaMacros.hpp similarity index 100% rename from src/common/ShivaMacros.hpp rename to include/common/ShivaMacros.hpp diff --git a/src/common/pmpl.hpp b/include/common/pmpl.hpp similarity index 100% rename from src/common/pmpl.hpp rename to include/common/pmpl.hpp diff --git a/src/common/types.hpp b/include/common/types.hpp similarity index 100% rename from src/common/types.hpp rename to include/common/types.hpp diff --git a/src/discretizations/CMakeLists.txt b/include/discretizations/CMakeLists.txt similarity index 51% rename from src/discretizations/CMakeLists.txt rename to include/discretizations/CMakeLists.txt index 2a7102a..6834d98 100644 --- a/src/discretizations/CMakeLists.txt +++ b/include/discretizations/CMakeLists.txt @@ -2,11 +2,4 @@ set( shiva_headers discretizations/finiteElementMethod/parentElements/ParentElement.hpp PARENT_SCOPE - ) - -set( shiva_sources - ) - -if( SHIVA_ENABLE_UNIT_TESTS ) - add_subdirectory( unitTests ) -endif() \ No newline at end of file + ) \ No newline at end of file diff --git a/src/discretizations/finiteElementMethod/parentElements/ParentElement.hpp b/include/discretizations/finiteElementMethod/parentElements/ParentElement.hpp similarity index 100% rename from src/discretizations/finiteElementMethod/parentElements/ParentElement.hpp rename to include/discretizations/finiteElementMethod/parentElements/ParentElement.hpp diff --git a/src/functions/CMakeLists.txt b/include/functions/CMakeLists.txt similarity index 70% rename from src/functions/CMakeLists.txt rename to include/functions/CMakeLists.txt index 2c2f34f..8b41948 100644 --- a/src/functions/CMakeLists.txt +++ b/include/functions/CMakeLists.txt @@ -5,8 +5,4 @@ set( shiva_headers functions/quadrature/Quadrature.hpp functions/spacing/Spacing.hpp PARENT_SCOPE - ) - -if( SHIVA_ENABLE_UNIT_TESTS ) - add_subdirectory( unitTests ) -endif() \ No newline at end of file + ) \ No newline at end of file diff --git a/src/functions/bases/BasisProduct.hpp b/include/functions/bases/BasisProduct.hpp similarity index 100% rename from src/functions/bases/BasisProduct.hpp rename to include/functions/bases/BasisProduct.hpp diff --git a/src/functions/bases/LagrangeBasis.hpp b/include/functions/bases/LagrangeBasis.hpp similarity index 100% rename from src/functions/bases/LagrangeBasis.hpp rename to include/functions/bases/LagrangeBasis.hpp diff --git a/src/functions/quadrature/Quadrature.hpp b/include/functions/quadrature/Quadrature.hpp similarity index 100% rename from src/functions/quadrature/Quadrature.hpp rename to include/functions/quadrature/Quadrature.hpp diff --git a/src/functions/spacing/Spacing.hpp b/include/functions/spacing/Spacing.hpp similarity index 100% rename from src/functions/spacing/Spacing.hpp rename to include/functions/spacing/Spacing.hpp diff --git a/src/geometry/CMakeLists.txt b/include/geometry/CMakeLists.txt similarity index 70% rename from src/geometry/CMakeLists.txt rename to include/geometry/CMakeLists.txt index e6bd809..6a04592 100644 --- a/src/geometry/CMakeLists.txt +++ b/include/geometry/CMakeLists.txt @@ -8,9 +8,4 @@ set( shiva_headers geometry/shapes/NCube.hpp geometry/shapes/NSimplex.hpp PARENT_SCOPE - ) - -if( SHIVA_ENABLE_UNIT_TESTS ) - add_subdirectory( mapping/unitTests ) - add_subdirectory( shapes/unitTests ) -endif() \ No newline at end of file + ) \ No newline at end of file diff --git a/src/geometry/mapping/JacobianTransforms.hpp b/include/geometry/mapping/JacobianTransforms.hpp similarity index 100% rename from src/geometry/mapping/JacobianTransforms.hpp rename to include/geometry/mapping/JacobianTransforms.hpp diff --git a/src/geometry/mapping/LinearTransform.hpp b/include/geometry/mapping/LinearTransform.hpp similarity index 100% rename from src/geometry/mapping/LinearTransform.hpp rename to include/geometry/mapping/LinearTransform.hpp diff --git a/src/geometry/mapping/Scaling.hpp b/include/geometry/mapping/Scaling.hpp similarity index 100% rename from src/geometry/mapping/Scaling.hpp rename to include/geometry/mapping/Scaling.hpp diff --git a/src/geometry/mapping/UniformScaling.hpp b/include/geometry/mapping/UniformScaling.hpp similarity index 100% rename from src/geometry/mapping/UniformScaling.hpp rename to include/geometry/mapping/UniformScaling.hpp diff --git a/src/geometry/shapes/InterpolatedShape.hpp b/include/geometry/shapes/InterpolatedShape.hpp similarity index 100% rename from src/geometry/shapes/InterpolatedShape.hpp rename to include/geometry/shapes/InterpolatedShape.hpp diff --git a/src/geometry/shapes/NCube.hpp b/include/geometry/shapes/NCube.hpp similarity index 100% rename from src/geometry/shapes/NCube.hpp rename to include/geometry/shapes/NCube.hpp diff --git a/src/geometry/shapes/NSimplex.hpp b/include/geometry/shapes/NSimplex.hpp similarity index 100% rename from src/geometry/shapes/NSimplex.hpp rename to include/geometry/shapes/NSimplex.hpp diff --git a/src/namespaceDocumentation.hpp b/include/namespaceDocumentation.hpp similarity index 100% rename from src/namespaceDocumentation.hpp rename to include/namespaceDocumentation.hpp diff --git a/src/uncrustify.cfg b/include/uncrustify.cfg similarity index 100% rename from src/uncrustify.cfg rename to include/uncrustify.cfg diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 0000000..e4922b0 --- /dev/null +++ b/tests/CMakeLists.txt @@ -0,0 +1,54 @@ +cmake_minimum_required(VERSION 3.23.1) +include(CTest) + +# One function for both CPU & CUDA cases. +function(shiva_add_gtest name) + set(options) + set(oneValueArgs) + set(multiValueArgs SOURCES CUDA_SOURCES LIBS) + cmake_parse_arguments(SAG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + add_executable(${name} ${SAG_SOURCES}) + + # If CUDA toolchain is active, tack on CUDA sources & props. + if (CMAKE_CUDA_COMPILER AND SAG_CUDA_SOURCES) + target_sources(${name} PRIVATE ${SAG_CUDA_SOURCES}) + set_target_properties(${name} PROPERTIES CUDA_SEPARABLE_COMPILATION ON) + # Your headers probably branch on this; usually comes via Shiva INTERFACE anyway. + target_compile_definitions(${name} PRIVATE SHIVA_USE_CUDA=1) + endif() + + target_link_libraries(${name} PRIVATE + Shiva # pulls include/shiva + build/include/shiva + GTest::gtest_main + ${SAG_LIBS} + ) + target_compile_features(${name} PRIVATE cxx_std_17) + + add_test(NAME ${name} COMMAND ${name}) +endfunction() + + +# --- Common tests --- +shiva_add_gtest(shiva_test_carray common/testCArray.cpp) +shiva_add_gtest(shiva_test_index_types common/testIndexTypes.cpp) +shiva_add_gtest(shiva_test_nested_seq_utils common/testNestedSequenceUtilities.cpp) +shiva_add_gtest(shiva_test_seq_utils common/testSequenceUtilities.cpp) +shiva_add_gtest(shiva_test_err_handling common/testShivaErrorHandling.cpp) + +shiva_add_gtest(shiva_test_parent_element discretizations/testParentElement.cpp) + +shiva_add_gtest(shiva_test_lagrange_basis functions/testLagrangeBasis.cpp) +shiva_add_gtest(shiva_test_quadrature functions/testQuadrature.cpp) +shiva_add_gtest(shiva_test_spacing functions/testSpacing.cpp) + +shiva_add_gtest(shiva_test_linear_transform geometry/mapping/testLinearTransform.cpp) +shiva_add_gtest(shiva_test_scaling geometry/mapping/testScaling.cpp) +shiva_add_gtest(shiva_test_uniform_scaling geometry/mapping/testUniformScaling.cpp) +shiva_add_gtest(shiva_test_interpolated geometry/shapes/testInterpolatedShape.cpp) +shiva_add_gtest(shiva_test_ncube geometry/shapes/testNCube.cpp) +shiva_add_gtest(shiva_test_nsimplex geometry/shapes/testNSimplex.cpp) + +# --- CUDA variants (only built when CUDA is enabled by parent or standalone) --- +# Example: add CUDA-only tests or CUDA-flavored versions: +# shiva_add_cuda_test(shiva_test_carray_cuda common/testCArrayCuda.cu) diff --git a/src/common/unitTests/CMakeLists.txt b/tests/common/CMakeLists.txt similarity index 100% rename from src/common/unitTests/CMakeLists.txt rename to tests/common/CMakeLists.txt diff --git a/src/common/unitTests/testCArray.cpp b/tests/common/testCArray.cpp similarity index 100% rename from src/common/unitTests/testCArray.cpp rename to tests/common/testCArray.cpp diff --git a/src/common/unitTests/testIndexTypes.cpp b/tests/common/testIndexTypes.cpp similarity index 100% rename from src/common/unitTests/testIndexTypes.cpp rename to tests/common/testIndexTypes.cpp diff --git a/src/common/unitTests/testNestedSequenceUtilities.cpp b/tests/common/testNestedSequenceUtilities.cpp similarity index 100% rename from src/common/unitTests/testNestedSequenceUtilities.cpp rename to tests/common/testNestedSequenceUtilities.cpp diff --git a/src/common/unitTests/testSequenceUtilities.cpp b/tests/common/testSequenceUtilities.cpp similarity index 100% rename from src/common/unitTests/testSequenceUtilities.cpp rename to tests/common/testSequenceUtilities.cpp diff --git a/src/common/unitTests/testShivaErrorHandling.cpp b/tests/common/testShivaErrorHandling.cpp similarity index 100% rename from src/common/unitTests/testShivaErrorHandling.cpp rename to tests/common/testShivaErrorHandling.cpp diff --git a/src/discretizations/unitTests/CMakeLists.txt b/tests/discretizations/finiteElementMethod/CMakeLists.txt similarity index 100% rename from src/discretizations/unitTests/CMakeLists.txt rename to tests/discretizations/finiteElementMethod/CMakeLists.txt diff --git a/src/discretizations/unitTests/testParentElement.cpp b/tests/discretizations/finiteElementMethod/testParentElement.cpp similarity index 100% rename from src/discretizations/unitTests/testParentElement.cpp rename to tests/discretizations/finiteElementMethod/testParentElement.cpp diff --git a/src/functions/unitTests/CMakeLists.txt b/tests/functions/CMakeLists.txt similarity index 100% rename from src/functions/unitTests/CMakeLists.txt rename to tests/functions/CMakeLists.txt diff --git a/src/functions/unitTests/testLagrangeBasis.cpp b/tests/functions/testLagrangeBasis.cpp similarity index 100% rename from src/functions/unitTests/testLagrangeBasis.cpp rename to tests/functions/testLagrangeBasis.cpp diff --git a/src/functions/unitTests/testQuadrature.cpp b/tests/functions/testQuadrature.cpp similarity index 100% rename from src/functions/unitTests/testQuadrature.cpp rename to tests/functions/testQuadrature.cpp diff --git a/src/functions/unitTests/testSpacing.cpp b/tests/functions/testSpacing.cpp similarity index 100% rename from src/functions/unitTests/testSpacing.cpp rename to tests/functions/testSpacing.cpp diff --git a/src/geometry/mapping/unitTests/CMakeLists.txt b/tests/geometry/mapping/CMakeLists.txt similarity index 100% rename from src/geometry/mapping/unitTests/CMakeLists.txt rename to tests/geometry/mapping/CMakeLists.txt diff --git a/src/geometry/mapping/unitTests/LinearTransformSolutions.nb b/tests/geometry/mapping/LinearTransformSolutions.nb similarity index 100% rename from src/geometry/mapping/unitTests/LinearTransformSolutions.nb rename to tests/geometry/mapping/LinearTransformSolutions.nb diff --git a/src/geometry/mapping/unitTests/testGeometryHelpers.hpp b/tests/geometry/mapping/testGeometryHelpers.hpp similarity index 100% rename from src/geometry/mapping/unitTests/testGeometryHelpers.hpp rename to tests/geometry/mapping/testGeometryHelpers.hpp diff --git a/src/geometry/mapping/unitTests/testLinearTransform.cpp b/tests/geometry/mapping/testLinearTransform.cpp similarity index 100% rename from src/geometry/mapping/unitTests/testLinearTransform.cpp rename to tests/geometry/mapping/testLinearTransform.cpp diff --git a/src/geometry/mapping/unitTests/testScaling.cpp b/tests/geometry/mapping/testScaling.cpp similarity index 100% rename from src/geometry/mapping/unitTests/testScaling.cpp rename to tests/geometry/mapping/testScaling.cpp diff --git a/src/geometry/mapping/unitTests/testUniformScaling.cpp b/tests/geometry/mapping/testUniformScaling.cpp similarity index 100% rename from src/geometry/mapping/unitTests/testUniformScaling.cpp rename to tests/geometry/mapping/testUniformScaling.cpp diff --git a/src/geometry/shapes/unitTests/CMakeLists.txt b/tests/geometry/shapes/CMakeLists.txt similarity index 100% rename from src/geometry/shapes/unitTests/CMakeLists.txt rename to tests/geometry/shapes/CMakeLists.txt diff --git a/src/geometry/shapes/unitTests/testInterpolatedShape.cpp b/tests/geometry/shapes/testInterpolatedShape.cpp similarity index 100% rename from src/geometry/shapes/unitTests/testInterpolatedShape.cpp rename to tests/geometry/shapes/testInterpolatedShape.cpp diff --git a/src/geometry/shapes/unitTests/testInterpolatedShapeSolutions.hpp b/tests/geometry/shapes/testInterpolatedShapeSolutions.hpp similarity index 100% rename from src/geometry/shapes/unitTests/testInterpolatedShapeSolutions.hpp rename to tests/geometry/shapes/testInterpolatedShapeSolutions.hpp diff --git a/src/geometry/shapes/unitTests/testNCube.cpp b/tests/geometry/shapes/testNCube.cpp similarity index 100% rename from src/geometry/shapes/unitTests/testNCube.cpp rename to tests/geometry/shapes/testNCube.cpp diff --git a/src/geometry/shapes/unitTests/testNSimplex.cpp b/tests/geometry/shapes/testNSimplex.cpp similarity index 100% rename from src/geometry/shapes/unitTests/testNSimplex.cpp rename to tests/geometry/shapes/testNSimplex.cpp From 052247e97f4e372a957cf9db22a4d959bd14ec18 Mon Sep 17 00:00:00 2001 From: Randolph Settgast Date: Sun, 14 Sep 2025 23:50:30 -0700 Subject: [PATCH 05/12] simplified build --- CMakeLists.txt | 209 ++++++------------ cmake/Config.cmake | 9 +- include/CMakeLists.txt | 52 ----- include/common/CMakeLists.txt | 15 -- include/discretizations/CMakeLists.txt | 5 - include/functions/CMakeLists.txt | 8 - include/geometry/CMakeLists.txt | 11 - include/{ => shiva}/Shiva.hpp | 0 include/{ => shiva}/ShivaConfig.hpp.in | 0 include/{ => shiva}/common/CArray.hpp | 2 +- include/{ => shiva}/common/CArrayHelper.hpp | 4 +- include/{ => shiva}/common/IndexTypes.hpp | 0 include/{ => shiva}/common/LinearIndex.hpp | 0 include/{ => shiva}/common/MathUtilities.hpp | 2 +- include/{ => shiva}/common/MultiIndex.hpp | 2 +- .../common/NestedSequenceUtilities.hpp | 2 +- .../{ => shiva}/common/SequenceUtilities.hpp | 2 +- .../{ => shiva}/common/ShivaErrorHandling.hpp | 0 include/{ => shiva}/common/ShivaMacros.hpp | 2 +- include/{ => shiva}/common/pmpl.hpp | 0 include/{ => shiva}/common/types.hpp | 2 +- .../parentElements/ParentElement.hpp | 8 +- .../functions/bases/BasisProduct.hpp | 6 +- .../functions/bases/LagrangeBasis.hpp | 4 +- .../functions/quadrature/Quadrature.hpp | 0 .../{ => shiva}/functions/spacing/Spacing.hpp | 2 +- .../geometry/mapping/JacobianTransforms.hpp | 0 .../geometry/mapping/LinearTransform.hpp | 12 +- .../{ => shiva}/geometry/mapping/Scaling.hpp | 6 +- .../geometry/mapping/UniformScaling.hpp | 8 +- .../geometry/shapes/InterpolatedShape.hpp | 9 +- include/{ => shiva}/geometry/shapes/NCube.hpp | 8 +- .../{ => shiva}/geometry/shapes/NSimplex.hpp | 8 +- .../{ => shiva}/namespaceDocumentation.hpp | 0 tests/CMakeLists.txt | 106 +++++---- tests/common/testCArray.cpp | 7 +- tests/common/testIndexTypes.cpp | 4 +- tests/common/testNestedSequenceUtilities.cpp | 4 +- tests/common/testSequenceUtilities.cpp | 4 +- tests/common/testShivaErrorHandling.cpp | 4 +- .../finiteElementMethod/testParentElement.cpp | 12 +- tests/functions/testLagrangeBasis.cpp | 10 +- tests/functions/testQuadrature.cpp | 2 +- tests/functions/testSpacing.cpp | 6 +- .../geometry/mapping/testLinearTransform.cpp | 14 +- tests/geometry/mapping/testScaling.cpp | 6 +- tests/geometry/mapping/testUniformScaling.cpp | 6 +- .../geometry/shapes/testInterpolatedShape.cpp | 12 +- tests/geometry/shapes/testNCube.cpp | 4 +- tests/geometry/shapes/testNSimplex.cpp | 4 +- 50 files changed, 231 insertions(+), 372 deletions(-) delete mode 100644 include/CMakeLists.txt delete mode 100644 include/common/CMakeLists.txt delete mode 100644 include/discretizations/CMakeLists.txt delete mode 100644 include/functions/CMakeLists.txt delete mode 100644 include/geometry/CMakeLists.txt rename include/{ => shiva}/Shiva.hpp (100%) rename include/{ => shiva}/ShivaConfig.hpp.in (100%) rename include/{ => shiva}/common/CArray.hpp (99%) rename include/{ => shiva}/common/CArrayHelper.hpp (98%) rename include/{ => shiva}/common/IndexTypes.hpp (100%) rename include/{ => shiva}/common/LinearIndex.hpp (100%) rename include/{ => shiva}/common/MathUtilities.hpp (99%) rename include/{ => shiva}/common/MultiIndex.hpp (98%) rename include/{ => shiva}/common/NestedSequenceUtilities.hpp (98%) rename include/{ => shiva}/common/SequenceUtilities.hpp (99%) rename include/{ => shiva}/common/ShivaErrorHandling.hpp (100%) rename include/{ => shiva}/common/ShivaMacros.hpp (99%) rename include/{ => shiva}/common/pmpl.hpp (100%) rename include/{ => shiva}/common/types.hpp (98%) rename include/{ => shiva}/discretizations/finiteElementMethod/parentElements/ParentElement.hpp (96%) rename include/{ => shiva}/functions/bases/BasisProduct.hpp (98%) rename include/{ => shiva}/functions/bases/LagrangeBasis.hpp (98%) rename include/{ => shiva}/functions/quadrature/Quadrature.hpp (100%) rename include/{ => shiva}/functions/spacing/Spacing.hpp (99%) rename include/{ => shiva}/geometry/mapping/JacobianTransforms.hpp (100%) rename include/{ => shiva}/geometry/mapping/LinearTransform.hpp (97%) rename include/{ => shiva}/geometry/mapping/Scaling.hpp (97%) rename include/{ => shiva}/geometry/mapping/UniformScaling.hpp (96%) rename include/{ => shiva}/geometry/shapes/InterpolatedShape.hpp (95%) rename include/{ => shiva}/geometry/shapes/NCube.hpp (97%) rename include/{ => shiva}/geometry/shapes/NSimplex.hpp (97%) rename include/{ => shiva}/namespaceDocumentation.hpp (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index d43b3f4..e102148 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,99 +1,38 @@ cmake_minimum_required(VERSION 3.23.1) +project(Shiva VERSION 0.1.0) -# Standalone project metadata -project(Shiva VERSION 0.1.0 ) - -# Are we the top-level project? -# (Reliable with CMake >= 3.21) -if (DEFINED PROJECT_IS_TOP_LEVEL) - set(SHIVA_IS_TOPLEVEL "${PROJECT_IS_TOP_LEVEL}") -else() - # Fallback (shouldn’t be needed given min version) - if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) - set(SHIVA_IS_TOPLEVEL TRUE) - else() - set(SHIVA_IS_TOPLEVEL FALSE) - endif() -endif() - -# Options -option( SHIVA_ENABLE_BLT "Enable BLT usage (standalone default ON)" ON ) -option( SHIVA_ENABLE_CAMP "Enable CAMP usage (requires BLT in this repo layout)" ON ) -option( CAMP_ENABLE_TESTS "Enable CAMP tests (if CAMP is added here)" OFF ) - -# Shiva’s public config toggles (exported in INTERFACE) -option(SHIVA_ENABLE_UNIT_TESTS "Builds tests (standalone only)" ON) -option(SHIVA_ENABLE_EXAMPLES "Builds examples (standalone only)" ON) -option(SHIVA_ENABLE_BENCHMARKS "Builds benchmarks (standalone only)" ON) -option(SHIVA_ENABLE_DOCS "Builds documentation (standalone only)" ON) - -# Device toggles are *interface* concerns for consumers; we do not enable languages here. -option(SHIVA_USE_CUDA "Consumer intends to use CUDA with Shiva headers" OFF) -option(SHIVA_USE_HIP "Consumer intends to use HIP with Shiva headers" OFF) - - - +# Portable install dir vars: ${CMAKE_INSTALL_INCLUDEDIR}, ${CMAKE_INSTALL_LIBDIR}, etc. +include(GNUInstallDirs) +# -------- Options (lean) ------------------------------------------------------- +option(SHIVA_USE_CUDA "Enable CUDA code paths in headers (interface define only)" OFF) +option(SHIVA_USE_HIP "Enable HIP code paths in headers (interface define only)" OFF) +option(SHIVA_ENABLE_UNIT_TESTS "Build unit tests (standalone only)" ON) +option(SHIVA_ENABLE_CAMP "Link against CAMP if available" OFF) -# BLT (standalone mode only, and only if requested) -if (SHIVA_IS_TOPLEVEL) - message(STATUS "Building Shiva as a standalone project") - - enable_language(CXX) - if( SHIVA_USE_CUDA ) - enable_language(CUDA) - endif() - - set( SHIVA_ENABLE_BLT ON CACHE BOOL "Force ON in standalone mode" ) - set( SHIVA_ENABLE_CAMP ON CACHE BOOL "Force ON in standalone mode" ) - - # Where to find BLT if vendored - set(BLT_SOURCE_DIR "${PROJECT_SOURCE_DIR}/cmake/blt" CACHE PATH "Path to BLT") - if (NOT EXISTS "${BLT_SOURCE_DIR}/SetupBLT.cmake") - message(FATAL_ERROR - "BLT not found at '${BLT_SOURCE_DIR}'. If this repository vendors BLT as a submodule, run:\n" - " git submodule update --init --recursive\n" - "Or set -DBLT_SOURCE_DIR=/path/to/blt") - endif() - - # Standardized C++ level for BLT toolchains - set(BLT_CXX_STD "c++17" CACHE STRING "Version of C++ standard" FORCE) - include("${BLT_SOURCE_DIR}/SetupBLT.cmake") - message(STATUS "BLT loaded") -else() - message(STATUS "Using Shiva as a subproject/submodule") - if (SHIVA_ENABLE_CAMP OR SHIVA_ENABLE_BLT) - if (NOT BLT_LOADED) - message(FATAL_ERROR - "Parent requested BLT/CAMP features, but BLT is not loaded. " - "Please load BLT in the top-level project before adding Shiva.") - endif() - endif() -endif() +# Top-level or subproject? +set(SHIVA_IS_TOPLEVEL "${PROJECT_IS_TOP_LEVEL}") -# Basic include paths (source + generated) +# Convenience dirs set(SHIVA_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") set(SHIVA_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}") -# Generate Shiva’s config header (your script) +# -------- Generate config header ---------------------------------------------- +# Expects: include/shiva/ShivaConfig.hpp.in include("${CMAKE_CURRENT_LIST_DIR}/cmake/Config.cmake") -# Create the header-only target unconditionally. +# -------- Header-only target --------------------------------------------------- add_library(Shiva INTERFACE) add_library(Shiva::shiva ALIAS Shiva) -# Public include dirs (source + current binary for generated headers) -target_include_directories( Shiva - INTERFACE - "$" - "$" - "$" +target_include_directories(Shiva INTERFACE + "$" # include/shiva/... + "$" # build/include/shiva/ShivaConfig.hpp + "$" ) -# Public compile features and interface defines (but no language enable here) target_compile_features(Shiva INTERFACE cxx_std_17) -# Device feature flags are exported as interface macros for consumers to react to in headers if (SHIVA_USE_CUDA) target_compile_definitions(Shiva INTERFACE SHIVA_USE_CUDA=1) endif() @@ -101,78 +40,62 @@ if (SHIVA_USE_HIP) target_compile_definitions(Shiva INTERFACE SHIVA_USE_HIP=1) endif() -# CAMP (only wire it up here if explicitly requested) +# Optional CAMP wiring (no BLT required here) if (SHIVA_ENABLE_CAMP) - # Option A (vendored via BLT/this repo): add_subdirectory - # Option B (preferred long-term): find_package(camp CONFIG REQUIRED) and link camp::camp - # Keeping your current approach but safer paths: - add_subdirectory(tpl/camp) - # Generated header into *current* binary dir to avoid collisions when subproject - configure_file( - tpl/camp/include/camp/config.in.hpp - "${SHIVA_BINARY_DIR}/include/camp/config.hpp" - @ONLY - ) - # The 'camp' target comes from the subdir. Be gentle with warnings: + find_package(camp CONFIG QUIET) if (TARGET camp) - # Example: silence -Wshadow on GCC/Clang only - target_compile_options(camp PRIVATE - $<$,$>:-Wno-shadow> - ) - # Export dependency to consumers target_link_libraries(Shiva INTERFACE camp) + elseif (SHIVA_IS_TOPLEVEL) + add_subdirectory(tpl/camp) # vendored fallback when standalone + target_link_libraries(Shiva INTERFACE camp) + else() + message(FATAL_ERROR "CAMP not found; enable it only if the parent provides it or build standalone.") endif() endif() -# Put the rest of your target wiring (headers-only structure, subdirs) under src/ -# Keep 'src' responsible for populating the header tree and optional tests/examples/etc. -add_subdirectory(include) - -# Standalone-only extras -if (SHIVA_IS_TOPLEVEL) - if (SHIVA_ENABLE_DOCS) - add_subdirectory(docs) +# -------- Tests (BLT only when standalone) ------------------------------------- +if (SHIVA_IS_TOPLEVEL AND SHIVA_ENABLE_UNIT_TESTS) + include(CTest) + # Load BLT you vendor under cmake/blt + set(BLT_SOURCE_DIR "${PROJECT_SOURCE_DIR}/cmake/blt" CACHE PATH "Path to BLT") + if (NOT EXISTS "${BLT_SOURCE_DIR}/SetupBLT.cmake") + message(FATAL_ERROR "BLT not found at '${BLT_SOURCE_DIR}'.") endif() + include("${BLT_SOURCE_DIR}/SetupBLT.cmake") + add_subdirectory(tests) +endif() - # Minimal install/export so consumers can find_package(Shiva) - include(GNUInstallDirs) - install(TARGETS Shiva - EXPORT ShivaTargets - ) - install(DIRECTORY "${SHIVA_SOURCE_DIR}/src/" - DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" - FILES_MATCHING PATTERN "*.hpp" PATTERN "*.h" - ) - # Also install generated headers if any - install(DIRECTORY "${SHIVA_BINARY_DIR}/include/" - DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" - OPTIONAL - ) - - include(CMakePackageConfigHelpers) - write_basic_package_version_file( - "${CMAKE_CURRENT_BINARY_DIR}/ShivaConfigVersion.cmake" - VERSION "${PROJECT_VERSION}" - COMPATIBILITY SameMajorVersion - ) - configure_package_config_file( - "${CMAKE_CURRENT_LIST_DIR}/cmake/ShivaConfig.cmake.in" - "${CMAKE_CURRENT_BINARY_DIR}/ShivaConfig.cmake" - INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/Shiva" - ) - install(FILES - "${CMAKE_CURRENT_BINARY_DIR}/ShivaConfig.cmake" - "${CMAKE_CURRENT_BINARY_DIR}/ShivaConfigVersion.cmake" - DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/Shiva" - ) - install(EXPORT ShivaTargets - NAMESPACE Shiva:: - DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/Shiva" - ) -endif() +# -------- Install & package ---------------------------------------------------- +install(TARGETS Shiva EXPORT ShivaTargets) +# Install public headers and generated config header tree +install(DIRECTORY "${SHIVA_SOURCE_DIR}/include/" + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") +install(DIRECTORY "${SHIVA_BINARY_DIR}/include/" + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" + OPTIONAL) -if( SHIVA_ENABLE_UNIT_TESTS ) - add_subdirectory(tests) -endif() +include(CMakePackageConfigHelpers) + +write_basic_package_version_file( + "${CMAKE_CURRENT_BINARY_DIR}/ShivaConfigVersion.cmake" + VERSION "${PROJECT_VERSION}" + COMPATIBILITY SameMajorVersion +) +configure_package_config_file( + "${CMAKE_CURRENT_LIST_DIR}/cmake/ShivaConfig.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/ShivaConfig.cmake" + INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/Shiva" +) + +install(FILES + "${CMAKE_CURRENT_BINARY_DIR}/ShivaConfig.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/ShivaConfigVersion.cmake" + DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/Shiva" +) +install(EXPORT ShivaTargets + FILE ShivaTargets.cmake + NAMESPACE Shiva:: + DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/Shiva" +) diff --git a/cmake/Config.cmake b/cmake/Config.cmake index 3c57dd7..5ddd4df 100644 --- a/cmake/Config.cmake +++ b/cmake/Config.cmake @@ -60,20 +60,19 @@ set(SHIVA_VERSION_MINOR "${PROJECT_VERSION_MINOR}") set(SHIVA_VERSION_PATCHLEVEL "${PROJECT_VERSION_PATCH}") # ---------- Emit the generated header(s) ---------- -set(_shiva_gen_inc "${SHIVA_BINARY_DIR}/include") +set(_shiva_gen_inc "${SHIVA_BINARY_DIR}/include/shiva") message( "SHIVA_BINARY_DIR = ${SHIVA_BINARY_DIR}" ) file(MAKE_DIRECTORY "${_shiva_gen_inc}") -configure_file( - "${SHIVA_SOURCE_DIR}/include/ShivaConfig.hpp.in" - "${_shiva_gen_inc}/ShivaConfig.hpp" +configure_file( "${SHIVA_SOURCE_DIR}/include/shiva/ShivaConfig.hpp.in" + "${_shiva_gen_inc}/ShivaConfig.hpp" ) # Optional: a copy for Doxygen without touching the source tree set(_shiva_gen_doc "${SHIVA_BINARY_DIR}/docs/doxygen") file(MAKE_DIRECTORY "${_shiva_gen_doc}") configure_file( - "${SHIVA_SOURCE_DIR}/include/ShivaConfig.hpp.in" + "${SHIVA_SOURCE_DIR}/include/shiva/ShivaConfig.hpp.in" "${_shiva_gen_doc}/ShivaConfig.hpp" ) diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt deleted file mode 100644 index 5c1d6d6..0000000 --- a/include/CMakeLists.txt +++ /dev/null @@ -1,52 +0,0 @@ - -set( shiva_headers - Shiva.hpp - ) - -set( shiva_dependencies ) - - -if( SHIVA_ENABLE_CAMP ) - list( APPEND shiva_dependencies camp ) -endif() - -if( SHIVA_ENABLE_BLT AND ENABLE_HIP ) - list( APPEND shiva_dependencies blt::hip ) -endif() - -if( ENABLE_CUDA ) - list( APPEND shiva_dependencies cuda ) -endif() - -add_subdirectory( common ) -add_subdirectory( functions ) -add_subdirectory( discretizations ) -add_subdirectory( geometry ) - - - - -add_library( shiva INTERFACE ${shiva_headers} ) - -target_include_directories( shiva - INTERFACE - ${shiva_headers} ) - -install( FILES ${shiva_headers} - DESTINATION include ) - - -install( TARGETS shiva - EXPORT shiva - ARCHIVE DESTINATION lib - LIBRARY DESTINATION lib - RUNTIME DESTINATION lib ) - -if( SHIVA_ENABLE_BLT ) - - install( EXPORT shiva - DESTINATION lib/cmake/shiva ) - - shiva_add_code_checks( PREFIX shiva - EXCLUDES "blt/*" ) -endif() \ No newline at end of file diff --git a/include/common/CMakeLists.txt b/include/common/CMakeLists.txt deleted file mode 100644 index a62a173..0000000 --- a/include/common/CMakeLists.txt +++ /dev/null @@ -1,15 +0,0 @@ - -set( shiva_headers - common/CArray.hpp - common/CArrayHelper.hpp - common/IndexTypes.hpp - common/LinearIndex.hpp - common/MathUtilities.hpp - common/MultiIndex.hpp - common/pmpl.hpp - common/SequenceUtilities.hpp - common/NestedSequenceUtilities.hpp - common/ShivaErrorHandling.hpp - common/ShivaMacros.hpp - common/types.hpp - PARENT_SCOPE ) \ No newline at end of file diff --git a/include/discretizations/CMakeLists.txt b/include/discretizations/CMakeLists.txt deleted file mode 100644 index 6834d98..0000000 --- a/include/discretizations/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ - -set( shiva_headers - discretizations/finiteElementMethod/parentElements/ParentElement.hpp - PARENT_SCOPE - ) \ No newline at end of file diff --git a/include/functions/CMakeLists.txt b/include/functions/CMakeLists.txt deleted file mode 100644 index 8b41948..0000000 --- a/include/functions/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ - -set( shiva_headers - functions/bases/BasisProduct.hpp - functions/bases/LagrangeBasis.hpp - functions/quadrature/Quadrature.hpp - functions/spacing/Spacing.hpp - PARENT_SCOPE - ) \ No newline at end of file diff --git a/include/geometry/CMakeLists.txt b/include/geometry/CMakeLists.txt deleted file mode 100644 index 6a04592..0000000 --- a/include/geometry/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ - -set( shiva_headers - geometry/mapping/JacobianTransforms.hpp - geometry/mapping/LinearTransform.hpp - geometry/mapping/Scaling.hpp - geometry/mapping/UniformScaling.hpp - geometry/shapes/InterpolatedShape.hpp - geometry/shapes/NCube.hpp - geometry/shapes/NSimplex.hpp - PARENT_SCOPE - ) \ No newline at end of file diff --git a/include/Shiva.hpp b/include/shiva/Shiva.hpp similarity index 100% rename from include/Shiva.hpp rename to include/shiva/Shiva.hpp diff --git a/include/ShivaConfig.hpp.in b/include/shiva/ShivaConfig.hpp.in similarity index 100% rename from include/ShivaConfig.hpp.in rename to include/shiva/ShivaConfig.hpp.in diff --git a/include/common/CArray.hpp b/include/shiva/common/CArray.hpp similarity index 99% rename from include/common/CArray.hpp rename to include/shiva/common/CArray.hpp index 63204c9..514f09e 100644 --- a/include/common/CArray.hpp +++ b/include/shiva/common/CArray.hpp @@ -19,7 +19,7 @@ #pragma once -#include "common/ShivaMacros.hpp" +#include "shiva/common/ShivaMacros.hpp" #include "CArrayHelper.hpp" diff --git a/include/common/CArrayHelper.hpp b/include/shiva/common/CArrayHelper.hpp similarity index 98% rename from include/common/CArrayHelper.hpp rename to include/shiva/common/CArrayHelper.hpp index 2529909..6c81bed 100644 --- a/include/common/CArrayHelper.hpp +++ b/include/shiva/common/CArrayHelper.hpp @@ -19,8 +19,8 @@ #pragma once -#include "common/ShivaErrorHandling.hpp" -#include "common/types.hpp" +#include "shiva/common/ShivaErrorHandling.hpp" +#include "shiva/common/types.hpp" #include #include #include diff --git a/include/common/IndexTypes.hpp b/include/shiva/common/IndexTypes.hpp similarity index 100% rename from include/common/IndexTypes.hpp rename to include/shiva/common/IndexTypes.hpp diff --git a/include/common/LinearIndex.hpp b/include/shiva/common/LinearIndex.hpp similarity index 100% rename from include/common/LinearIndex.hpp rename to include/shiva/common/LinearIndex.hpp diff --git a/include/common/MathUtilities.hpp b/include/shiva/common/MathUtilities.hpp similarity index 99% rename from include/common/MathUtilities.hpp rename to include/shiva/common/MathUtilities.hpp index 0d152ea..c9d1521 100644 --- a/include/common/MathUtilities.hpp +++ b/include/shiva/common/MathUtilities.hpp @@ -17,7 +17,7 @@ #pragma once -#include "common/ShivaMacros.hpp" +#include "shiva/common/ShivaMacros.hpp" #include diff --git a/include/common/MultiIndex.hpp b/include/shiva/common/MultiIndex.hpp similarity index 98% rename from include/common/MultiIndex.hpp rename to include/shiva/common/MultiIndex.hpp index 72ba7ef..0826173 100644 --- a/include/common/MultiIndex.hpp +++ b/include/shiva/common/MultiIndex.hpp @@ -18,7 +18,7 @@ #pragma once -#include "common/ShivaMacros.hpp" +#include "shiva/common/ShivaMacros.hpp" #include "SequenceUtilities.hpp" #include diff --git a/include/common/NestedSequenceUtilities.hpp b/include/shiva/common/NestedSequenceUtilities.hpp similarity index 98% rename from include/common/NestedSequenceUtilities.hpp rename to include/shiva/common/NestedSequenceUtilities.hpp index 03d6b7b..79b29a7 100644 --- a/include/common/NestedSequenceUtilities.hpp +++ b/include/shiva/common/NestedSequenceUtilities.hpp @@ -13,7 +13,7 @@ #pragma once -#include "common/ShivaMacros.hpp" +#include "shiva/common/ShivaMacros.hpp" #include #include diff --git a/include/common/SequenceUtilities.hpp b/include/shiva/common/SequenceUtilities.hpp similarity index 99% rename from include/common/SequenceUtilities.hpp rename to include/shiva/common/SequenceUtilities.hpp index 6e8eeaa..02eeee4 100644 --- a/include/common/SequenceUtilities.hpp +++ b/include/shiva/common/SequenceUtilities.hpp @@ -18,7 +18,7 @@ #pragma once -#include "common/ShivaMacros.hpp" +#include "shiva/common/ShivaMacros.hpp" #include #include diff --git a/include/common/ShivaErrorHandling.hpp b/include/shiva/common/ShivaErrorHandling.hpp similarity index 100% rename from include/common/ShivaErrorHandling.hpp rename to include/shiva/common/ShivaErrorHandling.hpp diff --git a/include/common/ShivaMacros.hpp b/include/shiva/common/ShivaMacros.hpp similarity index 99% rename from include/common/ShivaMacros.hpp rename to include/shiva/common/ShivaMacros.hpp index f8ddd3d..38d7d6b 100644 --- a/include/common/ShivaMacros.hpp +++ b/include/shiva/common/ShivaMacros.hpp @@ -18,7 +18,7 @@ #pragma once -#include "ShivaConfig.hpp" +#include "shiva/ShivaConfig.hpp" #include #include diff --git a/include/common/pmpl.hpp b/include/shiva/common/pmpl.hpp similarity index 100% rename from include/common/pmpl.hpp rename to include/shiva/common/pmpl.hpp diff --git a/include/common/types.hpp b/include/shiva/common/types.hpp similarity index 98% rename from include/common/types.hpp rename to include/shiva/common/types.hpp index 9c1ce28..8386479 100644 --- a/include/common/types.hpp +++ b/include/shiva/common/types.hpp @@ -17,7 +17,7 @@ */ #pragma once -#include "common/ShivaMacros.hpp" +#include "shiva/common/ShivaMacros.hpp" /// @brief Macro to define whether or not to use camp. #if defined(SHIVA_USE_CAMP) diff --git a/include/discretizations/finiteElementMethod/parentElements/ParentElement.hpp b/include/shiva/discretizations/finiteElementMethod/parentElements/ParentElement.hpp similarity index 96% rename from include/discretizations/finiteElementMethod/parentElements/ParentElement.hpp rename to include/shiva/discretizations/finiteElementMethod/parentElements/ParentElement.hpp index 9d4bdb1..20c8a99 100644 --- a/include/discretizations/finiteElementMethod/parentElements/ParentElement.hpp +++ b/include/shiva/discretizations/finiteElementMethod/parentElements/ParentElement.hpp @@ -13,11 +13,11 @@ #pragma once -#include "common/NestedSequenceUtilities.hpp" -#include "common/ShivaMacros.hpp" -#include "common/types.hpp" +#include "shiva/common/NestedSequenceUtilities.hpp" +#include "shiva/common/ShivaMacros.hpp" +#include "shiva/common/types.hpp" -#include "functions/bases/BasisProduct.hpp" +#include "shiva/functions/bases/BasisProduct.hpp" //#include diff --git a/include/functions/bases/BasisProduct.hpp b/include/shiva/functions/bases/BasisProduct.hpp similarity index 98% rename from include/functions/bases/BasisProduct.hpp rename to include/shiva/functions/bases/BasisProduct.hpp index 28f1075..2e19417 100644 --- a/include/functions/bases/BasisProduct.hpp +++ b/include/shiva/functions/bases/BasisProduct.hpp @@ -13,9 +13,9 @@ #pragma once -#include "common/NestedSequenceUtilities.hpp" -#include "common/MultiIndex.hpp" -#include "common/CArray.hpp" +#include "shiva/common/NestedSequenceUtilities.hpp" +#include "shiva/common/MultiIndex.hpp" +#include "shiva/common/CArray.hpp" namespace shiva { diff --git a/include/functions/bases/LagrangeBasis.hpp b/include/shiva/functions/bases/LagrangeBasis.hpp similarity index 98% rename from include/functions/bases/LagrangeBasis.hpp rename to include/shiva/functions/bases/LagrangeBasis.hpp index e18bb4a..9330885 100644 --- a/include/functions/bases/LagrangeBasis.hpp +++ b/include/shiva/functions/bases/LagrangeBasis.hpp @@ -18,8 +18,8 @@ #pragma once -#include "common/SequenceUtilities.hpp" -#include "common/ShivaMacros.hpp" +#include "shiva/common/SequenceUtilities.hpp" +#include "shiva/common/ShivaMacros.hpp" #include diff --git a/include/functions/quadrature/Quadrature.hpp b/include/shiva/functions/quadrature/Quadrature.hpp similarity index 100% rename from include/functions/quadrature/Quadrature.hpp rename to include/shiva/functions/quadrature/Quadrature.hpp diff --git a/include/functions/spacing/Spacing.hpp b/include/shiva/functions/spacing/Spacing.hpp similarity index 99% rename from include/functions/spacing/Spacing.hpp rename to include/shiva/functions/spacing/Spacing.hpp index de7c197..8f5ca29 100644 --- a/include/functions/spacing/Spacing.hpp +++ b/include/shiva/functions/spacing/Spacing.hpp @@ -18,7 +18,7 @@ #pragma once -#include "common/ShivaMacros.hpp" +#include "shiva/common/ShivaMacros.hpp" namespace shiva { diff --git a/include/geometry/mapping/JacobianTransforms.hpp b/include/shiva/geometry/mapping/JacobianTransforms.hpp similarity index 100% rename from include/geometry/mapping/JacobianTransforms.hpp rename to include/shiva/geometry/mapping/JacobianTransforms.hpp diff --git a/include/geometry/mapping/LinearTransform.hpp b/include/shiva/geometry/mapping/LinearTransform.hpp similarity index 97% rename from include/geometry/mapping/LinearTransform.hpp rename to include/shiva/geometry/mapping/LinearTransform.hpp index 7fde65f..63e78e3 100644 --- a/include/geometry/mapping/LinearTransform.hpp +++ b/include/shiva/geometry/mapping/LinearTransform.hpp @@ -18,12 +18,12 @@ #pragma once -#include "common/MathUtilities.hpp" -#include "common/ShivaMacros.hpp" -#include "common/types.hpp" -#include "common/IndexTypes.hpp" -#include "common/NestedSequenceUtilities.hpp" -#include "common/CArray.hpp" +#include "shiva/common/MathUtilities.hpp" +#include "shiva/common/ShivaMacros.hpp" +#include "shiva/common/types.hpp" +#include "shiva/common/IndexTypes.hpp" +#include "shiva/common/NestedSequenceUtilities.hpp" +#include "shiva/common/CArray.hpp" /** * namespace to encapsulate all shiva code diff --git a/include/geometry/mapping/Scaling.hpp b/include/shiva/geometry/mapping/Scaling.hpp similarity index 97% rename from include/geometry/mapping/Scaling.hpp rename to include/shiva/geometry/mapping/Scaling.hpp index d9a4e47..0cbccfe 100644 --- a/include/geometry/mapping/Scaling.hpp +++ b/include/shiva/geometry/mapping/Scaling.hpp @@ -17,9 +17,9 @@ #pragma once -#include "common/ShivaMacros.hpp" -#include "common/types.hpp" -#include "common/CArray.hpp" +#include "shiva/common/ShivaMacros.hpp" +#include "shiva/common/types.hpp" +#include "shiva/common/CArray.hpp" namespace shiva { diff --git a/include/geometry/mapping/UniformScaling.hpp b/include/shiva/geometry/mapping/UniformScaling.hpp similarity index 96% rename from include/geometry/mapping/UniformScaling.hpp rename to include/shiva/geometry/mapping/UniformScaling.hpp index 5b69dcb..72d25d4 100644 --- a/include/geometry/mapping/UniformScaling.hpp +++ b/include/shiva/geometry/mapping/UniformScaling.hpp @@ -17,10 +17,10 @@ #pragma once -#include "common/ShivaMacros.hpp" -#include "common/IndexTypes.hpp" -#include "common/types.hpp" -#include "common/CArray.hpp" +#include "shiva/common/ShivaMacros.hpp" +#include "shiva/common/IndexTypes.hpp" +#include "shiva/common/types.hpp" +#include "shiva/common/CArray.hpp" namespace shiva { diff --git a/include/geometry/shapes/InterpolatedShape.hpp b/include/shiva/geometry/shapes/InterpolatedShape.hpp similarity index 95% rename from include/geometry/shapes/InterpolatedShape.hpp rename to include/shiva/geometry/shapes/InterpolatedShape.hpp index 28afddb..e4c82f7 100644 --- a/include/geometry/shapes/InterpolatedShape.hpp +++ b/include/shiva/geometry/shapes/InterpolatedShape.hpp @@ -13,11 +13,10 @@ #pragma once -#include "common/SequenceUtilities.hpp" -#include "common/ShivaMacros.hpp" -#include "common/types.hpp" - -#include "functions/bases/BasisProduct.hpp" +#include "shiva/common/SequenceUtilities.hpp" +#include "shiva/common/ShivaMacros.hpp" +#include "shiva/common/types.hpp" +#include "shiva/functions/bases/BasisProduct.hpp" #include diff --git a/include/geometry/shapes/NCube.hpp b/include/shiva/geometry/shapes/NCube.hpp similarity index 97% rename from include/geometry/shapes/NCube.hpp rename to include/shiva/geometry/shapes/NCube.hpp index cd891c8..dc1b370 100644 --- a/include/geometry/shapes/NCube.hpp +++ b/include/shiva/geometry/shapes/NCube.hpp @@ -17,10 +17,10 @@ #pragma once -#include "common/ShivaMacros.hpp" -#include "common/IndexTypes.hpp" -#include "common/types.hpp" -#include "common/MathUtilities.hpp" +#include "shiva/common/ShivaMacros.hpp" +#include "shiva/common/IndexTypes.hpp" +#include "shiva/common/types.hpp" +#include "shiva/common/MathUtilities.hpp" namespace shiva { diff --git a/include/geometry/shapes/NSimplex.hpp b/include/shiva/geometry/shapes/NSimplex.hpp similarity index 97% rename from include/geometry/shapes/NSimplex.hpp rename to include/shiva/geometry/shapes/NSimplex.hpp index 4df2fa7..5fec076 100644 --- a/include/geometry/shapes/NSimplex.hpp +++ b/include/shiva/geometry/shapes/NSimplex.hpp @@ -17,10 +17,10 @@ #pragma once -#include "common/ShivaMacros.hpp" -#include "common/IndexTypes.hpp" -#include "common/types.hpp" -#include "common/MathUtilities.hpp" +#include "shiva/common/ShivaMacros.hpp" +#include "shiva/common/IndexTypes.hpp" +#include "shiva/common/types.hpp" +#include "shiva/common/MathUtilities.hpp" namespace shiva { diff --git a/include/namespaceDocumentation.hpp b/include/shiva/namespaceDocumentation.hpp similarity index 100% rename from include/namespaceDocumentation.hpp rename to include/shiva/namespaceDocumentation.hpp diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index e4922b0..ef6feb8 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,53 +1,83 @@ cmake_minimum_required(VERSION 3.23.1) -include(CTest) -# One function for both CPU & CUDA cases. -function(shiva_add_gtest name) +# Define only when BLT is loaded and tests are enabled +# (guard this in your tests/CMakeLists.txt or top-level) +# require: blt_add_executable, blt_add_test, and Shiva target + +# Default output dir if you didn't set one elsewhere +if(NOT DEFINED TEST_OUTPUT_DIRECTORY) + set(TEST_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/tests") +endif() + +# Default output dir (optional) +if(NOT DEFINED TEST_OUTPUT_DIRECTORY) + set(TEST_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/tests") +endif() + +macro(shiva_add_gtest) set(options) - set(oneValueArgs) - set(multiValueArgs SOURCES CUDA_SOURCES LIBS) - cmake_parse_arguments(SAG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - - add_executable(${name} ${SAG_SOURCES}) - - # If CUDA toolchain is active, tack on CUDA sources & props. - if (CMAKE_CUDA_COMPILER AND SAG_CUDA_SOURCES) - target_sources(${name} PRIVATE ${SAG_CUDA_SOURCES}) - set_target_properties(${name} PROPERTIES CUDA_SEPARABLE_COMPILATION ON) - # Your headers probably branch on this; usually comes via Shiva INTERFACE anyway. - target_compile_definitions(${name} PRIVATE SHIVA_USE_CUDA=1) + set(oneValueArgs NAME) + set(multiValueArgs SOURCES HEADERS DEPENDS_ON) + cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + if(NOT ARG_NAME) + message(FATAL_ERROR "shiva_add_gtest: NAME is required") + endif() + if(NOT ARG_SOURCES) + message(FATAL_ERROR "shiva_add_gtest(${ARG_NAME}): SOURCES is required") + endif() + + # Base deps: always link Shiva (propagates include paths + interface defs) + set(_deps Shiva gtest) + + # User-specified extras + if(ARG_DEPENDS_ON) + list(APPEND _deps ${ARG_DEPENDS_ON}) + endif() + + # Turn on toolchain deps as available in BLT + if(ENABLE_CUDA) + list(APPEND _deps cuda) + endif() + if(ENABLE_HIP) + # BLT usually exposes blt::hip; fallback to 'hip' if that’s your setup + if(TARGET blt::hip) + list(APPEND _deps blt::hip) + else() + list(APPEND _deps hip) + endif() endif() - target_link_libraries(${name} PRIVATE - Shiva # pulls include/shiva + build/include/shiva - GTest::gtest_main - ${SAG_LIBS} + blt_add_executable( + NAME ${ARG_NAME} + SOURCES ${ARG_SOURCES} + HEADERS ${ARG_HEADERS} + OUTPUT_DIR ${TEST_OUTPUT_DIRECTORY} + DEPENDS_ON ${_deps} ) - target_compile_features(${name} PRIVATE cxx_std_17) - add_test(NAME ${name} COMMAND ${name}) -endfunction() + blt_add_test(NAME ${ARG_NAME} COMMAND ${ARG_NAME}) +endmacro() -# --- Common tests --- -shiva_add_gtest(shiva_test_carray common/testCArray.cpp) -shiva_add_gtest(shiva_test_index_types common/testIndexTypes.cpp) -shiva_add_gtest(shiva_test_nested_seq_utils common/testNestedSequenceUtilities.cpp) -shiva_add_gtest(shiva_test_seq_utils common/testSequenceUtilities.cpp) -shiva_add_gtest(shiva_test_err_handling common/testShivaErrorHandling.cpp) +shiva_add_gtest( NAME shiva_test_carray SOURCES common/testCArray.cpp ) +shiva_add_gtest( NAME shiva_test_index_types SOURCES common/testIndexTypes.cpp ) +shiva_add_gtest( NAME shiva_test_nested_seq_utils SOURCES common/testNestedSequenceUtilities.cpp ) +shiva_add_gtest( NAME shiva_test_seq_utils SOURCES common/testSequenceUtilities.cpp ) +shiva_add_gtest( NAME shiva_test_err_handling SOURCES common/testShivaErrorHandling.cpp ) -shiva_add_gtest(shiva_test_parent_element discretizations/testParentElement.cpp) +shiva_add_gtest( NAME shiva_test_parent_element SOURCES discretizations/finiteElementMethod/testParentElement.cpp ) -shiva_add_gtest(shiva_test_lagrange_basis functions/testLagrangeBasis.cpp) -shiva_add_gtest(shiva_test_quadrature functions/testQuadrature.cpp) -shiva_add_gtest(shiva_test_spacing functions/testSpacing.cpp) +shiva_add_gtest( NAME shiva_test_lagrange_basis SOURCES functions/testLagrangeBasis.cpp ) +shiva_add_gtest( NAME shiva_test_quadrature SOURCES functions/testQuadrature.cpp ) +shiva_add_gtest( NAME shiva_test_spacing SOURCES functions/testSpacing.cpp ) -shiva_add_gtest(shiva_test_linear_transform geometry/mapping/testLinearTransform.cpp) -shiva_add_gtest(shiva_test_scaling geometry/mapping/testScaling.cpp) -shiva_add_gtest(shiva_test_uniform_scaling geometry/mapping/testUniformScaling.cpp) -shiva_add_gtest(shiva_test_interpolated geometry/shapes/testInterpolatedShape.cpp) -shiva_add_gtest(shiva_test_ncube geometry/shapes/testNCube.cpp) -shiva_add_gtest(shiva_test_nsimplex geometry/shapes/testNSimplex.cpp) +shiva_add_gtest( NAME shiva_test_linear_transform SOURCES geometry/mapping/testLinearTransform.cpp ) +shiva_add_gtest( NAME shiva_test_scaling SOURCES geometry/mapping/testScaling.cpp ) +shiva_add_gtest( NAME shiva_test_uniform_scaling SOURCES geometry/mapping/testUniformScaling.cpp ) +shiva_add_gtest( NAME shiva_test_interpolated SOURCES geometry/shapes/testInterpolatedShape.cpp ) +shiva_add_gtest( NAME shiva_test_ncube SOURCES geometry/shapes/testNCube.cpp ) +shiva_add_gtest( NAME shiva_test_nsimplex SOURCES geometry/shapes/testNSimplex.cpp ) # --- CUDA variants (only built when CUDA is enabled by parent or standalone) --- # Example: add CUDA-only tests or CUDA-flavored versions: diff --git a/tests/common/testCArray.cpp b/tests/common/testCArray.cpp index 9f7ea7d..c744fc0 100644 --- a/tests/common/testCArray.cpp +++ b/tests/common/testCArray.cpp @@ -12,10 +12,9 @@ */ -#include "../CArray.hpp" - -#include "../SequenceUtilities.hpp" -#include "common/pmpl.hpp" +#include "shiva/common/CArray.hpp" +#include "shiva/common/SequenceUtilities.hpp" +#include "shiva/common/pmpl.hpp" #include diff --git a/tests/common/testIndexTypes.cpp b/tests/common/testIndexTypes.cpp index 9b39004..0bd3da2 100644 --- a/tests/common/testIndexTypes.cpp +++ b/tests/common/testIndexTypes.cpp @@ -12,8 +12,8 @@ */ -#include "../IndexTypes.hpp" -#include "common/pmpl.hpp" +#include "shiva/common/IndexTypes.hpp" +#include "shiva/common/pmpl.hpp" #include diff --git a/tests/common/testNestedSequenceUtilities.cpp b/tests/common/testNestedSequenceUtilities.cpp index 5539bdd..622eff8 100644 --- a/tests/common/testNestedSequenceUtilities.cpp +++ b/tests/common/testNestedSequenceUtilities.cpp @@ -12,8 +12,8 @@ */ -#include "../NestedSequenceUtilities.hpp" -#include "common/pmpl.hpp" +#include "shiva/common/NestedSequenceUtilities.hpp" +#include "shiva/common/pmpl.hpp" #include diff --git a/tests/common/testSequenceUtilities.cpp b/tests/common/testSequenceUtilities.cpp index 7764e96..7b012ee 100644 --- a/tests/common/testSequenceUtilities.cpp +++ b/tests/common/testSequenceUtilities.cpp @@ -12,8 +12,8 @@ */ -#include "../SequenceUtilities.hpp" -#include "common/pmpl.hpp" +#include "shiva/common/SequenceUtilities.hpp" +#include "shiva/common/pmpl.hpp" #include diff --git a/tests/common/testShivaErrorHandling.cpp b/tests/common/testShivaErrorHandling.cpp index 43146f3..604c27b 100644 --- a/tests/common/testShivaErrorHandling.cpp +++ b/tests/common/testShivaErrorHandling.cpp @@ -12,8 +12,8 @@ */ -#include "../ShivaErrorHandling.hpp" -#include "../pmpl.hpp" +#include "shiva/common/ShivaErrorHandling.hpp" +#include "shiva/common/pmpl.hpp" #include diff --git a/tests/discretizations/finiteElementMethod/testParentElement.cpp b/tests/discretizations/finiteElementMethod/testParentElement.cpp index 72ce6c5..63dd5bd 100644 --- a/tests/discretizations/finiteElementMethod/testParentElement.cpp +++ b/tests/discretizations/finiteElementMethod/testParentElement.cpp @@ -12,12 +12,12 @@ */ -#include "../finiteElementMethod/parentElements/ParentElement.hpp" -#include "functions/bases/LagrangeBasis.hpp" -#include "functions/spacing/Spacing.hpp" -#include "geometry/shapes/NCube.hpp" -#include "common/ShivaMacros.hpp" -#include "common/pmpl.hpp" +#include "shiva/discretizations/finiteElementMethod/parentElements/ParentElement.hpp" +#include "shiva/functions/bases/LagrangeBasis.hpp" +#include "shiva/functions/spacing/Spacing.hpp" +#include "shiva/geometry/shapes/NCube.hpp" +#include "shiva/common/ShivaMacros.hpp" +#include "shiva/common/pmpl.hpp" diff --git a/tests/functions/testLagrangeBasis.cpp b/tests/functions/testLagrangeBasis.cpp index 4c875a8..b75955c 100644 --- a/tests/functions/testLagrangeBasis.cpp +++ b/tests/functions/testLagrangeBasis.cpp @@ -12,11 +12,11 @@ */ -#include "../bases/LagrangeBasis.hpp" -#include "../spacing/Spacing.hpp" -#include "../../common/ShivaMacros.hpp" -#include "common/pmpl.hpp" -#include "common/types.hpp" +#include "shiva/functions/bases/LagrangeBasis.hpp" +#include "shiva/functions/spacing/Spacing.hpp" +#include "shiva/common/ShivaMacros.hpp" +#include "shiva/common/pmpl.hpp" +#include "shiva/common/types.hpp" #include #include diff --git a/tests/functions/testQuadrature.cpp b/tests/functions/testQuadrature.cpp index 8fe6356..4f44d34 100644 --- a/tests/functions/testQuadrature.cpp +++ b/tests/functions/testQuadrature.cpp @@ -12,7 +12,7 @@ */ -#include "../quadrature/Quadrature.hpp" +#include "shiva/functions/quadrature/Quadrature.hpp" #include #include diff --git a/tests/functions/testSpacing.cpp b/tests/functions/testSpacing.cpp index 738924d..9dfd26b 100644 --- a/tests/functions/testSpacing.cpp +++ b/tests/functions/testSpacing.cpp @@ -13,9 +13,9 @@ -#include "../spacing/Spacing.hpp" -#include "common/SequenceUtilities.hpp" -#include "common/pmpl.hpp" +#include "shiva/functions/spacing/Spacing.hpp" +#include "shiva/common/SequenceUtilities.hpp" +#include "shiva/common/pmpl.hpp" #include #include diff --git a/tests/geometry/mapping/testLinearTransform.cpp b/tests/geometry/mapping/testLinearTransform.cpp index 5a575bf..7d78ed9 100644 --- a/tests/geometry/mapping/testLinearTransform.cpp +++ b/tests/geometry/mapping/testLinearTransform.cpp @@ -12,15 +12,15 @@ */ -#include "geometry/shapes/NCube.hpp" -#include "../LinearTransform.hpp" -#include "../JacobianTransforms.hpp" -#include "functions/bases/LagrangeBasis.hpp" -#include "functions/spacing/Spacing.hpp" -#include "geometry/shapes/InterpolatedShape.hpp" +#include "shiva/geometry/shapes/NCube.hpp" +#include "shiva/geometry/mapping/LinearTransform.hpp" +#include "shiva/geometry/mapping/JacobianTransforms.hpp" +#include "shiva/functions/bases/LagrangeBasis.hpp" +#include "shiva/functions/spacing/Spacing.hpp" +#include "shiva/geometry/shapes/InterpolatedShape.hpp" -#include "common/pmpl.hpp" +#include "shiva/common/pmpl.hpp" #include diff --git a/tests/geometry/mapping/testScaling.cpp b/tests/geometry/mapping/testScaling.cpp index b83bbb2..7a481da 100644 --- a/tests/geometry/mapping/testScaling.cpp +++ b/tests/geometry/mapping/testScaling.cpp @@ -12,9 +12,9 @@ */ -#include "../Scaling.hpp" -#include "../JacobianTransforms.hpp" -#include "common/pmpl.hpp" +#include "shiva/geometry/mapping/Scaling.hpp" +#include "shiva/geometry/mapping/JacobianTransforms.hpp" +#include "shiva/common/pmpl.hpp" #include diff --git a/tests/geometry/mapping/testUniformScaling.cpp b/tests/geometry/mapping/testUniformScaling.cpp index 543ae70..1687633 100644 --- a/tests/geometry/mapping/testUniformScaling.cpp +++ b/tests/geometry/mapping/testUniformScaling.cpp @@ -12,9 +12,9 @@ */ -#include "../UniformScaling.hpp" -#include "../JacobianTransforms.hpp" -#include "common/pmpl.hpp" +#include "shiva/geometry/mapping/UniformScaling.hpp" +#include "shiva/geometry/mapping/JacobianTransforms.hpp" +#include "shiva/common/pmpl.hpp" #include diff --git a/tests/geometry/shapes/testInterpolatedShape.cpp b/tests/geometry/shapes/testInterpolatedShape.cpp index 83dbbaa..3b0436b 100644 --- a/tests/geometry/shapes/testInterpolatedShape.cpp +++ b/tests/geometry/shapes/testInterpolatedShape.cpp @@ -12,12 +12,12 @@ */ -#include "../InterpolatedShape.hpp" -#include "functions/bases/LagrangeBasis.hpp" -#include "functions/spacing/Spacing.hpp" -#include "geometry/shapes/NCube.hpp" -#include "common/ShivaMacros.hpp" -#include "common/pmpl.hpp" +#include "shiva/geometry/shapes/InterpolatedShape.hpp" +#include "shiva/functions/bases/LagrangeBasis.hpp" +#include "shiva/functions/spacing/Spacing.hpp" +#include "shiva/geometry/shapes/NCube.hpp" +#include "shiva/common/ShivaMacros.hpp" +#include "shiva/common/pmpl.hpp" diff --git a/tests/geometry/shapes/testNCube.cpp b/tests/geometry/shapes/testNCube.cpp index 9c7ecc5..afcde80 100644 --- a/tests/geometry/shapes/testNCube.cpp +++ b/tests/geometry/shapes/testNCube.cpp @@ -12,8 +12,8 @@ */ -#include "../NCube.hpp" -#include "common/pmpl.hpp" +#include "shiva/geometry/shapes/NCube.hpp" +#include "shiva/common/pmpl.hpp" #include diff --git a/tests/geometry/shapes/testNSimplex.cpp b/tests/geometry/shapes/testNSimplex.cpp index bf0302c..5964c51 100644 --- a/tests/geometry/shapes/testNSimplex.cpp +++ b/tests/geometry/shapes/testNSimplex.cpp @@ -12,8 +12,8 @@ */ -#include "../NSimplex.hpp" -#include "common/pmpl.hpp" +#include "shiva/geometry/shapes/NSimplex.hpp" +#include "shiva/common/pmpl.hpp" #include From a646418e3c626d70ee32b2c522b67156a324f727 Mon Sep 17 00:00:00 2001 From: Randolph Settgast Date: Sun, 14 Sep 2025 23:50:48 -0700 Subject: [PATCH 06/12] add missing file --- cmake/ShivaConfig.cmake.in | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 cmake/ShivaConfig.cmake.in diff --git a/cmake/ShivaConfig.cmake.in b/cmake/ShivaConfig.cmake.in new file mode 100644 index 0000000..5310614 --- /dev/null +++ b/cmake/ShivaConfig.cmake.in @@ -0,0 +1,12 @@ +# cmake/ShivaConfig.cmake.in +@PACKAGE_INIT@ # sets up PACKAGE_PREFIX_DIR etc. + +# If Shiva has installed-time deps, find them here (optional): +include(CMakeFindDependencyMacro) +# find_dependency(camp CONFIG) # uncomment if you install+use camp externally + +# Import the exported targets for this package +include("${CMAKE_CURRENT_LIST_DIR}/ShivaTargets.cmake") + +# (Optional) convenience vars +set(Shiva_INCLUDE_DIRS "${PACKAGE_PREFIX_DIR}/@CMAKE_INSTALL_INCLUDEDIR@") From 7523a2730464ab88db5098c6b15d4dead3414bb1 Mon Sep 17 00:00:00 2001 From: Randolph Settgast Date: Mon, 15 Sep 2025 00:22:54 -0700 Subject: [PATCH 07/12] submodule updates and more cleanup --- CMakeLists.txt | 31 +++++++++++++--------------- cmake/CMakeBasics.cmake | 40 ------------------------------------- cmake/Config.cmake | 15 ++++++-------- cmake/blt | 2 +- cmake/shiva-config.cmake.in | 11 ---------- tests/CMakeLists.txt | 7 +++++++ tpl/camp | 2 +- 7 files changed, 29 insertions(+), 79 deletions(-) delete mode 100644 cmake/CMakeBasics.cmake delete mode 100644 cmake/shiva-config.cmake.in diff --git a/CMakeLists.txt b/CMakeLists.txt index e102148..d79b1ff 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,10 +5,12 @@ project(Shiva VERSION 0.1.0) include(GNUInstallDirs) # -------- Options (lean) ------------------------------------------------------- -option(SHIVA_USE_CUDA "Enable CUDA code paths in headers (interface define only)" OFF) -option(SHIVA_USE_HIP "Enable HIP code paths in headers (interface define only)" OFF) -option(SHIVA_ENABLE_UNIT_TESTS "Build unit tests (standalone only)" ON) -option(SHIVA_ENABLE_CAMP "Link against CAMP if available" OFF) +option( SHIVA_USE_CUDA "Enable CUDA code paths in headers (interface define only)" OFF ) +option( SHIVA_USE_HIP "Enable HIP code paths in headers (interface define only)" OFF ) +option( SHIVA_ENABLE_UNIT_TESTS "Build unit tests (standalone only)" ON ) +option( SHIVA_ENABLE_CAMP "Link against CAMP if available" OFF ) +option( SHIVA_BUILD_OBJ_LIBS "Build object libraries...useful for dependency trees" OFF ) +option( SHIVA_ENABLE_BOUNDS_CHECK "Enable bounds checking in shiva::CArray" OFF ) # Top-level or subproject? set(SHIVA_IS_TOPLEVEL "${PROJECT_IS_TOP_LEVEL}") @@ -25,20 +27,15 @@ include("${CMAKE_CURRENT_LIST_DIR}/cmake/Config.cmake") add_library(Shiva INTERFACE) add_library(Shiva::shiva ALIAS Shiva) -target_include_directories(Shiva INTERFACE - "$" # include/shiva/... - "$" # build/include/shiva/ShivaConfig.hpp - "$" -) + + +target_include_directories( Shiva INTERFACE + "$" # include/shiva/... + "$" # build/include/shiva/ShivaConfig.hpp + "$" ) target_compile_features(Shiva INTERFACE cxx_std_17) -if (SHIVA_USE_CUDA) - target_compile_definitions(Shiva INTERFACE SHIVA_USE_CUDA=1) -endif() -if (SHIVA_USE_HIP) - target_compile_definitions(Shiva INTERFACE SHIVA_USE_HIP=1) -endif() # Optional CAMP wiring (no BLT required here) if (SHIVA_ENABLE_CAMP) @@ -53,9 +50,9 @@ if (SHIVA_ENABLE_CAMP) endif() endif() -# -------- Tests (BLT only when standalone) ------------------------------------- +# -------- Tests (BLT only when standalone for testing and documentation ) ------ if (SHIVA_IS_TOPLEVEL AND SHIVA_ENABLE_UNIT_TESTS) - include(CTest) + set(BLT_CXX_STD "c++17") # Load BLT you vendor under cmake/blt set(BLT_SOURCE_DIR "${PROJECT_SOURCE_DIR}/cmake/blt" CACHE PATH "Path to BLT") if (NOT EXISTS "${BLT_SOURCE_DIR}/SetupBLT.cmake") diff --git a/cmake/CMakeBasics.cmake b/cmake/CMakeBasics.cmake deleted file mode 100644 index caaf03e..0000000 --- a/cmake/CMakeBasics.cmake +++ /dev/null @@ -1,40 +0,0 @@ -set(CMAKE_ENABLE_EXPORTS ON) - -if( CMAKE_BUILD_TYPE MATCHES "Debug" ) - -else() - -endif() - -set( SHIVA_BUILD_OBJ_LIBS OFF CACHE BOOL "" ) - - -option( SHIVA_ENABLE_BOUNDS_CHECK "Enable bounds checking in shiva::CArray" ON ) - - -if( CMAKE_CXX_STANDARD IN_LIST "98; 11; 14" ) - MESSAGE(FATAL_ERROR "Shiva requires at least c++17") -endif() - - -set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS} -Wpedantic -pedantic-errors -Wshadow -Wfloat-equal -Wcast-align -Wcast-qual" ) - -if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") # For Clang or AppleClang - set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fstandalone-debug" ) -endif() - - - -if( ENABLE_CUDA ) - if( CUDA_VERSION AND CUDA_VERSION_MAJOR AND CUDA_VERSION_MINOR ) - set( SHIVA_CUDA_VERSION ${CUDA_VERSION} ) - set( SHIVA_CUDA_MAJOR ${CUDA_VERSION_MAJOR} ) - set( SHIVA_CUDA_MINOR ${CUDA_VERSION_MINOR} ) - else() - message(FATAL_ERROR "CUDA_VERSION_MAJOR and CUDA_VERSION_MINOR not defined") - endif() -else() - set( SHIVA_CUDA_VERSION 0 ) - set( SHIVA_CUDA_MAJOR 0 ) - set( SHIVA_CUDA_MINOR 0 ) -endif() diff --git a/cmake/Config.cmake b/cmake/Config.cmake index 5ddd4df..1a59041 100644 --- a/cmake/Config.cmake +++ b/cmake/Config.cmake @@ -65,20 +65,17 @@ message( "SHIVA_BINARY_DIR = ${SHIVA_BINARY_DIR}" ) file(MAKE_DIRECTORY "${_shiva_gen_inc}") configure_file( "${SHIVA_SOURCE_DIR}/include/shiva/ShivaConfig.hpp.in" - "${_shiva_gen_inc}/ShivaConfig.hpp" -) + "${_shiva_gen_inc}/ShivaConfig.hpp" ) # Optional: a copy for Doxygen without touching the source tree set(_shiva_gen_doc "${SHIVA_BINARY_DIR}/docs/doxygen") file(MAKE_DIRECTORY "${_shiva_gen_doc}") -configure_file( - "${SHIVA_SOURCE_DIR}/include/shiva/ShivaConfig.hpp.in" - "${_shiva_gen_doc}/ShivaConfig.hpp" -) +configure_file( "${SHIVA_SOURCE_DIR}/include/shiva/ShivaConfig.hpp.in" + "${_shiva_gen_doc}/ShivaConfig.hpp" ) # Install the generated header (binary include tree) -install(FILES "${_shiva_gen_inc}/ShivaConfig.hpp" - DESTINATION include) +install( FILES "${_shiva_gen_inc}/ShivaConfig.hpp" + DESTINATION include ) -message(STATUS "Shiva config header -> ${SHIVA_BINARY_DIR}/include/ShivaConfig.hpp") +message( STATUS "Shiva config header -> ${SHIVA_BINARY_DIR}/include/ShivaConfig.hpp" ) diff --git a/cmake/blt b/cmake/blt index 9ff7734..e783e30 160000 --- a/cmake/blt +++ b/cmake/blt @@ -1 +1 @@ -Subproject commit 9ff77344f0b2a6ee345e452bddd6bfd46cbbfa35 +Subproject commit e783e30f2823ee1a208f7f90741b41c1f5a08063 diff --git a/cmake/shiva-config.cmake.in b/cmake/shiva-config.cmake.in deleted file mode 100644 index b1cb6c3..0000000 --- a/cmake/shiva-config.cmake.in +++ /dev/null @@ -1,11 +0,0 @@ -if( NOT SHIVA_FOUND ) - include(${CMAKE_CURRENT_LIST_DIR}/../../../lib/cmake/shiva/shiva.cmake) - - - set(SHIVA_FOUND TRUE) - - # Export version number - set( SHIVA_VERSION_MAJOR @SHIVA_VERSION_MAJOR@ ) - set( SHIVA_VERSION_MINOR @SHIVA_VERSION_MINOR@ ) - set( SHIVA_VERSION_PATCHLEVEL @SHIVA_VERSION_PATCHLEVEL@ ) -endif() \ No newline at end of file diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index ef6feb8..f8c83ad 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -14,6 +14,13 @@ if(NOT DEFINED TEST_OUTPUT_DIRECTORY) set(TEST_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/tests") endif() +set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS} -Wpedantic -pedantic-errors -Wshadow -Wfloat-equal -Wcast-align -Wcast-qual" ) + +if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") # For Clang or AppleClang + set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fstandalone-debug" ) +endif() + + macro(shiva_add_gtest) set(options) set(oneValueArgs NAME) diff --git a/tpl/camp b/tpl/camp index 0f07de4..4070ce9 160000 --- a/tpl/camp +++ b/tpl/camp @@ -1 +1 @@ -Subproject commit 0f07de4240c42e0b38a8d872a20440cb4b33d9f5 +Subproject commit 4070ce93a802849d61037310a87c50cc24c9e498 From 51397ad7a831ad72aa25eee89a9b450549eda384 Mon Sep 17 00:00:00 2001 From: Randolph Settgast Date: Mon, 15 Sep 2025 01:40:51 -0700 Subject: [PATCH 08/12] cleanup --- CMakeLists.txt | 130 ++++++++++-------- cmake/Config.cmake | 56 +------- docs/doxygen/ShivaConfig.hpp | 10 +- hostconfigs/apple/macOS_base.cmake | 4 +- include/shiva/ShivaConfig.hpp.in | 8 +- include/shiva/common/CArray.hpp | 2 +- include/shiva/common/CArrayHelper.hpp | 2 +- include/shiva/common/ShivaMacros.hpp | 8 +- include/shiva/common/pmpl.hpp | 12 +- include/shiva/common/types.hpp | 8 +- tests/common/testCArray.cpp | 8 +- tests/common/testNestedSequenceUtilities.cpp | 2 +- tests/common/testSequenceUtilities.cpp | 2 +- .../finiteElementMethod/testParentElement.cpp | 4 +- tests/functions/testLagrangeBasis.cpp | 6 +- tests/functions/testSpacing.cpp | 6 +- .../geometry/mapping/testLinearTransform.cpp | 2 +- tests/geometry/mapping/testScaling.cpp | 2 +- tests/geometry/mapping/testUniformScaling.cpp | 2 +- .../geometry/shapes/testInterpolatedShape.cpp | 4 +- 20 files changed, 125 insertions(+), 153 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d79b1ff..ad087b1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,30 +5,35 @@ project(Shiva VERSION 0.1.0) include(GNUInstallDirs) # -------- Options (lean) ------------------------------------------------------- -option( SHIVA_USE_CUDA "Enable CUDA code paths in headers (interface define only)" OFF ) -option( SHIVA_USE_HIP "Enable HIP code paths in headers (interface define only)" OFF ) +option( SHIVA_ENABLE_BLT "Enable BLT integration (testing, packaging, etc.)" OFF ) +option( SHIVA_ENABLE_CUDA "Enable CUDA code paths in headers (interface define only)" OFF ) +option( SHIVA_ENABLE_HIP "Enable HIP code paths in headers (interface define only)" OFF ) option( SHIVA_ENABLE_UNIT_TESTS "Build unit tests (standalone only)" ON ) option( SHIVA_ENABLE_CAMP "Link against CAMP if available" OFF ) option( SHIVA_BUILD_OBJ_LIBS "Build object libraries...useful for dependency trees" OFF ) option( SHIVA_ENABLE_BOUNDS_CHECK "Enable bounds checking in shiva::CArray" OFF ) + +if( SHIVA_ENABLE_CUDA AND SHIVA_ENABLE_HIP ) + message( FATAL_ERROR "CUDA and HIP are mutually exclusive; enable only one." ) +endif() + + # Top-level or subproject? -set(SHIVA_IS_TOPLEVEL "${PROJECT_IS_TOP_LEVEL}") +set( SHIVA_IS_TOPLEVEL "${PROJECT_IS_TOP_LEVEL}" ) # Convenience dirs -set(SHIVA_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") -set(SHIVA_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}") +set( SHIVA_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}" ) +set( SHIVA_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}" ) # -------- Generate config header ---------------------------------------------- # Expects: include/shiva/ShivaConfig.hpp.in -include("${CMAKE_CURRENT_LIST_DIR}/cmake/Config.cmake") +include( "${CMAKE_CURRENT_LIST_DIR}/cmake/Config.cmake" ) # -------- Header-only target --------------------------------------------------- add_library(Shiva INTERFACE) add_library(Shiva::shiva ALIAS Shiva) - - target_include_directories( Shiva INTERFACE "$" # include/shiva/... "$" # build/include/shiva/ShivaConfig.hpp @@ -37,62 +42,73 @@ target_include_directories( Shiva INTERFACE target_compile_features(Shiva INTERFACE cxx_std_17) -# Optional CAMP wiring (no BLT required here) -if (SHIVA_ENABLE_CAMP) - find_package(camp CONFIG QUIET) - if (TARGET camp) - target_link_libraries(Shiva INTERFACE camp) - elseif (SHIVA_IS_TOPLEVEL) - add_subdirectory(tpl/camp) # vendored fallback when standalone - target_link_libraries(Shiva INTERFACE camp) + + +# -------- BLT (optional; usable as top-level or submodule) --------------------- +if( SHIVA_ENABLE_BLT ) + set( BLT_CXX_STD "c++17" ) + # Load BLT if Shiva is standalone + if( SHIVA_IS_TOPLEVEL ) + set(BLT_SOURCE_DIR "${PROJECT_SOURCE_DIR}/cmake/blt" CACHE PATH "Path to BLT") + if (NOT EXISTS "${BLT_SOURCE_DIR}/SetupBLT.cmake") + message(FATAL_ERROR "BLT not found at '${BLT_SOURCE_DIR}'.") + endif() + include("${BLT_SOURCE_DIR}/SetupBLT.cmake") else() - message(FATAL_ERROR "CAMP not found; enable it only if the parent provides it or build standalone.") + + + endif( SHIVA_IS_TOPLEVEL ) + + + if( BLT_LOADED ) + message( STATUS "BLT loaded successfully." ) + else() + message( FATAL_ERROR "BLT requested but failed to load." ) + endif( BLT_LOADED ) + + if( SHIVA_ENABLE_CAMP ) + add_subdirectory(tpl/camp) # vendored fallback when standalone + target_link_libraries(Shiva INTERFACE camp) endif() -endif() -# -------- Tests (BLT only when standalone for testing and documentation ) ------ -if (SHIVA_IS_TOPLEVEL AND SHIVA_ENABLE_UNIT_TESTS) - set(BLT_CXX_STD "c++17") - # Load BLT you vendor under cmake/blt - set(BLT_SOURCE_DIR "${PROJECT_SOURCE_DIR}/cmake/blt" CACHE PATH "Path to BLT") - if (NOT EXISTS "${BLT_SOURCE_DIR}/SetupBLT.cmake") - message(FATAL_ERROR "BLT not found at '${BLT_SOURCE_DIR}'.") + if( SHIVA_ENABLE_UNIT_TESTS ) + # Enable GPU languages **only** for tests/examples at the top level + if ( SHIVA_ENABLE_CUDA AND NOT CMAKE_CUDA_COMPILER ) + enable_language ( CUDA ) + endif () + if ( SHIVA_ENABLE_HIP AND NOT CMAKE_HIP_COMPILER ) + enable_language ( HIP ) + endif () + + add_subdirectory(tests) endif() - include("${BLT_SOURCE_DIR}/SetupBLT.cmake") - add_subdirectory(tests) -endif() + +endif( SHIVA_ENABLE_BLT) # -------- Install & package ---------------------------------------------------- install(TARGETS Shiva EXPORT ShivaTargets) # Install public headers and generated config header tree -install(DIRECTORY "${SHIVA_SOURCE_DIR}/include/" - DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") -install(DIRECTORY "${SHIVA_BINARY_DIR}/include/" - DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" - OPTIONAL) - -include(CMakePackageConfigHelpers) - -write_basic_package_version_file( - "${CMAKE_CURRENT_BINARY_DIR}/ShivaConfigVersion.cmake" - VERSION "${PROJECT_VERSION}" - COMPATIBILITY SameMajorVersion -) -configure_package_config_file( - "${CMAKE_CURRENT_LIST_DIR}/cmake/ShivaConfig.cmake.in" - "${CMAKE_CURRENT_BINARY_DIR}/ShivaConfig.cmake" - INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/Shiva" -) - -install(FILES - "${CMAKE_CURRENT_BINARY_DIR}/ShivaConfig.cmake" - "${CMAKE_CURRENT_BINARY_DIR}/ShivaConfigVersion.cmake" - DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/Shiva" -) -install(EXPORT ShivaTargets - FILE ShivaTargets.cmake - NAMESPACE Shiva:: - DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/Shiva" -) +install( DIRECTORY "${SHIVA_SOURCE_DIR}/include/" + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" ) +install( DIRECTORY "${SHIVA_BINARY_DIR}/include/" + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" + OPTIONAL ) + +include( CMakePackageConfigHelpers ) + +write_basic_package_version_file( "${CMAKE_CURRENT_BINARY_DIR}/ShivaConfigVersion.cmake" + VERSION "${PROJECT_VERSION}" + COMPATIBILITY SameMajorVersion ) + +configure_package_config_file( "${CMAKE_CURRENT_LIST_DIR}/cmake/ShivaConfig.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/ShivaConfig.cmake" + INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/Shiva" ) + +install( FILES "${CMAKE_CURRENT_BINARY_DIR}/ShivaConfig.cmake" "${CMAKE_CURRENT_BINARY_DIR}/ShivaConfigVersion.cmake" + DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/Shiva" ) +install( EXPORT ShivaTargets + FILE ShivaTargets.cmake + NAMESPACE Shiva:: + DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/Shiva" ) diff --git a/cmake/Config.cmake b/cmake/Config.cmake index 1a59041..0a04996 100644 --- a/cmake/Config.cmake +++ b/cmake/Config.cmake @@ -1,49 +1,17 @@ # cmake/Config.cmake include_guard(DIRECTORY) -# Expect these to be set by the parent CMakeLists: -# - SHIVA_SOURCE_DIR -# - SHIVA_BINARY_DIR - -# ---------- Feature switches (normalize to SHIVA_USE_* booleans) ---------- -# Start from user options if you expose them; fall back to CMake signals. - -# CUDA -if (DEFINED SHIVA_USE_CUDA) - # keep as-is -elseif (CMAKE_CUDA_COMPILER) - set(SHIVA_USE_CUDA TRUE) -else() - set(SHIVA_USE_CUDA FALSE) -endif() - -# HIP -if (DEFINED SHIVA_USE_HIP) - # keep as-is -elseif (DEFINED HIP_FOUND OR CMAKE_HIP_COMPILER) - set(SHIVA_USE_HIP TRUE) -else() - set(SHIVA_USE_HIP FALSE) -endif() - -# CAMP -if (DEFINED SHIVA_USE_CAMP) - # keep as-is -elseif (DEFINED SHIVA_ENABLE_CAMP) - set(SHIVA_USE_CAMP "${SHIVA_ENABLE_CAMP}") -else() - set(SHIVA_USE_CAMP FALSE) -endif() +# ---------- Version numbers expected by the header ---------- +# Your header expects *_PATCHLEVEL; map from project() version. +set(SHIVA_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}") +set(SHIVA_VERSION_MINOR "${PROJECT_VERSION_MINOR}") +set(SHIVA_VERSION_PATCHLEVEL "${PROJECT_VERSION_PATCH}") -# BOUNDS_CHECK (provide an option upstream if you want this user-tunable) -if (NOT DEFINED SHIVA_USE_BOUNDS_CHECK) - set(SHIVA_USE_BOUNDS_CHECK FALSE) -endif() # ---------- CUDA version numbers (if available) ---------- set(SHIVA_CUDA_MAJOR 0) set(SHIVA_CUDA_MINOR 0) -if (SHIVA_USE_CUDA AND DEFINED CMAKE_CUDA_COMPILER_VERSION) +if (SHIVA_ENABLE_CUDA AND DEFINED CMAKE_CUDA_COMPILER_VERSION) # CMAKE_CUDA_COMPILER_VERSION like "12.4" string(REPLACE "." ";" _cuda_ver_list "${CMAKE_CUDA_COMPILER_VERSION}") list(GET _cuda_ver_list 0 SHIVA_CUDA_MAJOR) @@ -53,11 +21,6 @@ if (SHIVA_USE_CUDA AND DEFINED CMAKE_CUDA_COMPILER_VERSION) endif() endif() -# ---------- Version numbers expected by the header ---------- -# Your header expects *_PATCHLEVEL; map from project() version. -set(SHIVA_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}") -set(SHIVA_VERSION_MINOR "${PROJECT_VERSION_MINOR}") -set(SHIVA_VERSION_PATCHLEVEL "${PROJECT_VERSION_PATCH}") # ---------- Emit the generated header(s) ---------- set(_shiva_gen_inc "${SHIVA_BINARY_DIR}/include/shiva") @@ -72,10 +35,3 @@ set(_shiva_gen_doc "${SHIVA_BINARY_DIR}/docs/doxygen") file(MAKE_DIRECTORY "${_shiva_gen_doc}") configure_file( "${SHIVA_SOURCE_DIR}/include/shiva/ShivaConfig.hpp.in" "${_shiva_gen_doc}/ShivaConfig.hpp" ) - -# Install the generated header (binary include tree) -install( FILES "${_shiva_gen_inc}/ShivaConfig.hpp" - DESTINATION include ) - - -message( STATUS "Shiva config header -> ${SHIVA_BINARY_DIR}/include/ShivaConfig.hpp" ) diff --git a/docs/doxygen/ShivaConfig.hpp b/docs/doxygen/ShivaConfig.hpp index 222aa09..b590b18 100644 --- a/docs/doxygen/ShivaConfig.hpp +++ b/docs/doxygen/ShivaConfig.hpp @@ -8,15 +8,15 @@ #define SHIVA_VERSION_PATCHLEVEL -/* #undef SHIVA_USE_CUDA */ +/* #undef SHIVA_ENABLE_CUDA */ -/* #undef SHIVA_USE_HIP */ +/* #undef SHIVA_ENABLE_HIP */ -/* #undef SHIVA_USE_CALIPER */ +/* #undef SHIVA_ENABLE_CALIPER */ -/* #undef SHIVA_USE_CAMP */ +/* #undef SHIVA_ENABLE_CAMP */ -/* #undef SHIVA_USE_BOUNDS_CHECK */ +/* #undef SHIVA_ENABLE_BOUNDS_CHECK */ #define SHIVA_CUDA_MAJOR #define SHIVA_CUDA_MINOR diff --git a/hostconfigs/apple/macOS_base.cmake b/hostconfigs/apple/macOS_base.cmake index 4206551..9022409 100644 --- a/hostconfigs/apple/macOS_base.cmake +++ b/hostconfigs/apple/macOS_base.cmake @@ -27,6 +27,6 @@ set( CLANGTIDY_EXECUTABLE "${HOMEBREW_DIR}/opt/llvm/bin/clang-tidy" CACHE PATH " set( ENABLE_COVERAGE OFF CACHE BOOL "" FORCE) set( GCOV_EXECUTABLE "/usr/bin/gcov" CACHE PATH "" FORCE) set( LCOV_EXECUTABLE "${HOMEBREW_DIR}/bin/lcov" CACHE PATH "" FORCE) +set( SHIVA_ENABLE_BOUNDS_CHECK ON CACHE BOOL "" FORCE) - -set(SHIVA_BUILD_OBJ_LIBS ON CACHE BOOL "" FORCE) +set( SHIVA_ENABLE_BLT ON CACHE BOOL "" FORCE) \ No newline at end of file diff --git a/include/shiva/ShivaConfig.hpp.in b/include/shiva/ShivaConfig.hpp.in index 2b9a173..f147792 100644 --- a/include/shiva/ShivaConfig.hpp.in +++ b/include/shiva/ShivaConfig.hpp.in @@ -8,13 +8,13 @@ #define SHIVA_VERSION_PATCHLEVEL @SHIVA_VERSION_PATCHLEVEL@ -#cmakedefine SHIVA_USE_CUDA +#cmakedefine SHIVA_ENABLE_CUDA -#cmakedefine SHIVA_USE_HIP +#cmakedefine SHIVA_ENABLE_HIP -#cmakedefine SHIVA_USE_CAMP +#cmakedefine SHIVA_ENABLE_CAMP -#cmakedefine SHIVA_USE_BOUNDS_CHECK +#cmakedefine SHIVA_ENABLE_BOUNDS_CHECK #define SHIVA_CUDA_MAJOR @SHIVA_CUDA_MAJOR@ #define SHIVA_CUDA_MINOR @SHIVA_CUDA_MINOR@ diff --git a/include/shiva/common/CArray.hpp b/include/shiva/common/CArray.hpp index 514f09e..d7cb7d5 100644 --- a/include/shiva/common/CArray.hpp +++ b/include/shiva/common/CArray.hpp @@ -230,7 +230,7 @@ CArray< T, DATA_BUFFER, DIMS ... >::squareBracketOperatorHelper( index_type inde { static_assert( sizeof...(DIMS) >= 1, "operator[] is only valid for sizeof...(DIMS) >= 1" ); -#if defined( SHIVA_USE_BOUNDS_CHECK ) +#if defined( SHIVA_ENABLE_BOUNDS_CHECK ) constexpr int DIM = CArrayHelper::IntPeeler< DIMS... >::first; SHIVA_ASSERT_MSG( index >= 0 && index < DIM, "Index out of bounds: 0 < index(%jd) < dim(%jd)", diff --git a/include/shiva/common/CArrayHelper.hpp b/include/shiva/common/CArrayHelper.hpp index 6c81bed..9ec7a1a 100644 --- a/include/shiva/common/CArrayHelper.hpp +++ b/include/shiva/common/CArrayHelper.hpp @@ -113,7 +113,7 @@ struct linearIndexHelper static constexpr SHIVA_HOST_DEVICE SHIVA_FORCE_INLINE int level( INDEX_TYPE const index, INDICES_TYPE const ... indices ) { -#if defined( SHIVA_USE_BOUNDS_CHECK ) +#if defined( SHIVA_ENABLE_BOUNDS_CHECK ) SHIVA_ASSERT_MSG( index >= 0 && index < DIM, "Index out of bounds: 0 < index(%jd) < dim(%jd)", static_cast< intmax_t >( index ), diff --git a/include/shiva/common/ShivaMacros.hpp b/include/shiva/common/ShivaMacros.hpp index 38d7d6b..add0299 100644 --- a/include/shiva/common/ShivaMacros.hpp +++ b/include/shiva/common/ShivaMacros.hpp @@ -26,13 +26,13 @@ #include #include -#if defined( SHIVA_USE_HIP ) +#if defined( SHIVA_ENABLE_HIP ) #include #endif -#if defined(SHIVA_USE_CUDA) || defined(SHIVA_USE_HIP) +#if defined(SHIVA_ENABLE_CUDA) || defined(SHIVA_ENABLE_HIP) /// This macro is used to indicate that the code is being compiled for device. -#define SHIVA_USE_DEVICE +#define SHIVA_ENABLE_DEVICE #endif #if defined( __CUDA_ARCH__ ) || defined( __HIP_DEVICE_COMPILE__ ) @@ -40,7 +40,7 @@ #endif -#if defined(SHIVA_USE_DEVICE) +#if defined(SHIVA_ENABLE_DEVICE) /// This macro is used to indicate that the code is being compiled for host /// execution. #define SHIVA_HOST __host__ diff --git a/include/shiva/common/pmpl.hpp b/include/shiva/common/pmpl.hpp index eb8d3b8..a6f133e 100644 --- a/include/shiva/common/pmpl.hpp +++ b/include/shiva/common/pmpl.hpp @@ -27,8 +27,8 @@ #include namespace shiva { -#if defined(SHIVA_USE_DEVICE) -#if defined(SHIVA_USE_CUDA) +#if defined(SHIVA_ENABLE_DEVICE) +#if defined(SHIVA_ENABLE_CUDA) #define deviceMalloc( PTR, BYTES ) cudaMalloc( PTR, BYTES ); #define deviceMallocManaged( PTR, BYTES ) cudaMallocManaged( PTR, BYTES ); #define deviceDeviceSynchronize() cudaDeviceSynchronize(); @@ -38,7 +38,7 @@ namespace shiva #define deviceGetErrorString cudaGetErrorString #define deviceMemcpyDeviceToHost cudaMemcpyDeviceToHost constexpr cudaError_t deviceSuccess = cudaSuccess; -#elif defined(SHIVA_USE_HIP) +#elif defined(SHIVA_ENABLE_HIP) #define deviceMalloc( PTR, BYTES ) hipMalloc( PTR, BYTES ); #define deviceMallocManaged( PTR, BYTES ) hipMallocManaged( PTR, BYTES ); #define deviceDeviceSynchronize() hipDeviceSynchronize(); @@ -99,7 +99,7 @@ SHIVA_GLOBAL void genericKernel( LAMBDA func ) template< typename LAMBDA > void genericKernelWrapper( LAMBDA && func, bool const abortOnError = true ) { -#if defined(SHIVA_USE_DEVICE) +#if defined(SHIVA_ENABLE_DEVICE) // UNCRUSTIFY-OFF genericKernel <<< 1, 1 >>> ( std::forward< LAMBDA >( func ) ); // UNCRUSTIFY-ON @@ -156,7 +156,7 @@ template< typename DATA_TYPE, typename LAMBDA > void genericKernelWrapper( int const N, DATA_TYPE * const hostData, LAMBDA && func, bool const abortOnError = true ) { -#if defined(SHIVA_USE_DEVICE) +#if defined(SHIVA_ENABLE_DEVICE) DATA_TYPE * deviceData; deviceMalloc( &deviceData, N * sizeof(DATA_TYPE) ); deviceMemCpy( deviceData, hostData, N * sizeof(DATA_TYPE), cudaMemcpyHostToDevice ); @@ -192,7 +192,7 @@ void genericKernelWrapper( int const N, DATA_TYPE * const hostData, LAMBDA && fu template< typename DATA_TYPE > SHIVA_CONSTEXPR_HOSTDEVICE_FORCEINLINE void deallocateData( DATA_TYPE * data ) { -#if defined(SHIVA_USE_DEVICE) +#if defined(SHIVA_ENABLE_DEVICE) deviceFree( data ); #else delete[] data; diff --git a/include/shiva/common/types.hpp b/include/shiva/common/types.hpp index 8386479..3db772f 100644 --- a/include/shiva/common/types.hpp +++ b/include/shiva/common/types.hpp @@ -20,11 +20,11 @@ #include "shiva/common/ShivaMacros.hpp" /// @brief Macro to define whether or not to use camp. -#if defined(SHIVA_USE_CAMP) +#if defined(SHIVA_ENABLE_CAMP) #include #else -#if defined(SHIVA_USE_CUDA) +#if defined(SHIVA_ENABLE_CUDA) #include #else #include @@ -35,7 +35,7 @@ namespace shiva { -#if defined(SHIVA_USE_CAMP) +#if defined(SHIVA_ENABLE_CAMP) /** * @brief Wrapper for camp::tuple. @@ -59,7 +59,7 @@ make_tuple( T && ... t ) } #else -#if defined(SHIVA_USE_CUDA) +#if defined(SHIVA_ENABLE_CUDA) /** * @brief Wrapper for cuda::std::tuple. * @tparam T Types of the elements of the tuple. diff --git a/tests/common/testCArray.cpp b/tests/common/testCArray.cpp index c744fc0..739048c 100644 --- a/tests/common/testCArray.cpp +++ b/tests/common/testCArray.cpp @@ -132,7 +132,7 @@ TEST( testCArray, testStrides ) testStridesHelper(); } -#if !defined( SHIVA_USE_BOUNDS_CHECK ) || !defined(SHIVA_USE_DEVICE) +#if !defined( SHIVA_ENABLE_BOUNDS_CHECK ) || !defined(SHIVA_ENABLE_DEVICE) void testLinearIndexCT() { pmpl::genericKernelWrapper( [] SHIVA_DEVICE () @@ -192,13 +192,13 @@ void testLinearIndexRT() TEST( testCArray, testLinearIndex ) { -#if !defined( SHIVA_USE_BOUNDS_CHECK ) || !defined(SHIVA_USE_DEVICE) +#if !defined( SHIVA_ENABLE_BOUNDS_CHECK ) || !defined(SHIVA_ENABLE_DEVICE) testLinearIndexCT(); #endif testLinearIndexRT(); } -#if !defined( SHIVA_USE_BOUNDS_CHECK ) || !defined(SHIVA_USE_DEVICE) +#if !defined( SHIVA_ENABLE_BOUNDS_CHECK ) || !defined(SHIVA_ENABLE_DEVICE) void testParenthesesOperatorCT() { using Array = TestCArrayHelper::Array3d; @@ -264,7 +264,7 @@ void testParenthesesOperatorRT() } TEST( testCArray, testParenthesesOperator ) { -#if !defined( SHIVA_USE_BOUNDS_CHECK ) || !defined(SHIVA_USE_DEVICE) +#if !defined( SHIVA_ENABLE_BOUNDS_CHECK ) || !defined(SHIVA_ENABLE_DEVICE) testParenthesesOperatorCT(); #endif testParenthesesOperatorRT(); diff --git a/tests/common/testNestedSequenceUtilities.cpp b/tests/common/testNestedSequenceUtilities.cpp index 622eff8..fc51356 100644 --- a/tests/common/testNestedSequenceUtilities.cpp +++ b/tests/common/testNestedSequenceUtilities.cpp @@ -37,7 +37,7 @@ SHIVA_GLOBAL void testSequenceExpansionHelper( FUNC func ) template< typename FUNC > void kernelLaunch( FUNC && func ) { -#if defined(SHIVA_USE_DEVICE) +#if defined(SHIVA_ENABLE_DEVICE) testSequenceExpansionHelper << < 1, 1 >> > ( std::forward< FUNC >( func ) ); #else testSequenceExpansionHelper( std::forward< FUNC >( func ) ); diff --git a/tests/common/testSequenceUtilities.cpp b/tests/common/testSequenceUtilities.cpp index 7b012ee..c0a6ae1 100644 --- a/tests/common/testSequenceUtilities.cpp +++ b/tests/common/testSequenceUtilities.cpp @@ -35,7 +35,7 @@ SHIVA_GLOBAL void testSequenceExpansionHelper( FUNC func ) template< typename FUNC > void kernelLaunch( FUNC && func ) { -#if defined(SHIVA_USE_DEVICE) +#if defined(SHIVA_ENABLE_DEVICE) testSequenceExpansionHelper << < 1, 1 >> > ( std::forward< FUNC >( func ) ); #else testSequenceExpansionHelper( std::forward< FUNC >( func ) ); diff --git a/tests/discretizations/finiteElementMethod/testParentElement.cpp b/tests/discretizations/finiteElementMethod/testParentElement.cpp index 63dd5bd..9931904 100644 --- a/tests/discretizations/finiteElementMethod/testParentElement.cpp +++ b/tests/discretizations/finiteElementMethod/testParentElement.cpp @@ -132,7 +132,7 @@ SHIVA_GLOBAL void compileTimeKernel() template< typename TEST_PARENT_ELEMENT_HELPER > void testParentElementAtCompileTime() { -#if defined(SHIVA_USE_DEVICE) +#if defined(SHIVA_ENABLE_DEVICE) compileTimeKernel< TEST_PARENT_ELEMENT_HELPER ><< < 1, 1 >> > (); #else compileTimeKernel< TEST_PARENT_ELEMENT_HELPER >(); @@ -169,7 +169,7 @@ void testParentElementAtRunTime() fieldValues.data()[i] = TEST_PARENT_ELEMENT_HELPER::fieldValues.data()[i]; } -#if defined(SHIVA_USE_DEVICE) +#if defined(SHIVA_ENABLE_DEVICE) constexpr int bytes = sizeof(double); double * value; double * gradient; diff --git a/tests/functions/testLagrangeBasis.cpp b/tests/functions/testLagrangeBasis.cpp index b75955c..07fcb4e 100644 --- a/tests/functions/testLagrangeBasis.cpp +++ b/tests/functions/testLagrangeBasis.cpp @@ -70,7 +70,7 @@ SHIVA_GLOBAL void compileTimeKernel() template< typename BASIS_HELPER_TYPE > void testBasisAtCompileTime() { -#if defined(SHIVA_USE_DEVICE) +#if defined(SHIVA_ENABLE_DEVICE) compileTimeKernel< BASIS_HELPER_TYPE ><< < 1, 1 >> > (); #else compileTimeKernel< BASIS_HELPER_TYPE >(); @@ -99,7 +99,7 @@ void testBasisAtRunTime() { constexpr int order = BASIS_HELPER_TYPE::order; constexpr int N = order + 1; -#if defined(SHIVA_USE_DEVICE) +#if defined(SHIVA_ENABLE_DEVICE) constexpr int bytes = N * sizeof(double); double * values; double * gradients; @@ -120,7 +120,7 @@ void testBasisAtRunTime() EXPECT_NEAR( gradients[a], BASIS_HELPER_TYPE::refGradients[a], fabs( BASIS_HELPER_TYPE::refGradients[a] * tolerance ) ); } -#if defined(SHIVA_USE_DEVICE) +#if defined(SHIVA_ENABLE_DEVICE) deviceFree( values ); deviceFree( gradients ); #endif diff --git a/tests/functions/testSpacing.cpp b/tests/functions/testSpacing.cpp index 9dfd26b..59f81ac 100644 --- a/tests/functions/testSpacing.cpp +++ b/tests/functions/testSpacing.cpp @@ -122,7 +122,7 @@ void testSpacingValuesAtRuntime() using SpacingType = SPACING< REAL_TYPE, N >; using Ref = ReferenceSolution< SpacingType >; -#if defined(SHIVA_USE_DEVICE) +#if defined(SHIVA_ENABLE_DEVICE) constexpr int bytes = N * sizeof(REAL_TYPE); REAL_TYPE *values; deviceMallocManaged( &values, bytes ); @@ -138,7 +138,7 @@ void testSpacingValuesAtRuntime() EXPECT_NEAR( values[a], Ref::coords[a], 1e-14 ); } -#if defined(SHIVA_USE_DEVICE) +#if defined(SHIVA_ENABLE_DEVICE) deviceFree( values ); #endif } @@ -162,7 +162,7 @@ SHIVA_GLOBAL void compileTimeValuesKernel( std::index_sequence< I... > ) template< template< typename, int > typename SPACING, typename REAL_TYPE, typename INDEX_SEQUENCE > void testSpacingValuesAtCompileTime( INDEX_SEQUENCE iSeq ) { -#if defined(SHIVA_USE_DEVICE) +#if defined(SHIVA_ENABLE_DEVICE) compileTimeValuesKernel< SPACING, REAL_TYPE ><< < 1, 1 >> > ( iSeq ); #else compileTimeValuesKernel< SPACING, REAL_TYPE >( iSeq ); diff --git a/tests/geometry/mapping/testLinearTransform.cpp b/tests/geometry/mapping/testLinearTransform.cpp index 7d78ed9..4c8aa5c 100644 --- a/tests/geometry/mapping/testLinearTransform.cpp +++ b/tests/geometry/mapping/testLinearTransform.cpp @@ -305,7 +305,7 @@ void testInvJacobianFunctionReturnByValueHelper() auto cell = makeLinearTransform( Xref ); for ( int q = 0; q < 8; ++q ) { -#if defined(SHIVA_USE_CUDA) && SHIVA_CUDA_MAJOR < 12 +#if defined(SHIVA_ENABLE_CUDA) && SHIVA_CUDA_MAJOR < 12 auto tmp = inverseJacobian( cell, qCoords[q] ); auto detJ = shiva::get< 0 >( tmp ); auto invJ = shiva::get< 1 >( tmp ); diff --git a/tests/geometry/mapping/testScaling.cpp b/tests/geometry/mapping/testScaling.cpp index 7a481da..4f14fc9 100644 --- a/tests/geometry/mapping/testScaling.cpp +++ b/tests/geometry/mapping/testScaling.cpp @@ -143,7 +143,7 @@ void testInvJacobianFunctionReturnByValueHelper() { auto cell = makeScaling( h ); -#if defined(SHIVA_USE_CUDA) && SHIVA_CUDA_MAJOR < 12 +#if defined(SHIVA_ENABLE_CUDA) && SHIVA_CUDA_MAJOR < 12 auto tmp = inverseJacobian( cell ); auto detJ = shiva::get< 0 >( tmp ); auto invJ = shiva::get< 1 >( tmp ); diff --git a/tests/geometry/mapping/testUniformScaling.cpp b/tests/geometry/mapping/testUniformScaling.cpp index 1687633..ead9f57 100644 --- a/tests/geometry/mapping/testUniformScaling.cpp +++ b/tests/geometry/mapping/testUniformScaling.cpp @@ -100,7 +100,7 @@ TEST( testUniformScaling, testInvJacobianFunctionReturnByValue ) auto cell = makeUniformScaling( h ); // libcudacxx in CUDA 11 lacks SB support for cuda::std::tuple -#if defined(SHIVA_USE_CUDA) && SHIVA_CUDA_MAJOR < 12 +#if defined(SHIVA_ENABLE_CUDA) && SHIVA_CUDA_MAJOR < 12 auto tmp = inverseJacobian( cell ); auto detJ = shiva::get< 0 >( tmp ); auto invJ = shiva::get< 1 >( tmp ); diff --git a/tests/geometry/shapes/testInterpolatedShape.cpp b/tests/geometry/shapes/testInterpolatedShape.cpp index 3b0436b..c1e6cd1 100644 --- a/tests/geometry/shapes/testInterpolatedShape.cpp +++ b/tests/geometry/shapes/testInterpolatedShape.cpp @@ -69,7 +69,7 @@ SHIVA_GLOBAL void compileTimeKernel() template< typename TEST_INTERPOLATED_SHAPE_HELPER > void testInterpolatedShapeAtCompileTime() { -#if defined(SHIVA_USE_DEVICE) +#if defined(SHIVA_ENABLE_DEVICE) compileTimeKernel< TEST_INTERPOLATED_SHAPE_HELPER ><< < 1, 1 >> > (); #else compileTimeKernel< TEST_INTERPOLATED_SHAPE_HELPER >(); @@ -117,7 +117,7 @@ void testInterpolatedShapeAtRunTime() constexpr int order = TEST_INTERPOLATED_SHAPE_HELPER::order; constexpr int N = order + 1; -#if defined(SHIVA_USE_DEVICE) +#if defined(SHIVA_ENABLE_DEVICE) constexpr int bytes = N * N * N * sizeof(double); double * values; double * gradients; From 3ca5b58d4997ea721ceab45264acf6d168668162 Mon Sep 17 00:00:00 2001 From: Randolph Settgast Date: Wed, 24 Sep 2025 19:00:55 -0700 Subject: [PATCH 09/12] reenable code checks while using blt --- CMakeLists.txt | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ad087b1..a928c76 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,14 +5,21 @@ project(Shiva VERSION 0.1.0) include(GNUInstallDirs) # -------- Options (lean) ------------------------------------------------------- -option( SHIVA_ENABLE_BLT "Enable BLT integration (testing, packaging, etc.)" OFF ) -option( SHIVA_ENABLE_CUDA "Enable CUDA code paths in headers (interface define only)" OFF ) -option( SHIVA_ENABLE_HIP "Enable HIP code paths in headers (interface define only)" OFF ) +option( SHIVA_ENABLE_BLT "Enable BLT integration (testing, packaging, etc.)" ON ) +option( SHIVA_ENABLE_CUDA "Enable CUDA code paths in headers (interface define only)" OFF ) +option( SHIVA_ENABLE_HIP "Enable HIP code paths in headers (interface define only)" OFF ) option( SHIVA_ENABLE_UNIT_TESTS "Build unit tests (standalone only)" ON ) option( SHIVA_ENABLE_CAMP "Link against CAMP if available" OFF ) option( SHIVA_BUILD_OBJ_LIBS "Build object libraries...useful for dependency trees" OFF ) option( SHIVA_ENABLE_BOUNDS_CHECK "Enable bounds checking in shiva::CArray" OFF ) +if( ENABLE_CUDA ) + set( SHIVA_ENABLE_CUDA ON ) +endif() + +if( ENABLE_HIP ) + set( SHIVA_ENABLE_HIP ON ) +endif() if( SHIVA_ENABLE_CUDA AND SHIVA_ENABLE_HIP ) message( FATAL_ERROR "CUDA and HIP are mutually exclusive; enable only one." ) @@ -56,7 +63,6 @@ if( SHIVA_ENABLE_BLT ) include("${BLT_SOURCE_DIR}/SetupBLT.cmake") else() - endif( SHIVA_IS_TOPLEVEL ) @@ -65,7 +71,9 @@ if( SHIVA_ENABLE_BLT ) else() message( FATAL_ERROR "BLT requested but failed to load." ) endif( BLT_LOADED ) - + + + if( SHIVA_ENABLE_CAMP ) add_subdirectory(tpl/camp) # vendored fallback when standalone target_link_libraries(Shiva INTERFACE camp) @@ -83,6 +91,10 @@ if( SHIVA_ENABLE_BLT ) add_subdirectory(tests) endif() + include( "${CMAKE_CURRENT_LIST_DIR}/cmake/Macros.cmake" ) + shiva_add_code_checks( PREFIX shiva + EXCLUDES "blt/*" ) + endif( SHIVA_ENABLE_BLT) From fd08bdc7cf58d024d2670b1f12433aa5a65e7b95 Mon Sep 17 00:00:00 2001 From: Randolph Settgast Date: Wed, 24 Sep 2025 19:17:38 -0700 Subject: [PATCH 10/12] restrict check and format files --- CMakeLists.txt | 2 +- cmake/Macros.cmake | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a928c76..12211aa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -93,7 +93,7 @@ if( SHIVA_ENABLE_BLT ) include( "${CMAKE_CURRENT_LIST_DIR}/cmake/Macros.cmake" ) shiva_add_code_checks( PREFIX shiva - EXCLUDES "blt/*" ) + EXCLUDES build* blt/* camp/* ) endif( SHIVA_ENABLE_BLT) diff --git a/cmake/Macros.cmake b/cmake/Macros.cmake index cafe3dd..b2deed1 100644 --- a/cmake/Macros.cmake +++ b/cmake/Macros.cmake @@ -31,6 +31,7 @@ macro(shiva_add_code_checks) endif() endforeach() endif() + message( STATUS "shiva_add_code_checks: After excludes, have ${_sources}" ) set( CPPCHECK_FLAGS --std=c++17 --enable=all From 9d3b96f3c83014009295d89d62fa48f2ddc9ef38 Mon Sep 17 00:00:00 2001 From: Randolph Settgast Date: Wed, 24 Sep 2025 20:06:14 -0700 Subject: [PATCH 11/12] some hostconfig change --- CMakeLists.txt | 11 +++++------ cmake/Config.cmake | 1 - cmake/Macros.cmake | 1 - hostconfigs/apple/macOS_base.cmake | 6 ++++-- hostconfigs/environment.cmake | 6 +++++- 5 files changed, 14 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 12211aa..ef4ae26 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,10 +5,10 @@ project(Shiva VERSION 0.1.0) include(GNUInstallDirs) # -------- Options (lean) ------------------------------------------------------- -option( SHIVA_ENABLE_BLT "Enable BLT integration (testing, packaging, etc.)" ON ) +option( SHIVA_ENABLE_BLT "Enable BLT integration (testing, packaging, etc.)" OFF ) option( SHIVA_ENABLE_CUDA "Enable CUDA code paths in headers (interface define only)" OFF ) option( SHIVA_ENABLE_HIP "Enable HIP code paths in headers (interface define only)" OFF ) -option( SHIVA_ENABLE_UNIT_TESTS "Build unit tests (standalone only)" ON ) +option( SHIVA_ENABLE_UNIT_TESTS "Build unit tests (standalone only)" OFF ) option( SHIVA_ENABLE_CAMP "Link against CAMP if available" OFF ) option( SHIVA_BUILD_OBJ_LIBS "Build object libraries...useful for dependency trees" OFF ) option( SHIVA_ENABLE_BOUNDS_CHECK "Enable bounds checking in shiva::CArray" OFF ) @@ -48,9 +48,6 @@ target_include_directories( Shiva INTERFACE target_compile_features(Shiva INTERFACE cxx_std_17) - - - # -------- BLT (optional; usable as top-level or submodule) --------------------- if( SHIVA_ENABLE_BLT ) set( BLT_CXX_STD "c++17" ) @@ -87,8 +84,10 @@ if( SHIVA_ENABLE_BLT ) if ( SHIVA_ENABLE_HIP AND NOT CMAKE_HIP_COMPILER ) enable_language ( HIP ) endif () - + message( STATUS "Building unit tests." ) add_subdirectory(tests) + else() + message( STATUS "Skipping unit tests." ) endif() include( "${CMAKE_CURRENT_LIST_DIR}/cmake/Macros.cmake" ) diff --git a/cmake/Config.cmake b/cmake/Config.cmake index 0a04996..1622087 100644 --- a/cmake/Config.cmake +++ b/cmake/Config.cmake @@ -24,7 +24,6 @@ endif() # ---------- Emit the generated header(s) ---------- set(_shiva_gen_inc "${SHIVA_BINARY_DIR}/include/shiva") -message( "SHIVA_BINARY_DIR = ${SHIVA_BINARY_DIR}" ) file(MAKE_DIRECTORY "${_shiva_gen_inc}") configure_file( "${SHIVA_SOURCE_DIR}/include/shiva/ShivaConfig.hpp.in" diff --git a/cmake/Macros.cmake b/cmake/Macros.cmake index b2deed1..cafe3dd 100644 --- a/cmake/Macros.cmake +++ b/cmake/Macros.cmake @@ -31,7 +31,6 @@ macro(shiva_add_code_checks) endif() endforeach() endif() - message( STATUS "shiva_add_code_checks: After excludes, have ${_sources}" ) set( CPPCHECK_FLAGS --std=c++17 --enable=all diff --git a/hostconfigs/apple/macOS_base.cmake b/hostconfigs/apple/macOS_base.cmake index 9022409..965b244 100644 --- a/hostconfigs/apple/macOS_base.cmake +++ b/hostconfigs/apple/macOS_base.cmake @@ -27,6 +27,8 @@ set( CLANGTIDY_EXECUTABLE "${HOMEBREW_DIR}/opt/llvm/bin/clang-tidy" CACHE PATH " set( ENABLE_COVERAGE OFF CACHE BOOL "" FORCE) set( GCOV_EXECUTABLE "/usr/bin/gcov" CACHE PATH "" FORCE) set( LCOV_EXECUTABLE "${HOMEBREW_DIR}/bin/lcov" CACHE PATH "" FORCE) -set( SHIVA_ENABLE_BOUNDS_CHECK ON CACHE BOOL "" FORCE) -set( SHIVA_ENABLE_BLT ON CACHE BOOL "" FORCE) \ No newline at end of file + +set( SHIVA_ENABLE_BLT ON CACHE BOOL "" FORCE) +set( SHIVA_ENABLE_UNIT_TESTS ON CACHE BOOL "" FORCE ) +set( SHIVA_ENABLE_BOUNDS_CHECK ON CACHE BOOL "" FORCE) diff --git a/hostconfigs/environment.cmake b/hostconfigs/environment.cmake index 2a1b752..7e961f4 100644 --- a/hostconfigs/environment.cmake +++ b/hostconfigs/environment.cmake @@ -20,4 +20,8 @@ if(ENABLE_CUDA) set(CMAKE_CUDA_COMPILER ${CUDA_TOOLKIT_ROOT_DIR}/bin/nvcc CACHE STRING "") set(CMAKE_CUDA_FLAGS "-restrict --expt-extended-lambda --expt-relaxed-constexpr -Werror cross-execution-space-call,reorder,deprecated-declarations" CACHE STRING "") -endif() \ No newline at end of file +endif() + +set( SHIVA_ENABLE_BLT ON CACHE BOOL "" FORCE) +set( SHIVA_ENABLE_UNIT_TESTS ON CACHE BOOL "" FORCE ) +set( SHIVA_ENABLE_BOUNDS_CHECK ON CACHE BOOL "" FORCE) From 6c9bdf78c347e805223359bc0732610c7b6e0031 Mon Sep 17 00:00:00 2001 From: Randolph Settgast Date: Wed, 24 Sep 2025 20:15:48 -0700 Subject: [PATCH 12/12] change codecov directory --- cmake/Macros.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/Macros.cmake b/cmake/Macros.cmake index cafe3dd..7fc55ec 100644 --- a/cmake/Macros.cmake +++ b/cmake/Macros.cmake @@ -69,6 +69,6 @@ macro(shiva_add_code_checks) if (ENABLE_COVERAGE) blt_add_code_coverage_target(NAME ${arg_PREFIX}_coverage RUNNER ctest -E 'blt_gtest_smoke|testCppCheck|testClangTidy|testUncrustifyCheck|testDoxygenCheck|testCppCheck|testClangTidy' - SOURCE_DIRECTORIES ${PROJECT_SOURCE_DIR}/src ) + SOURCE_DIRECTORIES ${PROJECT_SOURCE_DIR}/include ) endif() endmacro(shiva_add_code_checks) \ No newline at end of file