From 34b2752cce6e1eb7e8527fb98ac8466e015f103a Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Fri, 21 Jun 2024 07:27:51 -0700 Subject: [PATCH] apply formatting --- CMakeLists.txt | 62 +-- cmake/SundialsBuildOptionsPost.cmake | 395 ++++++++++---- cmake/SundialsBuildOptionsPre.cmake | 185 ++++--- cmake/SundialsDeprecated.cmake | 140 +++-- cmake/SundialsExampleOptions.cmake | 52 +- cmake/SundialsIndexSize.cmake | 10 +- cmake/SundialsSetupCXX.cmake | 10 +- cmake/SundialsSetupCompilers.cmake | 195 ++++--- cmake/SundialsSetupConfig.cmake | 7 +- cmake/SundialsSetupCuda.cmake | 27 +- cmake/SundialsSetupFortran.cmake | 35 +- cmake/SundialsSetupHIP.cmake | 24 +- cmake/SundialsSetupTPLs.cmake | 1 - cmake/SundialsSetupTesting.cmake | 113 ++-- cmake/SundialsTPLOptions.cmake | 498 ++++++++++++------ cmake/macros/SundialsAddBenchmark.cmake | 42 +- cmake/macros/SundialsAddExamplesGinkgo.cmake | 50 +- cmake/macros/SundialsAddExecutable.cmake | 26 +- cmake/macros/SundialsAddLibrary.cmake | 257 +++++---- cmake/macros/SundialsAddTest.cmake | 89 ++-- cmake/macros/SundialsAddTestInstall.cmake | 29 +- cmake/macros/SundialsCMakeMacros.cmake | 51 +- cmake/macros/SundialsInstallExamples.cmake | 52 +- .../SundialsInstallExamplesGinkgo.cmake | 30 +- cmake/macros/SundialsOption.cmake | 24 +- cmake/macros/SundialsTryCompileExecute.cmake | 22 +- cmake/tpl/FindHYPRE.cmake | 76 +-- cmake/tpl/FindKLU.cmake | 109 ++-- cmake/tpl/FindMAGMA.cmake | 61 ++- cmake/tpl/FindPETSC.cmake | 52 +- cmake/tpl/FindSUPERLUDIST.cmake | 100 ++-- cmake/tpl/FindSUPERLUMT.cmake | 62 ++- cmake/tpl/FindTrilinos.cmake | 28 +- cmake/tpl/FindXBRAID.cmake | 196 +++---- cmake/tpl/SundialsAdiak.cmake | 26 +- cmake/tpl/SundialsCaliper.cmake | 32 +- cmake/tpl/SundialsGinkgo.cmake | 30 +- cmake/tpl/SundialsHypre.cmake | 69 +-- cmake/tpl/SundialsKLU.cmake | 56 +- cmake/tpl/SundialsKokkos.cmake | 15 +- cmake/tpl/SundialsKokkosKernels.cmake | 16 +- cmake/tpl/SundialsLapack.cmake | 105 ++-- cmake/tpl/SundialsMAGMA.cmake | 15 +- cmake/tpl/SundialsONEMKL.cmake | 25 +- cmake/tpl/SundialsOpenMP.cmake | 28 +- cmake/tpl/SundialsPETSC.cmake | 35 +- cmake/tpl/SundialsPOSIXTimers.cmake | 32 +- cmake/tpl/SundialsPthread.cmake | 2 +- cmake/tpl/SundialsRAJA.cmake | 60 ++- cmake/tpl/SundialsSuperLUDIST.cmake | 42 +- cmake/tpl/SundialsSuperLUMT.cmake | 25 +- cmake/tpl/SundialsTrilinos.cmake | 88 +++- cmake/tpl/SundialsXBRAID.cmake | 27 +- 53 files changed, 2386 insertions(+), 1452 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0f8fa7933f..04e16b9d73 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,11 +32,8 @@ project(SUNDIALS C) # Specify the location of additional CMAKE modules set(CMAKE_MODULE_PATH - ${CMAKE_MODULE_PATH} - ${PROJECT_SOURCE_DIR}/cmake - ${PROJECT_SOURCE_DIR}/cmake/macros - ${PROJECT_SOURCE_DIR}/cmake/tpl - ) + ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake + ${PROJECT_SOURCE_DIR}/cmake/macros ${PROJECT_SOURCE_DIR}/cmake/tpl) # MACRO definitions include(SundialsCMakeMacros) @@ -44,7 +41,6 @@ include(CMakePrintHelpers) include(CheckCSourceCompiles) include(FindPackageHandleStandardArgs) - # Set some variables with info on the SUNDIALS project set(PACKAGE_BUGREPORT "sundials-users@llnl.gov") set(PACKAGE_NAME "SUNDIALS") @@ -133,23 +129,28 @@ mark_as_advanced(CLEAR CMAKE_INSTALL_INCLUDEDIR) # Suffixes to use for static and shared targets. set(_STATIC_LIB_SUFFIX "_static" - CACHE INTERNAL "" FORCE -) + CACHE INTERNAL "" FORCE) set(_SHARED_LIB_SUFFIX "_shared" - CACHE INTERNAL "" FORCE -) + CACHE INTERNAL "" FORCE) # A list of all the alias targets created. -set(_SUNDIALS_ALIAS_TARGETS "" +set(_SUNDIALS_ALIAS_TARGETS + "" CACHE INTERNAL "" FORCE) # We default to release builds set(_DEFAULT_CMAKE_BUILD_TYPE RelWithDebInfo) if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) - message(STATUS "Building SUNDIALS in '${_DEFAULT_CMAKE_BUILD_TYPE}' mode as CMAKE_BUILD_TYPE was not specified.") - set(CMAKE_BUILD_TYPE "${_DEFAULT_CMAKE_BUILD_TYPE}" CACHE STRING "Choose the type of build." FORCE) - set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo") + message( + STATUS + "Building SUNDIALS in '${_DEFAULT_CMAKE_BUILD_TYPE}' mode as CMAKE_BUILD_TYPE was not specified." + ) + set(CMAKE_BUILD_TYPE + "${_DEFAULT_CMAKE_BUILD_TYPE}" + CACHE STRING "Choose the type of build." FORCE) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" + "MinSizeRel" "RelWithDebInfo") else() message(STATUS "Building SUNDIALS in '${CMAKE_BUILD_TYPE}' mode.") endif() @@ -231,13 +232,11 @@ endif() # install sundials_export header file install(FILES "${PROJECT_BINARY_DIR}/include/sundials/sundials_export.h" - DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/sundials" -) + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/sundials") # install configured header file install(FILES "${PROJECT_BINARY_DIR}/include/sundials/sundials_config.h" - DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/sundials" -) + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/sundials") # install shared Fortran 2003 modules if(BUILD_FORTRAN_MODULE_INTERFACE) @@ -246,53 +245,44 @@ if(BUILD_FORTRAN_MODULE_INTERFACE) # of the .mod files. if(BUILD_STATIC_LIBS) install(DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}_STATIC/ - DESTINATION ${Fortran_INSTALL_MODDIR} - ) + DESTINATION ${Fortran_INSTALL_MODDIR}) else() install(DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}_SHARED/ - DESTINATION ${Fortran_INSTALL_MODDIR} - ) + DESTINATION ${Fortran_INSTALL_MODDIR}) endif() endif() # install license and notice files install(FILES "${PROJECT_SOURCE_DIR}/LICENSE" - DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/sundials" -) + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/sundials") install(FILES "${PROJECT_SOURCE_DIR}/NOTICE" - DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/sundials" -) + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/sundials") # create package version file include(CMakePackageConfigHelpers) write_basic_package_version_file( SUNDIALSConfigVersion.cmake VERSION ${PACKAGE_VERSION} - COMPATIBILITY AnyNewerVersion -) + COMPATIBILITY AnyNewerVersion) # install targets install( EXPORT sundials-targets FILE SUNDIALSTargets.cmake NAMESPACE SUNDIALS:: - DESTINATION "${SUNDIALS_INSTALL_CMAKEDIR}" -) + DESTINATION "${SUNDIALS_INSTALL_CMAKEDIR}") # install SUNDIALSConfig.cmake configure_package_config_file( "${PROJECT_SOURCE_DIR}/cmake/SUNDIALSConfig.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/SUNDIALSConfig.cmake" - INSTALL_DESTINATION "${SUNDIALS_INSTALL_CMAKEDIR}" -) + INSTALL_DESTINATION "${SUNDIALS_INSTALL_CMAKEDIR}") install(FILES "${CMAKE_CURRENT_BINARY_DIR}/SUNDIALSConfig.cmake" "${CMAKE_CURRENT_BINARY_DIR}/SUNDIALSConfigVersion.cmake" - DESTINATION "${SUNDIALS_INSTALL_CMAKEDIR}" -) + DESTINATION "${SUNDIALS_INSTALL_CMAKEDIR}") # Export targets so build directory can be used directly export( EXPORT sundials-targets FILE "${CMAKE_CURRENT_BINARY_DIR}/SUNDIALSTargets.cmake" - NAMESPACE SUNDIALS:: -) + NAMESPACE SUNDIALS::) diff --git a/cmake/SundialsBuildOptionsPost.cmake b/cmake/SundialsBuildOptionsPost.cmake index 01d6969bc6..af3ea473b2 100644 --- a/cmake/SundialsBuildOptionsPost.cmake +++ b/cmake/SundialsBuildOptionsPost.cmake @@ -26,9 +26,15 @@ else() set(CUDA_OR_HIP FALSE) endif() -sundials_option(SUNDIALS_BUILD_PACKAGE_FUSED_KERNELS BOOL "Build specialized fused GPU kernels" OFF - DEPENDS_ON BUILD_CVODE CUDA_OR_HIP - DEPENDS_ON_THROW_ERROR) +sundials_option( + SUNDIALS_BUILD_PACKAGE_FUSED_KERNELS + BOOL + "Build specialized fused GPU kernels" + OFF + DEPENDS_ON + BUILD_CVODE + CUDA_OR_HIP + DEPENDS_ON_THROW_ERROR) # --------------------------------------------------------------- # Options to enable/disable build for NVECTOR modules. @@ -38,81 +44,160 @@ sundials_option(SUNDIALS_BUILD_PACKAGE_FUSED_KERNELS BOOL "Build specialized fus set(BUILD_NVECTOR_SERIAL TRUE) list(APPEND SUNDIALS_BUILD_LIST "BUILD_NVECTOR_SERIAL") -sundials_option(BUILD_NVECTOR_CUDA BOOL "Build the NVECTOR_CUDA module (requires CUDA)" ON - DEPENDS_ON ENABLE_CUDA CMAKE_CUDA_COMPILER - ADVANCED) +sundials_option( + BUILD_NVECTOR_CUDA + BOOL + "Build the NVECTOR_CUDA module (requires CUDA)" + ON + DEPENDS_ON + ENABLE_CUDA + CMAKE_CUDA_COMPILER + ADVANCED) list(APPEND SUNDIALS_BUILD_LIST "BUILD_NVECTOR_CUDA") -sundials_option(BUILD_NVECTOR_HIP BOOL "Build the NVECTOR_HIP module (requires HIP)" ON - DEPENDS_ON ENABLE_HIP - ADVANCED) +sundials_option( + BUILD_NVECTOR_HIP + BOOL + "Build the NVECTOR_HIP module (requires HIP)" + ON + DEPENDS_ON + ENABLE_HIP + ADVANCED) list(APPEND SUNDIALS_BUILD_LIST "BUILD_NVECTOR_HIP") -sundials_option(BUILD_NVECTOR_SYCL BOOL "Build the NVECTOR_SYCL module (requires SYCL)" ON - DEPENDS_ON ENABLE_SYCL - ADVANCED) +sundials_option( + BUILD_NVECTOR_SYCL + BOOL + "Build the NVECTOR_SYCL module (requires SYCL)" + ON + DEPENDS_ON + ENABLE_SYCL + ADVANCED) list(APPEND SUNDIALS_BUILD_LIST "BUILD_NVECTOR_SYCL") -sundials_option(BUILD_NVECTOR_MANYVECTOR BOOL "Build the NVECTOR_MANYVECTOR module" ON - ADVANCED) +sundials_option(BUILD_NVECTOR_MANYVECTOR BOOL + "Build the NVECTOR_MANYVECTOR module" ON ADVANCED) list(APPEND SUNDIALS_BUILD_LIST "BUILD_NVECTOR_MANYVECTOR") -sundials_option(BUILD_NVECTOR_MPIMANYVECTOR BOOL "Build the NVECTOR_MPIMANYVECTOR module (requires MPI)" ON - DEPENDS_ON ENABLE_MPI MPI_C_FOUND - ADVANCED) +sundials_option( + BUILD_NVECTOR_MPIMANYVECTOR + BOOL + "Build the NVECTOR_MPIMANYVECTOR module (requires MPI)" + ON + DEPENDS_ON + ENABLE_MPI + MPI_C_FOUND + ADVANCED) list(APPEND SUNDIALS_BUILD_LIST "BUILD_NVECTOR_MPIMANYVECTOR") -sundials_option(BUILD_NVECTOR_MPIPLUSX BOOL "Build the NVECTOR_MPIPLUSX module (requires MPI)" ON - DEPENDS_ON ENABLE_MPI MPI_C_FOUND BUILD_NVECTOR_MPIMANYVECTOR - ADVANCED) +sundials_option( + BUILD_NVECTOR_MPIPLUSX + BOOL + "Build the NVECTOR_MPIPLUSX module (requires MPI)" + ON + DEPENDS_ON + ENABLE_MPI + MPI_C_FOUND + BUILD_NVECTOR_MPIMANYVECTOR + ADVANCED) list(APPEND SUNDIALS_BUILD_LIST "BUILD_NVECTOR_MPIPLUSX") -sundials_option(BUILD_NVECTOR_PARALLEL BOOL "Build the NVECTOR_PARALLEL module (requires MPI)" ON - DEPENDS_ON ENABLE_MPI MPI_C_FOUND - ADVANCED) +sundials_option( + BUILD_NVECTOR_PARALLEL + BOOL + "Build the NVECTOR_PARALLEL module (requires MPI)" + ON + DEPENDS_ON + ENABLE_MPI + MPI_C_FOUND + ADVANCED) list(APPEND SUNDIALS_BUILD_LIST "BUILD_NVECTOR_PARALLEL") -sundials_option(BUILD_NVECTOR_OPENMP BOOL "Build the NVECTOR_OPENMP module" ON - DEPENDS_ON ENABLE_OPENMP - ADVANCED) +sundials_option( + BUILD_NVECTOR_OPENMP + BOOL + "Build the NVECTOR_OPENMP module" + ON + DEPENDS_ON + ENABLE_OPENMP + ADVANCED) list(APPEND SUNDIALS_BUILD_LIST "BUILD_NVECTOR_OPENMP") -sundials_option(BUILD_NVECTOR_OPENMPDEV BOOL "Build the NVECTOR_OPENMPDEV module" ON - DEPENDS_ON ENABLE_OPENMP_DEVICE OPENMP_SUPPORTS_DEVICE_OFFLOADING - ADVANCED) +sundials_option( + BUILD_NVECTOR_OPENMPDEV + BOOL + "Build the NVECTOR_OPENMPDEV module" + ON + DEPENDS_ON + ENABLE_OPENMP_DEVICE + OPENMP_SUPPORTS_DEVICE_OFFLOADING + ADVANCED) list(APPEND SUNDIALS_BUILD_LIST "BUILD_NVECTOR_OPENMPDEV") -sundials_option(BUILD_NVECTOR_PARHYP BOOL "Build the NVECTOR_PARHYP module (requires hypre)" ON - DEPENDS_ON ENABLE_HYPRE HYPRE_WORKS - ADVANCED) +sundials_option( + BUILD_NVECTOR_PARHYP + BOOL + "Build the NVECTOR_PARHYP module (requires hypre)" + ON + DEPENDS_ON + ENABLE_HYPRE + HYPRE_WORKS + ADVANCED) list(APPEND SUNDIALS_BUILD_LIST "BUILD_NVECTOR_PARHYP") -sundials_option(BUILD_NVECTOR_PETSC BOOL "Build the NVECTOR_PETSC module (requires PETSc)" ON - DEPENDS_ON ENABLE_PETSC PETSC_WORKS - ADVANCED) +sundials_option( + BUILD_NVECTOR_PETSC + BOOL + "Build the NVECTOR_PETSC module (requires PETSc)" + ON + DEPENDS_ON + ENABLE_PETSC + PETSC_WORKS + ADVANCED) list(APPEND SUNDIALS_BUILD_LIST "BUILD_NVECTOR_PETSC") -sundials_option(BUILD_NVECTOR_PTHREADS BOOL "Build the NVECTOR_PTHREADS module" ON - DEPENDS_ON ENABLE_PTHREAD - ADVANCED) +sundials_option( + BUILD_NVECTOR_PTHREADS + BOOL + "Build the NVECTOR_PTHREADS module" + ON + DEPENDS_ON + ENABLE_PTHREAD + ADVANCED) list(APPEND SUNDIALS_BUILD_LIST "BUILD_NVECTOR_PTHREADS") -sundials_option(BUILD_NVECTOR_RAJA BOOL "Build the NVECTOR_RAJA module (requires RAJA)" ON - DEPENDS_ON ENABLE_RAJA - ADVANCED) +sundials_option( + BUILD_NVECTOR_RAJA + BOOL + "Build the NVECTOR_RAJA module (requires RAJA)" + ON + DEPENDS_ON + ENABLE_RAJA + ADVANCED) list(APPEND SUNDIALS_BUILD_LIST "BUILD_NVECTOR_RAJA") -sundials_option(BUILD_NVECTOR_TRILINOS BOOL "Build the NVECTOR_TRILINOS module (requires Trilinos)" ON - DEPENDS_ON ENABLE_TRILINOS Trilinos_WORKS - ADVANCED) +sundials_option( + BUILD_NVECTOR_TRILINOS + BOOL + "Build the NVECTOR_TRILINOS module (requires Trilinos)" + ON + DEPENDS_ON + ENABLE_TRILINOS + Trilinos_WORKS + ADVANCED) list(APPEND SUNDIALS_BUILD_LIST "BUILD_NVECTOR_TRILINOS") -sundials_option(BUILD_NVECTOR_KOKKOS BOOL "Build the NVECTOR_KOKKOS module (requires Kokkos)" ON - DEPENDS_ON ENABLE_KOKKOS KOKKOS_WORKS - ADVANCED) +sundials_option( + BUILD_NVECTOR_KOKKOS + BOOL + "Build the NVECTOR_KOKKOS module (requires Kokkos)" + ON + DEPENDS_ON + ENABLE_KOKKOS + KOKKOS_WORKS + ADVANCED) list(APPEND SUNDIALS_BUILD_LIST "BUILD_NVECTOR_KOKKOS") - # --------------------------------------------------------------- # Options to enable/disable build for SUNMATRIX modules. # --------------------------------------------------------------- @@ -129,34 +214,74 @@ set(_COMPATIBLE_INDEX_SIZE FALSE) if(SUNDIALS_INDEX_SIZE MATCHES "32") set(_COMPATIBLE_INDEX_SIZE TRUE) endif() -sundials_option(BUILD_SUNMATRIX_CUSPARSE BOOL "Build the SUNMATRIX_CUSPARSE module (requires CUDA and 32-bit indexing)" ON - DEPENDS_ON ENABLE_CUDA CMAKE_CUDA_COMPILER _COMPATIBLE_INDEX_SIZE BUILD_NVECTOR_CUDA - ADVANCED) +sundials_option( + BUILD_SUNMATRIX_CUSPARSE + BOOL + "Build the SUNMATRIX_CUSPARSE module (requires CUDA and 32-bit indexing)" + ON + DEPENDS_ON + ENABLE_CUDA + CMAKE_CUDA_COMPILER + _COMPATIBLE_INDEX_SIZE + BUILD_NVECTOR_CUDA + ADVANCED) list(APPEND SUNDIALS_BUILD_LIST "BUILD_SUNMATRIX_CUSPARSE") -sundials_option(BUILD_SUNMATRIX_GINKGO BOOL "Build the SUNMATRIX_GINKGO module (requires Ginkgo)" ON - DEPENDS_ON ENABLE_GINKGO GINKGO_WORKS - ADVANCED) +sundials_option( + BUILD_SUNMATRIX_GINKGO + BOOL + "Build the SUNMATRIX_GINKGO module (requires Ginkgo)" + ON + DEPENDS_ON + ENABLE_GINKGO + GINKGO_WORKS + ADVANCED) list(APPEND SUNDIALS_BUILD_LIST "BUILD_SUNMATRIX_GINKGO") -sundials_option(BUILD_SUNMATRIX_KOKKOSDENSE BOOL "Build the SUNMATRIX_KOKKOSDENSE module" ON - DEPENDS_ON ENABLE_KOKKOS KOKKOS_WORKS ENABLE_KOKKOS_KERNELS KOKKOS_KERNELS_WORKS - ADVANCED) +sundials_option( + BUILD_SUNMATRIX_KOKKOSDENSE + BOOL + "Build the SUNMATRIX_KOKKOSDENSE module" + ON + DEPENDS_ON + ENABLE_KOKKOS + KOKKOS_WORKS + ENABLE_KOKKOS_KERNELS + KOKKOS_KERNELS_WORKS + ADVANCED) list(APPEND SUNDIALS_BUILD_LIST "BUILD_SUNMATRIX_KOKKOSDENSE") -sundials_option(BUILD_SUNMATRIX_MAGMADENSE BOOL "Build the SUNMATRIX_MAGMADENSE module (requires MAGMA)" ON - DEPENDS_ON ENABLE_MAGMA MAGMA_WORKS - ADVANCED) +sundials_option( + BUILD_SUNMATRIX_MAGMADENSE + BOOL + "Build the SUNMATRIX_MAGMADENSE module (requires MAGMA)" + ON + DEPENDS_ON + ENABLE_MAGMA + MAGMA_WORKS + ADVANCED) list(APPEND SUNDIALS_BUILD_LIST "BUILD_SUNMATRIX_MAGMADENSE") -sundials_option(BUILD_SUNMATRIX_ONEMKLDENSE BOOL "Build the SUNMATRIX_ONEMKLDENSE module (requires oneMKL)" ON - DEPENDS_ON ENABLE_ONEMKL ONEMKL_WORKS - ADVANCED) +sundials_option( + BUILD_SUNMATRIX_ONEMKLDENSE + BOOL + "Build the SUNMATRIX_ONEMKLDENSE module (requires oneMKL)" + ON + DEPENDS_ON + ENABLE_ONEMKL + ONEMKL_WORKS + ADVANCED) list(APPEND SUNDIALS_BUILD_LIST "BUILD_SUNMATRIX_ONEMKLDENSE") -sundials_option(BUILD_SUNMATRIX_SLUNRLOC BOOL "Build the SUNMATRIX_SLUNRLOC module (requires SuperLU_DIST)" ON - DEPENDS_ON ENABLE_SUPERLUDIST SUPERLUDIST_WORKS - ADVANCED) +sundials_option( + BUILD_SUNMATRIX_SLUNRLOC + BOOL + "Build the SUNMATRIX_SLUNRLOC module (requires SuperLU_DIST)" + ON + DEPENDS_ON + ENABLE_SUPERLUDIST + SUPERLUDIST_WORKS + ADVANCED) list(APPEND SUNDIALS_BUILD_LIST "BUILD_SUNMATRIX_SLUNRLOC") # --------------------------------------------------------------- @@ -179,57 +304,121 @@ list(APPEND SUNDIALS_BUILD_LIST "BUILD_SUNLINSOL_SPGMR") set(BUILD_SUNLINSOL_SPTFQMR TRUE) list(APPEND SUNDIALS_BUILD_LIST "BUILD_SUNLINSOL_SPTFQMR") -sundials_option(BUILD_SUNLINSOL_CUSOLVERSP BOOL "Build the SUNLINSOL_CUSOLVERSP module (requires CUDA and 32-bit indexing)" ON - DEPENDS_ON ENABLE_CUDA CMAKE_CUDA_COMPILER BUILD_NVECTOR_CUDA BUILD_SUNMATRIX_CUSPARSE - ADVANCED) +sundials_option( + BUILD_SUNLINSOL_CUSOLVERSP + BOOL + "Build the SUNLINSOL_CUSOLVERSP module (requires CUDA and 32-bit indexing)" + ON + DEPENDS_ON + ENABLE_CUDA + CMAKE_CUDA_COMPILER + BUILD_NVECTOR_CUDA + BUILD_SUNMATRIX_CUSPARSE + ADVANCED) list(APPEND SUNDIALS_BUILD_LIST "BUILD_SUNLINSOL_CUSOLVERSP") -sundials_option(BUILD_SUNLINSOL_GINKGO BOOL "Build the SUNLINSOL_GINKGO module (requires Ginkgo)" ON - DEPENDS_ON ENABLE_GINKGO GINKGO_WORKS - ADVANCED) +sundials_option( + BUILD_SUNLINSOL_GINKGO + BOOL + "Build the SUNLINSOL_GINKGO module (requires Ginkgo)" + ON + DEPENDS_ON + ENABLE_GINKGO + GINKGO_WORKS + ADVANCED) list(APPEND SUNDIALS_BUILD_LIST "BUILD_SUNLINSOL_GINKGO") -sundials_option(BUILD_SUNLINSOL_KLU BOOL "Build the SUNLINSOL_KLU module (requires KLU)" ON - DEPENDS_ON ENABLE_KLU KLU_WORKS - ADVANCED) +sundials_option( + BUILD_SUNLINSOL_KLU + BOOL + "Build the SUNLINSOL_KLU module (requires KLU)" + ON + DEPENDS_ON + ENABLE_KLU + KLU_WORKS + ADVANCED) list(APPEND SUNDIALS_BUILD_LIST "BUILD_SUNLINSOL_KLU") -sundials_option(BUILD_SUNLINSOL_KOKKOSDENSE BOOL "Build the SUNLINSOL_KOKKOSDENSE module" ON - DEPENDS_ON ENABLE_KOKKOS KOKKOS_WORKS ENABLE_KOKKOS_KERNELS KOKKOS_KERNELS_WORKS - ADVANCED) +sundials_option( + BUILD_SUNLINSOL_KOKKOSDENSE + BOOL + "Build the SUNLINSOL_KOKKOSDENSE module" + ON + DEPENDS_ON + ENABLE_KOKKOS + KOKKOS_WORKS + ENABLE_KOKKOS_KERNELS + KOKKOS_KERNELS_WORKS + ADVANCED) list(APPEND SUNDIALS_BUILD_LIST "BUILD_SUNLINSOL_KOKKOSDENSE") -sundials_option(BUILD_SUNLINSOL_LAPACKBAND BOOL "Build the SUNLINSOL_LAPACKBAND module (requires LAPACK)" ON - DEPENDS_ON ENABLE_LAPACK LAPACK_WORKS - ADVANCED) +sundials_option( + BUILD_SUNLINSOL_LAPACKBAND + BOOL + "Build the SUNLINSOL_LAPACKBAND module (requires LAPACK)" + ON + DEPENDS_ON + ENABLE_LAPACK + LAPACK_WORKS + ADVANCED) list(APPEND SUNDIALS_BUILD_LIST "BUILD_SUNLINSOL_LAPACKBAND") -sundials_option(BUILD_SUNLINSOL_LAPACKDENSE BOOL "Build the SUNLINSOL_LAPACKDENSE module (requires LAPACK)" ON - DEPENDS_ON ENABLE_LAPACK LAPACK_WORKS - ADVANCED) +sundials_option( + BUILD_SUNLINSOL_LAPACKDENSE + BOOL + "Build the SUNLINSOL_LAPACKDENSE module (requires LAPACK)" + ON + DEPENDS_ON + ENABLE_LAPACK + LAPACK_WORKS + ADVANCED) list(APPEND SUNDIALS_BUILD_LIST "BUILD_SUNLINSOL_LAPACKDENSE") -sundials_option(BUILD_SUNLINSOL_MAGMADENSE BOOL "Build the SUNLINSOL_MAGMADENSE module (requires MAGMA)" ON - DEPENDS_ON ENABLE_MAGMA MAGMA_WORKS - ADVANCED) +sundials_option( + BUILD_SUNLINSOL_MAGMADENSE + BOOL + "Build the SUNLINSOL_MAGMADENSE module (requires MAGMA)" + ON + DEPENDS_ON + ENABLE_MAGMA + MAGMA_WORKS + ADVANCED) list(APPEND SUNDIALS_BUILD_LIST "BUILD_SUNLINSOL_MAGMADENSE") -sundials_option(BUILD_SUNLINSOL_ONEMKLDENSE BOOL "Build the SUNLINSOL_ONEMKLDENSE module (requires oneMKL)" ON - DEPENDS_ON ENABLE_ONEMKL ONEMKL_WORKS - ADVANCED) +sundials_option( + BUILD_SUNLINSOL_ONEMKLDENSE + BOOL + "Build the SUNLINSOL_ONEMKLDENSE module (requires oneMKL)" + ON + DEPENDS_ON + ENABLE_ONEMKL + ONEMKL_WORKS + ADVANCED) list(APPEND SUNDIALS_BUILD_LIST "BUILD_SUNLINSOL_ONEMKLDENSE") -sundials_option(BUILD_SUNLINSOL_SUPERLUDIST BOOL "Build the SUNLINSOL_SUPERLUDIST module (requires SUPERLUDIST)" ON - DEPENDS_ON ENABLE_SUPERLUDIST SUPERLUDIST_WORKS BUILD_SUNMATRIX_SLUNRLOC - ADVANCED) +sundials_option( + BUILD_SUNLINSOL_SUPERLUDIST + BOOL + "Build the SUNLINSOL_SUPERLUDIST module (requires SUPERLUDIST)" + ON + DEPENDS_ON + ENABLE_SUPERLUDIST + SUPERLUDIST_WORKS + BUILD_SUNMATRIX_SLUNRLOC + ADVANCED) list(APPEND SUNDIALS_BUILD_LIST "BUILD_SUNLINSOL_SUPERLUDIST") -sundials_option(BUILD_SUNLINSOL_SUPERLUMT BOOL "Build the SUNLINSOL_SUPERLUMT module (requires SUPERLUMT)" ON - DEPENDS_ON ENABLE_SUPERLUMT SUPERLUMT_WORKS - ADVANCED) +sundials_option( + BUILD_SUNLINSOL_SUPERLUMT + BOOL + "Build the SUNLINSOL_SUPERLUMT module (requires SUPERLUMT)" + ON + DEPENDS_ON + ENABLE_SUPERLUMT + SUPERLUMT_WORKS + ADVANCED) list(APPEND SUNDIALS_BUILD_LIST "BUILD_SUNLINSOL_SUPERLUMT") - # --------------------------------------------------------------- # Options to enable/disable build for SUNNONLINSOL modules. # --------------------------------------------------------------- @@ -240,7 +429,13 @@ list(APPEND SUNDIALS_BUILD_LIST "BUILD_SUNNONLINSOL_NEWTON") set(BUILD_SUNNONLINSOL_FIXEDPOINT TRUE) list(APPEND SUNDIALS_BUILD_LIST "BUILD_SUNNONLINSOL_FIXEDPOINT") -sundials_option(BUILD_SUNNONLINSOL_PETSCSNES BOOL "Build the SUNNONLINSOL_PETSCSNES module (requires PETSc)" ON - DEPENDS_ON ENABLE_PETSC PETSC_FOUND - ADVANCED) +sundials_option( + BUILD_SUNNONLINSOL_PETSCSNES + BOOL + "Build the SUNNONLINSOL_PETSCSNES module (requires PETSc)" + ON + DEPENDS_ON + ENABLE_PETSC + PETSC_FOUND + ADVANCED) list(APPEND SUNDIALS_BUILD_LIST "BUILD_SUNNONLINSOL_PETSCSNES") diff --git a/cmake/SundialsBuildOptionsPre.cmake b/cmake/SundialsBuildOptionsPre.cmake index b78212e720..e17ef9ae2b 100644 --- a/cmake/SundialsBuildOptionsPre.cmake +++ b/cmake/SundialsBuildOptionsPre.cmake @@ -33,7 +33,8 @@ endif() set(DOCSTR "single, double, or extended") sundials_option(SUNDIALS_PRECISION STRING "${DOCSTR}" "DOUBLE") string(TOUPPER ${SUNDIALS_PRECISION} _upper_SUNDIALS_PRECISION) -force_variable(SUNDIALS_PRECISION STRING "${DOCSTR}" ${_upper_SUNDIALS_PRECISION}) +force_variable(SUNDIALS_PRECISION STRING "${DOCSTR}" + ${_upper_SUNDIALS_PRECISION}) # --------------------------------------------------------------- # Option to specify index type @@ -65,7 +66,9 @@ set(DOCSTR "Build with simulation profiling capabilities enabled") sundials_option(SUNDIALS_BUILD_WITH_PROFILING BOOL "${DOCSTR}" OFF) if(SUNDIALS_BUILD_WITH_PROFILING) - message(WARNING "SUNDIALS built with profiling turned on, performance may be affected.") + message( + WARNING + "SUNDIALS built with profiling turned on, performance may be affected.") endif() # --------------------------------------------------------------- @@ -78,24 +81,35 @@ else() set(_default_err_checks ON) endif() -set(DOCSTR "Build with error checking enabled/disabled. Enabling error checks may affect performance.") -sundials_option(SUNDIALS_ENABLE_ERROR_CHECKS BOOL "${DOCSTR}" ${_default_err_checks}) +set(DOCSTR + "Build with error checking enabled/disabled. Enabling error checks may affect performance." +) +sundials_option(SUNDIALS_ENABLE_ERROR_CHECKS BOOL "${DOCSTR}" + ${_default_err_checks}) if(SUNDIALS_ENABLE_ERROR_CHECKS) message(STATUS "SUNDIALS error checking enabled") - message(WARNING "SUNDIALS is being built with extensive error checks, performance may be affected.") + message( + WARNING + "SUNDIALS is being built with extensive error checks, performance may be affected." + ) endif() # --------------------------------------------------------------- # Option to enable logging # --------------------------------------------------------------- -set(DOCSTR "Build with logging capabilities enabled (0 = no logging, 1 = errors, 2 = +warnings, 3 = +info, 4 = +debug, 5 = +extras") -sundials_option(SUNDIALS_LOGGING_LEVEL STRING "${DOCSTR}" 2 - OPTIONS "0;1;2;3;4;5") +set(DOCSTR + "Build with logging capabilities enabled (0 = no logging, 1 = errors, 2 = +warnings, 3 = +info, 4 = +debug, 5 = +extras" +) +sundials_option(SUNDIALS_LOGGING_LEVEL STRING "${DOCSTR}" 2 OPTIONS + "0;1;2;3;4;5") if(SUNDIALS_LOGGING_LEVEL GREATER_EQUAL 3) message(STATUS "SUNDIALS logging level set to ${SUNDIALS_LOGGING_LEVEL}") - message(WARNING "SUNDIALS built with additional logging turned on, performance may be affected.") + message( + WARNING + "SUNDIALS built with additional logging turned on, performance may be affected." + ) endif() # --------------------------------------------------------------- @@ -103,9 +117,11 @@ endif() # --------------------------------------------------------------- if(UNIX) - sundials_option(SUNDIALS_MATH_LIBRARY PATH "Which math library (e.g., libm) to link to" "-lm" ADVANCED) + sundials_option(SUNDIALS_MATH_LIBRARY PATH + "Which math library (e.g., libm) to link to" "-lm" ADVANCED) else() - sundials_option(SUNDIALS_MATH_LIBRARY PATH "Which math library (e.g., libm) to link to" "" ADVANCED) + sundials_option(SUNDIALS_MATH_LIBRARY PATH + "Which math library (e.g., libm) to link to" "" ADVANCED) endif() # all executables will be linked against the math library set(EXE_EXTRA_LINK_LIBS "${SUNDIALS_MATH_LIBRARY}") @@ -119,7 +135,8 @@ sundials_option(BUILD_SHARED_LIBS BOOL "Build shared libraries" ON) # Make sure we build at least one type of libraries if(NOT BUILD_STATIC_LIBS AND NOT BUILD_SHARED_LIBS) - message(FATAL_ERROR "Both static and shared library generation were disabled.") + message( + FATAL_ERROR "Both static and shared library generation were disabled.") endif() # --------------------------------------------------------------- @@ -182,7 +199,8 @@ sundials_option(BUILD_FORTRAN_MODULE_INTERFACE BOOL "${DOCSTR}" OFF) if(BUILD_FORTRAN_MODULE_INTERFACE) # F2003 interface only supports double precision if(NOT (SUNDIALS_PRECISION MATCHES "DOUBLE")) - print_error("F2003 interface is not compatible with ${SUNDIALS_PRECISION} precision") + print_error( + "F2003 interface is not compatible with ${SUNDIALS_PRECISION} precision") endif() # Allow a user to set where the Fortran modules will be installed @@ -196,7 +214,10 @@ endif() sundials_option(BUILD_BENCHMARKS BOOL "Build the SUNDIALS benchmark suite" OFF) -sundials_option(BENCHMARKS_INSTALL_PATH PATH "Output directory for installing benchmark executables" "${CMAKE_INSTALL_PREFIX}/benchmarks") +sundials_option( + BENCHMARKS_INSTALL_PATH PATH + "Output directory for installing benchmark executables" + "${CMAKE_INSTALL_PREFIX}/benchmarks") # --------------------------------------------------------------- # Options for CMake config installation @@ -210,14 +231,14 @@ sundials_option(SUNDIALS_INSTALL_CMAKEDIR STRING "${DOCSTR}" # Options to enable compiler warnings, address sanitizer # --------------------------------------------------------------- -sundials_option(ENABLE_ALL_WARNINGS BOOL - "Enable all compiler warnings" OFF ADVANCED) +sundials_option(ENABLE_ALL_WARNINGS BOOL "Enable all compiler warnings" OFF + ADVANCED) sundials_option(ENABLE_WARNINGS_AS_ERRORS BOOL - "Enable compiler warnings as errors" OFF ADVANCED) + "Enable compiler warnings as errors" OFF ADVANCED) -sundials_option(ENABLE_ADDRESS_SANITIZER BOOL - "Enable address sanitizer" OFF ADVANCED) +sundials_option(ENABLE_ADDRESS_SANITIZER BOOL "Enable address sanitizer" OFF + ADVANCED) # --------------------------------------------------------------- # Options to enable SUNDIALS debugging @@ -225,111 +246,143 @@ sundials_option(ENABLE_ADDRESS_SANITIZER BOOL # List of debugging options (used to add preprocessor directives) set(_SUNDIALS_DEBUG_OPTIONS - SUNDIALS_DEBUG - SUNDIALS_DEBUG_ASSERT - SUNDIALS_DEBUG_CUDA_LASTERROR - SUNDIALS_DEBUG_HIP_LASTERROR - SUNDIALS_DEBUG_PRINTVEC) + SUNDIALS_DEBUG SUNDIALS_DEBUG_ASSERT SUNDIALS_DEBUG_CUDA_LASTERROR + SUNDIALS_DEBUG_HIP_LASTERROR SUNDIALS_DEBUG_PRINTVEC) sundials_option(SUNDIALS_DEBUG BOOL - "Enable additional debugging output and options" OFF - ADVANCED) + "Enable additional debugging output and options" OFF ADVANCED) if(SUNDIALS_DEBUG AND SUNDIALS_LOGGING_LEVEL LESS 4) set(DOCSTR "SUNDIALS_DEBUG=ON forced the logging level to 4") message(STATUS "${DOCSTR}") - set(SUNDIALS_LOGGING_LEVEL "4" CACHE STRING "${DOCSTR}" FORCE) + set(SUNDIALS_LOGGING_LEVEL + "4" + CACHE STRING "${DOCSTR}" FORCE) endif() -sundials_option(SUNDIALS_DEBUG_ASSERT BOOL - "Enable assert when debugging" OFF - DEPENDS_ON SUNDIALS_DEBUG +sundials_option( + SUNDIALS_DEBUG_ASSERT + BOOL + "Enable assert when debugging" + OFF + DEPENDS_ON + SUNDIALS_DEBUG ADVANCED) -sundials_option(SUNDIALS_DEBUG_CUDA_LASTERROR BOOL - "Enable CUDA last error checks when debugging" OFF - DEPENDS_ON SUNDIALS_DEBUG ENABLE_CUDA +sundials_option( + SUNDIALS_DEBUG_CUDA_LASTERROR + BOOL + "Enable CUDA last error checks when debugging" + OFF + DEPENDS_ON + SUNDIALS_DEBUG + ENABLE_CUDA ADVANCED) -sundials_option(SUNDIALS_DEBUG_HIP_LASTERROR BOOL - "Enable HIP last error checks when debugging" OFF - DEPENDS_ON SUNDIALS_DEBUG ENABLE_HIP +sundials_option( + SUNDIALS_DEBUG_HIP_LASTERROR + BOOL + "Enable HIP last error checks when debugging" + OFF + DEPENDS_ON + SUNDIALS_DEBUG + ENABLE_HIP ADVANCED) -sundials_option(SUNDIALS_DEBUG_PRINTVEC BOOL - "Enable vector printing when debugging" OFF - DEPENDS_ON SUNDIALS_DEBUG +sundials_option( + SUNDIALS_DEBUG_PRINTVEC + BOOL + "Enable vector printing when debugging" + OFF + DEPENDS_ON + SUNDIALS_DEBUG ADVANCED) if(SUNDIALS_DEBUG_PRINTVEC AND SUNDIALS_LOGGING_LEVEL LESS 5) set(DOCSTR "SUNDIALS_DEBUG_PRINTVEC=ON forced the logging level to 5") message(STATUS "${DOCSTR}") - set(SUNDIALS_LOGGING_LEVEL "5" CACHE STRING "${DOCSTR}" FORCE) + set(SUNDIALS_LOGGING_LEVEL + "5" + CACHE STRING "${DOCSTR}" FORCE) endif() # --------------------------------------------------------------- # Options for SUNDIALS external # --------------------------------------------------------------- -sundials_option(SUNDIALS_ENABLE_EXTERNAL_ADDONS BOOL +sundials_option( + SUNDIALS_ENABLE_EXTERNAL_ADDONS BOOL "Enables including EXTERNALLY MAINTAINED addons in the SUNDIALS build." OFF) if(SUNDIALS_ENABLE_EXTERNAL_ADDONS) - message(WARNING "SUNDIALS_ENABLE_EXTERNAL_ADDONS=TRUE. External addons are not maintained by the SUNDIALS team. Use at your own risk.") + message( + WARNING + "SUNDIALS_ENABLE_EXTERNAL_ADDONS=TRUE. External addons are not maintained by the SUNDIALS team. Use at your own risk." + ) endif() # --------------------------------------------------------------- # Options for SUNDIALS testing # --------------------------------------------------------------- -sundials_option(SUNDIALS_TEST_FLOAT_PRECISION STRING +sundials_option( + SUNDIALS_TEST_FLOAT_PRECISION STRING "Precision for floating point comparisons (number of digits)" "-1" ADVANCED) -sundials_option(SUNDIALS_TEST_INTEGER_PRECISION STRING +sundials_option( + SUNDIALS_TEST_INTEGER_PRECISION STRING "Precision for integer comparisons (percent difference)" "-1" ADVANCED) sundials_option(SUNDIALS_TEST_OUTPUT_DIR PATH - "Location to write testing output files" "" ADVANCED) + "Location to write testing output files" "" ADVANCED) sundials_option(SUNDIALS_TEST_ANSWER_DIR PATH - "Location of testing answer files" "" ADVANCED) + "Location of testing answer files" "" ADVANCED) sundials_option(SUNDIALS_TEST_PROFILE BOOL - "Use Caliper to profile SUNDIALS tests" OFF ADVANCED) + "Use Caliper to profile SUNDIALS tests" OFF ADVANCED) -sundials_option(SUNDIALS_TEST_NODIFF BOOL +sundials_option( + SUNDIALS_TEST_NODIFF BOOL "Disable output comparison in the regression test suite" OFF ADVANCED) -sundials_option(SUNDIALS_TEST_CONTAINER_EXE PATH - "Path to docker or podman" "" ADVANCED) +sundials_option(SUNDIALS_TEST_CONTAINER_EXE PATH "Path to docker or podman" "" + ADVANCED) -sundials_option(SUNDIALS_TEST_CONTAINER_RUN_EXTRA_ARGS STRING - "Extra arguments to pass to docker/podman run command" "--tls-verify=false" ADVANCED) +sundials_option( + SUNDIALS_TEST_CONTAINER_RUN_EXTRA_ARGS STRING + "Extra arguments to pass to docker/podman run command" "--tls-verify=false" + ADVANCED) -sundials_option(SUNDIALS_TEST_CONTAINER_MNT STRING +sundials_option( + SUNDIALS_TEST_CONTAINER_MNT STRING "Path to project root inside the container" "/sundials" ADVANCED) # Include development examples in regression tests sundials_option(SUNDIALS_TEST_DEVTESTS BOOL - "Include development tests in make test" OFF ADVANCED) + "Include development tests in make test" OFF ADVANCED) # Include unit tests in regression tests -sundials_option(SUNDIALS_TEST_UNITTESTS BOOL - "Include unit tests in make test" OFF ADVANCED) +sundials_option(SUNDIALS_TEST_UNITTESTS BOOL "Include unit tests in make test" + OFF ADVANCED) # Include googletest unit tests in regression tests -sundials_option(SUNDIALS_TEST_ENABLE_GTEST BOOL - "Disable GTest unit tests" ON ADVANCED) +sundials_option(SUNDIALS_TEST_ENABLE_GTEST BOOL "Disable GTest unit tests" ON + ADVANCED) -sundials_option(SUNDIALS_DEV_IWYU BOOL - "Enable include-what-you-use" OFF ADVANCED) +sundials_option(SUNDIALS_DEV_IWYU BOOL "Enable include-what-you-use" OFF + ADVANCED) -sundials_option(SUNDIALS_DEV_CLANG_TIDY BOOL - "Enable clang-tidy" OFF ADVANCED) +sundials_option(SUNDIALS_DEV_CLANG_TIDY BOOL "Enable clang-tidy" OFF ADVANCED) -sundials_option(SUNDIALS_SCHEDULER_COMMAND STRING "Job scheduler command to use to launch SUNDIALS MPI tests" "" ADVANCED) +sundials_option( + SUNDIALS_SCHEDULER_COMMAND STRING + "Job scheduler command to use to launch SUNDIALS MPI tests" "" ADVANCED) -sundials_option(SUNDIALS_CALIPER_OUTPUT_DIR PATH "Location to write caliper output files" "" ADVANCED) +sundials_option(SUNDIALS_CALIPER_OUTPUT_DIR PATH + "Location to write caliper output files" "" ADVANCED) -sundials_option(SUNDIALS_BENCHMARK_NUM_CPUS STRING "Number of CPU cores to run benchmarks with" "40" ADVANCED) +sundials_option(SUNDIALS_BENCHMARK_NUM_CPUS STRING + "Number of CPU cores to run benchmarks with" "40" ADVANCED) -sundials_option(SUNDIALS_BENCHMARK_NUM_GPUS STRING "Number of GPUs to run benchmarks with" "4" ADVANCED) +sundials_option(SUNDIALS_BENCHMARK_NUM_GPUS STRING + "Number of GPUs to run benchmarks with" "4" ADVANCED) diff --git a/cmake/SundialsDeprecated.cmake b/cmake/SundialsDeprecated.cmake index 702ee00aa5..e79d96b273 100644 --- a/cmake/SundialsDeprecated.cmake +++ b/cmake/SundialsDeprecated.cmake @@ -18,9 +18,10 @@ if(DEFINED F2003_INTERFACE_ENABLE) print_warning("The CMake option F2003_INTERFACE_ENABLE is deprecated" - "Use BUILD_FORTRAN_MODULE_INTERFACE instead" - MODE DEPRECATION) - set(BUILD_FORTRAN_MODULE_INTERFACE ${F2003_INTERFACE_ENABLE} CACHE BOOL "Enable Fortran 2003 module interfaces") + "Use BUILD_FORTRAN_MODULE_INTERFACE instead" MODE DEPRECATION) + set(BUILD_FORTRAN_MODULE_INTERFACE + ${F2003_INTERFACE_ENABLE} + CACHE BOOL "Enable Fortran 2003 module interfaces") endif() unset(F2003_INTERFACE_ENABLE CACHE) @@ -30,121 +31,146 @@ unset(F2003_INTERFACE_ENABLE CACHE) # if(DEFINED MPI_ENABLE) - print_warning("The CMake option MPI_ENABLE is deprecated" "Use ENABLE_MPI instead" - MODE DEPRECATION) - set(ENABLE_MPI ${MPI_ENABLE} CACHE BOOL "Enable MPI support" FORCE) + print_warning("The CMake option MPI_ENABLE is deprecated" + "Use ENABLE_MPI instead" MODE DEPRECATION) + set(ENABLE_MPI + ${MPI_ENABLE} + CACHE BOOL "Enable MPI support" FORCE) unset(MPI_ENABLE CACHE) endif() if(DEFINED OPENMP_ENABLE) - print_warning("The CMake option OPENMP_ENABLE is deprecated" "Use ENABLE_OPENMP instead" - MODE DEPRECATION) - set(ENABLE_OPENMP ${OPENMP_ENABLE} CACHE BOOL "Enable OpenMP support" FORCE) + print_warning("The CMake option OPENMP_ENABLE is deprecated" + "Use ENABLE_OPENMP instead" MODE DEPRECATION) + set(ENABLE_OPENMP + ${OPENMP_ENABLE} + CACHE BOOL "Enable OpenMP support" FORCE) unset(OPENMP_ENABLE CACHE) endif() if(DEFINED OPENMP_DEVICE_ENABLE) print_warning("The CMake option OPENMP_DEVICE_ENABLE is deprecated" - "Use ENABLE_OPENMP_DEVICE instead" - MODE DEPRECATION) - set(ENABLE_OPENMP_DEVICE ${OPENMP_DEVICE_ENABLE} CACHE BOOL - "Enable OpenMP device offloading support" FORCE) + "Use ENABLE_OPENMP_DEVICE instead" MODE DEPRECATION) + set(ENABLE_OPENMP_DEVICE + ${OPENMP_DEVICE_ENABLE} + CACHE BOOL "Enable OpenMP device offloading support" FORCE) unset(OPENMP_DEVICE_ENABLE CACHE) endif() if(DEFINED SKIP_OPENMP_DEVICE_CHECK) print_warning("The CMake option SKIP_OPENMP_DEVICE_CHECK is deprecated" - "Use OPENMP_DEVICE_WORKS instead" - MODE DEPRECATION) - set(OPENMP_DEVICE_WORKS ${SKIP_OPENMP_DEVICE_CHECK} CACHE BOOL - "Skip the compiler check for OpenMP device offloading" FORCE) + "Use OPENMP_DEVICE_WORKS instead" MODE DEPRECATION) + set(OPENMP_DEVICE_WORKS + ${SKIP_OPENMP_DEVICE_CHECK} + CACHE BOOL "Skip the compiler check for OpenMP device offloading" FORCE) unset(SKIP_OPENMP_DEVICE_CHECK CACHE) endif() if(DEFINED PTHREAD_ENABLE) - print_warning("The CMake option PTHREAD_ENABLE is deprecated" "Use ENABLE_PTHREAD instead" - MODE DEPRECATION) - set(ENABLE_PTHREAD ${PTHREAD_ENABLE} CACHE BOOL "Enable Pthreads support" FORCE) + print_warning("The CMake option PTHREAD_ENABLE is deprecated" + "Use ENABLE_PTHREAD instead" MODE DEPRECATION) + set(ENABLE_PTHREAD + ${PTHREAD_ENABLE} + CACHE BOOL "Enable Pthreads support" FORCE) unset(PTHREAD_ENABLE CACHE) endif() if(DEFINED CUDA_ENABLE) - print_warning("The CMake option CUDA_ENABLE is deprecated" "Use ENABLE_CUDA instead" - MODE DEPRECATION) - set(ENABLE_CUDA ${CUDA_ENABLE} CACHE BOOL "Enable CUDA support" FORCE) + print_warning("The CMake option CUDA_ENABLE is deprecated" + "Use ENABLE_CUDA instead" MODE DEPRECATION) + set(ENABLE_CUDA + ${CUDA_ENABLE} + CACHE BOOL "Enable CUDA support" FORCE) unset(CUDA_ENABLE CACHE) endif() if(DEFINED LAPACK_ENABLE) - print_warning("The CMake option LAPACK_ENABLE is deprecated" "Use ENABLE_LAPACK instead" - MODE DEPRECATION) - set(ENABLE_LAPACK ${LAPACK_ENABLE} CACHE BOOL "Enable LAPACK support" FORCE) + print_warning("The CMake option LAPACK_ENABLE is deprecated" + "Use ENABLE_LAPACK instead" MODE DEPRECATION) + set(ENABLE_LAPACK + ${LAPACK_ENABLE} + CACHE BOOL "Enable LAPACK support" FORCE) unset(LAPACK_ENABLE CACHE) endif() if(DEFINED SUPERLUDIST_ENABLE) print_warning("The CMake option SUPERLUDIST_ENABLE is deprecated" - "Use ENABLE_SUPERLUDIST instead" - MODE DEPRECATION) - set(ENABLE_SUPERLUDIST ${SUPERLUDIST_ENABLE} CACHE BOOL "Enable SuperLU_DIST support" FORCE) + "Use ENABLE_SUPERLUDIST instead" MODE DEPRECATION) + set(ENABLE_SUPERLUDIST + ${SUPERLUDIST_ENABLE} + CACHE BOOL "Enable SuperLU_DIST support" FORCE) unset(SUPERLUDIST_ENABLE CACHE) endif() # Deprecated with SUNDIALS 6.4.0 if(DEFINED SUPERLUDIST_LIBRARY_DIR) print_warning("The CMake option SUPERLUDIST_LIBRARY_DIR is deprecated" - "Use SUPERLUDIST_DIR instead" - MODE DEPRECATION) - set(SUPERLUDIST_DIR "${SUPERLUDIST_LIBRARY_DIR}/../" CACHE BOOL "SuperLU_DIST root directory" FORCE) + "Use SUPERLUDIST_DIR instead" MODE DEPRECATION) + set(SUPERLUDIST_DIR + "${SUPERLUDIST_LIBRARY_DIR}/../" + CACHE BOOL "SuperLU_DIST root directory" FORCE) unset(SUPERLUDIST_LIBRARY_DIR CACHE) endif() if(DEFINED SUPERLUDIST_INCLUDE_DIR) print_warning("The CMake option SUPERLUDIST_INCLUDE_DIR is deprecated" - "Use SUPERLUDIST_INCLUDE_DIRS instead" - MODE DEPRECATION) - set(SUPERLUDIST_INCLUDE_DIRS "${SUPERLUDIST_INCLUDE_DIR}" CACHE BOOL "SuperLU_DIST include directoroes" FORCE) + "Use SUPERLUDIST_INCLUDE_DIRS instead" MODE DEPRECATION) + set(SUPERLUDIST_INCLUDE_DIRS + "${SUPERLUDIST_INCLUDE_DIR}" + CACHE BOOL "SuperLU_DIST include directoroes" FORCE) unset(SUPERLUDIST_INCLUDE_DIR CACHE) endif() if(DEFINED SUPERLUMT_ENABLE) - print_warning("The CMake option SUPERLUMT_ENABLE is deprecated" "Use ENABLE_SUPERLUMT instead" - MODE DEPRECATION) - set(ENABLE_SUPERLUMT ${SUPERLUMT_ENABLE} CACHE BOOL "Enable SuperLU_MT support" FORCE) + print_warning("The CMake option SUPERLUMT_ENABLE is deprecated" + "Use ENABLE_SUPERLUMT instead" MODE DEPRECATION) + set(ENABLE_SUPERLUMT + ${SUPERLUMT_ENABLE} + CACHE BOOL "Enable SuperLU_MT support" FORCE) unset(SUPERLUMT_ENABLE CACHE) endif() if(DEFINED KLU_ENABLE) - print_warning("The CMake option KLU_ENABLE is deprecated" "Use ENABLE_KLU instead" - MODE DEPRECATION) - set(ENABLE_KLU ${KLU_ENABLE} CACHE BOOL "Enable KLU support" FORCE) + print_warning("The CMake option KLU_ENABLE is deprecated" + "Use ENABLE_KLU instead" MODE DEPRECATION) + set(ENABLE_KLU + ${KLU_ENABLE} + CACHE BOOL "Enable KLU support" FORCE) unset(KLU_ENABLE CACHE) endif() if(DEFINED HYPRE_ENABLE) - print_warning("The CMake option HYPRE_ENABLE is deprecated" "Use ENABLE_HYPRE instead" - MODE DEPRECATION) - set(ENABLE_HYPRE ${HYPRE_ENABLE} CACHE BOOL "Enable HYPRE support" FORCE) + print_warning("The CMake option HYPRE_ENABLE is deprecated" + "Use ENABLE_HYPRE instead" MODE DEPRECATION) + set(ENABLE_HYPRE + ${HYPRE_ENABLE} + CACHE BOOL "Enable HYPRE support" FORCE) unset(HYPRE_ENABLE CACHE) endif() if(DEFINED PETSC_ENABLE) - print_warning("The CMake option PETSC_ENABLE is deprecated" "Use ENABLE_PETSC instead" - MODE DEPRECATION) - set(ENABLE_PETSC ${PETSC_ENABLE} CACHE BOOL "Enable PETSC support" FORCE) + print_warning("The CMake option PETSC_ENABLE is deprecated" + "Use ENABLE_PETSC instead" MODE DEPRECATION) + set(ENABLE_PETSC + ${PETSC_ENABLE} + CACHE BOOL "Enable PETSC support" FORCE) unset(PETSC_ENABLE CACHE) endif() if(DEFINED Trilinos_ENABLE) - print_warning("The CMake option Trilinos_ENABLE is deprecated" "Use ENABLE_TRILINOS instead" - MODE DEPRECATION) - set(ENABLE_TRILINOS ${Trilinos_ENABLE} CACHE BOOL "Enable Trilinos support" FORCE) + print_warning("The CMake option Trilinos_ENABLE is deprecated" + "Use ENABLE_TRILINOS instead" MODE DEPRECATION) + set(ENABLE_TRILINOS + ${Trilinos_ENABLE} + CACHE BOOL "Enable Trilinos support" FORCE) unset(Trilinos_ENABLE CACHE) endif() if(DEFINED RAJA_ENABLE) - print_warning("The CMake option RAJA_ENABLE is deprecated" "Use ENABLE_RAJA instead" - MODE DEPRECATION) - set(ENABLE_RAJA ${RAJA_ENABLE} CACHE BOOL "Enable RAJA support" FORCE) + print_warning("The CMake option RAJA_ENABLE is deprecated" + "Use ENABLE_RAJA instead" MODE DEPRECATION) + set(ENABLE_RAJA + ${RAJA_ENABLE} + CACHE BOOL "Enable RAJA support" FORCE) unset(RAJA_ENABLE CACHE) endif() @@ -153,10 +179,12 @@ endif() # if(DEFINED CUDA_ARCH) - print_warning("The CMake option CUDA_ARCH is deprecated" "Use CMAKE_CUDA_ARCHITECTURES instead" - MODE DEPRECATION) + print_warning("The CMake option CUDA_ARCH is deprecated" + "Use CMAKE_CUDA_ARCHITECTURES instead" MODE DEPRECATION) # convert sm_** to just ** string(REGEX MATCH "[0-9]+" arch_name "${CUDA_ARCH}") - set(CMAKE_CUDA_ARCHITECTURES ${arch_name} CACHE STRING "CUDA Architectures" FORCE) + set(CMAKE_CUDA_ARCHITECTURES + ${arch_name} + CACHE STRING "CUDA Architectures" FORCE) unset(CUDA_ARCH) endif() diff --git a/cmake/SundialsExampleOptions.cmake b/cmake/SundialsExampleOptions.cmake index 29f099eb1e..fb2431709d 100644 --- a/cmake/SundialsExampleOptions.cmake +++ b/cmake/SundialsExampleOptions.cmake @@ -22,9 +22,16 @@ sundials_option(EXAMPLES_ENABLE_C BOOL "Build SUNDIALS C examples" ON) # Some TPLs only have C++ examples. Default the C++ examples to ON if any of # these are enabled on the initial configuration pass. -if (ENABLE_TRILINOS OR ENABLE_SUPERLUDIST OR ENABLE_XBRAID OR ENABLE_HIP OR - ENABLE_MAGMA OR ENABLE_SYCL OR ENABLE_ONEMKL OR ENABLE_RAJA OR ENABLE_GINKGO OR - ENABLE_KOKKOS) +if(ENABLE_TRILINOS + OR ENABLE_SUPERLUDIST + OR ENABLE_XBRAID + OR ENABLE_HIP + OR ENABLE_MAGMA + OR ENABLE_SYCL + OR ENABLE_ONEMKL + OR ENABLE_RAJA + OR ENABLE_GINKGO + OR ENABLE_KOKKOS) sundials_option(EXAMPLES_ENABLE_CXX BOOL "Build SUNDIALS C++ examples" ON) else() sundials_option(EXAMPLES_ENABLE_CXX BOOL "Build SUNDIALS C++ examples" OFF) @@ -38,20 +45,24 @@ endif() # Fortran 2003 interface is enabled. set(DOCSTR "Build SUNDIALS Fortran 2003 examples") if(BUILD_FORTRAN_MODULE_INTERFACE) - set(EXAMPLES_ENABLE_F2003 ON CACHE BOOL "${DOCSTR}") + set(EXAMPLES_ENABLE_F2003 + ON + CACHE BOOL "${DOCSTR}") # Fortran 2003 examples only support double precision if(EXAMPLES_ENABLE_F2003 AND (NOT (SUNDIALS_PRECISION MATCHES "DOUBLE"))) - print_warning("F2003 examples are not compatible with ${SUNDIALS_PRECISION} precision. " - "Setting EXAMPLES_ENABLE_F2003 to OFF.") + print_warning( + "F2003 examples are not compatible with ${SUNDIALS_PRECISION} precision. " + "Setting EXAMPLES_ENABLE_F2003 to OFF.") force_variable(EXAMPLES_ENABLE_F2003 BOOL "${DOCSTR}" OFF) endif() else() # set back to OFF (in case it was ON) if(EXAMPLES_ENABLE_F2003) - print_warning("EXAMPLES_ENABLE_F2003 is ON but BUILD_FORTRAN_MODULE_INTERFACE is OFF. " - "Setting EXAMPLES_ENABLE_F2003 to OFF.") + print_warning( + "EXAMPLES_ENABLE_F2003 is ON but BUILD_FORTRAN_MODULE_INTERFACE is OFF. " + "Setting EXAMPLES_ENABLE_F2003 to OFF.") force_variable(EXAMPLES_ENABLE_F2003 BOOL "${DOCSTR}" OFF) endif() @@ -71,25 +82,32 @@ sundials_option(EXAMPLES_ENABLE_CUDA BOOL "Build SUNDIALS CUDA examples" ON # Enable installing examples by default sundials_option(EXAMPLES_INSTALL BOOL "Install SUNDIALS examples" ON) -sundials_option(EXAMPLES_INSTALL_PATH PATH "Output directory for installing example files" "${CMAKE_INSTALL_PREFIX}/examples") +sundials_option( + EXAMPLES_INSTALL_PATH PATH "Output directory for installing example files" + "${CMAKE_INSTALL_PREFIX}/examples") # If examples are to be exported, check where we should install them. if(EXAMPLES_INSTALL AND NOT EXAMPLES_INSTALL_PATH) print_warning("The example installation path is empty. " "Example installation path was reset to its default value") - set(EXAMPLES_INSTALL_PATH "${CMAKE_INSTALL_PREFIX}/examples" CACHE STRING - "Output directory for installing example files" FORCE) + set(EXAMPLES_INSTALL_PATH + "${CMAKE_INSTALL_PREFIX}/examples" + CACHE STRING "Output directory for installing example files" FORCE) endif() # ----------------------------------------------------------------------------- # Internal variables. # ----------------------------------------------------------------------------- -if(EXAMPLES_ENABLE_C OR - EXAMPLES_ENABLE_CXX OR - EXAMPLES_ENABLE_CUDA OR - EXAMPLES_ENABLE_F2003) - set(_BUILD_EXAMPLES TRUE CACHE INTERNAL "") +if(EXAMPLES_ENABLE_C + OR EXAMPLES_ENABLE_CXX + OR EXAMPLES_ENABLE_CUDA + OR EXAMPLES_ENABLE_F2003) + set(_BUILD_EXAMPLES + TRUE + CACHE INTERNAL "") else() - set(_BUILD_EXAMPLES FALSE CACHE INTERNAL "") + set(_BUILD_EXAMPLES + FALSE + CACHE INTERNAL "") endif() diff --git a/cmake/SundialsIndexSize.cmake b/cmake/SundialsIndexSize.cmake index 88c676b41b..5390af11b0 100644 --- a/cmake/SundialsIndexSize.cmake +++ b/cmake/SundialsIndexSize.cmake @@ -25,7 +25,7 @@ if(SUNDIALS_INDEX_SIZE MATCHES "64") set(SUNDIALS_CINDEX_TYPE "") # if the user specified an index type use it, otherwise try the standard options - if (SUNDIALS_INDEX_TYPE) + if(SUNDIALS_INDEX_TYPE) set(POSSIBLE_INT64 ${SUNDIALS_INDEX_TYPE}) else() set(POSSIBLE_INT64 int64_t;__int64;long long;long) @@ -42,7 +42,8 @@ if(SUNDIALS_INDEX_SIZE MATCHES "64") endforeach() if(NOT SUNDIALS_CINDEX_TYPE) - print_error("No integer type of size 8 was found.\n\ + print_error( + "No integer type of size 8 was found.\n\ Tried ${POSSIBLE_INT64}.\n\ Try setting the advanced option SUNDIALS_INDEX_TYPE.") endif() @@ -53,7 +54,7 @@ elseif(SUNDIALS_INDEX_SIZE MATCHES "32") set(SUNDIALS_CINDEX_TYPE "") # if the user specified an index type use it, otherwise try the standard options - if (SUNDIALS_INDEX_TYPE) + if(SUNDIALS_INDEX_TYPE) set(POSSIBLE_INT32 ${SUNDIALS_INDEX_TYPE}) else() set(POSSIBLE_INT32 int32_t;int;long) @@ -70,7 +71,8 @@ elseif(SUNDIALS_INDEX_SIZE MATCHES "32") endforeach() if(NOT SUNDIALS_CINDEX_TYPE) - print_error("No integer type of size 4 was found.\n\ + print_error( + "No integer type of size 4 was found.\n\ Tried ${POSSIBLE_INT32}\n\ Try setting the advanced option SUNDIALS_INDEX_TYPE.") endif() diff --git a/cmake/SundialsSetupCXX.cmake b/cmake/SundialsSetupCXX.cmake index 32a6a9b003..aa345d4ffb 100644 --- a/cmake/SundialsSetupCXX.cmake +++ b/cmake/SundialsSetupCXX.cmake @@ -26,17 +26,15 @@ set(CXX_FOUND TRUE) # Do not allow decaying to previous standards -- generates error if the standard # is not supported -sundials_option(CMAKE_CXX_STANDARD_REQUIRED BOOL - "Require C++ standard version" ON) +sundials_option(CMAKE_CXX_STANDARD_REQUIRED BOOL "Require C++ standard version" + ON) if(ENABLE_SYCL) set(DOCSTR "The C++ standard to use if C++ is enabled (17, 20)") - sundials_option(CMAKE_CXX_STANDARD STRING "${DOCSTR}" "17" - OPTIONS "17;20") + sundials_option(CMAKE_CXX_STANDARD STRING "${DOCSTR}" "17" OPTIONS "17;20") else() set(DOCSTR "The C++ standard to use if C++ is enabled (14, 17, 20)") - sundials_option(CMAKE_CXX_STANDARD STRING "${DOCSTR}" "14" - OPTIONS "14;17;20") + sundials_option(CMAKE_CXX_STANDARD STRING "${DOCSTR}" "14" OPTIONS "14;17;20") endif() message(STATUS "CXX standard set to ${CMAKE_CXX_STANDARD}") diff --git a/cmake/SundialsSetupCompilers.cmake b/cmake/SundialsSetupCompilers.cmake index f4b226e96d..9c887b4cfe 100644 --- a/cmake/SundialsSetupCompilers.cmake +++ b/cmake/SundialsSetupCompilers.cmake @@ -38,7 +38,8 @@ endif() if(APPLE) # Allow undefined symbols that will be resolved by a user program. - set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS} -undefined dynamic_lookup") + set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS + "${CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS} -undefined dynamic_lookup") endif() # =============================================================== @@ -61,7 +62,8 @@ if(BUILD_SHARED_LIBS) set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) # the RPATH to be used when installing, but only if it's not a system directory - list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_FULL_LIBDIR}" isSystemDir) + list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES + "${CMAKE_INSTALL_FULL_LIBDIR}" isSystemDir) if("${isSystemDir}" STREQUAL "-1") set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_FULL_LIBDIR}") endif() @@ -82,7 +84,8 @@ if(ENABLE_ALL_WARNINGS) set(CMAKE_CXX_FLAGS "-Wdouble-promotion ${CMAKE_CXX_FLAGS}") endif() - if((SUNDIALS_PRECISION MATCHES "DOUBLE") AND (SUNDIALS_INDEX_SIZE MATCHES "32")) + if((SUNDIALS_PRECISION MATCHES "DOUBLE") AND (SUNDIALS_INDEX_SIZE MATCHES "32" + )) set(CMAKE_C_FLAGS "-Wconversion -Wno-sign-conversion ${CMAKE_C_FLAGS}") set(CMAKE_CXX_FLAGS "-Wconversion -Wno-sign-conversion ${CMAKE_CXX_FLAGS}") endif() @@ -108,7 +111,9 @@ if(ENABLE_ALL_WARNINGS) # (no-recursion) e.g., ark_brusselator1D_task_local_nls_f2003 calls # SUNNonlinsolFree from within a custom nonlinear solver implementation of # SUNNonlinsolFree which causes a run-time error with this check - set(CMAKE_Fortran_FLAGS "-Wall -Wpedantic -Wno-unused-dummy-argument -Wno-c-binding-type -ffpe-summary=none ${CMAKE_Fortran_FLAGS}") + set(CMAKE_Fortran_FLAGS + "-Wall -Wpedantic -Wno-unused-dummy-argument -Wno-c-binding-type -ffpe-summary=none ${CMAKE_Fortran_FLAGS}" + ) endif() if(ENABLE_WARNINGS_AS_ERRORS) @@ -122,16 +127,22 @@ endif() if(ENABLE_ADDRESS_SANITIZER) message(STATUS "Enabling address sanitizer") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fsanitize=leak -fsanitize=undefined") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fsanitize=leak -fsanitize=undefined") - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fsanitize=address -fsanitize=leak -fsanitize=undefined") + set(CMAKE_C_FLAGS + "${CMAKE_C_FLAGS} -fsanitize=address -fsanitize=leak -fsanitize=undefined" + ) + set(CMAKE_CXX_FLAGS + "${CMAKE_CXX_FLAGS} -fsanitize=address -fsanitize=leak -fsanitize=undefined" + ) + set(CMAKE_Fortran_FLAGS + "${CMAKE_Fortran_FLAGS} -fsanitize=address -fsanitize=leak -fsanitize=undefined" + ) endif() if(SUNDIALS_DEBUG) message(STATUS "Adding debugging preprocessor directives") foreach(debug ${_SUNDIALS_DEBUG_OPTIONS}) - if (${${debug}}) + if(${${debug}}) add_compile_definitions(${debug}) endif() endforeach() @@ -142,8 +153,7 @@ endif() # =============================================================== set(DOCSTR "The C standard to use (99, 11, 17)") -sundials_option(CMAKE_C_STANDARD STRING "${DOCSTR}" "99" - OPTIONS "99;11;17") +sundials_option(CMAKE_C_STANDARD STRING "${DOCSTR}" "99" OPTIONS "99;11;17") message(STATUS "C standard set to ${CMAKE_C_STANDARD}") set(DOCSTR "Enable C compiler specific extensions") @@ -154,7 +164,8 @@ message(STATUS "C extensions set to ${CMAKE_C_EXTENSIONS}") # Check for __builtin_expect # --------------------------------------------------------------- -check_c_source_compiles(" +check_c_source_compiles( + " #include int main(void) { double a = 0.0; @@ -165,14 +176,16 @@ check_c_source_compiles(" printf(\"a=%g\", a); return 0; } -" SUNDIALS_C_COMPILER_HAS_BUILTIN_EXPECT) +" + SUNDIALS_C_COMPILER_HAS_BUILTIN_EXPECT) # --------------------------------------------------------------- # Check for assume related extensions # --------------------------------------------------------------- # gcc >= 13 should have __attribute__((assume)) -check_c_source_compiles(" +check_c_source_compiles( + " #include int main(void) { double a = 0.0; @@ -188,11 +201,13 @@ check_c_source_compiles(" printf(\"a=%g\", a); return 0; } -" SUNDIALS_C_COMPILER_HAS_ATTRIBUTE_ASSUME) +" + SUNDIALS_C_COMPILER_HAS_ATTRIBUTE_ASSUME) # LLVM based compilers should have __builtin_assume if(NOT SUNDIALS_C_COMPILER_HAS_ATTRIBUTE_ASSUME) - check_c_source_compiles(" + check_c_source_compiles( + " #include int main(void) { double a = 0.0; @@ -201,12 +216,15 @@ if(NOT SUNDIALS_C_COMPILER_HAS_ATTRIBUTE_ASSUME) printf(\"a=%g\", a); return 0; } - " SUNDIALS_C_COMPILER_HAS_BUILTIN_ASSUME) + " + SUNDIALS_C_COMPILER_HAS_BUILTIN_ASSUME) endif() # MSVC provides __assume -if(NOT (SUNDIALS_C_COMPILER_HAS_ATTRIBUTE_ASSUME OR SUNDIALS_C_COMPILER_HAS_BUILTIN_ASSUME)) - check_c_source_compiles(" +if(NOT (SUNDIALS_C_COMPILER_HAS_ATTRIBUTE_ASSUME + OR SUNDIALS_C_COMPILER_HAS_BUILTIN_ASSUME)) + check_c_source_compiles( + " #include int main(void) { double a = 0.0; @@ -215,19 +233,22 @@ if(NOT (SUNDIALS_C_COMPILER_HAS_ATTRIBUTE_ASSUME OR SUNDIALS_C_COMPILER_HAS_BUIL printf(\"a=%g\", a); return 0; } - " SUNDIALS_C_COMPILER_HAS_ASSUME) + " + SUNDIALS_C_COMPILER_HAS_ASSUME) endif() # --------------------------------------------------------------- # Check for unused extension # --------------------------------------------------------------- -check_c_source_compiles(" +check_c_source_compiles( + " int main(void) { __attribute__((unused)) double a = 0.0; return 0; } -" SUNDIALS_C_COMPILER_HAS_ATTRIBUTE_UNUSED) +" + SUNDIALS_C_COMPILER_HAS_ATTRIBUTE_UNUSED) # --------------------------------------------------------------- # Check for POSIX timers @@ -236,25 +257,29 @@ include(SundialsPOSIXTimers) if(SUNDIALS_POSIX_TIMERS AND POSIX_TIMERS_NEED_POSIX_C_SOURCE) set(DOCSTR "Value of _POSIX_C_SOURCE") - sundials_option(SUNDIALS_POSIX_C_SOURCE STRING "${DOCSTR}" "200112L" - ADVANCED) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_POSIX_C_SOURCE=${SUNDIALS_POSIX_C_SOURCE}") + sundials_option(SUNDIALS_POSIX_C_SOURCE STRING "${DOCSTR}" "200112L" ADVANCED) + set(CMAKE_C_FLAGS + "${CMAKE_C_FLAGS} -D_POSIX_C_SOURCE=${SUNDIALS_POSIX_C_SOURCE}") endif() - # --------------------------------------------------------------- # Check for deprecated attribute with message # --------------------------------------------------------------- if(WIN32) - set(COMPILER_DEPRECATED_MSG_ATTRIBUTE "__declspec(deprecated(msg))" CACHE INTERNAL "") + set(COMPILER_DEPRECATED_MSG_ATTRIBUTE + "__declspec(deprecated(msg))" + CACHE INTERNAL "") else() - set(COMPILER_DEPRECATED_MSG_ATTRIBUTE "__attribute__ ((__deprecated__(msg)))" CACHE INTERNAL "") + set(COMPILER_DEPRECATED_MSG_ATTRIBUTE + "__attribute__ ((__deprecated__(msg)))" + CACHE INTERNAL "") endif() -check_c_source_compiles(" +check_c_source_compiles( + " #define msg \"test\" ${COMPILER_DEPRECATED_MSG_ATTRIBUTE} int somefunc(void) { return 0; } - int main(void) { return somefunc();}" COMPILER_HAS_DEPRECATED_MSG -) + int main(void) { return somefunc();}" + COMPILER_HAS_DEPRECATED_MSG) # =============================================================== # Fortran settings @@ -282,24 +307,22 @@ endif() # The case to use in the name-mangling scheme sundials_option(SUNDIALS_LAPACK_CASE STRING - "case of LAPACK function names (lower/upper)" - "" - ADVANCED) + "case of LAPACK function names (lower/upper)" "" ADVANCED) # The number of underscores of appended in the name-mangling scheme -sundials_option(SUNDIALS_LAPACK_UNDERSCORES STRING - "number of underscores appended to LAPACK function names (none/one/two)" - "" - ADVANCED) +sundials_option( + SUNDIALS_LAPACK_UNDERSCORES STRING + "number of underscores appended to LAPACK function names (none/one/two)" "" + ADVANCED) # If used, both case and underscores must be set if((NOT SUNDIALS_LAPACK_CASE) AND SUNDIALS_LAPACK_UNDERSCORES) print_error("If SUNDIALS_LAPACK_UNDERSCORES is set, " - "SUNDIALS_LAPACK_CASE must also be set.") + "SUNDIALS_LAPACK_CASE must also be set.") endif() if(SUNDIALS_LAPACK_CASE AND (NOT SUNDIALS_LAPACK_UNDERSCORES)) print_error("If SUNDIALS_LAPACK_CASE is set, " - "SUNDIALS_LAPACK_UNDERSCORES must also be set.") + "SUNDIALS_LAPACK_UNDERSCORES must also be set.") endif() # Did the user provide a name-mangling scheme? @@ -318,11 +341,15 @@ if(SUNDIALS_LAPACK_CASE AND SUNDIALS_LAPACK_UNDERSCORES) set(LAPACK_MANGLE_MACRO1 "#define SUNDIALS_LAPACK_FUNC(name,NAME) name") set(LAPACK_MANGLE_MACRO2 "#define SUNDIALS_LAPACK_FUNC_(name,NAME) name") elseif(SUNDIALS_LAPACK_UNDERSCORES MATCHES "ONE") - set(LAPACK_MANGLE_MACRO1 "#define SUNDIALS_LAPACK_FUNC(name,NAME) name ## _") - set(LAPACK_MANGLE_MACRO2 "#define SUNDIALS_LAPACK_FUNC_(name,NAME) name ## _") + set(LAPACK_MANGLE_MACRO1 + "#define SUNDIALS_LAPACK_FUNC(name,NAME) name ## _") + set(LAPACK_MANGLE_MACRO2 + "#define SUNDIALS_LAPACK_FUNC_(name,NAME) name ## _") elseif(SUNDIALS_LAPACK_UNDERSCORES MATCHES "TWO") - set(LAPACK_MANGLE_MACRO1 "#define SUNDIALS_LAPACK_FUNC(name,NAME) name ## __") - set(LAPACK_MANGLE_MACRO2 "#define SUNDIALS_LAPACK_FUNC_(name,NAME) name ## __") + set(LAPACK_MANGLE_MACRO1 + "#define SUNDIALS_LAPACK_FUNC(name,NAME) name ## __") + set(LAPACK_MANGLE_MACRO2 + "#define SUNDIALS_LAPACK_FUNC_(name,NAME) name ## __") else() print_error("Invalid SUNDIALS_LAPACK_UNDERSCORES option.") endif() @@ -331,11 +358,15 @@ if(SUNDIALS_LAPACK_CASE AND SUNDIALS_LAPACK_UNDERSCORES) set(LAPACK_MANGLE_MACRO1 "#define SUNDIALS_LAPACK_FUNC(name,NAME) NAME") set(LAPACK_MANGLE_MACRO2 "#define SUNDIALS_LAPACK_FUNC_(name,NAME) NAME") elseif(SUNDIALS_LAPACK_UNDERSCORES MATCHES "ONE") - set(LAPACK_MANGLE_MACRO1 "#define SUNDIALS_LAPACK_FUNC(name,NAME) NAME ## _") - set(LAPACK_MANGLE_MACRO2 "#define SUNDIALS_LAPACK_FUNC_(name,NAME) NAME ## _") + set(LAPACK_MANGLE_MACRO1 + "#define SUNDIALS_LAPACK_FUNC(name,NAME) NAME ## _") + set(LAPACK_MANGLE_MACRO2 + "#define SUNDIALS_LAPACK_FUNC_(name,NAME) NAME ## _") elseif(SUNDIALS_LAPACK_UNDERSCORES MATCHES "TWO") - set(LAPACK_MANGLE_MACRO1 "#define SUNDIALS_LAPACK_FUNC(name,NAME) NAME ## __") - set(LAPACK_MANGLE_MACRO2 "#define SUNDIALS_LAPACK_FUNC_(name,NAME) NAME ## __") + set(LAPACK_MANGLE_MACRO1 + "#define SUNDIALS_LAPACK_FUNC(name,NAME) NAME ## __") + set(LAPACK_MANGLE_MACRO2 + "#define SUNDIALS_LAPACK_FUNC_(name,NAME) NAME ## __") else() print_error("Invalid SUNDIALS_LAPACK_UNDERSCORES option.") endif() @@ -346,16 +377,13 @@ if(SUNDIALS_LAPACK_CASE AND SUNDIALS_LAPACK_UNDERSCORES) # name-mangling scheme has been manually set set(NEED_FORTRAN_NAME_MANGLING FALSE) - configure_file( - ${PROJECT_SOURCE_DIR}/src/sundials/sundials_lapack_defs.h.in - ${PROJECT_BINARY_DIR}/src/sundials/sundials_lapack_defs.h - ) + configure_file(${PROJECT_SOURCE_DIR}/src/sundials/sundials_lapack_defs.h.in + ${PROJECT_BINARY_DIR}/src/sundials/sundials_lapack_defs.h) endif() # Do we need a Fortran compiler? -if(BUILD_FORTRAN_MODULE_INTERFACE OR - NEED_FORTRAN_NAME_MANGLING) +if(BUILD_FORTRAN_MODULE_INTERFACE OR NEED_FORTRAN_NAME_MANGLING) include(SundialsSetupFortran) endif() @@ -363,17 +391,19 @@ endif() # C++ settings # =============================================================== -if(BUILD_BENCHMARKS OR SUNDIALS_TEST_UNITTESTS OR EXAMPLES_ENABLE_CXX OR - ENABLE_CUDA OR - ENABLE_HIP OR - ENABLE_SYCL OR - ENABLE_RAJA OR - ENABLE_TRILINOS OR - ENABLE_SUPERLUDIST OR - ENABLE_MAGMA OR - ENABLE_GINKGO OR - ENABLE_KOKKOS OR - ENABLE_ADIAK) +if(BUILD_BENCHMARKS + OR SUNDIALS_TEST_UNITTESTS + OR EXAMPLES_ENABLE_CXX + OR ENABLE_CUDA + OR ENABLE_HIP + OR ENABLE_SYCL + OR ENABLE_RAJA + OR ENABLE_TRILINOS + OR ENABLE_SUPERLUDIST + OR ENABLE_MAGMA + OR ENABLE_GINKGO + OR ENABLE_KOKKOS + OR ENABLE_ADIAK) include(SundialsSetupCXX) endif() @@ -431,7 +461,6 @@ foreach(lang ${_SUNDIALS_ENABLED_LANGS}) mark_as_advanced(CLEAR CMAKE_${lang}_COMPILER CMAKE_${lang}_FLAGS) endforeach() - # =============================================================== # Configure compilers for installed examples # =============================================================== @@ -439,14 +468,17 @@ endforeach() foreach(lang ${_SUNDIALS_ENABLED_LANGS}) if(ENABLE_MPI) if(DEFINED MPI_${lang}_COMPILER) - set(_EXAMPLES_${lang}_COMPILER "${MPI_${lang}_COMPILER}" CACHE INTERNAL "${lang} compiler for installed examples") + set(_EXAMPLES_${lang}_COMPILER + "${MPI_${lang}_COMPILER}" + CACHE INTERNAL "${lang} compiler for installed examples") endif() else() - set(_EXAMPLES_${lang}_COMPILER "${CMAKE_${lang}_COMPILER}" CACHE INTERNAL "${lang} compiler for installed examples") + set(_EXAMPLES_${lang}_COMPILER + "${CMAKE_${lang}_COMPILER}" + CACHE INTERNAL "${lang} compiler for installed examples") endif() endforeach() - # =============================================================== # Configure clang-tidy for linting # =============================================================== @@ -456,7 +488,7 @@ set(SUNDIALS_DEV_CLANG_TIDY_DIR ${CMAKE_BINARY_DIR}/clang-tidy/) if(SUNDIALS_DEV_CLANG_TIDY) find_program(CLANG_TIDY_PATH NAMES clang-tidy) if(NOT CLANG_TIDY_PATH) - message(FATAL_ERROR "Could not find the program clang-tidy") + message(FATAL_ERROR "Could not find the program clang-tidy") endif() message(STATUS "Found clang-tidy: ${CLANG_TIDY_PATH}") @@ -465,15 +497,12 @@ if(SUNDIALS_DEV_CLANG_TIDY) set(CMAKE_C_CLANG_TIDY ${CLANG_TIDY_PATH} -format-style='file' --fix) set(CMAKE_CXX_CLANG_TIDY ${CLANG_TIDY_PATH} -format-style='file' --fix) else() - set(CMAKE_C_CLANG_TIDY ${CLANG_TIDY_PATH} - -format-style='file' - --export-fixes=${SUNDIALS_DEV_CLANG_TIDY_DIR}/clang-tidy-fixes.yaml - ) + set(CMAKE_C_CLANG_TIDY + ${CLANG_TIDY_PATH} -format-style='file' + --export-fixes=${SUNDIALS_DEV_CLANG_TIDY_DIR}/clang-tidy-fixes.yaml) set(CMAKE_CXX_CLANG_TIDY - ${CLANG_TIDY_PATH} - -format-style='file' - --export-fixes=${SUNDIALS_DEV_CLANG_TIDY_DIR}/clang-tidy-cxx-fixes.yaml - ) + ${CLANG_TIDY_PATH} -format-style='file' + --export-fixes=${SUNDIALS_DEV_CLANG_TIDY_DIR}/clang-tidy-cxx-fixes.yaml) endif() endif() @@ -483,10 +512,10 @@ if(SUNDIALS_DEV_IWYU) message(FATAL_ERROR "Could not find the program include-what-you-use") endif() message(STATUS "Found IWYU: ${IWYU_PATH}") - set(CMAKE_C_INCLUDE_WHAT_YOU_USE ${IWYU_PATH} - -Xiwyu --mapping_file=${CMAKE_SOURCE_DIR}/scripts/iwyu.imp - -Xiwyu --error_always) - set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE ${IWYU_PATH} - -Xiwyu --mapping_file=${CMAKE_SOURCE_DIR}/scripts/iwyu.imp - -Xiwyu --error_always) + set(CMAKE_C_INCLUDE_WHAT_YOU_USE + ${IWYU_PATH} -Xiwyu --mapping_file=${CMAKE_SOURCE_DIR}/scripts/iwyu.imp + -Xiwyu --error_always) + set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE + ${IWYU_PATH} -Xiwyu --mapping_file=${CMAKE_SOURCE_DIR}/scripts/iwyu.imp + -Xiwyu --error_always) endif() diff --git a/cmake/SundialsSetupConfig.cmake b/cmake/SundialsSetupConfig.cmake index 482a267ac4..c506ea1ac9 100644 --- a/cmake/SundialsSetupConfig.cmake +++ b/cmake/SundialsSetupConfig.cmake @@ -44,7 +44,6 @@ else() string(TIMESTAMP JOB_START_TIME "%Y%m%d%H%M%S") endif() - # ============================================================================ # Generate macros and substitution variables related to TPLs # that SUNDIALS is being built with. @@ -94,7 +93,5 @@ endif() # Generate the header file and place it in the binary dir. # ============================================================================= -configure_file( - ${PROJECT_SOURCE_DIR}/include/sundials/sundials_config.in - ${PROJECT_BINARY_DIR}/include/sundials/sundials_config.h - ) +configure_file(${PROJECT_SOURCE_DIR}/include/sundials/sundials_config.in + ${PROJECT_BINARY_DIR}/include/sundials/sundials_config.h) diff --git a/cmake/SundialsSetupCuda.cmake b/cmake/SundialsSetupCuda.cmake index f971e691a6..1a56507221 100644 --- a/cmake/SundialsSetupCuda.cmake +++ b/cmake/SundialsSetupCuda.cmake @@ -21,7 +21,9 @@ if(NOT CMAKE_CUDA_HOST_COMPILER) # If a user did not provide the host compiler, then we # assume that they want to use the CXX compiler that was set. - set(CMAKE_CUDA_HOST_COMPILER ${CMAKE_CXX_COMPILER} CACHE FILEPATH "NVCC host compiler") + set(CMAKE_CUDA_HOST_COMPILER + ${CMAKE_CXX_COMPILER} + CACHE FILEPATH "NVCC host compiler") endif() # =============================================================== @@ -31,18 +33,19 @@ endif() # Do not allow decaying to previous standards -- generates error if the standard # is not supported sundials_option(CMAKE_CUDA_STANDARD_REQUIRED BOOL - "Require C++ standard version" ON) + "Require C++ standard version" ON) set(DOCSTR "The CUDA standard to use if CUDA is enabled (14, 17, 20)") sundials_option(CMAKE_CUDA_STANDARD STRING "${DOCSTR}" "${CMAKE_CXX_STANDARD}" OPTIONS "14;17;20") message(STATUS "CUDA standard set to ${CMAKE_CUDA_STANDARD}") -set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --expt-extended-lambda --expt-relaxed-constexpr") +set(CMAKE_CUDA_FLAGS + "${CMAKE_CUDA_FLAGS} --expt-extended-lambda --expt-relaxed-constexpr") -if( (CMAKE_CXX_COMPILER_ID MATCHES GNU) - OR (CMAKE_CXX_COMPILER_ID MATCHES Clang) - AND (CMAKE_SYSTEM_PROCESSOR MATCHES ppc64le) ) +if((CMAKE_CXX_COMPILER_ID MATCHES GNU) + OR (CMAKE_CXX_COMPILER_ID MATCHES Clang) + AND (CMAKE_SYSTEM_PROCESSOR MATCHES ppc64le)) include(CheckCXXCompilerFlag) check_cxx_compiler_flag(-mno-float128 _hasflag) if(_hasflag) @@ -75,15 +78,19 @@ message(STATUS "CUDA Library Directory: ${CUDAToolkit_LIBRARY_DIR}") message(STATUS "CUDA Compile Flags: ${CMAKE_CUDA_FLAGS}") message(STATUS "CUDA Link Flags: ${CMAKE_CUDA_LINK_FLAGS}") message(STATUS "CUDA Link Executable: ${CMAKE_CUDA_LINK_EXECUTABLE}") -message(STATUS "CUDA Separable Compilation: ${CMAKE_CUDA_SEPARABLE_COMPILATION}") - +message( + STATUS "CUDA Separable Compilation: ${CMAKE_CUDA_SEPARABLE_COMPILATION}") # =============================================================== # Configure compiler for installed examples # =============================================================== if(ENABLE_MPI) - set(_EXAMPLES_CUDA_HOST_COMPILER "${MPI_CXX_COMPILER}" CACHE INTERNAL "${lang} compiler for installed examples") + set(_EXAMPLES_CUDA_HOST_COMPILER + "${MPI_CXX_COMPILER}" + CACHE INTERNAL "${lang} compiler for installed examples") else() - set(_EXAMPLES_CUDA_HOST_COMPILER "${CMAKE_CUDA_HOST_COMPILER}" CACHE INTERNAL "${lang} compiler for installed examples") + set(_EXAMPLES_CUDA_HOST_COMPILER + "${CMAKE_CUDA_HOST_COMPILER}" + CACHE INTERNAL "${lang} compiler for installed examples") endif() diff --git a/cmake/SundialsSetupFortran.cmake b/cmake/SundialsSetupFortran.cmake index 1daee0b7b2..6ab3d8d325 100644 --- a/cmake/SundialsSetupFortran.cmake +++ b/cmake/SundialsSetupFortran.cmake @@ -39,7 +39,8 @@ if(BUILD_FORTRAN_MODULE_INTERFACE) file(MAKE_DIRECTORY ${F2003Test_DIR}) # Create a CMakeLists.txt file - file(WRITE ${F2003Test_DIR}/CMakeLists.txt + file( + WRITE ${F2003Test_DIR}/CMakeLists.txt "CMAKE_MINIMUM_REQUIRED(VERSION ${CMAKE_VERSION})\n" "PROJECT(ftest Fortran)\n" "SET(CMAKE_VERBOSE_MAKEFILE ON)\n" @@ -54,29 +55,41 @@ if(BUILD_FORTRAN_MODULE_INTERFACE) # Create a Fortran source file which tries to use iso_c_binding file(WRITE ${F2003Test_DIR}/ftest.f90 - "program main\n" - "use, intrinsic :: iso_c_binding\n" - "end program main\n") + "program main\n" "use, intrinsic :: iso_c_binding\n" + "end program main\n") # Attempt compile the executable - try_compile(FTEST_OK ${F2003Test_DIR} ${F2003Test_DIR} - ftest OUTPUT_VARIABLE COMPILE_OUTPUT) + try_compile( + FTEST_OK ${F2003Test_DIR} + ${F2003Test_DIR} ftest + OUTPUT_VARIABLE COMPILE_OUTPUT) # To ensure we do not use stuff from the previous attempts, # we must remove the CMakeFiles directory. file(REMOVE_RECURSE ${F2003Test_DIR}/CMakeFiles) if(FTEST_OK) - message(STATUS "Checking whether ${CMAKE_Fortran_COMPILER} supports F2003 -- yes") - set(F2003_FOUND TRUE CACHE BOOL "${CMAKE_Fortran_COMPILER} supports F2003" FORCE) + message( + STATUS + "Checking whether ${CMAKE_Fortran_COMPILER} supports F2003 -- yes") + set(F2003_FOUND + TRUE + CACHE BOOL "${CMAKE_Fortran_COMPILER} supports F2003" FORCE) else() - message(STATUS "Checking whether ${CMAKE_Fortran_COMPILER} supports F2003 -- no") + message( + STATUS "Checking whether ${CMAKE_Fortran_COMPILER} supports F2003 -- no" + ) message(STATUS "Check output:") message("${COMPILE_OUTPUT}") - print_error("BUILD_FORTRAN_MODULE_INTERFACE is set to ON, but the CMAKE_Fortran_COMPILER does not support F2003") + print_error( + "BUILD_FORTRAN_MODULE_INTERFACE is set to ON, but the CMAKE_Fortran_COMPILER does not support F2003" + ) endif() else() - message(STATUS "Skipped F2003 tests, assuming ${CMAKE_Fortran_COMPILER} supports the f2003 standard. To rerun the F2003 tests, set F2003_FOUND to FALSE.") + message( + STATUS + "Skipped F2003 tests, assuming ${CMAKE_Fortran_COMPILER} supports the f2003 standard. To rerun the F2003 tests, set F2003_FOUND to FALSE." + ) endif() endif() diff --git a/cmake/SundialsSetupHIP.cmake b/cmake/SundialsSetupHIP.cmake index 7c147019a7..c722787ab2 100644 --- a/cmake/SundialsSetupHIP.cmake +++ b/cmake/SundialsSetupHIP.cmake @@ -16,25 +16,37 @@ if(NOT DEFINED ROCM_PATH) if(NOT DEFINED ENV{ROCM_PATH}) - set(ROCM_PATH "/opt/rocm/" CACHE PATH "Path to which ROCm has been installed") + set(ROCM_PATH + "/opt/rocm/" + CACHE PATH "Path to which ROCm has been installed") else() - set(ROCM_PATH "$ENV{ROCM_PATH}" CACHE PATH "Path to which ROCm has been installed") + set(ROCM_PATH + "$ENV{ROCM_PATH}" + CACHE PATH "Path to which ROCm has been installed") endif() endif() if(NOT DEFINED HIP_PATH) if(NOT DEFINED ENV{HIP_PATH}) - set(HIP_PATH "/opt/rocm/hip" CACHE PATH "Path to which HIP has been installed") + set(HIP_PATH + "/opt/rocm/hip" + CACHE PATH "Path to which HIP has been installed") else() - set(HIP_PATH "$ENV{HIP_PATH}" CACHE PATH "Path to which HIP has been installed") + set(HIP_PATH + "$ENV{HIP_PATH}" + CACHE PATH "Path to which HIP has been installed") endif() endif() if(NOT DEFINED HIP_PLATFORM) if(NOT DEFINED ENV{HIP_PLATFORM}) - set(HIP_PLATFORM "amd" CACHE STRING "HIP platform (amd, nvidia)") + set(HIP_PLATFORM + "amd" + CACHE STRING "HIP platform (amd, nvidia)") else() - set(HIP_PLATFORM "$ENV{HIP_PLATFORM}" CACHE STRING "HIP platform (amd, nvidia)") + set(HIP_PLATFORM + "$ENV{HIP_PLATFORM}" + CACHE STRING "HIP platform (amd, nvidia)") endif() endif() diff --git a/cmake/SundialsSetupTPLs.cmake b/cmake/SundialsSetupTPLs.cmake index fe57c20a7c..153b62be9b 100644 --- a/cmake/SundialsSetupTPLs.cmake +++ b/cmake/SundialsSetupTPLs.cmake @@ -77,7 +77,6 @@ if(ENABLE_GINKGO) list(APPEND SUNDIALS_TPL_LIST "GINKGO") endif() - # --------------------------------------------------------------- # Find (and test) the hypre libraries # --------------------------------------------------------------- diff --git a/cmake/SundialsSetupTesting.cmake b/cmake/SundialsSetupTesting.cmake index 57dd7b1635..edadd99910 100644 --- a/cmake/SundialsSetupTesting.cmake +++ b/cmake/SundialsSetupTesting.cmake @@ -18,17 +18,24 @@ include(CTest) # Check if development tests are enabled -if (SUNDIALS_TEST_DEVTESTS OR BUILD_BENCHMARKS) +if(SUNDIALS_TEST_DEVTESTS OR BUILD_BENCHMARKS) # Python is needed to use the test runner find_package(Python3 REQUIRED) # look for the testRunner script in the test directory - find_program(TESTRUNNER testRunner PATHS test NO_DEFAULT_PATH) + find_program( + TESTRUNNER testRunner + PATHS test + NO_DEFAULT_PATH) if(NOT TESTRUNNER) - print_error("Could not locate testRunner. Set SUNDIALS_TEST_DEVTESTS=OFF or BUILD_BENCHMARKS=OFF to continue.") + print_error( + "Could not locate testRunner. Set SUNDIALS_TEST_DEVTESTS=OFF or BUILD_BENCHMARKS=OFF to continue." + ) endif() message(STATUS "Found testRunner: ${TESTRUNNER}") - set(TESTRUNNER ${TESTRUNNER} CACHE INTERNAL "") + set(TESTRUNNER + ${TESTRUNNER} + CACHE INTERNAL "") endif() @@ -46,7 +53,9 @@ if(SUNDIALS_TEST_DEVTESTS) # If a non-default output directory was provided make sure it exists if(SUNDIALS_TEST_OUTPUT_DIR) - message(STATUS "Using non-default test output directory: ${SUNDIALS_TEST_OUTPUT_DIR}") + message( + STATUS + "Using non-default test output directory: ${SUNDIALS_TEST_OUTPUT_DIR}") if(NOT EXISTS ${SUNDIALS_TEST_OUTPUT_DIR}) file(MAKE_DIRECTORY ${SUNDIALS_TEST_OUTPUT_DIR}) endif() @@ -54,7 +63,9 @@ if(SUNDIALS_TEST_DEVTESTS) # If a non-default answer directory was provided make sure it exists if(SUNDIALS_TEST_ANSWER_DIR) - message(STATUS "Using non-default test answer directory: ${SUNDIALS_TEST_ANSWER_DIR}") + message( + STATUS + "Using non-default test answer directory: ${SUNDIALS_TEST_ANSWER_DIR}") if(NOT EXISTS ${SUNDIALS_TEST_ANSWER_DIR}) print_error("SUNDIALS_TEST_ANSWER_DIR does not exist!") endif() @@ -62,7 +73,10 @@ if(SUNDIALS_TEST_DEVTESTS) # If a non-default caliper output directory was provided make sure it exists if(SUNDIALS_CALIPER_OUTPUT_DIR) - message(STATUS "Using non-default caliper output directory: ${SUNDIALS_CALIPER_OUTPUT_DIR}") + message( + STATUS + "Using non-default caliper output directory: ${SUNDIALS_CALIPER_OUTPUT_DIR}" + ) if(NOT EXISTS ${SUNDIALS_CALIPER_OUTPUT_DIR}/Example/${JOB_ID}) file(MAKE_DIRECTORY ${SUNDIALS_CALIPER_OUTPUT_DIR}/Example/${JOB_ID}) endif() @@ -70,11 +84,16 @@ if(SUNDIALS_TEST_DEVTESTS) # Check if using non-default comparison precisions when testing if(SUNDIALS_TEST_FLOAT_PRECISION GREATER_EQUAL "0") - message(STATUS "Using non-default float precision: ${SUNDIALS_TEST_FLOAT_PRECISION}") + message( + STATUS + "Using non-default float precision: ${SUNDIALS_TEST_FLOAT_PRECISION}") endif() if(SUNDIALS_TEST_INTEGER_PRECISION GREATER_EQUAL "0") - message(STATUS "Using non-default integer precision: ${SUNDIALS_TEST_INTEGER_PRECISION}") + message( + STATUS + "Using non-default integer precision: ${SUNDIALS_TEST_INTEGER_PRECISION}" + ) endif() # @@ -85,32 +104,57 @@ if(SUNDIALS_TEST_DEVTESTS) if(NOT container_exe) find_program(container_exe podman) endif() - set(SUNDIALS_TEST_CONTAINER_EXE ${container_exe} CACHE PATH "Path to docker or podman" FORCE) + set(SUNDIALS_TEST_CONTAINER_EXE + ${container_exe} + CACHE PATH "Path to docker or podman" FORCE) endif() if(SUNDIALS_TEST_CONTAINER_EXE) - add_custom_target(setup_local_ci - ${CMAKE_COMMAND} -E cmake_echo_color --cyan - "Pulled SUNDIALS CI containers.") + add_custom_target(setup_local_ci ${CMAKE_COMMAND} -E cmake_echo_color + --cyan "Pulled SUNDIALS CI containers.") - add_custom_target(test_local_ci - ${CMAKE_COMMAND} -E cmake_echo_color --cyan - "All testing with SUNDIALS CI containers complete.") + add_custom_target( + test_local_ci ${CMAKE_COMMAND} -E cmake_echo_color --cyan + "All testing with SUNDIALS CI containers complete.") macro(add_local_ci_target index_size precision tag) string(TOLOWER "${precision}" precision_) set(container sundials-ci-int${index_size}-${precision_}) - set(container_exe_args run ${SUNDIALS_TEST_CONTAINER_RUN_EXTRA_ARGS} -t -d --name ${container} --cap-add SYS_PTRACE - -v ${CMAKE_SOURCE_DIR}:${SUNDIALS_TEST_CONTAINER_MNT} ghcr.io/llnl/${container}:${tag}) - add_custom_target(setup_local_ci_${index_size}_${precision_} + set(container_exe_args + run + ${SUNDIALS_TEST_CONTAINER_RUN_EXTRA_ARGS} + -t + -d + --name + ${container} + --cap-add + SYS_PTRACE + -v + ${CMAKE_SOURCE_DIR}:${SUNDIALS_TEST_CONTAINER_MNT} + ghcr.io/llnl/${container}:${tag}) + add_custom_target( + setup_local_ci_${index_size}_${precision_} COMMENT "Pulling SUNDIALS CI container ghcr.io/llnl/${container}:${tag}" COMMAND ${SUNDIALS_TEST_CONTAINER_EXE} ${container_exe_args}) - add_dependencies(setup_local_ci setup_local_ci_${index_size}_${precision_}) + add_dependencies(setup_local_ci + setup_local_ci_${index_size}_${precision_}) set(container_test_exe ./test_driver.sh) - set(container_test_exe_args --testtype CUSTOM --env env/docker.sh --tpls --sunrealtype ${precision_} --indexsize ${index_size}) - set(container_exe_args exec -w ${SUNDIALS_TEST_CONTAINER_MNT}/test ${container} ${container_test_exe} ${container_test_exe_args}) - add_custom_target(test_local_ci_${index_size}_${precision_} + set(container_test_exe_args + --testtype + CUSTOM + --env + env/docker.sh + --tpls + --sunrealtype + ${precision_} + --indexsize + ${index_size}) + set(container_exe_args + exec -w ${SUNDIALS_TEST_CONTAINER_MNT}/test ${container} + ${container_test_exe} ${container_test_exe_args}) + add_custom_target( + test_local_ci_${index_size}_${precision_} COMMENT "Running tests in CI container ${container}:${tag}" WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} COMMAND ${SUNDIALS_TEST_CONTAINER_EXE} ${container_exe_args} @@ -136,11 +180,12 @@ if(SUNDIALS_TEST_UNITTESTS AND SUNDIALS_TEST_ENABLE_GTEST) FetchContent_Declare( googletest URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip - GIT_TAG v1.14.0 - ) + GIT_TAG v1.14.0) if(WIN32) # For Windows: Prevent overriding the parent project's compiler/linker settings - set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) + set(gtest_force_shared_crt + ON + CACHE BOOL "" FORCE) endif() FetchContent_MakeAvailable(googletest) include(GoogleTest) @@ -164,13 +209,11 @@ if(EXAMPLES_INSTALL) endif() # Create test_install and test_install_all targets - add_custom_target(test_install - ${CMAKE_COMMAND} -E cmake_echo_color --cyan - "All installation tests complete.") + add_custom_target(test_install ${CMAKE_COMMAND} -E cmake_echo_color --cyan + "All installation tests complete.") - add_custom_target(test_install_all - ${CMAKE_COMMAND} -E cmake_echo_color --cyan - "All installation tests complete.") + add_custom_target(test_install_all ${CMAKE_COMMAND} -E cmake_echo_color + --cyan "All installation tests complete.") endif() @@ -180,8 +223,6 @@ if(BUILD_BENCHMARKS) message("SUNDIALS Benchmarking") # Create benchmark targets - add_custom_target(benchmark - ${CMAKE_COMMAND} -E cmake_echo_color --cyan - "All benchmarks complete." - ) + add_custom_target(benchmark ${CMAKE_COMMAND} -E cmake_echo_color --cyan + "All benchmarks complete.") endif() diff --git a/cmake/SundialsTPLOptions.cmake b/cmake/SundialsTPLOptions.cmake index 36e0dc5a1b..f37eab4914 100644 --- a/cmake/SundialsTPLOptions.cmake +++ b/cmake/SundialsTPLOptions.cmake @@ -34,8 +34,7 @@ sundials_option(ENABLE_OPENMP_DEVICE BOOL # This is needed for a specific compiler that doesn't correctly # report its OpenMP spec date (with CMake >= 3.9). sundials_option(OPENMP_DEVICE_WORKS BOOL - "Skip the OpenMP device offloading support check" OFF - ADVANCED) + "Skip the OpenMP device offloading support check" OFF ADVANCED) # --------------------------------------------------------------- # Enable Pthread support? @@ -61,112 +60,173 @@ sundials_option(ENABLE_HIP BOOL "Enable HIP support" OFF) # ------------------------------------------------------------- sundials_option(ENABLE_SYCL BOOL "Enable SYCL support" OFF) -sundials_option(SUNDIALS_SYCL_2020_UNSUPPORTED BOOL - "Disable the use of some SYCL 2020 features in SUNDIALS libraries and examples" OFF - DEPENDS_ON ENABLE_SYCL - ADVANCED) +sundials_option( + SUNDIALS_SYCL_2020_UNSUPPORTED + BOOL + "Disable the use of some SYCL 2020 features in SUNDIALS libraries and examples" + OFF + DEPENDS_ON + ENABLE_SYCL + ADVANCED) # --------------------------------------------------------------- # Enable LAPACK support? # --------------------------------------------------------------- sundials_option(ENABLE_LAPACK BOOL "Enable Lapack support" OFF) -sundials_option(LAPACK_LIBRARIES STRING "Lapack and Blas libraries" "${LAPACK_LIBRARIES}" - DEPENDS_ON ENABLE_LAPACK) +sundials_option(LAPACK_LIBRARIES STRING "Lapack and Blas libraries" + "${LAPACK_LIBRARIES}" DEPENDS_ON ENABLE_LAPACK) -sundials_option(LAPACK_WORKS BOOL "Set to ON to force CMake to accept a given LAPACK configuration" OFF - DEPENDS_ON ENABLE_LAPACK - ADVANCED) +sundials_option( + LAPACK_WORKS + BOOL + "Set to ON to force CMake to accept a given LAPACK configuration" + OFF + DEPENDS_ON + ENABLE_LAPACK + ADVANCED) # --------------------------------------------------------------- # Enable Ginkgo support? # --------------------------------------------------------------- sundials_option(ENABLE_GINKGO BOOL "Enable Ginkgo support" OFF) -sundials_option(Ginkgo_DIR PATH "Path to the root of a Ginkgo installation" "${Ginkgo_DIR}" - DEPENDS_ON ENABLE_GINKGO) +sundials_option(Ginkgo_DIR PATH "Path to the root of a Ginkgo installation" + "${Ginkgo_DIR}" DEPENDS_ON ENABLE_GINKGO) -sundials_option(SUNDIALS_GINKGO_BACKENDS STRING "Which Ginkgo backend(s) to build the SUNDIALS Ginkgo interfaces for (REF, OMP, CUDA, HIP, SYCL)" "REF;OMP" - DEPENDS_ON ENABLE_GINKGO) +sundials_option( + SUNDIALS_GINKGO_BACKENDS + STRING + "Which Ginkgo backend(s) to build the SUNDIALS Ginkgo interfaces for (REF, OMP, CUDA, HIP, SYCL)" + "REF;OMP" + DEPENDS_ON + ENABLE_GINKGO) -sundials_option(GINKGO_WORKS BOOL "Set to ON to force CMake to accept a given Ginkgo configuration" OFF - DEPENDS_ON ENABLE_GINKGO - ADVANCED) +sundials_option( + GINKGO_WORKS + BOOL + "Set to ON to force CMake to accept a given Ginkgo configuration" + OFF + DEPENDS_ON + ENABLE_GINKGO + ADVANCED) # --------------------------------------------------------------- # Enable MAGMA support? # --------------------------------------------------------------- sundials_option(ENABLE_MAGMA BOOL "Enable MAGMA support" OFF) -sundials_option(MAGMA_DIR PATH "Path to the root of a MAGMA installation" "${MAGMA_DIR}" - DEPENDS_ON ENABLE_MAGMA) - -sundials_option(SUNDIALS_MAGMA_BACKENDS STRING "Which MAGMA backend to use under the SUNDIALS MAGMA interfaces (CUDA, HIP)" "CUDA" - OPTIONS "CUDA;HIP" - DEPENDS_ON ENABLE_MAGMA) - -sundials_option(MAGMA_WORKS BOOL "Set to ON to force CMake to accept a given MAGMA configuration" OFF - DEPENDS_ON ENABLE_MAGMA - ADVANCED) +sundials_option(MAGMA_DIR PATH "Path to the root of a MAGMA installation" + "${MAGMA_DIR}" DEPENDS_ON ENABLE_MAGMA) + +sundials_option( + SUNDIALS_MAGMA_BACKENDS + STRING + "Which MAGMA backend to use under the SUNDIALS MAGMA interfaces (CUDA, HIP)" + "CUDA" + OPTIONS + "CUDA;HIP" + DEPENDS_ON + ENABLE_MAGMA) + +sundials_option( + MAGMA_WORKS + BOOL + "Set to ON to force CMake to accept a given MAGMA configuration" + OFF + DEPENDS_ON + ENABLE_MAGMA + ADVANCED) # --------------------------------------------------------------- # Enable SuperLU_DIST support? # --------------------------------------------------------------- sundials_option(ENABLE_SUPERLUDIST BOOL "Enable SuperLU_DIST support" OFF) -sundials_option(SUPERLUDIST_DIR PATH "Path to the root of the SuperLU_DIST installation" "${SUPERLUDIST_DIR}" - DEPENDS_ON ENABLE_SUPERLUDIST) - -sundials_option(SUPERLUDIST_INCLUDE_DIRS PATH "SuperLU_DIST include directories" "${SUPERLUDIST_INCLUDE_DIRS}" - DEPENDS_ON ENABLE_SUPERLUDIST - ADVANCED) - -sundials_option(SUPERLUDIST_LIBRARIES STRING "Semi-colon separated list of libraries needed for SuperLU_DIST." "${SUPERLUDIST_LIBRARIES}" - DEPENDS_ON ENABLE_SUPERLUDIST - ADVANCED) - -sundials_option(SUPERLUDIST_OpenMP BOOL "Enable SUNDIALS support for SuperLU_DIST OpenMP on-node parallelism" OFF - DEPENDS_ON ENABLE_SUPERLUDIST) - -sundials_option(SUPERLUDIST_WORKS BOOL "Set to ON to force CMake to accept a given SuperLU_DIST configuration" OFF - DEPENDS_ON ENABLE_SUPERLUDIST - ADVANCED) +sundials_option( + SUPERLUDIST_DIR PATH "Path to the root of the SuperLU_DIST installation" + "${SUPERLUDIST_DIR}" DEPENDS_ON ENABLE_SUPERLUDIST) + +sundials_option( + SUPERLUDIST_INCLUDE_DIRS + PATH + "SuperLU_DIST include directories" + "${SUPERLUDIST_INCLUDE_DIRS}" + DEPENDS_ON + ENABLE_SUPERLUDIST + ADVANCED) + +sundials_option( + SUPERLUDIST_LIBRARIES + STRING + "Semi-colon separated list of libraries needed for SuperLU_DIST." + "${SUPERLUDIST_LIBRARIES}" + DEPENDS_ON + ENABLE_SUPERLUDIST + ADVANCED) + +sundials_option( + SUPERLUDIST_OpenMP BOOL + "Enable SUNDIALS support for SuperLU_DIST OpenMP on-node parallelism" OFF + DEPENDS_ON ENABLE_SUPERLUDIST) + +sundials_option( + SUPERLUDIST_WORKS + BOOL + "Set to ON to force CMake to accept a given SuperLU_DIST configuration" + OFF + DEPENDS_ON + ENABLE_SUPERLUDIST + ADVANCED) # --------------------------------------------------------------- # Enable SuperLU_MT support? # --------------------------------------------------------------- sundials_option(ENABLE_SUPERLUMT BOOL "Enable SuperLU_MT support" OFF) -sundials_option(SUPERLUMT_INCLUDE_DIR PATH "SuperLU_MT include directory" "${SUPERLUMT_INCLUDE_DIR}" - DEPENDS_ON ENABLE_SUPERLUMT) +sundials_option(SUPERLUMT_INCLUDE_DIR PATH "SuperLU_MT include directory" + "${SUPERLUMT_INCLUDE_DIR}" DEPENDS_ON ENABLE_SUPERLUMT) -sundials_option(SUPERLUMT_LIBRARY_DIR PATH "SuperLU_MT library directory" "${SUPERLUMT_LIBRARY_DIR}" - DEPENDS_ON ENABLE_SUPERLUMT) +sundials_option(SUPERLUMT_LIBRARY_DIR PATH "SuperLU_MT library directory" + "${SUPERLUMT_LIBRARY_DIR}" DEPENDS_ON ENABLE_SUPERLUMT) -sundials_option(SUPERLUMT_LIBRARIES STRING "Semi-colon separated list of additional libraries needed for SuperLU_MT." "${SUPERLUMT_LIBRARIES}" - DEPENDS_ON ENABLE_SUPERLUMT) +sundials_option( + SUPERLUMT_LIBRARIES STRING + "Semi-colon separated list of additional libraries needed for SuperLU_MT." + "${SUPERLUMT_LIBRARIES}" DEPENDS_ON ENABLE_SUPERLUMT) -sundials_option(SUPERLUMT_THREAD_TYPE STRING "SuperLU_MT threading type: OPENMP or PTHREAD" "PTHREAD" - DEPENDS_ON ENABLE_SUPERLUMT) +sundials_option( + SUPERLUMT_THREAD_TYPE STRING "SuperLU_MT threading type: OPENMP or PTHREAD" + "PTHREAD" DEPENDS_ON ENABLE_SUPERLUMT) -sundials_option(SUPERLUMT_WORKS BOOL "Set to ON to force CMake to accept a given SUPERLUMT configuration" OFF - DEPENDS_ON ENABLE_SUPERLUMT - ADVANCED) +sundials_option( + SUPERLUMT_WORKS + BOOL + "Set to ON to force CMake to accept a given SUPERLUMT configuration" + OFF + DEPENDS_ON + ENABLE_SUPERLUMT + ADVANCED) # --------------------------------------------------------------- # Enable KLU support? # --------------------------------------------------------------- sundials_option(ENABLE_KLU BOOL "Enable KLU support" OFF) -sundials_option(KLU_INCLUDE_DIR PATH "KLU include directory" "${KLU_INCLUDE_DIR}" - DEPENDS_ON ENABLE_KLU) +sundials_option(KLU_INCLUDE_DIR PATH "KLU include directory" + "${KLU_INCLUDE_DIR}" DEPENDS_ON ENABLE_KLU) -sundials_option(KLU_LIBRARY_DIR PATH "KLU library directory" "${KLU_LIBRARY_DIR}" - DEPENDS_ON ENABLE_KLU) +sundials_option(KLU_LIBRARY_DIR PATH "KLU library directory" + "${KLU_LIBRARY_DIR}" DEPENDS_ON ENABLE_KLU) -sundials_option(KLU_WORKS BOOL "Set to ON to force CMake to accept a given KLU configuration" OFF - DEPENDS_ON ENABLE_KLU - ADVANCED) +sundials_option( + KLU_WORKS + BOOL + "Set to ON to force CMake to accept a given KLU configuration" + OFF + DEPENDS_ON + ENABLE_KLU + ADVANCED) # --------------------------------------------------------------- # Enable hypre support? @@ -176,15 +236,20 @@ sundials_option(ENABLE_HYPRE BOOL "Enable hypre support" OFF) sundials_option(HYPRE_DIR PATH "Path to hypre installation" "${HYPRE_DIR}" DEPENDS_ON ENABLE_HYPRE) -sundials_option(HYPRE_INCLUDE_DIR PATH "HYPRE include directory" "${HYPRE_INCLUDE_DIR}" - DEPENDS_ON ENABLE_HYPRE) +sundials_option(HYPRE_INCLUDE_DIR PATH "HYPRE include directory" + "${HYPRE_INCLUDE_DIR}" DEPENDS_ON ENABLE_HYPRE) -sundials_option(HYPRE_LIBRARY_DIR PATH "HYPRE library directory" "${HYPRE_LIBRARY_DIR}" - DEPENDS_ON ENABLE_HYPRE) +sundials_option(HYPRE_LIBRARY_DIR PATH "HYPRE library directory" + "${HYPRE_LIBRARY_DIR}" DEPENDS_ON ENABLE_HYPRE) -sundials_option(HYPRE_WORKS BOOL "Set to ON to force CMake to accept a given hypre configuration" OFF - DEPENDS_ON ENABLE_HYPRE - ADVANCED) +sundials_option( + HYPRE_WORKS + BOOL + "Set to ON to force CMake to accept a given hypre configuration" + OFF + DEPENDS_ON + ENABLE_HYPRE + ADVANCED) # --------------------------------------------------------------- # Enable PETSc support? @@ -192,23 +257,38 @@ sundials_option(HYPRE_WORKS BOOL "Set to ON to force CMake to accept a given hyp sundials_option(ENABLE_PETSC BOOL "Enable PETSc support" OFF) -sundials_option(PETSC_DIR PATH "Path to the root of a PETSc installation" "${PETSC_DIR}" - DEPENDS_ON ENABLE_PETSC) - -sundials_option(PETSC_ARCH STRING "PETSc architecture (optional)" "${PETSC_ARCH}" - DEPENDS_ON ENABLE_PETSC) - -sundials_option(PETSC_LIBRARIES STRING "Semi-colon separated list of PETSc link libraries" "${PETSC_LIBRARIES}" - DEPENDS_ON ENABLE_PETSC - ADVANCED) - -sundials_option(PETSC_INCLUDES STRING "Semi-colon separated list of PETSc include directories" "${PETSC_INCLUDES}" - DEPENDS_ON ENABLE_PETSC - ADVANCED) - -sundials_option(PETSC_WORKS BOOL "Set to ON to force CMake to accept a given PETSc configuration" OFF - DEPENDS_ON ENABLE_PETSC - ADVANCED) +sundials_option(PETSC_DIR PATH "Path to the root of a PETSc installation" + "${PETSC_DIR}" DEPENDS_ON ENABLE_PETSC) + +sundials_option(PETSC_ARCH STRING "PETSc architecture (optional)" + "${PETSC_ARCH}" DEPENDS_ON ENABLE_PETSC) + +sundials_option( + PETSC_LIBRARIES + STRING + "Semi-colon separated list of PETSc link libraries" + "${PETSC_LIBRARIES}" + DEPENDS_ON + ENABLE_PETSC + ADVANCED) + +sundials_option( + PETSC_INCLUDES + STRING + "Semi-colon separated list of PETSc include directories" + "${PETSC_INCLUDES}" + DEPENDS_ON + ENABLE_PETSC + ADVANCED) + +sundials_option( + PETSC_WORKS + BOOL + "Set to ON to force CMake to accept a given PETSc configuration" + OFF + DEPENDS_ON + ENABLE_PETSC + ADVANCED) # ------------------------------------------------------------- # Enable RAJA support? @@ -218,46 +298,77 @@ sundials_option(ENABLE_RAJA BOOL "Enable RAJA support" OFF) sundials_option(RAJA_DIR PATH "Path to root of RAJA installation" "${RAJA_DIR}" DEPENDS_ON ENABLE_RAJA) -sundials_option(SUNDIALS_RAJA_BACKENDS STRING "Which RAJA backend under the SUNDIALS RAJA interfaces (CUDA, HIP, SYCL)" "CUDA" - OPTIONS "CUDA;HIP;SYCL" - DEPENDS_ON ENABLE_RAJA) +sundials_option( + SUNDIALS_RAJA_BACKENDS + STRING + "Which RAJA backend under the SUNDIALS RAJA interfaces (CUDA, HIP, SYCL)" + "CUDA" + OPTIONS + "CUDA;HIP;SYCL" + DEPENDS_ON + ENABLE_RAJA) # --------------------------------------------------------------- # Enable Trilinos support? # --------------------------------------------------------------- sundials_option(ENABLE_TRILINOS BOOL "Enable Trilinos support" OFF) -sundials_option(Trilinos_DIR PATH "Path to root of Trilinos installation" "${Trilinos_DIR}" - DEPENDS_ON ENABLE_TRILINOS) - -sundials_option(Trilinos_INTERFACE_CXX_COMPILER STRING - "C++ compiler for Trilinos interface" "${Trilinos_CXX_COMPILER}" - DEPENDS_ON ENABLE_TRILINOS - ADVANCED) - -sundials_option(Trilinos_INTERFACE_C_COMPILER STRING - "C compiler for Trilinos interface" "${Trilinos_C_COMPILER}" - DEPENDS_ON ENABLE_TRILINOS - ADVANCED) - -sundials_option(Trilinos_INTERFACE_CXX_COMPILER_FLAGS STRING - "C++ compiler flags for Trilinos interface" "${Trilinos_CXX_COMPILER_FLAGS}" - DEPENDS_ON ENABLE_TRILINOS - ADVANCED) - -sundials_option(Trilinos_INTERFACE_C_COMPILER_FLAGS STRING - "C compiler flags for Trilinos interface" "${Trilinos_C_COMPILER_FLAGS}" - DEPENDS_ON ENABLE_TRILINOS - ADVANCED) - -sundials_option(Trilinos_INTERFACE_MPIEXEC STRING - "MPI executable for Trilinos interface" "${Trilinos_MPI_EXEC}" - DEPENDS_ON ENABLE_TRILINOS - ADVANCED) - -sundials_option(Trilinos_WORKS BOOL "Set to ON to force CMake to accept a given Trilinos configuration" OFF - DEPENDS_ON ENABLE_TRILINOS - ADVANCED) +sundials_option(Trilinos_DIR PATH "Path to root of Trilinos installation" + "${Trilinos_DIR}" DEPENDS_ON ENABLE_TRILINOS) + +sundials_option( + Trilinos_INTERFACE_CXX_COMPILER + STRING + "C++ compiler for Trilinos interface" + "${Trilinos_CXX_COMPILER}" + DEPENDS_ON + ENABLE_TRILINOS + ADVANCED) + +sundials_option( + Trilinos_INTERFACE_C_COMPILER + STRING + "C compiler for Trilinos interface" + "${Trilinos_C_COMPILER}" + DEPENDS_ON + ENABLE_TRILINOS + ADVANCED) + +sundials_option( + Trilinos_INTERFACE_CXX_COMPILER_FLAGS + STRING + "C++ compiler flags for Trilinos interface" + "${Trilinos_CXX_COMPILER_FLAGS}" + DEPENDS_ON + ENABLE_TRILINOS + ADVANCED) + +sundials_option( + Trilinos_INTERFACE_C_COMPILER_FLAGS + STRING + "C compiler flags for Trilinos interface" + "${Trilinos_C_COMPILER_FLAGS}" + DEPENDS_ON + ENABLE_TRILINOS + ADVANCED) + +sundials_option( + Trilinos_INTERFACE_MPIEXEC + STRING + "MPI executable for Trilinos interface" + "${Trilinos_MPI_EXEC}" + DEPENDS_ON + ENABLE_TRILINOS + ADVANCED) + +sundials_option( + Trilinos_WORKS + BOOL + "Set to ON to force CMake to accept a given Trilinos configuration" + OFF + DEPENDS_ON + ENABLE_TRILINOS + ADVANCED) # --------------------------------------------------------------- # Enable XBraid support? @@ -265,20 +376,35 @@ sundials_option(Trilinos_WORKS BOOL "Set to ON to force CMake to accept a given sundials_option(ENABLE_XBRAID BOOL "Enable XBraid support" OFF) -sundials_option(XBRAID_DIR PATH "Path to the root of an XBraid installation" "${XBRAID_DIR}" - DEPENDS_ON ENABLE_XBRAID) - -sundials_option(XBRAID_LIBRARIES STRING "Semi-colon separated list of XBraid link libraries" "${XBRAID_LIBRARIES}" - DEPENDS_ON ENABLE_XBRAID - ADVANCED) - -sundials_option(XBRAID_INCLUDES STRING "Semi-colon separated list of XBraid include directories" "${XBRAID_INCLUDES}" - DEPENDS_ON ENABLE_XBRAID - ADVANCED) - -sundials_option(XBRAID_WORKS BOOL "Set to ON to force CMake to accept a given XBraid configuration" OFF - DEPENDS_ON ENABLE_XBRAID - ADVANCED) +sundials_option(XBRAID_DIR PATH "Path to the root of an XBraid installation" + "${XBRAID_DIR}" DEPENDS_ON ENABLE_XBRAID) + +sundials_option( + XBRAID_LIBRARIES + STRING + "Semi-colon separated list of XBraid link libraries" + "${XBRAID_LIBRARIES}" + DEPENDS_ON + ENABLE_XBRAID + ADVANCED) + +sundials_option( + XBRAID_INCLUDES + STRING + "Semi-colon separated list of XBraid include directories" + "${XBRAID_INCLUDES}" + DEPENDS_ON + ENABLE_XBRAID + ADVANCED) + +sundials_option( + XBRAID_WORKS + BOOL + "Set to ON to force CMake to accept a given XBraid configuration" + OFF + DEPENDS_ON + ENABLE_XBRAID + ADVANCED) # ------------------------------------------------------------- # Enable oneMKL support? @@ -286,44 +412,64 @@ sundials_option(XBRAID_WORKS BOOL "Set to ON to force CMake to accept a given XB sundials_option(ENABLE_ONEMKL BOOL "Enable oneMKL support" OFF) -sundials_option(ONEMKL_DIR PATH "Path to root of oneMKL installation" "${ONEMKL_DIR}" - DEPENDS_ON ENABLE_ONEMKL) - -sundials_option(ONEMKL_WORKS BOOL "Set to ON to force CMake to accept a given oneMKL configuration" OFF - DEPENDS_ON ENABLE_ONEMKL - ADVANCED) - -sundials_option(SUNDIALS_ONEMKL_USE_GETRF_LOOP BOOL - "Replace batched getrf call with loop over getrf" OFF - DEPENDS_ON ENABLE_ONEMKL - ADVANCED) - -sundials_option(SUNDIALS_ONEMKL_USE_GETRS_LOOP BOOL - "Replace batched getrs call with loop over getrs" OFF - DEPENDS_ON ENABLE_ONEMKL - ADVANCED) +sundials_option(ONEMKL_DIR PATH "Path to root of oneMKL installation" + "${ONEMKL_DIR}" DEPENDS_ON ENABLE_ONEMKL) + +sundials_option( + ONEMKL_WORKS + BOOL + "Set to ON to force CMake to accept a given oneMKL configuration" + OFF + DEPENDS_ON + ENABLE_ONEMKL + ADVANCED) + +sundials_option( + SUNDIALS_ONEMKL_USE_GETRF_LOOP + BOOL + "Replace batched getrf call with loop over getrf" + OFF + DEPENDS_ON + ENABLE_ONEMKL + ADVANCED) + +sundials_option( + SUNDIALS_ONEMKL_USE_GETRS_LOOP + BOOL + "Replace batched getrs call with loop over getrs" + OFF + DEPENDS_ON + ENABLE_ONEMKL + ADVANCED) # --------------------------------------------------------------- # Enable Caliper support? # --------------------------------------------------------------- -sundials_option(ENABLE_CALIPER BOOL "Enable CALIPER support" OFF - DEPENDS_ON SUNDIALS_BUILD_WITH_PROFILING) +sundials_option(ENABLE_CALIPER BOOL "Enable CALIPER support" OFF DEPENDS_ON + SUNDIALS_BUILD_WITH_PROFILING) -sundials_option(CALIPER_DIR PATH "Path to the root of an CALIPER installation" "${CALIPER_DIR}" - DEPENDS_ON ENABLE_CALIPER) +sundials_option(CALIPER_DIR PATH "Path to the root of an CALIPER installation" + "${CALIPER_DIR}" DEPENDS_ON ENABLE_CALIPER) -sundials_option(CALIPER_WORKS BOOL "Set to ON to force CMake to accept a given CALIPER configuration" OFF - DEPENDS_ON ENABLE_CALIPER - ADVANCED) +sundials_option( + CALIPER_WORKS + BOOL + "Set to ON to force CMake to accept a given CALIPER configuration" + OFF + DEPENDS_ON + ENABLE_CALIPER + ADVANCED) # --------------------------------------------------------------- # Enable Adiak support? # --------------------------------------------------------------- -sundials_option(ENABLE_ADIAK BOOL "Enable Adiak support" OFF DEPENDS_ON SUNDIALS_BUILD_WITH_PROFILING) +sundials_option(ENABLE_ADIAK BOOL "Enable Adiak support" OFF DEPENDS_ON + SUNDIALS_BUILD_WITH_PROFILING) -sundials_option(adiak_DIR PATH "Path to the root of an Adiak installation" "${ADIAK_DIR}" DEPENDS_ON ENABLE_ADIAK) +sundials_option(adiak_DIR PATH "Path to the root of an Adiak installation" + "${ADIAK_DIR}" DEPENDS_ON ENABLE_ADIAK) # --------------------------------------------------------------- # Enable Kokkos support? @@ -331,11 +477,17 @@ sundials_option(adiak_DIR PATH "Path to the root of an Adiak installation" "${AD sundials_option(ENABLE_KOKKOS BOOL "Enable Kokkos support" OFF) -sundials_option(Kokkos_DIR PATH "Path to the root of a Kokkos installation" "${Kokkos_DIR}") +sundials_option(Kokkos_DIR PATH "Path to the root of a Kokkos installation" + "${Kokkos_DIR}") -sundials_option(KOKKOS_WORKS BOOL "Set to ON to force CMake to accept a given Kokkos configuration" OFF - DEPENDS_ON ENABLE_KOKKOS - ADVANCED) +sundials_option( + KOKKOS_WORKS + BOOL + "Set to ON to force CMake to accept a given Kokkos configuration" + OFF + DEPENDS_ON + ENABLE_KOKKOS + ADVANCED) # --------------------------------------------------------------- # Enable Kokkos Kernels support? @@ -343,8 +495,16 @@ sundials_option(KOKKOS_WORKS BOOL "Set to ON to force CMake to accept a given Ko sundials_option(ENABLE_KOKKOS_KERNELS BOOL "Enable Kokkos Kernels support" OFF) -sundials_option(KokkosKernels_DIR PATH "Path to the root of a Kokkos Kernels installation" "${KokkosKernels_DIR}") - -sundials_option(KOKKOS_KERNELS_WORKS BOOL "Set to ON to force CMake to accept a given Kokkos configuration" OFF - DEPENDS_ON ENABLE_KOKKOS ENABLE_KOKKOS_KERNELS - ADVANCED) +sundials_option( + KokkosKernels_DIR PATH "Path to the root of a Kokkos Kernels installation" + "${KokkosKernels_DIR}") + +sundials_option( + KOKKOS_KERNELS_WORKS + BOOL + "Set to ON to force CMake to accept a given Kokkos configuration" + OFF + DEPENDS_ON + ENABLE_KOKKOS + ENABLE_KOKKOS_KERNELS + ADVANCED) diff --git a/cmake/macros/SundialsAddBenchmark.cmake b/cmake/macros/SundialsAddBenchmark.cmake index f3b3aec4e6..d4850a0689 100644 --- a/cmake/macros/SundialsAddBenchmark.cmake +++ b/cmake/macros/SundialsAddBenchmark.cmake @@ -24,20 +24,21 @@ macro(sundials_add_benchmark NAME EXECUTABLE BASE_BENCHMARK_NAME) set(oneValueArgs NUM_CORES BENCHMARK_ARGS IDENTIFIER) # TEST_RUNNER_ARGS = command line arguments to pass to the test executable - set(multiValueArgs TEST_RUNNER_ARGS ) + set(multiValueArgs TEST_RUNNER_ARGS) # ENABLE_GPU = indicate this benchmark should be run with GPUs set(options ENABLE_GPU) - cmake_parse_arguments(sundials_add_benchmark - "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + cmake_parse_arguments(sundials_add_benchmark "${options}" "${oneValueArgs}" + "${multiValueArgs}" ${ARGN}) # set the target name if(sundials_add_benchmark_IDENTIFIER) set(TARGET_NAME ${NAME}_${sundials_add_benchmark_IDENTIFIER}) else() if(sundials_add_benchmark_BENCHMARK_ARGS) - string(REPLACE " " "_" TEST_SUFFIX "${sundials_add_benchmark_BENCHMARK_ARGS}") + string(REPLACE " " "_" TEST_SUFFIX + "${sundials_add_benchmark_BENCHMARK_ARGS}") set(TARGET_NAME ${NAME}_${TEST_SUFFIX}) else() set(TARGET_NAME ${NAME}_run) @@ -46,9 +47,11 @@ macro(sundials_add_benchmark NAME EXECUTABLE BASE_BENCHMARK_NAME) # Create default benchmark caliper output directory if custom directory is not defined if(SUNDIALS_CALIPER_OUTPUT_DIR) - set(SUNDIALS_BENCHMARK_OUTPUT_DIR ${SUNDIALS_CALIPER_OUTPUT_DIR}/Benchmarking/${BASE_BENCHMARK_NAME}) + set(SUNDIALS_BENCHMARK_OUTPUT_DIR + ${SUNDIALS_CALIPER_OUTPUT_DIR}/Benchmarking/${BASE_BENCHMARK_NAME}) else() - set(SUNDIALS_BENCHMARK_OUTPUT_DIR ${PROJECT_BINARY_DIR}/Benchmarking/${BASE_BENCHMARK_NAME}) + set(SUNDIALS_BENCHMARK_OUTPUT_DIR + ${PROJECT_BINARY_DIR}/Benchmarking/${BASE_BENCHMARK_NAME}) endif() # make the caliper output directory if it doesn't exist @@ -63,22 +66,24 @@ macro(sundials_add_benchmark NAME EXECUTABLE BASE_BENCHMARK_NAME) # command line arguments for the test runner script set(TEST_RUNNER_ARGS - "--profile" - "--verbose" - "--executablename=$" - "--outputdir=${SUNDIALS_BENCHMARK_OUTPUT_DIR}/output" - "--calidir=${SUNDIALS_BENCHMARK_OUTPUT_DIR}/${TARGET_NAME}" - "--nodiff") + "--profile" "--verbose" "--executablename=$" + "--outputdir=${SUNDIALS_BENCHMARK_OUTPUT_DIR}/output" + "--calidir=${SUNDIALS_BENCHMARK_OUTPUT_DIR}/${TARGET_NAME}" "--nodiff") # incorporate scheduler arguments into test_runner if(SUNDIALS_SCHEDULER_COMMAND STREQUAL "flux run") set(SCHEDULER_STRING " -n${sundials_add_benchmark_NUM_CORES}") - elseif(SUNDIALS_SCHEDULER_COMMAND STREQUAL "jsrun" AND ${sundials_add_benchmark_ENABLE_GPU}) - set(SCHEDULER_STRING " --smpiargs=\\\"-gpu\\\" -n${sundials_add_benchmark_NUM_CORES} -a1 -c1 -g1") + elseif(SUNDIALS_SCHEDULER_COMMAND STREQUAL "jsrun" + AND ${sundials_add_benchmark_ENABLE_GPU}) + set(SCHEDULER_STRING + " --smpiargs=\\\"-gpu\\\" -n${sundials_add_benchmark_NUM_CORES} -a1 -c1 -g1" + ) elseif(SUNDIALS_SCHEDULER_COMMAND STREQUAL "jsrun") set(SCHEDULER_STRING " -n${sundials_add_benchmark_NUM_CORES} -a1 -c1") elseif(SUNDIALS_SCHEDULER_COMMAND STREQUAL "srun") - set(SCHEDULER_STRING " -n${sundials_add_benchmark_NUM_CORES} --cpus-per-task=1 --ntasks-per-node=1") + set(SCHEDULER_STRING + " -n${sundials_add_benchmark_NUM_CORES} --cpus-per-task=1 --ntasks-per-node=1" + ) endif() string(REPLACE " " ";" SCHEDULER_ARGS "${SCHEDULER_STRING}") string(REPLACE " " ";" SCHEDULER_COMMAND_ARGS "${SUNDIALS_SCHEDULER_COMMAND}") @@ -87,8 +92,11 @@ macro(sundials_add_benchmark NAME EXECUTABLE BASE_BENCHMARK_NAME) set(RUN_COMMAND ${SCHEDULER_COMMAND_ARGS} ${SCHEDULER_ARGS}) list(APPEND TEST_RUNNER_ARGS "--runcommand=\"${RUN_COMMAND}\"") - list(APPEND TEST_RUNNER_ARGS "--runargs=${sundials_add_benchmark_BENCHMARK_ARGS}" "--testname=${TARGET_NAME}") - add_custom_target(${TARGET_NAME} + list(APPEND TEST_RUNNER_ARGS + "--runargs=${sundials_add_benchmark_BENCHMARK_ARGS}" + "--testname=${TARGET_NAME}") + add_custom_target( + ${TARGET_NAME} COMMENT "Running ${TARGET_NAME}" COMMAND ${PYTHON_EXECUTABLE} ${TESTRUNNER} ${TEST_RUNNER_ARGS}) add_dependencies(benchmark ${TARGET_NAME}) diff --git a/cmake/macros/SundialsAddExamplesGinkgo.cmake b/cmake/macros/SundialsAddExamplesGinkgo.cmake index 1e23dfdb58..2deb2046b0 100644 --- a/cmake/macros/SundialsAddExamplesGinkgo.cmake +++ b/cmake/macros/SundialsAddExamplesGinkgo.cmake @@ -40,8 +40,8 @@ macro(sundials_add_examples_ginkgo EXAMPLES_VAR) set(multiValueArgs TARGETS BACKENDS) # Parse keyword arguments and options - cmake_parse_arguments(arg - "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + cmake_parse_arguments(arg "${options}" "${oneValueArgs}" "${multiValueArgs}" + ${ARGN}) foreach(example_tuple ${${EXAMPLES_VAR}}) foreach(backend ${arg_BACKENDS}) @@ -87,17 +87,13 @@ macro(sundials_add_examples_ginkgo EXAMPLES_VAR) target_compile_definitions(${example_target} PRIVATE USE_${backend}) # directories to include - target_include_directories(${example_target} - PRIVATE - "${PROJECT_SOURCE_DIR}/examples/utilities") + target_include_directories( + ${example_target} PRIVATE "${PROJECT_SOURCE_DIR}/examples/utilities") # libraries to link against - target_link_libraries(${example_target} - PRIVATE - ${arg_TARGETS} - sundials_${vector} - Ginkgo::ginkgo - ${EXTRA_LINK_LIBS}) + target_link_libraries( + ${example_target} PRIVATE ${arg_TARGETS} sundials_${vector} + Ginkgo::ginkgo ${EXTRA_LINK_LIBS}) endif() @@ -105,22 +101,34 @@ macro(sundials_add_examples_ginkgo EXAMPLES_VAR) if("${example_args}" STREQUAL "") set(test_name ${example_target}) else() - string(REGEX REPLACE " " "_" test_name ${example_target}_${example_args}) + string(REGEX REPLACE " " "_" test_name + ${example_target}_${example_args}) endif() # add example to regression tests if(${arg_UNIT_TEST}) - sundials_add_test(${test_name} ${example_target} - EXAMPLE_TYPE ${example_type} - TEST_ARGS ${example_args} + sundials_add_test( + ${test_name} + ${example_target} + EXAMPLE_TYPE + ${example_type} + TEST_ARGS + ${example_args} NODIFF) else() - sundials_add_test(${test_name} ${example_target} - EXAMPLE_TYPE ${example_type} - TEST_ARGS ${example_args} - ANSWER_DIR ${CMAKE_CURRENT_SOURCE_DIR} - ANSWER_FILE ${test_name}.out - FLOAT_PRECISION ${float_precision}) + sundials_add_test( + ${test_name} + ${example_target} + EXAMPLE_TYPE + ${example_type} + TEST_ARGS + ${example_args} + ANSWER_DIR + ${CMAKE_CURRENT_SOURCE_DIR} + ANSWER_FILE + ${test_name}.out + FLOAT_PRECISION + ${float_precision}) endif() endforeach() diff --git a/cmake/macros/SundialsAddExecutable.cmake b/cmake/macros/SundialsAddExecutable.cmake index a2582a3485..00508c76b2 100644 --- a/cmake/macros/SundialsAddExecutable.cmake +++ b/cmake/macros/SundialsAddExecutable.cmake @@ -16,30 +16,26 @@ macro(sundials_add_nvector_benchmark NAME) - set(options ) - set(singleValueArgs ) - set(multiValueArgs SOURCES SUNDIALS_TARGETS LINK_LIBRARIES - INSTALL_SUBDIR) + set(options) + set(singleValueArgs) + set(multiValueArgs SOURCES SUNDIALS_TARGETS LINK_LIBRARIES INSTALL_SUBDIR) - cmake_parse_arguments(arg - "${options}" "${singleValueArgs}" "${multiValueArgs}" ${ARGN}) + cmake_parse_arguments(arg "${options}" "${singleValueArgs}" + "${multiValueArgs}" ${ARGN}) set(BENCHMARKS_DIR ${PROJECT_SOURCE_DIR}/benchmarks) - add_executable(${NAME} - ${BENCHMARKS_DIR}/nvector/test_nvector_performance.c - ${arg_SOURCES}) + add_executable(${NAME} ${BENCHMARKS_DIR}/nvector/test_nvector_performance.c + ${arg_SOURCES}) set_target_properties(${NAME} PROPERTIES FOLDER "Benchmarks") - target_include_directories(${NAME} PRIVATE - ${BENCHMARKS_DIR}/nvector) + target_include_directories(${NAME} PRIVATE ${BENCHMARKS_DIR}/nvector) - target_link_libraries(${NAME} PRIVATE - ${arg_SUNDIALS_TARGETS} ${arg_LINK_LIBRARIES} -lm) + target_link_libraries(${NAME} PRIVATE ${arg_SUNDIALS_TARGETS} + ${arg_LINK_LIBRARIES} -lm) install(TARGETS ${NAME} - DESTINATION "${BENCHMARKS_INSTALL_PATH}/${arg_INSTALL_SUBDIR}") + DESTINATION "${BENCHMARKS_INSTALL_PATH}/${arg_INSTALL_SUBDIR}") endmacro(sundials_add_nvector_benchmark) - diff --git a/cmake/macros/SundialsAddLibrary.cmake b/cmake/macros/SundialsAddLibrary.cmake index 199f790e66..467512d4ae 100644 --- a/cmake/macros/SundialsAddLibrary.cmake +++ b/cmake/macros/SundialsAddLibrary.cmake @@ -15,7 +15,6 @@ # Wraps the add_library command for sundials specific needs. # --------------------------------------------------------------- - # The macro: # # SUNDIALS_ADD_LIBRARY( @@ -112,13 +111,20 @@ macro(sundials_add_library target) set(options STATIC_ONLY SHARED_ONLY OBJECT_LIB_ONLY) set(oneValueArgs INCLUDE_SUBDIR OUTPUT_NAME VERSION SOVERSION) - set(multiValueArgs SOURCES HEADERS OBJECT_LIBRARIES LINK_LIBRARIES - INCLUDE_DIRECTORIES COMPILE_DEFINITIONS COMPILE_OPTIONS - COMPILE_FEATURES PROPERTIES) + set(multiValueArgs + SOURCES + HEADERS + OBJECT_LIBRARIES + LINK_LIBRARIES + INCLUDE_DIRECTORIES + COMPILE_DEFINITIONS + COMPILE_OPTIONS + COMPILE_FEATURES + PROPERTIES) # parse keyword arguments/options - cmake_parse_arguments(sundials_add_library - "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + cmake_parse_arguments(sundials_add_library "${options}" "${oneValueArgs}" + "${multiValueArgs}" ${ARGN}) # library types to create set(_libtypes "") @@ -150,14 +156,15 @@ macro(sundials_add_library target) # -------------------------------------------------------------------------- # create the target for the object library - add_library(${obj_target} OBJECT ${sources} ${sundials_add_library_UNPARSED_ARGUMENTS}) + add_library(${obj_target} OBJECT ${sources} + ${sundials_add_library_UNPARSED_ARGUMENTS}) set_target_properties(${obj_target} PROPERTIES FOLDER "obj") # add all object libraries to object library if(sundials_add_library_OBJECT_LIBRARIES) target_link_libraries(${obj_target} - PRIVATE ${sundials_add_library_OBJECT_LIBRARIES}) + PRIVATE ${sundials_add_library_OBJECT_LIBRARIES}) endif() # add all link libraries to object library @@ -184,7 +191,8 @@ macro(sundials_add_library target) endif() endforeach() add_custom_target(fake_to_force_build_order_${obj_target}) - add_dependencies(fake_to_force_build_order_${obj_target} ${_stripped_all_libs}) + add_dependencies(fake_to_force_build_order_${obj_target} + ${_stripped_all_libs}) add_dependencies(${obj_target} fake_to_force_build_order_${obj_target}) target_link_libraries(${obj_target} ${_all_libs}) endif() @@ -194,20 +202,21 @@ macro(sundials_add_library target) target_link_libraries(${obj_target} PUBLIC caliper) endif() if(ENABLE_ADIAK) - target_link_libraries(${obj_target} PUBLIC adiak::adiak ${CMAKE_DL_LIBS}) + target_link_libraries(${obj_target} PUBLIC adiak::adiak + ${CMAKE_DL_LIBS}) endif() endif() # add includes to object library - target_include_directories(${obj_target} - PUBLIC - $ - $ - $ - $ - ) + target_include_directories( + ${obj_target} + PUBLIC $ + $ + $ + $) if(sundials_add_library_INCLUDE_DIRECTORIES) - string(REPLACE "{{libtype}}" "${_libtype}" _includes "${sundials_add_library_INCLUDE_DIRECTORIES}") + string(REPLACE "{{libtype}}" "${_libtype}" _includes + "${sundials_add_library_INCLUDE_DIRECTORIES}") target_include_directories(${obj_target} ${_includes}) endif() @@ -220,25 +229,30 @@ macro(sundials_add_library target) # add all other compile definitions to object library if(sundials_add_library_COMPILE_DEFINITIONS) - target_compile_definitions(${obj_target} ${sundials_add_library_COMPILE_DEFINITIONS}) + target_compile_definitions(${obj_target} + ${sundials_add_library_COMPILE_DEFINITIONS}) endif() # add compile options to object library if(sundials_add_library_COMPILE_OPTIONS) - target_compile_options(${obj_target} ${sundials_add_library_COMPILE_OPTIONS}) + target_compile_options(${obj_target} + ${sundials_add_library_COMPILE_OPTIONS}) endif() # add compile features if(sundials_add_library_COMPILE_FEATURES) - target_compile_features(${obj_target} ${sundials_add_library_COMPILE_FEATURES}) + target_compile_features(${obj_target} + ${sundials_add_library_COMPILE_FEATURES}) endif() # object files going into shared libs need PIC code - set_target_properties(${obj_target} PROPERTIES POSITION_INDEPENDENT_CODE TRUE) + set_target_properties(${obj_target} PROPERTIES POSITION_INDEPENDENT_CODE + TRUE) # set any other properties if(sundials_add_library_PROPERTIES) - string(REPLACE "{{libtype}}" "${_libtype}" _properties "${sundials_add_library_PROPERTIES}") + string(REPLACE "{{libtype}}" "${_libtype}" _properties + "${sundials_add_library_PROPERTIES}") set_target_properties(${obj_target} PROPERTIES ${_properties}) endif() @@ -264,19 +278,24 @@ macro(sundials_add_library target) endforeach() endif() - add_library(${_actual_target_name} ${_libtype} ${_object_sources} ${sundials_add_library_UNPARSED_ARGUMENTS}) + add_library( + ${_actual_target_name} ${_libtype} ${_object_sources} + ${sundials_add_library_UNPARSED_ARGUMENTS}) set_target_properties(${_actual_target_name} PROPERTIES FOLDER "src") # add all link libraries if(SUNDIALS_MATH_LIBRARY) - target_link_libraries(${_actual_target_name} PRIVATE "${SUNDIALS_MATH_LIBRARY}") + target_link_libraries(${_actual_target_name} + PRIVATE "${SUNDIALS_MATH_LIBRARY}") endif() if(SUNDIALS_RT_LIBRARY) - target_link_libraries(${_actual_target_name} PRIVATE "${SUNDIALS_RT_LIBRARY}") + target_link_libraries(${_actual_target_name} + PRIVATE "${SUNDIALS_RT_LIBRARY}") endif() if(sundials_add_library_LINK_LIBRARIES) - target_link_libraries(${_actual_target_name} ${sundials_add_library_LINK_LIBRARIES}) + target_link_libraries(${_actual_target_name} + ${sundials_add_library_LINK_LIBRARIES}) endif() if(SUNDIALS_BUILD_WITH_PROFILING) @@ -284,90 +303,99 @@ macro(sundials_add_library target) target_link_libraries(${_actual_target_name} PUBLIC caliper) endif() if(ENABLE_ADIAK) - target_link_libraries(${_actual_target_name} PUBLIC adiak::adiak ${CMAKE_DL_LIBS}) + target_link_libraries(${_actual_target_name} PUBLIC adiak::adiak + ${CMAKE_DL_LIBS}) endif() endif() # add common includes # Building: public, config/export generated, and shared private headers # Installing: installed include directory - target_include_directories(${_actual_target_name} PUBLIC - $ - $ - $ - $ - $) + target_include_directories( + ${_actual_target_name} + PUBLIC $ + $ + $ + $ + $) # add all other includes if(sundials_add_library_INCLUDE_DIRECTORIES) - string(REPLACE "{{libtype}}" "${_libtype}" _includes "${sundials_add_library_INCLUDE_DIRECTORIES}") + string(REPLACE "{{libtype}}" "${_libtype}" _includes + "${sundials_add_library_INCLUDE_DIRECTORIES}") target_include_directories(${_actual_target_name} ${_includes}) endif() # add compile definitions for SUNDIALS_EXPORT if(${_libtype} MATCHES "STATIC") - target_compile_definitions(${_actual_target_name} PUBLIC SUNDIALS_STATIC_DEFINE) + target_compile_definitions(${_actual_target_name} + PUBLIC SUNDIALS_STATIC_DEFINE) else() target_compile_definitions(${obj_target} PRIVATE sundials_core_EXPORTS) endif() # add all other compile definitions if(sundials_add_library_COMPILE_DEFINITIONS) - target_compile_definitions(${_actual_target_name} ${sundials_add_library_COMPILE_DEFINITIONS}) + target_compile_definitions(${_actual_target_name} + ${sundials_add_library_COMPILE_DEFINITIONS}) endif() # add all compile options if(sundials_add_library_COMPILE_OPTIONS) - target_compile_options(${_actual_target_name} ${sundials_add_library_COMPILE_OPTIONS}) + target_compile_options(${_actual_target_name} + ${sundials_add_library_COMPILE_OPTIONS}) endif() # add compile features if(sundials_add_library_COMPILE_FEATURES) - target_compile_features(${_actual_target_name} ${sundials_add_library_COMPILE_FEATURES}) + target_compile_features(${_actual_target_name} + ${sundials_add_library_COMPILE_FEATURES}) endif() # exported targets are in the SUNDIALS:: namespace, so we remove the sundials_ prefix from the exported name string(REPLACE "sundials_" "" _export_name "${_actual_target_name}") - set_target_properties(${_actual_target_name} PROPERTIES EXPORT_NAME ${_export_name}) + set_target_properties(${_actual_target_name} PROPERTIES EXPORT_NAME + ${_export_name}) # create an alias to match the exported target name, this way another projects can use it with either find_package() or add_subdirectory() add_library(SUNDIALS::${_export_name} ALIAS ${_actual_target_name}) # set the correct output name if(sundials_add_library_OUTPUT_NAME) - if((MSVC OR ("${CMAKE_C_SIMULATE_ID}" STREQUAL "MSVC")) AND ${_libtype} MATCHES "STATIC") - set_target_properties(${_actual_target_name} PROPERTIES - OUTPUT_NAME "${sundials_add_library_OUTPUT_NAME}_static" - CLEAN_DIRECT_OUTPUT 1 - ) + if((MSVC OR ("${CMAKE_C_SIMULATE_ID}" STREQUAL "MSVC")) + AND ${_libtype} MATCHES "STATIC") + set_target_properties( + ${_actual_target_name} + PROPERTIES OUTPUT_NAME "${sundials_add_library_OUTPUT_NAME}_static" + CLEAN_DIRECT_OUTPUT 1) else() - set_target_properties(${_actual_target_name} PROPERTIES - OUTPUT_NAME ${sundials_add_library_OUTPUT_NAME} - CLEAN_DIRECT_OUTPUT 1 - ) + set_target_properties( + ${_actual_target_name} + PROPERTIES OUTPUT_NAME ${sundials_add_library_OUTPUT_NAME} + CLEAN_DIRECT_OUTPUT 1) endif() else() - set_target_properties(${_actual_target_name} PROPERTIES - OUTPUT_NAME ${target} - CLEAN_DIRECT_OUTPUT 1 - ) + set_target_properties( + ${_actual_target_name} PROPERTIES OUTPUT_NAME ${target} + CLEAN_DIRECT_OUTPUT 1) endif() # set the library versions if(sundials_add_library_VERSION) - set_target_properties(${_actual_target_name} PROPERTIES - VERSION ${sundials_add_library_VERSION} - ) + set_target_properties( + ${_actual_target_name} PROPERTIES VERSION + ${sundials_add_library_VERSION}) endif() if(sundials_add_library_SOVERSION) - set_target_properties(${_actual_target_name} PROPERTIES - SOVERSION ${sundials_add_library_SOVERSION} - ) + set_target_properties( + ${_actual_target_name} PROPERTIES SOVERSION + ${sundials_add_library_SOVERSION}) endif() # set any other properties if(sundials_add_library_PROPERTIES) - string(REPLACE "{{libtype}}" "${_libtype}" _properties "${sundials_add_library_PROPERTIES}") + string(REPLACE "{{libtype}}" "${_libtype}" _properties + "${sundials_add_library_PROPERTIES}") set_target_properties(${_actual_target_name} PROPERTIES ${_properties}) endif() @@ -383,8 +411,10 @@ macro(sundials_add_library target) # -------------------------------------------------------------------------- if(sundials_add_library_HEADERS) - install(FILES ${sundials_add_library_HEADERS} - DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${sundials_add_library_INCLUDE_SUBDIR}") + install( + FILES ${sundials_add_library_HEADERS} + DESTINATION + "${CMAKE_INSTALL_INCLUDEDIR}/${sundials_add_library_INCLUDE_SUBDIR}") endif() # -------------------------------------------------------------------------- @@ -395,21 +425,27 @@ macro(sundials_add_library target) add_library(${target}_obj ALIAS ${target}_obj${_SHARED_LIB_SUFFIX}) if(NOT sundials_add_library_OBJECT_LIB_ONLY) add_library(${target} ALIAS ${target}${_SHARED_LIB_SUFFIX}) - set(_SUNDIALS_ALIAS_TARGETS "${target}->${target}${_SHARED_LIB_SUFFIX};${_SUNDIALS_ALIAS_TARGETS}" CACHE INTERNAL "" FORCE) + set(_SUNDIALS_ALIAS_TARGETS + "${target}->${target}${_SHARED_LIB_SUFFIX};${_SUNDIALS_ALIAS_TARGETS}" + CACHE INTERNAL "" FORCE) # Namespaced alias for using build directory directly string(REPLACE "sundials_" "" _export_name "${target}") - add_library(SUNDIALS::${_export_name} ALIAS ${target}${_SHARED_LIB_SUFFIX}) + add_library(SUNDIALS::${_export_name} ALIAS + ${target}${_SHARED_LIB_SUFFIX}) endif() else() add_library(${target}_obj ALIAS ${target}_obj${_STATIC_LIB_SUFFIX}) if(NOT sundials_add_library_OBJECT_LIB_ONLY) add_library(${target} ALIAS ${target}${_STATIC_LIB_SUFFIX}) - set(_SUNDIALS_ALIAS_TARGETS "${target}->${target}${_STATIC_LIB_SUFFIX};${_SUNDIALS_ALIAS_TARGETS}" CACHE INTERNAL "" FORCE) + set(_SUNDIALS_ALIAS_TARGETS + "${target}->${target}${_STATIC_LIB_SUFFIX};${_SUNDIALS_ALIAS_TARGETS}" + CACHE INTERNAL "" FORCE) # Namespaced alias for using build directory directly string(REPLACE "sundials_" "" _export_name "${target}") - add_library(SUNDIALS::${_export_name} ALIAS ${target}${_STATIC_LIB_SUFFIX}) + add_library(SUNDIALS::${_export_name} ALIAS + ${target}${_STATIC_LIB_SUFFIX}) endif() endif() @@ -419,40 +455,45 @@ macro(sundials_add_library target) if(NOT sundials_add_library_OBJECT_LIB_ONLY) string(REPLACE "sundials_" "" _comp_name "${target}") - set(_SUNDIALS_INSTALLED_COMPONENTS "${_comp_name};${_SUNDIALS_INSTALLED_COMPONENTS}" CACHE INTERNAL "" FORCE) + set(_SUNDIALS_INSTALLED_COMPONENTS + "${_comp_name};${_SUNDIALS_INSTALLED_COMPONENTS}" + CACHE INTERNAL "" FORCE) endif() endmacro(sundials_add_library) - macro(sundials_add_f2003_library target) - set(options ) + set(options) set(oneValueArgs OUTPUT_NAME VERSION SOVERSION) - set(multiValueArgs SOURCES OBJECT_LIBRARIES LINK_LIBRARIES INCLUDE_DIRECTORIES - COMPILE_DEFINITIONS COMPILE_OPTIONS PROPERTIES) + set(multiValueArgs + SOURCES + OBJECT_LIBRARIES + LINK_LIBRARIES + INCLUDE_DIRECTORIES + COMPILE_DEFINITIONS + COMPILE_OPTIONS + PROPERTIES) # parse keyword arguments/options - cmake_parse_arguments(sundials_add_f2003_library - "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + cmake_parse_arguments(sundials_add_f2003_library "${options}" + "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) if(CMAKE_Fortran_MODULE_DIRECTORY) set(_includes - PUBLIC - $ - $ - ) - set(_properties PROPERTIES - Fortran_MODULE_DIRECTORY "${CMAKE_Fortran_MODULE_DIRECTORY}_{{libtype}}" + PUBLIC $ + $) + set(_properties + PROPERTIES Fortran_MODULE_DIRECTORY + "${CMAKE_Fortran_MODULE_DIRECTORY}_{{libtype}}" WINDOWS_EXPORT_ALL_SYMBOLS ON) else() set(_includes - PUBLIC - $ - $ - ) - set(_properties PROPERTIES - Fortran_MODULE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${target}.dir" + PUBLIC $ + $) + set(_properties + PROPERTIES Fortran_MODULE_DIRECTORY + "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${target}.dir" WINDOWS_EXPORT_ALL_SYMBOLS ON) endif() @@ -462,30 +503,40 @@ macro(sundials_add_f2003_library target) if(TARGET ${_clib_name}) set(_clib_target ${_clib_name}) else() - set(_clib_target ) + set(_clib_target) endif() - sundials_add_library(${target} - SOURCES ${sundials_add_f2003_library_SOURCES} - OBJECT_LIBRARIES ${sundials_add_f2003_library_OBJECT_LIBRARIES} + sundials_add_library( + ${target} + SOURCES + ${sundials_add_f2003_library_SOURCES} + OBJECT_LIBRARIES + ${sundials_add_f2003_library_OBJECT_LIBRARIES} LINK_LIBRARIES - PUBLIC ${_clib_target} # depend on the c library - ${sundials_add_f2003_library_LINK_LIBRARIES} + PUBLIC + ${_clib_target} # depend on the c library + ${sundials_add_f2003_library_LINK_LIBRARIES} INCLUDE_DIRECTORIES - ${sundials_add_f2003_library_INCLUDE_DIRECTORIES} - ${_includes} - COMPILE_DEFINITIONS ${sundials_add_f2003_library_COMPILE_DEFINITIONS} - PUBLIC "SUNDIALS_INT${SUNDIALS_INDEX_SIZE}_T" - COMPILE_OPTIONS ${sundials_add_f2003_library_COMPILE_OPTIONS} - PROPERTIES ${sundials_add_f2003_library_PROPERTIES} ${_properties} - OUTPUT_NAME ${sundials_add_f2003_library_OUTPUT_NAME} - VERSION ${sundials_add_f2003_library_VERSION} - SOVERSION ${sundials_add_f2003_library_SOVERSION} - ${sundials_add_f2003_library_UNPARSED_ARGUMENTS} - ) + ${sundials_add_f2003_library_INCLUDE_DIRECTORIES} + ${_includes} + COMPILE_DEFINITIONS + ${sundials_add_f2003_library_COMPILE_DEFINITIONS} + PUBLIC + "SUNDIALS_INT${SUNDIALS_INDEX_SIZE}_T" + COMPILE_OPTIONS + ${sundials_add_f2003_library_COMPILE_OPTIONS} + PROPERTIES + ${sundials_add_f2003_library_PROPERTIES} + ${_properties} + OUTPUT_NAME + ${sundials_add_f2003_library_OUTPUT_NAME} + VERSION + ${sundials_add_f2003_library_VERSION} + SOVERSION + ${sundials_add_f2003_library_SOVERSION} + ${sundials_add_f2003_library_UNPARSED_ARGUMENTS}) endmacro() - macro(append_static_suffix libs_in libs_out) set(${libs_out} "") foreach(_lib ${${libs_in}}) diff --git a/cmake/macros/SundialsAddTest.cmake b/cmake/macros/SundialsAddTest.cmake index 33eb8d7fa1..f276d754f6 100644 --- a/cmake/macros/SundialsAddTest.cmake +++ b/cmake/macros/SundialsAddTest.cmake @@ -66,22 +66,25 @@ macro(SUNDIALS_ADD_TEST NAME EXECUTABLE) # ANSWER_FILE = name of test answer file # EXAMPLE_TYPE = release or develop examples set(oneValueArgs "MPI_NPROCS" "FLOAT_PRECISION" "INTEGER_PRECISION" - "ANSWER_DIR" "ANSWER_FILE" "EXAMPLE_TYPE") + "ANSWER_DIR" "ANSWER_FILE" "EXAMPLE_TYPE") # macro keyword inputs followed by multiple values # TEST_ARGS = command line arguments to pass to the test executable set(multiValueArgs "TEST_ARGS" "EXTRA_ARGS") # parse inputs and create variables SUNDIALS_ADD_TEST_ - cmake_parse_arguments(SUNDIALS_ADD_TEST - "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + cmake_parse_arguments(SUNDIALS_ADD_TEST "${options}" "${oneValueArgs}" + "${multiValueArgs}" ${ARGN}) # check that the test is not excluded string(TOLOWER "exclude-${SUNDIALS_PRECISION}" _exclude_precision) - if( ("${SUNDIALS_ADD_TEST_EXAMPLE_TYPE}" STREQUAL "exclude") OR - ("${SUNDIALS_ADD_TEST_EXAMPLE_TYPE}" STREQUAL _exclude_precision) ) + if(("${SUNDIALS_ADD_TEST_EXAMPLE_TYPE}" STREQUAL "exclude") + OR ("${SUNDIALS_ADD_TEST_EXAMPLE_TYPE}" STREQUAL _exclude_precision)) - message(STATUS "Skipped test ${NAME} because it had type ${SUNDIALS_ADD_TEST_EXAMPLE_TYPE}") + message( + STATUS + "Skipped test ${NAME} because it had type ${SUNDIALS_ADD_TEST_EXAMPLE_TYPE}" + ) else() @@ -90,16 +93,14 @@ macro(SUNDIALS_ADD_TEST NAME EXECUTABLE) # run all tests (standard and develop) with the test runner # command line arguments for the test runner script - set(TEST_ARGS - "--verbose" - "--testname=${NAME}" - "--executablename=$" - ) + set(TEST_ARGS "--verbose" "--testname=${NAME}" + "--executablename=$") if(SUNDIALS_TEST_PROFILE) list(APPEND TEST_ARGS "--profile") - if (SUNDIALS_CALIPER_OUTPUT_DIR) - list(APPEND TEST_ARGS "--calidir=${SUNDIALS_CALIPER_OUTPUT_DIR}/Example/${JOB_ID}") + if(SUNDIALS_CALIPER_OUTPUT_DIR) + list(APPEND TEST_ARGS + "--calidir=${SUNDIALS_CALIPER_OUTPUT_DIR}/Example/${JOB_ID}") else() list(APPEND TEST_ARGS "--calidir=${TEST_OUTPUT_DIR}/Caliper/Example") endif() @@ -130,27 +131,38 @@ macro(SUNDIALS_ADD_TEST NAME EXECUTABLE) list(APPEND TEST_ARGS "--nodiff") else() # set a non-default floating point precision (number of digits, default 4) - if(SUNDIALS_ADD_TEST_FLOAT_PRECISION AND - (NOT SUNDIALS_ADD_TEST_FLOAT_PRECISION MATCHES "DEFAULT|default")) - list(APPEND TEST_ARGS "--floatprecision=${SUNDIALS_ADD_TEST_FLOAT_PRECISION}") + if(SUNDIALS_ADD_TEST_FLOAT_PRECISION + AND (NOT SUNDIALS_ADD_TEST_FLOAT_PRECISION MATCHES "DEFAULT|default" + )) + list(APPEND TEST_ARGS + "--floatprecision=${SUNDIALS_ADD_TEST_FLOAT_PRECISION}") elseif(SUNDIALS_TEST_FLOAT_PRECISION GREATER_EQUAL "0") - list(APPEND TEST_ARGS "--floatprecision=${SUNDIALS_TEST_FLOAT_PRECISION}") + list(APPEND TEST_ARGS + "--floatprecision=${SUNDIALS_TEST_FLOAT_PRECISION}") endif() # set a non-default integer precision (percent difference, default 10%) - if(SUNDIALS_ADD_TEST_INTEGER_PRECISION AND - (NOT SUNDIALS_ADD_TEST_INTEGER_PRECISION MATCHES "DEFAULT|default")) - list(APPEND TEST_ARGS "--integerpercentage=${SUNDIALS_ADD_TEST_INTEGER_PRECISION}") + if(SUNDIALS_ADD_TEST_INTEGER_PRECISION + AND (NOT SUNDIALS_ADD_TEST_INTEGER_PRECISION MATCHES + "DEFAULT|default")) + list(APPEND TEST_ARGS + "--integerpercentage=${SUNDIALS_ADD_TEST_INTEGER_PRECISION}") elseif(SUNDIALS_TEST_INTEGER_PRECISION GREATER_EQUAL "0") - list(APPEND TEST_ARGS "--integerpercentage=${SUNDIALS_TEST_INTEGER_PRECISION}") + list(APPEND TEST_ARGS + "--integerpercentage=${SUNDIALS_TEST_INTEGER_PRECISION}") endif() endif() # check if this test is run with MPI and set the MPI run command - if((SUNDIALS_ADD_TEST_MPI_NPROCS) AND ((MPIEXEC_EXECUTABLE) OR (SUNDIALS_TEST_MPIRUN_COMMAND))) - if (SUNDIALS_TEST_MPIRUN_COMMAND) - set(RUN_COMMAND "${SUNDIALS_TEST_MPIRUN_COMMAND} ${MPIEXEC_NUMPROC_FLAG} ${SUNDIALS_ADD_TEST_MPI_NPROCS} ${MPIEXEC_PREFLAGS}") + if((SUNDIALS_ADD_TEST_MPI_NPROCS) AND ((MPIEXEC_EXECUTABLE) + OR (SUNDIALS_TEST_MPIRUN_COMMAND))) + if(SUNDIALS_TEST_MPIRUN_COMMAND) + set(RUN_COMMAND + "${SUNDIALS_TEST_MPIRUN_COMMAND} ${MPIEXEC_NUMPROC_FLAG} ${SUNDIALS_ADD_TEST_MPI_NPROCS} ${MPIEXEC_PREFLAGS}" + ) elseif(MPIEXEC_EXECUTABLE) - set(RUN_COMMAND "${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${SUNDIALS_ADD_TEST_MPI_NPROCS} ${MPIEXEC_PREFLAGS}") + set(RUN_COMMAND + "${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${SUNDIALS_ADD_TEST_MPI_NPROCS} ${MPIEXEC_PREFLAGS}" + ) endif() # remove trailing white space (empty MPIEXEC_PREFLAGS) as it can cause @@ -170,7 +182,7 @@ macro(SUNDIALS_ADD_TEST NAME EXECUTABLE) set(_run_args "${_run_args} ${_extra_args}") unset(_extra_args) endif() - if (_run_args) + if(_run_args) string(STRIP "${_run_args}" _run_args) list(APPEND TEST_ARGS "--runargs=\"${_run_args}\"") unset(_run_args) @@ -178,7 +190,8 @@ macro(SUNDIALS_ADD_TEST NAME EXECUTABLE) # create test case with the corresponding test runner command and arguments # all tests are added during development and only unlabeled tests when released - add_test(NAME ${NAME} COMMAND ${PYTHON_EXECUTABLE} ${TESTRUNNER} ${TEST_ARGS}) + add_test(NAME ${NAME} COMMAND ${PYTHON_EXECUTABLE} ${TESTRUNNER} + ${TEST_ARGS}) elseif(NOT SUNDIALS_ADD_TEST_EXAMPLE_TYPE) @@ -190,15 +203,27 @@ macro(SUNDIALS_ADD_TEST NAME EXECUTABLE) endif() # check if this test is run with MPI and add the test run command - if((SUNDIALS_ADD_TEST_MPI_NPROCS) AND ((MPIEXEC_EXECUTABLE) OR (SUNDIALS_TEST_MPIRUN_COMMAND))) + if((SUNDIALS_ADD_TEST_MPI_NPROCS) AND ((MPIEXEC_EXECUTABLE) + OR (SUNDIALS_TEST_MPIRUN_COMMAND))) if(MPIEXEC_PREFLAGS) string(REPLACE " " ";" PREFLAGS "${MPIEXEC_PREFLAGS}") endif() - if (SUNDIALS_TEST_MPIRUN_COMMAND) - string(REPLACE " " ";" MPI_EXEC_ARGS "${SUNDIALS_TEST_MPIRUN_COMMAND}") - add_test(NAME ${NAME} COMMAND ${MPI_EXEC_ARGS} ${MPIEXEC_NUMPROC_FLAG} ${SUNDIALS_ADD_TEST_MPI_NPROCS} ${PREFLAGS} $ ${TEST_ARGS}) + if(SUNDIALS_TEST_MPIRUN_COMMAND) + string(REPLACE " " ";" MPI_EXEC_ARGS + "${SUNDIALS_TEST_MPIRUN_COMMAND}") + add_test( + NAME ${NAME} + COMMAND + ${MPI_EXEC_ARGS} ${MPIEXEC_NUMPROC_FLAG} + ${SUNDIALS_ADD_TEST_MPI_NPROCS} ${PREFLAGS} + $ ${TEST_ARGS}) else() - add_test(NAME ${NAME} COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${SUNDIALS_ADD_TEST_MPI_NPROCS} ${PREFLAGS} $ ${TEST_ARGS}) + add_test( + NAME ${NAME} + COMMAND + ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} + ${SUNDIALS_ADD_TEST_MPI_NPROCS} ${PREFLAGS} + $ ${TEST_ARGS}) endif() else() add_test(NAME ${NAME} COMMAND $ ${TEST_ARGS}) diff --git a/cmake/macros/SundialsAddTestInstall.cmake b/cmake/macros/SundialsAddTestInstall.cmake index cf2a6fb76b..8829908982 100644 --- a/cmake/macros/SundialsAddTestInstall.cmake +++ b/cmake/macros/SundialsAddTestInstall.cmake @@ -24,18 +24,18 @@ macro(SUNDIALS_ADD_TEST_INSTALL PACKAGE TESTDIR) # TESTDIR = Test directory name (e.g., serial, C_parallel, etc.) # macro options - set(options ) + set(options) # macro keyword inputs followed by a single value # EXECUTABLE = executable to add to make test_install target set(oneValueArgs EXECUTABLE) # macro keyword inputs followed by multiple values - set(multiValueArgs ) + set(multiValueArgs) # parse inputs and create variables SUNDIALS_ADD_TEST_ - cmake_parse_arguments(SUNDIALS_ADD_TEST_INSTALL - "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + cmake_parse_arguments(SUNDIALS_ADD_TEST_INSTALL "${options}" + "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) if(SUNDIALS_ADD_TEST_INSTALL_EXECUTABLE) @@ -45,13 +45,17 @@ macro(SUNDIALS_ADD_TEST_INSTALL PACKAGE TESTDIR) endif() # build and run only the desired install test - add_custom_target(test_install_${PACKAGE}_${TESTDIR} + add_custom_target( + test_install_${PACKAGE}_${TESTDIR} COMMENT "Running ${PACKAGE} installation tests" WORKING_DIRECTORY ${TEST_INSTALL_DIR}/${PACKAGE}/${TESTDIR} VERBATIM - COMMAND ${CMAKE_COMMAND} ${EXAMPLES_INSTALL_PATH}/${PACKAGE}/${TESTDIR} > cmake.out - COMMAND ${CMAKE_COMMAND} --build ${TEST_INSTALL_DIR}/${PACKAGE}/${TESTDIR} --target ${SUNDIALS_ADD_TEST_INSTALL_EXECUTABLE} > make.out - COMMAND ${CMAKE_CTEST_COMMAND} -R ^${SUNDIALS_ADD_TEST_INSTALL_EXECUTABLE}$) + COMMAND ${CMAKE_COMMAND} ${EXAMPLES_INSTALL_PATH}/${PACKAGE}/${TESTDIR} > + cmake.out + COMMAND ${CMAKE_COMMAND} --build ${TEST_INSTALL_DIR}/${PACKAGE}/${TESTDIR} + --target ${SUNDIALS_ADD_TEST_INSTALL_EXECUTABLE} > make.out + COMMAND ${CMAKE_CTEST_COMMAND} -R + ^${SUNDIALS_ADD_TEST_INSTALL_EXECUTABLE}$) # make test_install depend on test_install_package add_dependencies(test_install test_install_${PACKAGE}_${TESTDIR}) @@ -68,12 +72,15 @@ macro(SUNDIALS_ADD_TEST_INSTALL PACKAGE TESTDIR) endif() # build and run all install tests - add_custom_target(test_install_all_${PACKAGE}_${TESTDIR} + add_custom_target( + test_install_all_${PACKAGE}_${TESTDIR} COMMENT "Running ${PACKAGE} installation tests" WORKING_DIRECTORY ${TEST_INSTALL_ALL_DIR}/${PACKAGE}/${TESTDIR} VERBATIM - COMMAND ${CMAKE_COMMAND} ${EXAMPLES_INSTALL_PATH}/${PACKAGE}/${TESTDIR} > cmake.out - COMMAND ${CMAKE_COMMAND} --build ${TEST_INSTALL_ALL_DIR}/${PACKAGE}/${TESTDIR} > make.out) + COMMAND ${CMAKE_COMMAND} ${EXAMPLES_INSTALL_PATH}/${PACKAGE}/${TESTDIR} > + cmake.out + COMMAND ${CMAKE_COMMAND} --build + ${TEST_INSTALL_ALL_DIR}/${PACKAGE}/${TESTDIR} > make.out) # In the future add "COMMAND ${CMAKE_CTEST_COMMAND}" here to run ctest with # the installed examples. Left out for now as some MPI tests require running # with a specific number of MPI tasks. diff --git a/cmake/macros/SundialsCMakeMacros.cmake b/cmake/macros/SundialsCMakeMacros.cmake index 237c7c6ac8..53f30b7f87 100644 --- a/cmake/macros/SundialsCMakeMacros.cmake +++ b/cmake/macros/SundialsCMakeMacros.cmake @@ -19,13 +19,15 @@ # show variable (set as cache) and overwrite (force) its value macro(FORCE_VARIABLE var type doc val) - set(${var} "${val}" CACHE "${type}" "${doc}" FORCE) + set(${var} + "${val}" + CACHE "${type}" "${doc}" FORCE) endmacro(FORCE_VARIABLE) # Macros to append a common suffix or prefix to the elements of a list macro(ADD_SUFFIX rootlist suffix) - set(outlist ) + set(outlist) foreach(root ${${rootlist}}) list(APPEND outlist ${root}${suffix}) endforeach(root) @@ -33,7 +35,7 @@ macro(ADD_SUFFIX rootlist suffix) endmacro(ADD_SUFFIX) macro(ADD_PREFIX prefix rootlist) - set(outlist ) + set(outlist) foreach(root ${${rootlist}}) list(APPEND outlist ${prefix}${root}) endforeach(root) @@ -43,12 +45,13 @@ endmacro(ADD_PREFIX) # Macro to print warnings. macro(print_warning message action) - set(options ) + set(options) set(oneValueArgs MODE) - set(multiValueArgs ) + set(multiValueArgs) # parse inputs and create variables print_warning_ - cmake_parse_arguments(print_warning "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} ) + cmake_parse_arguments(print_warning "${options}" "${oneValueArgs}" + "${multiValueArgs}" ${ARGN}) if(print_warning_MODE) set(_mode ${print_warning_MODE}) @@ -57,10 +60,11 @@ macro(print_warning message action) endif() set(MSG - "------------------------------------------------------------------------\n" - "WARNING: ${message}\n" - "${action}\n" - "------------------------------------------------------------------------") + "------------------------------------------------------------------------\n" + "WARNING: ${message}\n" + "${action}\n" + "------------------------------------------------------------------------" + ) message(${_mode} ${MSG}) endmacro() @@ -68,12 +72,13 @@ endmacro() # Macro to print error messages. macro(print_error message) - set(options ) + set(options) set(oneValueArgs MODE) - set(multiValueArgs ) + set(multiValueArgs) # parse inputs and create variables print_warning_ - cmake_parse_arguments(print_error "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} ) + cmake_parse_arguments(print_error "${options}" "${oneValueArgs}" + "${multiValueArgs}" ${ARGN}) if(print_error_MODE) set(_mode ${print_error_MODE}) @@ -82,9 +87,10 @@ macro(print_error message) endif() set(MSG - "************************************************************************\n" - "ERROR: ${message}\n" - "************************************************************************") + "************************************************************************\n" + "ERROR: ${message}\n" + "************************************************************************" + ) message(${_mode} ${MSG}) endmacro() @@ -95,7 +101,7 @@ endmacro() macro(LIST2STRING alist astring) foreach(elem ${${alist}}) - set(${astring} "${${astring}} ${elem}") + set(${astring} "${${astring}} ${elem}") endforeach(elem) endmacro(LIST2STRING) @@ -119,13 +125,16 @@ function(sundials_git_version) set(_tmp "") if(EXISTS ${CMAKE_CURRENT_LIST_DIR}/.git AND ${GIT_FOUND}) - execute_process(COMMAND git describe --abbrev=12 --dirty --always --tags - WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} - OUTPUT_VARIABLE _tmp) + execute_process( + COMMAND git describe --abbrev=12 --dirty --always --tags + WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} + OUTPUT_VARIABLE _tmp) string(STRIP "${_tmp}" _tmp) endif() - set(SUNDIALS_GIT_VERSION "${_tmp}" CACHE INTERNAL "") + set(SUNDIALS_GIT_VERSION + "${_tmp}" + CACHE INTERNAL "") unset(_tmp) endfunction() diff --git a/cmake/macros/SundialsInstallExamples.cmake b/cmake/macros/SundialsInstallExamples.cmake index 7f40b7af6e..e48d9430e7 100644 --- a/cmake/macros/SundialsInstallExamples.cmake +++ b/cmake/macros/SundialsInstallExamples.cmake @@ -72,35 +72,42 @@ macro(sundials_install_examples MODULE EXAMPLES_VAR) - set(options ) + set(options) set(oneValueArgs SOLVER_LIBRARY DESTINATION CMAKE_TEMPLATE MAKE_TEMPLATE - TEST_INSTALL) + TEST_INSTALL) set(multiValueArgs SUNDIALS_TARGETS SUNDIALS_COMPONENTS OTHER_TARGETS - EXAMPLES_DEPENDENCIES EXTRA_FILES EXTRA_INCLUDES) + EXAMPLES_DEPENDENCIES EXTRA_FILES EXTRA_INCLUDES) # Parse keyword arguments/options - cmake_parse_arguments(sundials_install_examples - "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + cmake_parse_arguments(sundials_install_examples "${options}" + "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) # Install the extra files foreach(file ${sundials_install_examples_EXTRA_FILES}) - install(FILES ${file} DESTINATION ${EXAMPLES_INSTALL_PATH}/${sundials_install_examples_DESTINATION}) + install( + FILES ${file} + DESTINATION + ${EXAMPLES_INSTALL_PATH}/${sundials_install_examples_DESTINATION}) endforeach() # Install the examples foreach(example_tuple ${${EXAMPLES_VAR}}) - list(GET example_tuple 0 example) # filename always has to be the first item in the example tuple + list(GET example_tuple 0 example + )# filename always has to be the first item in the example tuple get_filename_component(example_noext ${example} NAME_WE) file(GLOB example_header ${example_noext}.h*) file(GLOB example_out ${example_noext}*.out) - install(FILES ${example} ${example_header} ${example_out} - DESTINATION ${EXAMPLES_INSTALL_PATH}/${sundials_install_examples_DESTINATION}) + install( + FILES ${example} ${example_header} ${example_out} + DESTINATION + ${EXAMPLES_INSTALL_PATH}/${sundials_install_examples_DESTINATION}) endforeach() # Prepare substitution variables for Makefile and/or CMakeLists templates string(TOUPPER "${MODULE}" SOLVER) set(SOLVER_LIB "${sundials_install_examples_SOLVER_LIBRARY}") - set(EXAMPLES_DEPENDENCIES "${sundials_install_examples_EXAMPLES_DEPENDENCIES}") + set(EXAMPLES_DEPENDENCIES + "${sundials_install_examples_EXAMPLES_DEPENDENCIES}") set(EXTRA_INCLUDES "${sundials_install_examples_EXTRA_INCLUDES}") examples2string(${EXAMPLES_VAR} EXAMPLES) @@ -136,13 +143,13 @@ macro(sundials_install_examples MODULE EXAMPLES_VAR) configure_file( ${PROJECT_SOURCE_DIR}/examples/templates/${sundials_install_examples_CMAKE_TEMPLATE} ${PROJECT_BINARY_DIR}/examples/${sundials_install_examples_DESTINATION}/CMakeLists.txt - @ONLY - ) + @ONLY) # install CMakelists.txt install( - FILES ${PROJECT_BINARY_DIR}/examples/${sundials_install_examples_DESTINATION}/CMakeLists.txt - DESTINATION ${EXAMPLES_INSTALL_PATH}/${sundials_install_examples_DESTINATION} - ) + FILES + ${PROJECT_BINARY_DIR}/examples/${sundials_install_examples_DESTINATION}/CMakeLists.txt + DESTINATION + ${EXAMPLES_INSTALL_PATH}/${sundials_install_examples_DESTINATION}) # On UNIX-type platforms, we also generate and install a makefile for # building the examples. This makefile can then be used as a template @@ -153,19 +160,20 @@ macro(sundials_install_examples MODULE EXAMPLES_VAR) configure_file( ${PROJECT_SOURCE_DIR}/examples/templates/${sundials_install_examples_MAKE_TEMPLATE} ${PROJECT_BINARY_DIR}/examples/${sundials_install_examples_DESTINATION}/Makefile_ex - @ONLY - ) + @ONLY) # install the configured Makefile_ex as Makefile install( - FILES ${PROJECT_BINARY_DIR}/examples/${sundials_install_examples_DESTINATION}/Makefile_ex - DESTINATION ${EXAMPLES_INSTALL_PATH}/${sundials_install_examples_DESTINATION} - RENAME Makefile - ) + FILES + ${PROJECT_BINARY_DIR}/examples/${sundials_install_examples_DESTINATION}/Makefile_ex + DESTINATION + ${EXAMPLES_INSTALL_PATH}/${sundials_install_examples_DESTINATION} + RENAME Makefile) endif() # Add test_install target if(DEFINED sundials_install_examples_TEST_INSTALL) - sundials_add_test_install(${MODULE} ${sundials_install_examples_TEST_INSTALL}) + sundials_add_test_install(${MODULE} + ${sundials_install_examples_TEST_INSTALL}) endif() endmacro() diff --git a/cmake/macros/SundialsInstallExamplesGinkgo.cmake b/cmake/macros/SundialsInstallExamplesGinkgo.cmake index 05427f2051..34347ec342 100644 --- a/cmake/macros/SundialsInstallExamplesGinkgo.cmake +++ b/cmake/macros/SundialsInstallExamplesGinkgo.cmake @@ -48,14 +48,20 @@ macro(sundials_install_examples_ginkgo MODULE) - set(options ) + set(options) set(oneValueArgs DESTINATION) - set(multiValueArgs CPU_EXAMPLES_VAR GPU_EXAMPLES_VAR CPU_GPU_EXAMPLES_VAR - SUNDIALS_COMPONENTS SUNDIALS_TARGETS EXTRA_FILES DEPENDENCIES) + set(multiValueArgs + CPU_EXAMPLES_VAR + GPU_EXAMPLES_VAR + CPU_GPU_EXAMPLES_VAR + SUNDIALS_COMPONENTS + SUNDIALS_TARGETS + EXTRA_FILES + DEPENDENCIES) # Parse keyword arguments/options - cmake_parse_arguments(arg - "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + cmake_parse_arguments(arg "${options}" "${oneValueArgs}" "${multiValueArgs}" + ${ARGN}) # Install the example source, header, and output file foreach(example_type CPU GPU CPU_GPU) @@ -73,7 +79,7 @@ macro(sundials_install_examples_ginkgo MODULE) # install files install(FILES ${example} ${example_header} ${example_out} - DESTINATION ${EXAMPLES_INSTALL_PATH}/${arg_DESTINATION}) + DESTINATION ${EXAMPLES_INSTALL_PATH}/${arg_DESTINATION}) endforeach() endforeach() @@ -81,7 +87,7 @@ macro(sundials_install_examples_ginkgo MODULE) # Install the extra files and dependencies if(arg_EXTRA_FILES OR arg_DEPENDENCIES) install(FILES ${arg_EXTRA_FILES} ${arg_DEPENDENCIES} - DESTINATION ${EXAMPLES_INSTALL_PATH}/${arg_DESTINATION}) + DESTINATION ${EXAMPLES_INSTALL_PATH}/${arg_DESTINATION}) endif() # Prepare substitution variables for CMakeLists and/or Makefile templates @@ -115,15 +121,11 @@ macro(sundials_install_examples_ginkgo MODULE) # Generate CMakelists.txt in the binary directory configure_file( ${PROJECT_SOURCE_DIR}/examples/templates/cmakelists_CXX_ginkgo_ex.in - ${PROJECT_BINARY_DIR}/examples/${arg_DESTINATION}/CMakeLists.txt - @ONLY - ) + ${PROJECT_BINARY_DIR}/examples/${arg_DESTINATION}/CMakeLists.txt @ONLY) # Install CMakelists.txt - install( - FILES ${PROJECT_BINARY_DIR}/examples/${arg_DESTINATION}/CMakeLists.txt - DESTINATION ${EXAMPLES_INSTALL_PATH}/${arg_DESTINATION} - ) + install(FILES ${PROJECT_BINARY_DIR}/examples/${arg_DESTINATION}/CMakeLists.txt + DESTINATION ${EXAMPLES_INSTALL_PATH}/${arg_DESTINATION}) # Add test_install target sundials_add_test_install(${MODULE} ginkgo) diff --git a/cmake/macros/SundialsOption.cmake b/cmake/macros/SundialsOption.cmake index 252db50f69..975b1f3312 100644 --- a/cmake/macros/SundialsOption.cmake +++ b/cmake/macros/SundialsOption.cmake @@ -42,7 +42,7 @@ macro(sundials_option NAME TYPE DOCSTR DEFAULT_VALUE) # parse inputs and create variables sundials_option_ cmake_parse_arguments(sundials_option "${options}" "${oneValueArgs}" - "${multiValueArgs}" ${ARGN} ) + "${multiValueArgs}" ${ARGN}) # check if dependencies for this option have been met set(all_depends_on_dependencies_met TRUE) @@ -58,9 +58,13 @@ macro(sundials_option NAME TYPE DOCSTR DEFAULT_VALUE) if(all_depends_on_dependencies_met) if(NOT DEFINED ${NAME}) - set(${NAME} "${DEFAULT_VALUE}" CACHE ${TYPE} ${DOCSTR}) + set(${NAME} + "${DEFAULT_VALUE}" + CACHE ${TYPE} ${DOCSTR}) else() - set(${NAME} "${${NAME}}" CACHE ${TYPE} ${DOCSTR}) + set(${NAME} + "${${NAME}}" + CACHE ${TYPE} ${DOCSTR}) endif() # make the option advanced if necessary @@ -73,11 +77,10 @@ macro(sundials_option NAME TYPE DOCSTR DEFAULT_VALUE) # if necessary, remove the CACHE variable i.e., all the variable # dependencies were previously met but are no longer satisfied if(DEFINED ${NAME}) - string(CONCAT _warn_msg_string - "The variable ${NAME} was set to ${${NAME}} " - "but not all of its dependencies " - "(${depends_on_dependencies_not_met}) evaluate to TRUE." - ) + string( + CONCAT _warn_msg_string "The variable ${NAME} was set to ${${NAME}} " + "but not all of its dependencies " + "(${depends_on_dependencies_not_met}) evaluate to TRUE.") unset(${NAME} CACHE) if(sundials_option_DEPENDS_ON_THROW_ERROR) print_error("${_warn_msg_string}" "Unsetting ${NAME}") @@ -96,7 +99,10 @@ macro(sundials_option NAME TYPE DOCSTR DEFAULT_VALUE) print_error("Value of ${NAME} must be one of ${_options_msg}") endif() endforeach() - get_property(is_in_cache CACHE ${NAME} PROPERTY TYPE) + get_property( + is_in_cache + CACHE ${NAME} + PROPERTY TYPE) if(is_in_cache) set_property(CACHE ${NAME} PROPERTY STRINGS ${sundials_option_OPTIONS}) endif() diff --git a/cmake/macros/SundialsTryCompileExecute.cmake b/cmake/macros/SundialsTryCompileExecute.cmake index 81e972b92d..3bf431e167 100644 --- a/cmake/macros/SundialsTryCompileExecute.cmake +++ b/cmake/macros/SundialsTryCompileExecute.cmake @@ -28,20 +28,28 @@ macro(sundials_trycompile_execute EXECUTABLE CWD COMPILE_OK RUN_OK) - set(options ) + set(options) set(oneValueArgs COMPILE_OUTPUT RUN_OUTPUT) - set(multiValueArgs ) + set(multiValueArgs) set(COMPILE_OK FALSE) set(RUN_OK FALSE) - set(COMPILE_OUTPUT ) - set(RUN_OUTPUT ) + set(COMPILE_OUTPUT) + set(RUN_OUTPUT) - cmake_parse_arguments(sundials_trycompile_execute "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} ) + cmake_parse_arguments(sundials_trycompile_execute "${options}" + "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) # compile the code and then try to run it - try_compile(COMPILE_OK ${CWD} ${CWD} ${EXECUTABLE} OUTPUT_VARIABLE COMPILE_OUTPUT) + try_compile( + COMPILE_OK ${CWD} + ${CWD} ${EXECUTABLE} + OUTPUT_VARIABLE COMPILE_OUTPUT) if(COMPILE_OK) - execute_process(COMMAND "./${EXECUTABLE}" WORKING_DIRECTORY ${CWD} RESULT_VARIABLE RUN_OK OUTPUT_VARIABLE RUN_OUTPUT) + execute_process( + COMMAND "./${EXECUTABLE}" + WORKING_DIRECTORY ${CWD} + RESULT_VARIABLE RUN_OK + OUTPUT_VARIABLE RUN_OUTPUT) if(RUN_OK MATCHES "0") set(RUN_OK TRUE) endif() diff --git a/cmake/tpl/FindHYPRE.cmake b/cmake/tpl/FindHYPRE.cmake index 691647544a..13ebbe70a0 100644 --- a/cmake/tpl/FindHYPRE.cmake +++ b/cmake/tpl/FindHYPRE.cmake @@ -33,52 +33,57 @@ # --------------------------------------------------------------- ### Find include dir -find_path(temp_HYPRE_INCLUDE_DIR - NAMES HYPRE.h hypre.h - HINTS "${HYPRE_DIR}" "${HYPRE_DIR}/include" "${HYPRE_INCLUDE_DIR}") -if (temp_HYPRE_INCLUDE_DIR) - set(HYPRE_INCLUDE_DIR "${temp_HYPRE_INCLUDE_DIR}" CACHE PATH "" FORCE) +find_path( + temp_HYPRE_INCLUDE_DIR + NAMES HYPRE.h hypre.h + HINTS "${HYPRE_DIR}" "${HYPRE_DIR}/include" "${HYPRE_INCLUDE_DIR}") +if(temp_HYPRE_INCLUDE_DIR) + set(HYPRE_INCLUDE_DIR + "${temp_HYPRE_INCLUDE_DIR}" + CACHE PATH "" FORCE) endif() unset(temp_HYPRE_INCLUDE_DIR CACHE) -if (HYPRE_LIBRARY) - # We have (or were given) HYPRE_LIBRARY - get path to use for any related libs - get_filename_component(HYPRE_LIBRARY_DIR ${HYPRE_LIBRARY} PATH) +if(HYPRE_LIBRARY) + # We have (or were given) HYPRE_LIBRARY - get path to use for any related libs + get_filename_component(HYPRE_LIBRARY_DIR ${HYPRE_LIBRARY} PATH) - # force CACHE update to show user DIR that will be used - set(HYPRE_LIBRARY_DIR ${HYPRE_LIBRARY_DIR} CACHE PATH "" FORCE) -else () - # find library with user provided directory path - set(HYPRE_LIBRARY_NAMES hypre HYPRE) - find_library(HYPRE_LIBRARY - NAMES ${HYPRE_LIBRARY_NAMES} - HINTS "${HYPRE_DIR}" "${HYPRE_DIR}/lib" "${HYPRE_DIR}/lib64" "${HYPRE_LIBRARY_DIR}" - NO_DEFAULT_PATH - ) -endif () + # force CACHE update to show user DIR that will be used + set(HYPRE_LIBRARY_DIR + ${HYPRE_LIBRARY_DIR} + CACHE PATH "" FORCE) +else() + # find library with user provided directory path + set(HYPRE_LIBRARY_NAMES hypre HYPRE) + find_library( + HYPRE_LIBRARY + NAMES ${HYPRE_LIBRARY_NAMES} + HINTS "${HYPRE_DIR}" "${HYPRE_DIR}/lib" "${HYPRE_DIR}/lib64" + "${HYPRE_LIBRARY_DIR}" + NO_DEFAULT_PATH) +endif() mark_as_advanced(HYPRE_LIBRARY) list(FIND HYPRE_LIBRARIES ${HYPRE_LIBRARY} _idx) -if (_idx EQUAL -1) - set(HYPRE_LIBRARIES "${HYPRE_LIBRARY};${HYPRE_LIBRARIES}" CACHE STRING "" FORCE) -endif () +if(_idx EQUAL -1) + set(HYPRE_LIBRARIES + "${HYPRE_LIBRARY};${HYPRE_LIBRARIES}" + CACHE STRING "" FORCE) +endif() # set a more informative error message in case the library was not found -set(HYPRE_NOT_FOUND_MESSAGE "\ +set(HYPRE_NOT_FOUND_MESSAGE + "\ ************************************************************************\n\ ERROR: Could not find HYPRE. Please check the variables:\n\ HYPRE_INCLUDE_DIR and HYPRE_LIBRARY_DIR\n\ ************************************************************************") # set package variables including HYPRE_FOUND -find_package_handle_standard_args(HYPRE - REQUIRED_VARS - HYPRE_LIBRARY - HYPRE_LIBRARIES - HYPRE_INCLUDE_DIR - FAIL_MESSAGE - "${HYPRE_NOT_FOUND_MESSAGE}" - ) +find_package_handle_standard_args( + HYPRE + REQUIRED_VARS HYPRE_LIBRARY HYPRE_LIBRARIES HYPRE_INCLUDE_DIR + FAIL_MESSAGE "${HYPRE_NOT_FOUND_MESSAGE}") # Create target for HYPRE if(HYPRE_FOUND) @@ -87,9 +92,10 @@ if(HYPRE_FOUND) add_library(SUNDIALS::HYPRE UNKNOWN IMPORTED) endif() - set_target_properties(SUNDIALS::HYPRE PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${HYPRE_INCLUDE_DIR}" - INTERFACE_LINK_LIBRARIES "${HYPRE_LIBRARIES}" - IMPORTED_LOCATION "${HYPRE_LIBRARY}") + set_target_properties( + SUNDIALS::HYPRE + PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${HYPRE_INCLUDE_DIR}" + INTERFACE_LINK_LIBRARIES "${HYPRE_LIBRARIES}" + IMPORTED_LOCATION "${HYPRE_LIBRARY}") endif() diff --git a/cmake/tpl/FindKLU.cmake b/cmake/tpl/FindKLU.cmake index a3d817d037..32caf09433 100644 --- a/cmake/tpl/FindKLU.cmake +++ b/cmake/tpl/FindKLU.cmake @@ -30,7 +30,10 @@ # KLU_LIBRARIES - all of the libraries needed for KLU # --------------------------------------------------------------- -if (NOT (KLU_INCLUDE_DIR OR KLU_LIBRARY_DIR OR KLU_LIBRARY)) +if(NOT + (KLU_INCLUDE_DIR + OR KLU_LIBRARY_DIR + OR KLU_LIBRARY)) # Prefer the import target from upstream SuiteSparse if it is available # and the user didn't point to a specific (different) version. find_package(KLU CONFIG) @@ -55,61 +58,66 @@ endif() ### Find include dir find_path(temp_KLU_INCLUDE_DIR klu.h ${KLU_INCLUDE_DIR}) -if (temp_KLU_INCLUDE_DIR) - set(KLU_INCLUDE_DIR ${temp_KLU_INCLUDE_DIR}) +if(temp_KLU_INCLUDE_DIR) + set(KLU_INCLUDE_DIR ${temp_KLU_INCLUDE_DIR}) endif() unset(temp_KLU_INCLUDE_DIR CACHE) -if (KLU_LIBRARY) - # We have (or were given) KLU_LIBRARY - get path to use for other Suitesparse libs - get_filename_component(KLU_LIBRARY_DIR ${KLU_LIBRARY} PATH) +if(KLU_LIBRARY) + # We have (or were given) KLU_LIBRARY - get path to use for other Suitesparse libs + get_filename_component(KLU_LIBRARY_DIR ${KLU_LIBRARY} PATH) - # force CACHE update to show user DIR that will be used - set(KLU_LIBRARY_DIR ${KLU_LIBRARY_DIR} CACHE PATH "" FORCE) + # force CACHE update to show user DIR that will be used + set(KLU_LIBRARY_DIR + ${KLU_LIBRARY_DIR} + CACHE PATH "" FORCE) -else () - # find library with user provided directory path - set(KLU_LIBRARY_NAME klu) - find_library(KLU_LIBRARY ${KLU_LIBRARY_NAME} ${KLU_LIBRARY_DIR} NO_DEFAULT_PATH) -endif () +else() + # find library with user provided directory path + set(KLU_LIBRARY_NAME klu) + find_library(KLU_LIBRARY ${KLU_LIBRARY_NAME} ${KLU_LIBRARY_DIR} + NO_DEFAULT_PATH) +endif() mark_as_advanced(KLU_LIBRARY) -if (NOT AMD_LIBRARY) - set(AMD_LIBRARY_NAME amd) - find_library(AMD_LIBRARY ${AMD_LIBRARY_NAME} ${KLU_LIBRARY_DIR} NO_DEFAULT_PATH) - mark_as_advanced(AMD_LIBRARY) -endif () - -if (NOT COLAMD_LIBRARY) - set(COLAMD_LIBRARY_NAME colamd) - find_library(COLAMD_LIBRARY ${COLAMD_LIBRARY_NAME} ${KLU_LIBRARY_DIR} NO_DEFAULT_PATH) - mark_as_advanced(COLAMD_LIBRARY) -endif () - -if (NOT BTF_LIBRARY) - set(BTF_LIBRARY_NAME btf) - find_library( BTF_LIBRARY ${BTF_LIBRARY_NAME} ${KLU_LIBRARY_DIR} NO_DEFAULT_PATH) - mark_as_advanced(BTF_LIBRARY) -endif () - -if (NOT SUITESPARSECONFIG_LIBRARY) - set(SUITESPARSECONFIG_LIBRARY_NAME suitesparseconfig) - # NOTE: no prefix for this library on windows - if(MSVC OR ("${CMAKE_C_SIMULATE_ID}" STREQUAL "MSVC")) - set(CMAKE_FIND_LIBRARY_PREFIXES "") - endif() - find_library( SUITESPARSECONFIG_LIBRARY ${SUITESPARSECONFIG_LIBRARY_NAME} ${KLU_LIBRARY_DIR} NO_DEFAULT_PATH) - mark_as_advanced(SUITESPARSECONFIG_LIBRARY) -endif () +if(NOT AMD_LIBRARY) + set(AMD_LIBRARY_NAME amd) + find_library(AMD_LIBRARY ${AMD_LIBRARY_NAME} ${KLU_LIBRARY_DIR} + NO_DEFAULT_PATH) + mark_as_advanced(AMD_LIBRARY) +endif() + +if(NOT COLAMD_LIBRARY) + set(COLAMD_LIBRARY_NAME colamd) + find_library(COLAMD_LIBRARY ${COLAMD_LIBRARY_NAME} ${KLU_LIBRARY_DIR} + NO_DEFAULT_PATH) + mark_as_advanced(COLAMD_LIBRARY) +endif() + +if(NOT BTF_LIBRARY) + set(BTF_LIBRARY_NAME btf) + find_library(BTF_LIBRARY ${BTF_LIBRARY_NAME} ${KLU_LIBRARY_DIR} + NO_DEFAULT_PATH) + mark_as_advanced(BTF_LIBRARY) +endif() + +if(NOT SUITESPARSECONFIG_LIBRARY) + set(SUITESPARSECONFIG_LIBRARY_NAME suitesparseconfig) + # NOTE: no prefix for this library on windows + if(MSVC OR ("${CMAKE_C_SIMULATE_ID}" STREQUAL "MSVC")) + set(CMAKE_FIND_LIBRARY_PREFIXES "") + endif() + find_library(SUITESPARSECONFIG_LIBRARY ${SUITESPARSECONFIG_LIBRARY_NAME} + ${KLU_LIBRARY_DIR} NO_DEFAULT_PATH) + mark_as_advanced(SUITESPARSECONFIG_LIBRARY) +endif() -set(KLU_LIBRARIES ${KLU_LIBRARY} ${AMD_LIBRARY} ${COLAMD_LIBRARY} ${BTF_LIBRARY} ${SUITESPARSECONFIG_LIBRARY}) +set(KLU_LIBRARIES ${KLU_LIBRARY} ${AMD_LIBRARY} ${COLAMD_LIBRARY} + ${BTF_LIBRARY} ${SUITESPARSECONFIG_LIBRARY}) # set package variables including KLU_FOUND -find_package_handle_standard_args(KLU - REQUIRED_VARS - KLU_LIBRARY - KLU_LIBRARIES - KLU_INCLUDE_DIR) +find_package_handle_standard_args(KLU REQUIRED_VARS KLU_LIBRARY KLU_LIBRARIES + KLU_INCLUDE_DIR) # Create target for KLU if(KLU_FOUND) @@ -118,9 +126,10 @@ if(KLU_FOUND) add_library(SUNDIALS::KLU UNKNOWN IMPORTED) endif() - set_target_properties(SUNDIALS::KLU PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${KLU_INCLUDE_DIR}" - INTERFACE_LINK_LIBRARIES "${KLU_LIBRARIES}" - IMPORTED_LOCATION "${KLU_LIBRARY}") + set_target_properties( + SUNDIALS::KLU + PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${KLU_INCLUDE_DIR}" + INTERFACE_LINK_LIBRARIES "${KLU_LIBRARIES}" + IMPORTED_LOCATION "${KLU_LIBRARY}") endif() diff --git a/cmake/tpl/FindMAGMA.cmake b/cmake/tpl/FindMAGMA.cmake index 28b8fa8c7d..2012db81dd 100644 --- a/cmake/tpl/FindMAGMA.cmake +++ b/cmake/tpl/FindMAGMA.cmake @@ -15,16 +15,17 @@ # ----------------------------------------------------------------------------- # find the MAGMA include path -find_path(MAGMA_INCLUDE_DIR magma_v2.h +find_path( + MAGMA_INCLUDE_DIR magma_v2.h NAMES magma_v2.h HINTS ${MAGMA_DIR} $ENV{MAGMA_DIR} PATH_SUFFIXES include NO_DEFAULT_PATH - DOC "Directory with MAGMA header" -) + DOC "Directory with MAGMA header") # find the main MAGMA library -find_library(MAGMA_LIBRARY +find_library( + MAGMA_LIBRARY NAMES magma HINTS ${MAGMA_DIR} $ENV{MAGMA_DIR} PATH_SUFFIXES lib lib64 @@ -34,14 +35,15 @@ find_library(MAGMA_LIBRARY # Find the optional sparse component if("SPARSE" IN_LIST MAGMA_FIND_COMPONENTS) set(_sparse_required MAGMA_SPARSE_LIBRARY) - find_library(MAGMA_SPARSE_LIBRARY + find_library( + MAGMA_SPARSE_LIBRARY NAMES magma_sparse HINTS ${MAGMA_DIR} $ENV{MAGMA_DIR} PATH_SUFFIXES lib lib64 NO_DEFAULT_PATH DOC "The MAGMA sparse library.") else() - set(_sparse_required ) + set(_sparse_required) endif() # Determine MAGMA version and libraries it depends on @@ -52,7 +54,8 @@ if(MAGMA_LIBRARY AND MAGMA_INCLUDE_DIR) if(MAGMA_PKG_CONFIG_PATH) - file(STRINGS ${MAGMA_PKG_CONFIG_PATH} _version_string REGEX "Version: [0-9].[0-9].[0-9]") + file(STRINGS ${MAGMA_PKG_CONFIG_PATH} _version_string + REGEX "Version: [0-9].[0-9].[0-9]") string(REGEX MATCHALL "[0-9]" _version_full "${_version_string}") list(GET _version_full 0 _version_major) @@ -65,7 +68,7 @@ if(MAGMA_LIBRARY AND MAGMA_INCLUDE_DIR) string(REPLACE " " ";" _libraries_list ${_libraries_string}) list(SUBLIST _libraries_list 1 -1 _libraries_list) # remove 'Libs:' part - set(_interface_libraires ) + set(_interface_libraires) if(SUNDIALS_MAGMA_BACKENDS MATCHES "HIP") if(NOT TARGET roc::hipblas) @@ -79,14 +82,17 @@ if(MAGMA_LIBRARY AND MAGMA_INCLUDE_DIR) endif() if(SUNDIALS_MAGMA_BACKENDS MATCHES "CUDA") - if (NOT TARGET CUDA::cudart) + if(NOT TARGET CUDA::cudart) find_package(CUDAToolkit REQUIRED) endif() endif() foreach(lib ${_libraries_list}) - if(NOT (lib STREQUAL "-lmagma" OR lib STREQUAL "-lmagma_sparse" - OR lib STREQUAL "-L\${libdir}" OR lib STREQUAL "") ) + if(NOT + (lib STREQUAL "-lmagma" + OR lib STREQUAL "-lmagma_sparse" + OR lib STREQUAL "-L\${libdir}" + OR lib STREQUAL "")) # Check if we need to find cusparse or cublas if(SUNDIALS_MAGMA_BACKENDS MATCHES "CUDA") @@ -110,15 +116,11 @@ endif() set(MAGMA_LIBRARIES "${MAGMA_LIBRARY};${_interface_libraires}") -find_package_handle_standard_args(MAGMA - REQUIRED_VARS - MAGMA_LIBRARY - MAGMA_LIBRARIES - MAGMA_INCLUDE_DIR - ${_sparse_required} - VERSION_VAR - MAGMA_VERSION - ) +find_package_handle_standard_args( + MAGMA + REQUIRED_VARS MAGMA_LIBRARY MAGMA_LIBRARIES MAGMA_INCLUDE_DIR + ${_sparse_required} + VERSION_VAR MAGMA_VERSION) # Create target for MAGMA if(MAGMA_FOUND) @@ -127,20 +129,23 @@ if(MAGMA_FOUND) add_library(SUNDIALS::MAGMA UNKNOWN IMPORTED) endif() - set_target_properties(SUNDIALS::MAGMA PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${MAGMA_INCLUDE_DIR}" - INTERFACE_LINK_LIBRARIES "${_interface_libraires}" - IMPORTED_LOCATION "${MAGMA_LIBRARY}") + set_target_properties( + SUNDIALS::MAGMA + PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${MAGMA_INCLUDE_DIR}" + INTERFACE_LINK_LIBRARIES "${_interface_libraires}" + IMPORTED_LOCATION "${MAGMA_LIBRARY}") if(MAGMA_SPARSE_LIBRARY) if(NOT TARGET SUNDIALS::MAGMA_SPARSE) add_library(SUNDIALS::MAGMA_SPARSE UNKNOWN IMPORTED) endif() - set_target_properties(SUNDIALS::MAGMA_SPARSE PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${MAGMA_INCLUDE_DIR}" - INTERFACE_LINK_LIBRARIES "${MAGMA_LIBRARY};${_interface_libraires}" - IMPORTED_LOCATION "${MAGMA_SPARSE_LIBRARY}") + set_target_properties( + SUNDIALS::MAGMA_SPARSE + PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${MAGMA_INCLUDE_DIR}" + INTERFACE_LINK_LIBRARIES + "${MAGMA_LIBRARY};${_interface_libraires}" + IMPORTED_LOCATION "${MAGMA_SPARSE_LIBRARY}") endif() endif() diff --git a/cmake/tpl/FindPETSC.cmake b/cmake/tpl/FindPETSC.cmake index 80a01f69ad..d85e199f9b 100644 --- a/cmake/tpl/FindPETSC.cmake +++ b/cmake/tpl/FindPETSC.cmake @@ -38,9 +38,12 @@ pkg_check_modules(PKG_PETSC "PETSc${_pkg_version_spec}") unset(_pkg_version_spec) # Find the PETSC libraries -set(_petsc_libs ) +set(_petsc_libs) foreach(_next_lib IN LISTS PKG_PETSC_LIBRARIES) - find_library(_petsc_lib_${_next_lib} NAMES ${_next_lib} HINTS ${PKG_PETSC_LIBRARY_DIRS}) + find_library( + _petsc_lib_${_next_lib} + NAMES ${_next_lib} + HINTS ${PKG_PETSC_LIBRARY_DIRS}) if(_petsc_lib_${_next_lib}) list(APPEND _petsc_libs "${_petsc_lib_${_next_lib}}") endif() @@ -56,17 +59,15 @@ foreach(_next_lib IN LISTS PKG_PETSC_STATIC_LIBRARIES) endif() if(_next_lib MATCHES "kokkoskernels") if(NOT TARGET Kokkos::kokkoskernels) - find_package(KokkosKernels REQUIRED - HINTS "${KokkosKernels_DIR}" "${PKG_PETSC_LIBRARY_DIRS}" - NO_DEFAULT_PATH) + find_package(KokkosKernels REQUIRED HINTS "${KokkosKernels_DIR}" + "${PKG_PETSC_LIBRARY_DIRS}" NO_DEFAULT_PATH) endif() list(APPEND _petsc_libs "Kokkos::kokkoskernels") endif() if(_next_lib MATCHES "kokkos") if(NOT TARGET Kokkos::kokkos) - find_package(Kokkos REQUIRED - HINTS "${Kokkos_DIR}" "${PKG_PETSC_LIBRARY_DIRS}" - NO_DEFAULT_PATH) + find_package(Kokkos REQUIRED HINTS "${Kokkos_DIR}" + "${PKG_PETSC_LIBRARY_DIRS}" NO_DEFAULT_PATH) endif() list(APPEND _petsc_libs "Kokkos::kokkos") endif() @@ -87,10 +88,18 @@ if(PKG_PETSC_VERSION) list(GET _petsc_versions 1 _petsc_version_minor) list(GET _petsc_versions 2 _petsc_version_patch) - set(PETSC_VERSION ${PKG_PETSC_VERSION} CACHE STRING "Full version of PETSC") - set(PETSC_VERSION_MAJOR ${_petsc_version_major} CACHE INTERNAL "Major version of PETSC") - set(PETSC_VERSION_MINOR ${_petsc_version_minor} CACHE INTERNAL "Minor version of PETSC") - set(PETSC_VERSION_PATCH ${_petsc_version_patch} CACHE INTERNAL "Patch version of PETSC") + set(PETSC_VERSION + ${PKG_PETSC_VERSION} + CACHE STRING "Full version of PETSC") + set(PETSC_VERSION_MAJOR + ${_petsc_version_major} + CACHE INTERNAL "Major version of PETSC") + set(PETSC_VERSION_MINOR + ${_petsc_version_minor} + CACHE INTERNAL "Minor version of PETSC") + set(PETSC_VERSION_PATCH + ${_petsc_version_patch} + CACHE INTERNAL "Patch version of PETSC") unset(_petsc_versions) unset(_petsc_version_major) @@ -98,18 +107,19 @@ if(PKG_PETSC_VERSION) unset(_petsc_version_patch) endif() -include (FindPackageHandleStandardArgs) -find_package_handle_standard_args (PETSC +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args( + PETSC REQUIRED_VARS PETSC_FOUND PETSC_INCLUDE_DIRS PETSC_LIBRARIES - VERSION_VAR PETSC_VERSION - ) + VERSION_VAR PETSC_VERSION) if(NOT TARGET SUNDIALS::PETSC) add_library(SUNDIALS::PETSC INTERFACE IMPORTED) - set_target_properties(SUNDIALS::PETSC PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${PETSC_INCLUDE_DIRS}" - INTERFACE_LINK_LIBRARIES "${PETSC_LIBRARIES}" - ) + set_target_properties( + SUNDIALS::PETSC + PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${PETSC_INCLUDE_DIRS}" + INTERFACE_LINK_LIBRARIES "${PETSC_LIBRARIES}") endif() -mark_as_advanced(PETSC_INCLUDE_DIRS PETSC_LIBRARIES PETSC_VERSION_MAJOR PETSC_VERSION_MINOR PETSC_VERSION_PATCH PETSC_VERSION) +mark_as_advanced(PETSC_INCLUDE_DIRS PETSC_LIBRARIES PETSC_VERSION_MAJOR + PETSC_VERSION_MINOR PETSC_VERSION_PATCH PETSC_VERSION) diff --git a/cmake/tpl/FindSUPERLUDIST.cmake b/cmake/tpl/FindSUPERLUDIST.cmake index 016f1c8ecf..1dcaf00c20 100644 --- a/cmake/tpl/FindSUPERLUDIST.cmake +++ b/cmake/tpl/FindSUPERLUDIST.cmake @@ -35,7 +35,9 @@ # --------------------------------------------------------------- if(NOT SUPERLUDIST_LINK_LIBRARIES AND SUPERLUDIST_LIBRARIES) - set(SUPERLUDIST_LINK_LIBRARIES "${SUPERLUDIST_LIBRARIES}" CACHE INTERNAL "") + set(SUPERLUDIST_LINK_LIBRARIES + "${SUPERLUDIST_LIBRARIES}" + CACHE INTERNAL "") elseif(NOT SUPERLUDIST_LINK_LIBRARIES) find_package(PkgConfig REQUIRED) list(APPEND CMAKE_PREFIX_PATH "${SUPERLUDIST_DIR}") @@ -47,39 +49,61 @@ elseif(NOT SUPERLUDIST_LINK_LIBRARIES) endif() endif() pkg_search_module(SUPERLUDIST REQUIRED "superlu_dist${_pkg_version_spec}") - set(SUPERLUDIST_LINK_LIBRARIES "${SUPERLUDIST_LINK_LIBRARIES}" CACHE INTERNAL "") - set(SUPERLUDIST_INCLUDE_DIRS "${SUPERLUDIST_INCLUDE_DIRS}" CACHE INTERNAL "") + set(SUPERLUDIST_LINK_LIBRARIES + "${SUPERLUDIST_LINK_LIBRARIES}" + CACHE INTERNAL "") + set(SUPERLUDIST_INCLUDE_DIRS + "${SUPERLUDIST_INCLUDE_DIRS}" + CACHE INTERNAL "") endif() # find the library configuration file -set(SUPERLUDIST_CUDA FALSE CACHE BOOL "SuperLU DIST was built with CUDA support") -set(SUPERLUDIST_ROCM FALSE CACHE BOOL "SuperLU DIST was built with ROCm support") +set(SUPERLUDIST_CUDA + FALSE + CACHE BOOL "SuperLU DIST was built with CUDA support") +set(SUPERLUDIST_ROCM + FALSE + CACHE BOOL "SuperLU DIST was built with ROCm support") if(SUPERLUDIST_INCLUDE_DIRS) - find_file(SUPERLUDIST_CONFIG_PATH superlu_dist_config.h PATHS "${SUPERLUDIST_INCLUDE_DIRS}") + find_file(SUPERLUDIST_CONFIG_PATH superlu_dist_config.h + PATHS "${SUPERLUDIST_INCLUDE_DIRS}") mark_as_advanced(FORCE SUPERLUDIST_CONFIG_PATH) if(SUPERLUDIST_VERSION VERSION_GREATER_EQUAL "8.0.0") - file(STRINGS "${SUPERLUDIST_CONFIG_PATH}" _index_size_64 REGEX "#define XSDK_INDEX_SIZE 64") - file(STRINGS "${SUPERLUDIST_CONFIG_PATH}" _index_size_32 REGEX "#undef XSDK_INDEX_SIZE") - if(_index_size_64) - set(SUPERLUDIST_INDEX_SIZE 64 CACHE STRING "SuperLU DIST index size (bit width)" FORCE) - else() - set(SUPERLUDIST_INDEX_SIZE 32 CACHE STRING "SuperLU DIST index size (bit width)" FORCE) - endif() - mark_as_advanced(FORCE SUPERLUDIST_INDEX_SIZE) + file(STRINGS "${SUPERLUDIST_CONFIG_PATH}" _index_size_64 + REGEX "#define XSDK_INDEX_SIZE 64") + file(STRINGS "${SUPERLUDIST_CONFIG_PATH}" _index_size_32 + REGEX "#undef XSDK_INDEX_SIZE") + if(_index_size_64) + set(SUPERLUDIST_INDEX_SIZE + 64 + CACHE STRING "SuperLU DIST index size (bit width)" FORCE) + else() + set(SUPERLUDIST_INDEX_SIZE + 32 + CACHE STRING "SuperLU DIST index size (bit width)" FORCE) + endif() + mark_as_advanced(FORCE SUPERLUDIST_INDEX_SIZE) else() - file(STRINGS "${SUPERLUDIST_CONFIG_PATH}" _strings_with_index_size REGEX "XSDK_INDEX_SIZE") + file(STRINGS "${SUPERLUDIST_CONFIG_PATH}" _strings_with_index_size + REGEX "XSDK_INDEX_SIZE") list(GET _strings_with_index_size 0 _index_size_string) - string(REGEX MATCHALL "[0-9][0-9]" SUPERLUDIST_INDEX_SIZE "${_index_size_string}") + string(REGEX MATCHALL "[0-9][0-9]" SUPERLUDIST_INDEX_SIZE + "${_index_size_string}") endif() - file(STRINGS "${SUPERLUDIST_CONFIG_PATH}" _strings_have_cuda REGEX "HAVE_CUDA") + file(STRINGS "${SUPERLUDIST_CONFIG_PATH}" _strings_have_cuda + REGEX "HAVE_CUDA") string(REGEX MATCH "TRUE|FALSE" _has_cuda "${_strings_have_cuda}") file(STRINGS "${SUPERLUDIST_CONFIG_PATH}" _strings_have_rocm REGEX "HAVE_HIP") string(REGEX MATCH "TRUE|FALSE" _has_rocm "${_strings_have_rocm}") if(_has_cuda) - set(SUPERLUDIST_CUDA TRUE CACHE BOOL "SuperLU DIST was built with CUDA support" FORCE) + set(SUPERLUDIST_CUDA + TRUE + CACHE BOOL "SuperLU DIST was built with CUDA support" FORCE) endif() if(_has_rocm) - set(SUPERLUDIST_ROCM TRUE CACHE BOOL "SuperLU DIST was built with ROCm support" FORCE) + set(SUPERLUDIST_ROCM + TRUE + CACHE BOOL "SuperLU DIST was built with ROCm support" FORCE) endif() unset(_has_cuda) unset(_has_rocm) @@ -87,21 +111,26 @@ endif() # find the library version file if(NOT SUPERLUDIST_VERSION AND SUPERLUDIST_INCLUDE_DIRS) - find_file(SUPERLUDIST_VERSION_PATH superlu_defs.h PATHS "${SUPERLUDIST_INCLUDE_DIRS}") + find_file(SUPERLUDIST_VERSION_PATH superlu_defs.h + PATHS "${SUPERLUDIST_INCLUDE_DIRS}") - file(STRINGS "${SUPERLUDIST_VERSION_PATH}" _version_major REGEX "SUPERLU_DIST_MAJOR_VERSION") + file(STRINGS "${SUPERLUDIST_VERSION_PATH}" _version_major + REGEX "SUPERLU_DIST_MAJOR_VERSION") list(GET _version_major 0 _version_string) string(REGEX MATCHALL "[0-9]" _version_major "${_version_string}") - file(STRINGS "${SUPERLUDIST_VERSION_PATH}" _version_minor REGEX "SUPERLU_DIST_MINOR_VERSION") + file(STRINGS "${SUPERLUDIST_VERSION_PATH}" _version_minor + REGEX "SUPERLU_DIST_MINOR_VERSION") list(GET _version_minor 0 _version_string) string(REGEX MATCHALL "[0-9]" _version_minor "${_version_string}") - file(STRINGS "${SUPERLUDIST_VERSION_PATH}" _version_patch REGEX "SUPERLU_DIST_PATCH_VERSION") + file(STRINGS "${SUPERLUDIST_VERSION_PATH}" _version_patch + REGEX "SUPERLU_DIST_PATCH_VERSION") list(GET _version_patch 0 _version_string) string(REGEX MATCHALL "[0-9]" _version_patch "${_version_string}") - set(SUPERLUDIST_VERSION "${_version_major}.${_version_minor}.${_version_patch}") + set(SUPERLUDIST_VERSION + "${_version_major}.${_version_minor}.${_version_patch}") mark_as_advanced(FORCE SUPERLUDIST_VERSION_PATH) endif() @@ -117,18 +146,16 @@ if(SUPERLUDIST_ROCM) find_package(hipblas REQUIRED) find_package(rocsolver REQUIRED) find_package(rocblas REQUIRED) - list(APPEND SUPERLUDIST_LINK_LIBRARIES hip::device roc::hipblas roc::rocblas roc::rocsolver) + list(APPEND SUPERLUDIST_LINK_LIBRARIES hip::device roc::hipblas roc::rocblas + roc::rocsolver) endif() # set package variables including SUPERLUDIST_FOUND -find_package_handle_standard_args(SUPERLUDIST - REQUIRED_VARS - SUPERLUDIST_LINK_LIBRARIES - SUPERLUDIST_INCLUDE_DIRS - SUPERLUDIST_INDEX_SIZE - VERSION_VAR - SUPERLUDIST_VERSION - ) +find_package_handle_standard_args( + SUPERLUDIST + REQUIRED_VARS SUPERLUDIST_LINK_LIBRARIES SUPERLUDIST_INCLUDE_DIRS + SUPERLUDIST_INDEX_SIZE + VERSION_VAR SUPERLUDIST_VERSION) # Create target for SuperLU_DIST if(SUPERLUDIST_FOUND) @@ -137,8 +164,9 @@ if(SUPERLUDIST_FOUND) add_library(SUNDIALS::SUPERLUDIST INTERFACE IMPORTED) endif() - set_target_properties(SUNDIALS::SUPERLUDIST PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${SUPERLUDIST_INCLUDE_DIRS}" - INTERFACE_LINK_LIBRARIES "${SUPERLUDIST_LINK_LIBRARIES}") + set_target_properties( + SUNDIALS::SUPERLUDIST + PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${SUPERLUDIST_INCLUDE_DIRS}" + INTERFACE_LINK_LIBRARIES "${SUPERLUDIST_LINK_LIBRARIES}") endif() diff --git a/cmake/tpl/FindSUPERLUMT.cmake b/cmake/tpl/FindSUPERLUMT.cmake index 8c9cbbfb73..48530e0cec 100644 --- a/cmake/tpl/FindSUPERLUMT.cmake +++ b/cmake/tpl/FindSUPERLUMT.cmake @@ -33,12 +33,15 @@ # check for valid thread type string(TOUPPER ${SUPERLUMT_THREAD_TYPE} _upper_SUPERLUMT_THREAD_TYPE) -force_variable(SUPERLUMT_THREAD_TYPE STRING "SuperLU_MT threading type: OPENMP or PTHREAD" ${_upper_SUPERLUMT_THREAD_TYPE}) - -if(SUPERLUMT_THREAD_TYPE AND - NOT SUPERLUMT_THREAD_TYPE STREQUAL "OPENMP" AND - NOT SUPERLUMT_THREAD_TYPE STREQUAL "PTHREAD") - print_error("Unknown thread type: ${SUPERLUMT_THREAD_TYPE}" "Please enter PTHREAD or OPENMP") +force_variable( + SUPERLUMT_THREAD_TYPE STRING "SuperLU_MT threading type: OPENMP or PTHREAD" + ${_upper_SUPERLUMT_THREAD_TYPE}) + +if(SUPERLUMT_THREAD_TYPE + AND NOT SUPERLUMT_THREAD_TYPE STREQUAL "OPENMP" + AND NOT SUPERLUMT_THREAD_TYPE STREQUAL "PTHREAD") + print_error("Unknown thread type: ${SUPERLUMT_THREAD_TYPE}" + "Please enter PTHREAD or OPENMP") endif() # check if the threading library has been found @@ -82,8 +85,10 @@ endif() # find library if(NOT SUPERLUMT_LIBRARY) # search user provided directory path - find_library(SUPERLUMT_LIBRARY ${SUPERLUMT_LIBRARY_NAME} - PATHS ${SUPERLUMT_LIBRARY_DIR} NO_DEFAULT_PATH) + find_library( + SUPERLUMT_LIBRARY ${SUPERLUMT_LIBRARY_NAME} + PATHS ${SUPERLUMT_LIBRARY_DIR} + NO_DEFAULT_PATH) # if user didn't provide a path, search anywhere if(NOT (SUPERLUMT_LIBRARY_DIR OR SUPERLUMT_LIBRARY)) find_library(SUPERLUMT_LIBRARY ${SUPERLUMT_LIBRARY_NAME}) @@ -93,38 +98,42 @@ endif() # set the libraries, stripping out 'NOTFOUND' from previous attempts if(NOT (SUPERLUMT_LIBRARIES MATCHES "${SUPERLUMT_LIBRARY_NAME}")) - set(SUPERLUMT_LIBRARIES "${SUPERLUMT_LIBRARY};${SUPERLUMT_LIBRARIES}" CACHE STRING "" FORCE) + set(SUPERLUMT_LIBRARIES + "${SUPERLUMT_LIBRARY};${SUPERLUMT_LIBRARIES}" + CACHE STRING "" FORCE) endif() # set the library dir option if it wasn't preset if(SUPERLUMT_LIBRARY AND (NOT SUPERLUMT_LIBRARY_DIR)) get_filename_component(SUPERLUMT_LIBRARY_DIR ${SUPERLUMT_LIBRARY} DIRECTORY) - set(SUPERLUMT_LIBRARY_DIR ${SUPERLUMT_LIBRARY_DIR} CACHE PATH "" FORCE) + set(SUPERLUMT_LIBRARY_DIR + ${SUPERLUMT_LIBRARY_DIR} + CACHE PATH "" FORCE) endif() # set the include dir option if it wasn't preset if(SUPERLUMT_LIBRARY AND (NOT SUPERLUMT_INCLUDE_DIR)) - get_filename_component(SUPERLUMT_INCLUDE_DIR ${SUPERLUMT_LIBRARY_DIR} DIRECTORY) - set(SUPERLUMT_INCLUDE_DIR "${SUPERLUMT_INCLUDE_DIR}/include" CACHE PATH "" FORCE) + get_filename_component(SUPERLUMT_INCLUDE_DIR ${SUPERLUMT_LIBRARY_DIR} + DIRECTORY) + set(SUPERLUMT_INCLUDE_DIR + "${SUPERLUMT_INCLUDE_DIR}/include" + CACHE PATH "" FORCE) endif() # set a more informative error message in case the library was not found -set(SUPERLUMT_NOT_FOUND_MESSAGE "\ +set(SUPERLUMT_NOT_FOUND_MESSAGE + "\ ************************************************************************\n\ ERROR: Could not find SuperLU_MT. Please check the variables:\n\ SUPERLUMT_INCLUDE_DIR and SUPERLUMT_LIBRARY_DIR\n\ ************************************************************************") # set package variables including SUPERLUMT_FOUND -find_package_handle_standard_args(SUPERLUMT - REQUIRED_VARS - SUPERLUMT_LIBRARY - SUPERLUMT_LIBRARIES - SUPERLUMT_INCLUDE_DIR - SUPERLUMT_THREAD_TYPE - FAIL_MESSAGE - "${SUPERLUMT_NOT_FOUND_MESSAGE}" - ) +find_package_handle_standard_args( + SUPERLUMT + REQUIRED_VARS SUPERLUMT_LIBRARY SUPERLUMT_LIBRARIES SUPERLUMT_INCLUDE_DIR + SUPERLUMT_THREAD_TYPE + FAIL_MESSAGE "${SUPERLUMT_NOT_FOUND_MESSAGE}") # Create target for SuperLU_MT if(SUPERLUMT_FOUND) @@ -133,10 +142,11 @@ if(SUPERLUMT_FOUND) add_library(SUNDIALS::SUPERLUMT UNKNOWN IMPORTED) endif() - set_target_properties(SUNDIALS::SUPERLUMT PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${SUPERLUMT_INCLUDE_DIR}" - INTERFACE_LINK_LIBRARIES "${SUPERLUMT_LIBRARIES}" - IMPORTED_LOCATION "${SUPERLUMT_LIBRARY}") + set_target_properties( + SUNDIALS::SUPERLUMT + PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${SUPERLUMT_INCLUDE_DIR}" + INTERFACE_LINK_LIBRARIES "${SUPERLUMT_LIBRARIES}" + IMPORTED_LOCATION "${SUPERLUMT_LIBRARY}") list2string(SUPERLUMT_LIBRARIES EXAMPLES_SUPERLUMT_LIBRARIES) diff --git a/cmake/tpl/FindTrilinos.cmake b/cmake/tpl/FindTrilinos.cmake index af4dff69b3..42be691041 100644 --- a/cmake/tpl/FindTrilinos.cmake +++ b/cmake/tpl/FindTrilinos.cmake @@ -16,20 +16,23 @@ # ----------------------------------------------------------------------------- # First try and find Trilinos using Trilinos_DIR only. -find_package(Trilinos - NAMES Trilinos TRILINOS +find_package( + Trilinos + NAMES + Trilinos + TRILINOS PATHS - ${Trilinos_DIR}/lib/cmake/Trilinos - ${Trilinos_DIR} + ${Trilinos_DIR}/lib/cmake/Trilinos + ${Trilinos_DIR} NO_DEFAULT_PATH QUIET) # set package variables including Trilinos_FOUND -find_package_handle_standard_args(Trilinos - REQUIRED_VARS - Trilinos_LIBRARIES # defined in TrilinosConfig.cmake - Trilinos_INCLUDE_DIRS # defined in TrilinosConfig.cmake - ) +find_package_handle_standard_args( + Trilinos + REQUIRED_VARS Trilinos_LIBRARIES # defined in TrilinosConfig.cmake + Trilinos_INCLUDE_DIRS # defined in TrilinosConfig.cmake +) # Create Trilinos target if(Trilinos_FOUND) @@ -38,8 +41,9 @@ if(Trilinos_FOUND) add_library(SUNDIALS::TRILINOS IMPORTED INTERFACE) endif() - set_target_properties(SUNDIALS::TRILINOS PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${Trilinos_INCLUDE_DIRS}" - INTERFACE_LINK_LIBRARIES "${Trilinos_LIBRARIES}") + set_target_properties( + SUNDIALS::TRILINOS + PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${Trilinos_INCLUDE_DIRS}" + INTERFACE_LINK_LIBRARIES "${Trilinos_LIBRARIES}") endif() diff --git a/cmake/tpl/FindXBRAID.cmake b/cmake/tpl/FindXBRAID.cmake index 8b60d4eec6..73d40716b7 100644 --- a/cmake/tpl/FindXBRAID.cmake +++ b/cmake/tpl/FindXBRAID.cmake @@ -29,28 +29,36 @@ # Check if we are locating XBraid using the root install directory or a list of # include directories and link libraries -if (XBRAID_INCLUDES OR XBRAID_LIBRARIES) +if(XBRAID_INCLUDES OR XBRAID_LIBRARIES) - if (XBRAID_INCLUDES AND XBRAID_LIBRARIES) + if(XBRAID_INCLUDES AND XBRAID_LIBRARIES) - set(XBRAID_DIR "" CACHE PATH "Path to the root of XBraid installation" FORCE) + set(XBRAID_DIR + "" + CACHE PATH "Path to the root of XBraid installation" FORCE) - else () + else() - string(CONCAT msg - "Both XBRAID_INCLUDES and XBRAID_LIBRARIES must be provided:\n" - " XBRAID_INCLUDES=${XBRAID_INCLUDES}\n" - " XBRAID_LIBRARIES=${XBRAID_LIBRARIES}") + string( + CONCAT msg + "Both XBRAID_INCLUDES and XBRAID_LIBRARIES must be provided:\n" + " XBRAID_INCLUDES=${XBRAID_INCLUDES}\n" + " XBRAID_LIBRARIES=${XBRAID_LIBRARIES}") message(FATAL_ERROR ${msg}) - endif () + endif() -else () +else() - set(XBRAID_INCLUDES "" CACHE STRING "Semi-colon separated list of XBraid include directories" FORCE) - set(XBRAID_LIBRARIES "" CACHE STRING "Semi-colon separated list of XBraid link libraries" FORCE) + set(XBRAID_INCLUDES + "" + CACHE STRING "Semi-colon separated list of XBraid include directories" + FORCE) + set(XBRAID_LIBRARIES + "" + CACHE STRING "Semi-colon separated list of XBraid link libraries" FORCE) -endif () +endif() # unset cache values for multiple passes unset(XBRAID_INCLUDE_DIR CACHE) @@ -59,138 +67,140 @@ unset(XBRAID_LIBRARY CACHE) unset(XBRAID_INCS CACHE) unset(XBRAID_LIBS CACHE) -if (XBRAID_INCLUDES AND XBRAID_LIBRARIES) +if(XBRAID_INCLUDES AND XBRAID_LIBRARIES) message(STATUS "Finding XBraid using XBRAID_INCLUDES and XBRAID_LIBRARIES") # extract path from XBRAID_INCLUDES - foreach (include_dir ${XBRAID_INCLUDES}) - if (EXISTS "${include_dir}/braid.h") - set(XBRAID_INCLUDE_DIR "${include_dir}" CACHE "XBraid include directory") + foreach(include_dir ${XBRAID_INCLUDES}) + if(EXISTS "${include_dir}/braid.h") + set(XBRAID_INCLUDE_DIR + "${include_dir}" + CACHE "XBraid include directory") break() - endif () - endforeach () + endif() + endforeach() # check if the include directory was found - if (NOT XBRAID_INCLUDE_DIR) - string(CONCAT msg - "Could not determine XBraid include directory from XBRAID_INCLUDES:\n" - " XBRAID_INCLUDES=${XBRAID_INCLUDES}\n") + if(NOT XBRAID_INCLUDE_DIR) + string( + CONCAT + msg + "Could not determine XBraid include directory from XBRAID_INCLUDES:\n" + " XBRAID_INCLUDES=${XBRAID_INCLUDES}\n") message(FATAL_ERROR ${msg}) - endif () + endif() # extract library from XBRAID_LIBRARIES - foreach (library_path ${XBRAID_LIBRARIES}) + foreach(library_path ${XBRAID_LIBRARIES}) get_filename_component(library_name "${library_path}" NAME) - if (library_name MATCHES "braid") - set(XBRAID_LIBRARY "${library_path}" CACHE "XBraid library") + if(library_name MATCHES "braid") + set(XBRAID_LIBRARY + "${library_path}" + CACHE "XBraid library") break() - endif () - endforeach () + endif() + endforeach() # check if the library directory was found - if (NOT XBRAID_LIBRARY) + if(NOT XBRAID_LIBRARY) string(CONCAT msg - "Could not determine XBraid library from XBRAID_LIBRARIES:\n" - " XBRAID_LIBRARIES=${XBRAID_LIBRARIES}") + "Could not determine XBraid library from XBRAID_LIBRARIES:\n" + " XBRAID_LIBRARIES=${XBRAID_LIBRARIES}") message(FATAL_ERROR ${msg}) - endif () + endif() -else () +else() message(STATUS "Finding XBraid using XBRAID_DIR") # find XBRAID_DIR - if (NOT XBRAID_DIR) + if(NOT XBRAID_DIR) message(STATUS "Looking for XBraid in common install locations") find_path(XBRAID_DIR include/braid.h braid/braid.h) - endif () + endif() # check if XBRAID_DIR was set/found - if (NOT XBRAID_DIR) + if(NOT XBRAID_DIR) - string(CONCAT msg - "Could not locate XBraid install directory please set:\n" - " - XBRAID_DIR\n" - "or used the advanced options\n" - " - XBRAID_INCLUDES and XBRAID_LIBRARIES.") + string(CONCAT msg "Could not locate XBraid install directory please set:\n" + " - XBRAID_DIR\n" "or used the advanced options\n" + " - XBRAID_INCLUDES and XBRAID_LIBRARIES.") message(FATAL_ERROR ${msg}) - endif () + endif() # Find the include dir - find_path(XBRAID_INCLUDE_DIR braid.h - PATHS - ${XBRAID_DIR} - PATH_SUFFIXES - include braid - DOC - "XBraid include directory" + find_path( + XBRAID_INCLUDE_DIR braid.h + PATHS ${XBRAID_DIR} + PATH_SUFFIXES include braid + DOC "XBraid include directory" NO_DEFAULT_PATH) # check if the include directory was found - if (NOT XBRAID_INCLUDE_DIR) - string(CONCAT msg - "Could not determine XBraid include directory from XBRAID_DIR:\n" - " XBRAID_DIR=${XBRAID_DIR}\n") + if(NOT XBRAID_INCLUDE_DIR) + string( + CONCAT msg + "Could not determine XBraid include directory from XBRAID_DIR:\n" + " XBRAID_DIR=${XBRAID_DIR}\n") message(FATAL_ERROR ${msg}) - endif () + endif() # Find the library - find_library(XBRAID_LIBRARY braid - PATHS - ${XBRAID_DIR} - PATH_SUFFIXES - lib braid - DOC - "XBraid library" + find_library( + XBRAID_LIBRARY braid + PATHS ${XBRAID_DIR} + PATH_SUFFIXES lib braid + DOC "XBraid library" NO_DEFAULT_PATH) # check if the library was found - if (NOT XBRAID_LIBRARY) - string(CONCAT msg - "Could not determine XBraid library from XBRAID_DIR:\n" - " XBRAID_DIR=${XBRAID_DIR}\n") + if(NOT XBRAID_LIBRARY) + string(CONCAT msg "Could not determine XBraid library from XBRAID_DIR:\n" + " XBRAID_DIR=${XBRAID_DIR}\n") message(FATAL_ERROR ${msg}) - endif () + endif() -endif () +endif() # set package variables including XBRAID_FOUND -find_package_handle_standard_args(XBRAID - REQUIRED_VARS - XBRAID_INCLUDE_DIR - XBRAID_LIBRARY - ) +find_package_handle_standard_args(XBRAID REQUIRED_VARS XBRAID_INCLUDE_DIR + XBRAID_LIBRARY) # XBraid target -if (XBRAID_FOUND) +if(XBRAID_FOUND) # create target if necessary - if (NOT TARGET SUNDIALS::XBRAID) + if(NOT TARGET SUNDIALS::XBRAID) add_library(SUNDIALS::XBRAID UNKNOWN IMPORTED) - endif () + endif() # update target properties (for multiple passes) - set_target_properties(SUNDIALS::XBRAID PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${XBRAID_INCLUDE_DIR}" - INTERFACE_LINK_LIBRARIES "${XBRAID_LIBRARIES}" - IMPORTED_LOCATION "${XBRAID_LIBRARY}") + set_target_properties( + SUNDIALS::XBRAID + PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${XBRAID_INCLUDE_DIR}" + INTERFACE_LINK_LIBRARIES "${XBRAID_LIBRARIES}" + IMPORTED_LOCATION "${XBRAID_LIBRARY}") # set variables for output message, compile tests, and # CMake/Makefile templates - if (XBRAID_INCLUDES AND XBRAID_LIBRARIES) - set(XBRAID_INCS "${XBRAID_INCLUDES}" CACHE INTERNAL - "Internal XBraid includes") - set(XBRAID_LIBS "${XBRAID_LIBRARIES}" CACHE INTERNAL - "Internal XBraid libraries") - else () - set(XBRAID_INCS "${XBRAID_INCLUDE_DIR}" CACHE INTERNAL - "Internal XBraid includes") - set(XBRAID_LIBS "${XBRAID_LIBRARY}" CACHE INTERNAL - "Internal XBraid libraries") - endif () - -endif () + if(XBRAID_INCLUDES AND XBRAID_LIBRARIES) + set(XBRAID_INCS + "${XBRAID_INCLUDES}" + CACHE INTERNAL "Internal XBraid includes") + set(XBRAID_LIBS + "${XBRAID_LIBRARIES}" + CACHE INTERNAL "Internal XBraid libraries") + else() + set(XBRAID_INCS + "${XBRAID_INCLUDE_DIR}" + CACHE INTERNAL "Internal XBraid includes") + set(XBRAID_LIBS + "${XBRAID_LIBRARY}" + CACHE INTERNAL "Internal XBraid libraries") + endif() + +endif() diff --git a/cmake/tpl/SundialsAdiak.cmake b/cmake/tpl/SundialsAdiak.cmake index a2b48cf1b9..132ab1852b 100644 --- a/cmake/tpl/SundialsAdiak.cmake +++ b/cmake/tpl/SundialsAdiak.cmake @@ -44,7 +44,6 @@ find_package(adiak REQUIRED) message(STATUS "ADIAK_LIBRARIES: ${adiak_LIBRARIES}") message(STATUS "ADIAK_INCLUDE_DIR: ${adiak_INCLUDE_DIR}") - # ----------------------------------------------------------------------------- # Section 4: Test the TPL # ----------------------------------------------------------------------------- @@ -57,28 +56,33 @@ if(adiak_FOUND AND (NOT adiak_WORKS)) file(MAKE_DIRECTORY ${adiak_TEST_DIR}) # Create a C source file - file(WRITE ${adiak_TEST_DIR}/ltest.c - "\#include \n" - "int main(void)\n" - "{\n" - " adiak_init(NULL);\n" - " adiak_fini();\n" - " return 0;\n" - "}\n") + file( + WRITE ${adiak_TEST_DIR}/ltest.c + "\#include \n" + "int main(void)\n" + "{\n" + " adiak_init(NULL);\n" + " adiak_fini();\n" + " return 0;\n" + "}\n") # To ensure we do not use stuff from the previous attempts, # we must remove the CMakeFiles directory. file(REMOVE_RECURSE ${adiak_TEST_DIR}/CMakeFiles) # Attempt to build and link the "ltest" executable - try_compile(COMPILE_OK ${adiak_TEST_DIR} ${adiak_TEST_DIR}/ltest.c + try_compile( + COMPILE_OK ${adiak_TEST_DIR} + ${adiak_TEST_DIR}/ltest.c OUTPUT_VARIABLE COMPILE_OUTPUT LINK_LIBRARIES adiak::adiak ${CMAKE_DL_LIBS}) # Process test result if(COMPILE_OK) message(STATUS "Checking if adiak works with SUNDIALS... OK") - set(adiak_WORKS TRUE CACHE BOOL "adiak works with SUNDIALS as configured" FORCE) + set(adiak_WORKS + TRUE + CACHE BOOL "adiak works with SUNDIALS as configured" FORCE) else() message(STATUS "Checking if adiak works with SUNDIALS... FAILED") message(STATUS "Check output: ") diff --git a/cmake/tpl/SundialsCaliper.cmake b/cmake/tpl/SundialsCaliper.cmake index 8a665a3f05..fb6b2f72ee 100644 --- a/cmake/tpl/SundialsCaliper.cmake +++ b/cmake/tpl/SundialsCaliper.cmake @@ -40,9 +40,7 @@ endif() # Section 3: Find the TPL # ----------------------------------------------------------------------------- -find_package(CALIPER - PATHS "${CALIPER_DIR}" - REQUIRED) +find_package(CALIPER PATHS "${CALIPER_DIR}" REQUIRED) message(STATUS "CALIPER_LIB_DIR: ${caliper_LIB_DIR}") message(STATUS "CALIPER_INCLUDE_DIR: ${caliper_INCLUDE_DIR}") @@ -59,7 +57,8 @@ if(CALIPER_FOUND AND (NOT CALIPER_WORKS)) file(MAKE_DIRECTORY ${CALIPER_TEST_DIR}) # Create a CMakeLists.txt file - file(WRITE ${CALIPER_TEST_DIR}/CMakeLists.txt + file( + WRITE ${CALIPER_TEST_DIR}/CMakeLists.txt "cmake_minimum_required(VERSION ${CMAKE_VERSION})\n" "project(ltest C)\n" "set(CMAKE_VERBOSE_MAKEFILE ON)\n" @@ -77,27 +76,32 @@ if(CALIPER_FOUND AND (NOT CALIPER_WORKS)) "target_link_libraries(ltest caliper)\n") # Create a C source file - file(WRITE ${CALIPER_TEST_DIR}/ltest.c - "\#include \n" - "int main(void)\n" - "{\n" - " CALI_MARK_FUNCTION_BEGIN;\n" - " CALI_MARK_FUNCTION_END;\n" - " return 0;\n" - "}\n") + file( + WRITE ${CALIPER_TEST_DIR}/ltest.c + "\#include \n" + "int main(void)\n" + "{\n" + " CALI_MARK_FUNCTION_BEGIN;\n" + " CALI_MARK_FUNCTION_END;\n" + " return 0;\n" + "}\n") # To ensure we do not use stuff from the previous attempts, # we must remove the CMakeFiles directory. file(REMOVE_RECURSE ${CALIPER_TEST_DIR}/CMakeFiles) # Attempt to build and link the "ltest" executable - try_compile(COMPILE_OK ${CALIPER_TEST_DIR} ${CALIPER_TEST_DIR} ltest + try_compile( + COMPILE_OK ${CALIPER_TEST_DIR} + ${CALIPER_TEST_DIR} ltest OUTPUT_VARIABLE COMPILE_OUTPUT) # Process test result if(COMPILE_OK) message(STATUS "Checking if CALIPER works with SUNDIALS... OK") - set(CALIPER_WORKS TRUE CACHE BOOL "CALIPER works with SUNDIALS as configured" FORCE) + set(CALIPER_WORKS + TRUE + CACHE BOOL "CALIPER works with SUNDIALS as configured" FORCE) else() message(STATUS "Checking if CALIPER works with SUNDIALS... FAILED") message(STATUS "Check output: ") diff --git a/cmake/tpl/SundialsGinkgo.cmake b/cmake/tpl/SundialsGinkgo.cmake index 595c96aa5a..cb3fe4a563 100644 --- a/cmake/tpl/SundialsGinkgo.cmake +++ b/cmake/tpl/SundialsGinkgo.cmake @@ -36,13 +36,10 @@ endif() # Section 2: Check to make sure options are compatible # ----------------------------------------------------------------------------- - # ----------------------------------------------------------------------------- # Section 3: Find the TPL # ----------------------------------------------------------------------------- -find_package(Ginkgo REQUIRED - HINTS "${Ginkgo_DIR}" - NO_DEFAULT_PATH) +find_package(Ginkgo REQUIRED HINTS "${Ginkgo_DIR}" NO_DEFAULT_PATH) message(STATUS "GINKGO VERSION: ${GINKGO_PROJECT_VERSION}") message(STATUS "GINKGO BUILD TYPE: ${GINKGO_BUILD_TYPE}") @@ -55,27 +52,38 @@ message(STATUS "GINKGO CXX FLAGS: ${GINKGO_INTERFACE_CXX_FLAGS}") # ----------------------------------------------------------------------------- if(Ginkgo_FOUND AND (NOT GINKGO_WORKS)) if(SUNDIALS_PRECISION MATCHES "extended|EXTENDED") - print_error("SUNDIALS GINKGO interface is not compatible with extended precision") + print_error( + "SUNDIALS GINKGO interface is not compatible with extended precision") endif() if(SUNDIALS_GINKGO_BACKENDS MATCHES "CUDA" AND NOT ENABLE_CUDA) - print_error("SUNDIALS_GINKGO_BACKENDS includes CUDA but CUDA is not enabled. Set ENABLE_CUDA=ON or change the backend.") + print_error( + "SUNDIALS_GINKGO_BACKENDS includes CUDA but CUDA is not enabled. Set ENABLE_CUDA=ON or change the backend." + ) endif() if(SUNDIALS_GINKGO_BACKENDS MATCHES "HIP" AND NOT ENABLE_HIP) - print_error("SUNDIALS_GINKGO_BACKENDS includes HIP but HIP is not enabled. Set ENABLE_HIP=ON or change the backend.") + print_error( + "SUNDIALS_GINKGO_BACKENDS includes HIP but HIP is not enabled. Set ENABLE_HIP=ON or change the backend." + ) endif() - if(SUNDIALS_GINKGO_BACKENDS MATCHES "SYCL" AND NOT ENABLE_SYCL) - print_error("SUNDIALS_GINKGO_BACKENDS includes SYCL but SYCL is not enabled. Set ENABLE_SYCL=ON or change the backend.") + if(SUNDIALS_GINKGO_BACKENDS MATCHES "SYCL" AND NOT ENABLE_SYCL) + print_error( + "SUNDIALS_GINKGO_BACKENDS includes SYCL but SYCL is not enabled. Set ENABLE_SYCL=ON or change the backend." + ) endif() if(SUNDIALS_GINKGO_BACKENDS MATCHES "OMP" AND NOT ENABLE_OPENMP) - print_error("SUNDIALS_GINKGO_BACKENDS includes OMP but OpenMP is not enabled. Set ENABLE_OPENMP=ON or change the backend.") + print_error( + "SUNDIALS_GINKGO_BACKENDS includes OMP but OpenMP is not enabled. Set ENABLE_OPENMP=ON or change the backend." + ) endif() message(STATUS "Checking if GINKGO works... OK") - set(GINKGO_WORKS TRUE CACHE BOOL "GINKGO works with SUNDIALS as configured" FORCE) + set(GINKGO_WORKS + TRUE + CACHE BOOL "GINKGO works with SUNDIALS as configured" FORCE) elseif(Ginkgo_FOUND AND GINKGO_WORKS) message(STATUS "Skipped GINKGO tests, assuming GINKGO works with SUNDIALS.") endif() diff --git a/cmake/tpl/SundialsHypre.cmake b/cmake/tpl/SundialsHypre.cmake index 56a6158165..c3d5779244 100644 --- a/cmake/tpl/SundialsHypre.cmake +++ b/cmake/tpl/SundialsHypre.cmake @@ -68,46 +68,52 @@ if(HYPRE_FOUND AND (NOT HYPRE_WORKS)) file(MAKE_DIRECTORY ${HYPRE_TEST_DIR}) # Create a CMakeLists.txt file - file(WRITE ${HYPRE_TEST_DIR}/CMakeLists.txt - "CMAKE_MINIMUM_REQUIRED(VERSION ${CMAKE_VERSION})\n" - "PROJECT(ltest C)\n" - "SET(CMAKE_VERBOSE_MAKEFILE ON)\n" - "SET(CMAKE_BUILD_TYPE \"${CMAKE_BUILD_TYPE}\")\n" - "SET(CMAKE_C_COMPILER ${MPI_C_COMPILER})\n" - "SET(CMAKE_C_STANDARD \"${CMAKE_C_STANDARD}\")\n" - "SET(CMAKE_C_FLAGS \"${CMAKE_C_FLAGS}\")\n" - "SET(CMAKE_C_FLAGS_RELEASE \"${CMAKE_C_FLAGS_RELEASE}\")\n" - "SET(CMAKE_C_FLAGS_DEBUG \"${CMAKE_C_FLAGS_DEBUG}\")\n" - "SET(CMAKE_C_FLAGS_RELWITHDEBUGINFO \"${CMAKE_C_FLAGS_RELWITHDEBUGINFO}\")\n" - "SET(CMAKE_C_FLAGS_MINSIZE \"${CMAKE_C_FLAGS_MINSIZE}\")\n" - "SET(CMAKE_EXE_LINKER_FLAGS \"${LINK_MATH_LIB}\")\n" - "INCLUDE_DIRECTORIES(${HYPRE_INCLUDE_DIR})\n" - "ADD_EXECUTABLE(ltest ltest.c)\n" - "TARGET_LINK_LIBRARIES(ltest ${HYPRE_LIBRARIES})\n") - - file(WRITE ${HYPRE_TEST_DIR}/ltest.c - "\#include \"HYPRE_parcsr_ls.h\"\n" - "int main(void) {\n" - "HYPRE_ParVector par_b;\n" - "HYPRE_IJVector b;\n" - "par_b = 0;\n" - "b = 0;\n" - "if (par_b != 0 || b != 0) return(1);\n" - "else return(0);\n" - "}\n") + file( + WRITE ${HYPRE_TEST_DIR}/CMakeLists.txt + "CMAKE_MINIMUM_REQUIRED(VERSION ${CMAKE_VERSION})\n" + "PROJECT(ltest C)\n" + "SET(CMAKE_VERBOSE_MAKEFILE ON)\n" + "SET(CMAKE_BUILD_TYPE \"${CMAKE_BUILD_TYPE}\")\n" + "SET(CMAKE_C_COMPILER ${MPI_C_COMPILER})\n" + "SET(CMAKE_C_STANDARD \"${CMAKE_C_STANDARD}\")\n" + "SET(CMAKE_C_FLAGS \"${CMAKE_C_FLAGS}\")\n" + "SET(CMAKE_C_FLAGS_RELEASE \"${CMAKE_C_FLAGS_RELEASE}\")\n" + "SET(CMAKE_C_FLAGS_DEBUG \"${CMAKE_C_FLAGS_DEBUG}\")\n" + "SET(CMAKE_C_FLAGS_RELWITHDEBUGINFO \"${CMAKE_C_FLAGS_RELWITHDEBUGINFO}\")\n" + "SET(CMAKE_C_FLAGS_MINSIZE \"${CMAKE_C_FLAGS_MINSIZE}\")\n" + "SET(CMAKE_EXE_LINKER_FLAGS \"${LINK_MATH_LIB}\")\n" + "INCLUDE_DIRECTORIES(${HYPRE_INCLUDE_DIR})\n" + "ADD_EXECUTABLE(ltest ltest.c)\n" + "TARGET_LINK_LIBRARIES(ltest ${HYPRE_LIBRARIES})\n") + + file( + WRITE ${HYPRE_TEST_DIR}/ltest.c + "\#include \"HYPRE_parcsr_ls.h\"\n" + "int main(void) {\n" + "HYPRE_ParVector par_b;\n" + "HYPRE_IJVector b;\n" + "par_b = 0;\n" + "b = 0;\n" + "if (par_b != 0 || b != 0) return(1);\n" + "else return(0);\n" + "}\n") # To ensure we do not use stuff from the previous attempts, # we must remove the CMakeFiles directory. file(REMOVE_RECURSE ${HYPRE_TEST_DIR}/CMakeFiles) # Attempt to build and link the "ltest" executable - try_compile(COMPILE_OK ${HYPRE_TEST_DIR} ${HYPRE_TEST_DIR} ltest + try_compile( + COMPILE_OK ${HYPRE_TEST_DIR} + ${HYPRE_TEST_DIR} ltest OUTPUT_VARIABLE COMPILE_OUTPUT) # Process test result if(COMPILE_OK) message(STATUS "Checking if HYPRE works... OK") - set(HYPRE_WORKS TRUE CACHE BOOL "HYPRE works with SUNDIALS as configured" FORCE) + set(HYPRE_WORKS + TRUE + CACHE BOOL "HYPRE works with SUNDIALS as configured" FORCE) else() message(STATUS "Checking if HYPRE works... FAILED") message(STATUS "Check output: ") @@ -116,5 +122,8 @@ if(HYPRE_FOUND AND (NOT HYPRE_WORKS)) endif() elseif(HYPRE_FOUND AND HYPRE_WORKS) - message(STATUS "Skipped HYPRE tests, assuming HYPRE works with SUNDIALS. Set HYPRE_WORKS=FALSE to (re)run compatibility test.") + message( + STATUS + "Skipped HYPRE tests, assuming HYPRE works with SUNDIALS. Set HYPRE_WORKS=FALSE to (re)run compatibility test." + ) endif() diff --git a/cmake/tpl/SundialsKLU.cmake b/cmake/tpl/SundialsKLU.cmake index aa71405687..cc806692a8 100644 --- a/cmake/tpl/SundialsKLU.cmake +++ b/cmake/tpl/SundialsKLU.cmake @@ -69,7 +69,9 @@ if(KLU_FOUND AND (NOT KLU_WORKS)) set(CMAKE_REQUIRED_INCLUDES ${save_CMAKE_REQUIRED_INCLUDES}) message(STATUS "Size of SuiteSparse_long is ${SIZEOF_SUITESPARSE_LONG}") if(NOT SIZEOF_SUITESPARSE_LONG EQUAL "8") - print_error("Size of 'sunindextype' is 8 but size of 'SuiteSparse_long' is ${SIZEOF_SUITESPARSE_LONG}. KLU cannot be used.") + print_error( + "Size of 'sunindextype' is 8 but size of 'SuiteSparse_long' is ${SIZEOF_SUITESPARSE_LONG}. KLU cannot be used." + ) endif() endif() @@ -78,43 +80,44 @@ if(KLU_FOUND AND (NOT KLU_WORKS)) file(MAKE_DIRECTORY ${KLU_TEST_DIR}) # Create a CMakeLists.txt file - file(WRITE ${KLU_TEST_DIR}/CMakeLists.txt - "CMAKE_MINIMUM_REQUIRED(VERSION ${CMAKE_VERSION})\n" - "PROJECT(ltest C)\n" - "SET(CMAKE_VERBOSE_MAKEFILE ON)\n" - "SET(CMAKE_BUILD_TYPE \"${CMAKE_BUILD_TYPE}\")\n" - "SET(CMAKE_C_COMPILER \"${CMAKE_C_COMPILER}\")\n" - "SET(CMAKE_C_STANDARD \"${CMAKE_C_STANDARD}\")\n" - "SET(CMAKE_C_FLAGS \"${CMAKE_C_FLAGS}\")\n" - "SET(CMAKE_C_FLAGS_RELEASE \"${CMAKE_C_FLAGS_RELEASE}\")\n" - "SET(CMAKE_C_FLAGS_DEBUG \"${CMAKE_C_FLAGS_DEBUG}\")\n" - "SET(CMAKE_C_FLAGS_RELWITHDEBUGINFO \"${CMAKE_C_FLAGS_RELWITHDEBUGINFO}\")\n" - "SET(CMAKE_C_FLAGS_MINSIZE \"${CMAKE_C_FLAGS_MINSIZE}\")\n" - "INCLUDE_DIRECTORIES(${KLU_INCLUDE_DIR})\n" - "ADD_EXECUTABLE(ltest ltest.c)\n" - "TARGET_LINK_LIBRARIES(ltest ${KLU_LIBRARIES})\n") + file( + WRITE ${KLU_TEST_DIR}/CMakeLists.txt + "CMAKE_MINIMUM_REQUIRED(VERSION ${CMAKE_VERSION})\n" + "PROJECT(ltest C)\n" + "SET(CMAKE_VERBOSE_MAKEFILE ON)\n" + "SET(CMAKE_BUILD_TYPE \"${CMAKE_BUILD_TYPE}\")\n" + "SET(CMAKE_C_COMPILER \"${CMAKE_C_COMPILER}\")\n" + "SET(CMAKE_C_STANDARD \"${CMAKE_C_STANDARD}\")\n" + "SET(CMAKE_C_FLAGS \"${CMAKE_C_FLAGS}\")\n" + "SET(CMAKE_C_FLAGS_RELEASE \"${CMAKE_C_FLAGS_RELEASE}\")\n" + "SET(CMAKE_C_FLAGS_DEBUG \"${CMAKE_C_FLAGS_DEBUG}\")\n" + "SET(CMAKE_C_FLAGS_RELWITHDEBUGINFO \"${CMAKE_C_FLAGS_RELWITHDEBUGINFO}\")\n" + "SET(CMAKE_C_FLAGS_MINSIZE \"${CMAKE_C_FLAGS_MINSIZE}\")\n" + "INCLUDE_DIRECTORIES(${KLU_INCLUDE_DIR})\n" + "ADD_EXECUTABLE(ltest ltest.c)\n" + "TARGET_LINK_LIBRARIES(ltest ${KLU_LIBRARIES})\n") # Create a C source file which calls a KLU function file(WRITE ${KLU_TEST_DIR}/ltest.c - "\#include \"klu.h\"\n" - "int main(void) {\n" - "klu_common Common;\n" - "klu_defaults (&Common);\n" - "return(0);\n" - "}\n") + "\#include \"klu.h\"\n" "int main(void) {\n" "klu_common Common;\n" + "klu_defaults (&Common);\n" "return(0);\n" "}\n") # To ensure we do not use stuff from the previous attempts, # we must remove the CMakeFiles directory. file(REMOVE_RECURSE ${KLU_TEST_DIR}/CMakeFiles) # Attempt to build and link the "ltest" executable - try_compile(COMPILE_OK ${KLU_TEST_DIR} ${KLU_TEST_DIR} ltest + try_compile( + COMPILE_OK ${KLU_TEST_DIR} + ${KLU_TEST_DIR} ltest OUTPUT_VARIABLE COMPILE_OUTPUT) # Process test result if(COMPILE_OK) message(STATUS "Checking if KLU works... OK") - set(KLU_WORKS TRUE CACHE BOOL "KLU works with SUNDIALS as configured" FORCE) + set(KLU_WORKS + TRUE + CACHE BOOL "KLU works with SUNDIALS as configured" FORCE) else() message(STATUS "Checking if KLU works... FAILED") message(STATUS "Check output: ") @@ -123,5 +126,8 @@ if(KLU_FOUND AND (NOT KLU_WORKS)) endif() elseif(KLU_FOUND AND KLU_WORKS) - message(STATUS "Skipped KLU tests, assuming KLU works with SUNDIALS. Set KLU_WORKS=FALSE to (re)run compatibility test.") + message( + STATUS + "Skipped KLU tests, assuming KLU works with SUNDIALS. Set KLU_WORKS=FALSE to (re)run compatibility test." + ) endif() diff --git a/cmake/tpl/SundialsKokkos.cmake b/cmake/tpl/SundialsKokkos.cmake index c082a14e87..14a187d708 100644 --- a/cmake/tpl/SundialsKokkos.cmake +++ b/cmake/tpl/SundialsKokkos.cmake @@ -36,18 +36,16 @@ endif() # Section 2: Check to make sure options are compatible # ----------------------------------------------------------------------------- - # ----------------------------------------------------------------------------- # Section 3: Find the TPL # ----------------------------------------------------------------------------- -find_package(Kokkos REQUIRED - HINTS "${Kokkos_DIR}" - NO_DEFAULT_PATH) +find_package(Kokkos REQUIRED HINTS "${Kokkos_DIR}" NO_DEFAULT_PATH) # We should be able to use Kokkos_DEVICES directly but it seems to get # removed or unset in some CMake versions -set(KOKKOS_EXAMPLES_BACKENDS "${Kokkos_DEVICES}" CACHE STRING - "Kokkos backends to build examples with") +set(KOKKOS_EXAMPLES_BACKENDS + "${Kokkos_DEVICES}" + CACHE STRING "Kokkos backends to build examples with") mark_as_advanced(FORCE KOKKOS_EXAMPLES_BACKENDS) message(STATUS "Kokkos VERSION: ${Kokkos_VERSION}") @@ -57,8 +55,9 @@ message(STATUS "Kokkos VERSION: ${Kokkos_VERSION}") if(Kokkos_FOUND AND (NOT KOKKOS_WORKS)) message(STATUS "Checking if Kokkos works... OK") - set(KOKKOS_WORKS TRUE CACHE BOOL "Kokkos works with SUNDIALS as configured" - FORCE) + set(KOKKOS_WORKS + TRUE + CACHE BOOL "Kokkos works with SUNDIALS as configured" FORCE) elseif(Kokkos_FOUND AND KOKKOS_WORKS) message(STATUS "Skipped Kokkos tests, assuming Kokkos works with SUNDIALS.") endif() diff --git a/cmake/tpl/SundialsKokkosKernels.cmake b/cmake/tpl/SundialsKokkosKernels.cmake index 93d68152bf..4f495725ee 100644 --- a/cmake/tpl/SundialsKokkosKernels.cmake +++ b/cmake/tpl/SundialsKokkosKernels.cmake @@ -36,13 +36,11 @@ endif() # Section 2: Check to make sure options are compatible # ----------------------------------------------------------------------------- - # ----------------------------------------------------------------------------- # Section 3: Find the TPL # ----------------------------------------------------------------------------- -find_package(KokkosKernels REQUIRED - HINTS "${KokkosKernels_DIR}" - NO_DEFAULT_PATH) +find_package(KokkosKernels REQUIRED HINTS "${KokkosKernels_DIR}" + NO_DEFAULT_PATH) message(STATUS "Kokkos Kernels VERSION: ${KokkosKernels_VERSION}") @@ -52,8 +50,12 @@ message(STATUS "Kokkos Kernels VERSION: ${KokkosKernels_VERSION}") if(KokkosKernels_FOUND AND (NOT KOKKOS_KERNELS_WORKS)) message(STATUS "Checking if Kokkos Kernels works... OK") - set(KOKKOS_KERNELS_WORKS TRUE CACHE BOOL - "Kokkos Kernels works with SUNDIALS as configured" FORCE) + set(KOKKOS_KERNELS_WORKS + TRUE + CACHE BOOL "Kokkos Kernels works with SUNDIALS as configured" FORCE) elseif(KokkosKernels_FOUND AND KOKKOS_WORKS) - message(STATUS "Skipped Kokkos Kernels tests, assuming Kokkos Kernels works with SUNDIALS.") + message( + STATUS + "Skipped Kokkos Kernels tests, assuming Kokkos Kernels works with SUNDIALS." + ) endif() diff --git a/cmake/tpl/SundialsLapack.cmake b/cmake/tpl/SundialsLapack.cmake index 63b8514520..f9251e20d1 100644 --- a/cmake/tpl/SundialsLapack.cmake +++ b/cmake/tpl/SundialsLapack.cmake @@ -94,7 +94,8 @@ if(NEED_FORTRAN_NAME_MANGLING) # Create a CMakeLists.txt file which will generate the "flib" library # and an executable "ftest" - file(WRITE ${FortranTest_DIR}/CMakeLists.txt + file( + WRITE ${FortranTest_DIR}/CMakeLists.txt "CMAKE_MINIMUM_REQUIRED(VERSION ${CMAKE_VERSION})\n" "PROJECT(ftest Fortran)\n" "SET(CMAKE_VERBOSE_MAKEFILE ON)\n" @@ -111,23 +112,19 @@ if(NEED_FORTRAN_NAME_MANGLING) # Create the Fortran source flib.f which defines two subroutines, "mysub" and "my_sub" file(WRITE ${FortranTest_DIR}/flib.f - " SUBROUTINE mysub\n" - " RETURN\n" - " END\n" - " SUBROUTINE my_sub\n" - " RETURN\n" - " END\n") + " SUBROUTINE mysub\n" " RETURN\n" " END\n" + " SUBROUTINE my_sub\n" " RETURN\n" " END\n") # Create the Fortran source ftest.f which calls "mysub" and "my_sub" file(WRITE ${FortranTest_DIR}/ftest.f - " PROGRAM ftest\n" - " CALL mysub()\n" - " CALL my_sub()\n" - " END\n") + " PROGRAM ftest\n" " CALL mysub()\n" + " CALL my_sub()\n" " END\n") # Use TRY_COMPILE to make the targets "flib" and "ftest" - try_compile(FTEST_OK ${FortranTest_DIR} ${FortranTest_DIR} - ftest OUTPUT_VARIABLE MY_OUTPUT) + try_compile( + FTEST_OK ${FortranTest_DIR} + ${FortranTest_DIR} ftest + OUTPUT_VARIABLE MY_OUTPUT) # To ensure we do not use stuff from the previous attempts, # we must remove the CMakeFiles directory. @@ -138,7 +135,8 @@ if(NEED_FORTRAN_NAME_MANGLING) # Infer Fortran name-mangling scheme for symbols WITHOUT underscores. # Overwrite CMakeLists.txt with one which will generate the "ctest1" executable - file(WRITE ${FortranTest_DIR}/CMakeLists.txt + file( + WRITE ${FortranTest_DIR}/CMakeLists.txt "CMAKE_MINIMUM_REQUIRED(VERSION ${CMAKE_VERSION})\n" "PROJECT(ctest1 C)\n" "SET(CMAKE_VERBOSE_MAKEFILE ON)\n" @@ -166,12 +164,13 @@ if(NEED_FORTRAN_NAME_MANGLING) list(GET options ${iopt} opt) # Generate C source which calls the "mysub" function using the current scheme file(WRITE ${FortranTest_DIR}/ctest1.c - "extern void ${opt}();\n" - "int main(void){${opt}();return(0);}\n") + "extern void ${opt}();\n" "int main(void){${opt}();return(0);}\n") # Use TRY_COMPILE to make the "ctest1" executable from the current C source # and linking to the previously created "flib" library. - try_compile(CTEST_OK ${FortranTest_DIR} ${FortranTest_DIR} - ctest1 OUTPUT_VARIABLE MY_OUTPUT) + try_compile( + CTEST_OK ${FortranTest_DIR} + ${FortranTest_DIR} ctest1 + OUTPUT_VARIABLE MY_OUTPUT) # Write output compiling the test code file(WRITE ${FortranTest_DIR}/ctest1_${opt}.out "${MY_OUTPUT}") # To ensure we do not use stuff from the previous attempts, @@ -191,7 +190,8 @@ if(NEED_FORTRAN_NAME_MANGLING) # Infer Fortran name-mangling scheme for symbols WITH underscores. # Practically a duplicate of the previous steps. - file(WRITE ${FortranTest_DIR}/CMakeLists.txt + file( + WRITE ${FortranTest_DIR}/CMakeLists.txt "CMAKE_MINIMUM_REQUIRED(VERSION ${CMAKE_VERSION})\n" "PROJECT(ctest2 C)\n" "SET(CMAKE_VERBOSE_MAKEFILE ON)\n" @@ -212,10 +212,11 @@ if(NEED_FORTRAN_NAME_MANGLING) while(${iopt} LESS ${imax}) list(GET options ${iopt} opt) file(WRITE ${FortranTest_DIR}/ctest2.c - "extern void ${opt}();\n" - "int main(void){${opt}();return(0);}\n") - try_compile(CTEST_OK ${FortranTest_DIR} ${FortranTest_DIR} - ctest2 OUTPUT_VARIABLE MY_OUTPUT) + "extern void ${opt}();\n" "int main(void){${opt}();return(0);}\n") + try_compile( + CTEST_OK ${FortranTest_DIR} + ${FortranTest_DIR} ctest2 + OUTPUT_VARIABLE MY_OUTPUT) file(WRITE ${FortranTest_DIR}/ctest2_${opt}.out "${MY_OUTPUT}") file(REMOVE_RECURSE ${FortranTest_DIR}/CMakeFiles) if(CTEST_OK) @@ -228,7 +229,8 @@ if(NEED_FORTRAN_NAME_MANGLING) # If a name-mangling scheme was found set the C preprocessor macros to use # that scheme. Otherwise default to lower case with one underscore. - if(CMAKE_Fortran_SCHEME_NO_UNDERSCORES AND CMAKE_Fortran_SCHEME_WITH_UNDERSCORES) + if(CMAKE_Fortran_SCHEME_NO_UNDERSCORES + AND CMAKE_Fortran_SCHEME_WITH_UNDERSCORES) message(STATUS "Determining Fortran name-mangling scheme... OK") else() message(STATUS "Determining Fortran name-mangling scheme... DEFAULT") @@ -241,19 +243,23 @@ if(NEED_FORTRAN_NAME_MANGLING) set(LAPACK_MANGLE_MACRO1 "#define SUNDIALS_LAPACK_FUNC(name,NAME) name") endif() if(${CMAKE_Fortran_SCHEME_NO_UNDERSCORES} MATCHES "mysub_") - set(LAPACK_MANGLE_MACRO1 "#define SUNDIALS_LAPACK_FUNC(name,NAME) name ## _") + set(LAPACK_MANGLE_MACRO1 + "#define SUNDIALS_LAPACK_FUNC(name,NAME) name ## _") endif() if(${CMAKE_Fortran_SCHEME_NO_UNDERSCORES} MATCHES "mysub__") - set(LAPACK_MANGLE_MACRO1 "#define SUNDIALS_LAPACK_FUNC(name,NAME) name ## __") + set(LAPACK_MANGLE_MACRO1 + "#define SUNDIALS_LAPACK_FUNC(name,NAME) name ## __") endif() if(${CMAKE_Fortran_SCHEME_NO_UNDERSCORES} MATCHES "MYSUB") set(LAPACK_MANGLE_MACRO1 "#define SUNDIALS_LAPACK_FUNC(name,NAME) NAME") endif() if(${CMAKE_Fortran_SCHEME_NO_UNDERSCORES} MATCHES "MYSUB_") - set(LAPACK_MANGLE_MACRO1 "#define SUNDIALS_LAPACK_FUNC(name,NAME) NAME ## _") + set(LAPACK_MANGLE_MACRO1 + "#define SUNDIALS_LAPACK_FUNC(name,NAME) NAME ## _") endif() if(${CMAKE_Fortran_SCHEME_NO_UNDERSCORES} MATCHES "MYSUB__") - set(LAPACK_MANGLE_MACRO1 "#define SUNDIALS_LAPACK_FUNC(name,NAME) NAME ## __") + set(LAPACK_MANGLE_MACRO1 + "#define SUNDIALS_LAPACK_FUNC(name,NAME) NAME ## __") endif() # Symbols WITH underscores @@ -261,28 +267,30 @@ if(NEED_FORTRAN_NAME_MANGLING) set(LAPACK_MANGLE_MACRO2 "#define SUNDIALS_LAPACK_FUNC_(name,NAME) name") endif() if(${CMAKE_Fortran_SCHEME_WITH_UNDERSCORES} MATCHES "my_sub_") - set(LAPACK_MANGLE_MACRO2 "#define SUNDIALS_LAPACK_FUNC_(name,NAME) name ## _") + set(LAPACK_MANGLE_MACRO2 + "#define SUNDIALS_LAPACK_FUNC_(name,NAME) name ## _") endif() if(${CMAKE_Fortran_SCHEME_WITH_UNDERSCORES} MATCHES "my_sub__") - set(LAPACK_MANGLE_MACRO2 "#define SUNDIALS_LAPACK_FUNC_(name,NAME) name ## __") + set(LAPACK_MANGLE_MACRO2 + "#define SUNDIALS_LAPACK_FUNC_(name,NAME) name ## __") endif() if(${CMAKE_Fortran_SCHEME_WITH_UNDERSCORES} MATCHES "MY_SUB") set(LAPACK_MANGLE_MACRO2 "#define SUNDIALS_LAPACK_FUNC_(name,NAME) NAME") endif() if(${CMAKE_Fortran_SCHEME_WITH_UNDERSCORES} MATCHES "MY_SUB_") - set(LAPACK_MANGLE_MACRO2 "#define SUNDIALS_LAPACK_FUNC_(name,NAME) NAME ## _") + set(LAPACK_MANGLE_MACRO2 + "#define SUNDIALS_LAPACK_FUNC_(name,NAME) NAME ## _") endif() if(${CMAKE_Fortran_SCHEME_WITH_UNDERSCORES} MATCHES "MY_SUB__") - set(LAPACK_MANGLE_MACRO2 "#define SUNDIALS_LAPACK_FUNC_(name,NAME) NAME ## __") + set(LAPACK_MANGLE_MACRO2 + "#define SUNDIALS_LAPACK_FUNC_(name,NAME) NAME ## __") endif() # name-mangling scheme has been set set(NEED_FORTRAN_NAME_MANGLING FALSE) - configure_file( - ${PROJECT_SOURCE_DIR}/src/sundials/sundials_lapack_defs.h.in - ${PROJECT_BINARY_DIR}/src/sundials/sundials_lapack_defs.h - ) + configure_file(${PROJECT_SOURCE_DIR}/src/sundials/sundials_lapack_defs.h.in + ${PROJECT_BINARY_DIR}/src/sundials/sundials_lapack_defs.h) else(FTEST_OK) message(STATUS "Determining Fortran name-mangling scheme... FAILED") @@ -297,7 +305,8 @@ if(LAPACK_LIBRARIES AND (NOT LAPACK_WORKS)) file(MAKE_DIRECTORY ${LapackTest_DIR}) # Create a CMakeLists.txt file - file(WRITE ${LapackTest_DIR}/CMakeLists.txt + file( + WRITE ${LapackTest_DIR}/CMakeLists.txt "CMAKE_MINIMUM_REQUIRED(VERSION ${CMAKE_VERSION})\n" "PROJECT(ltest C)\n" "SET(CMAKE_VERBOSE_MAKEFILE ON)\n" @@ -313,7 +322,8 @@ if(LAPACK_LIBRARIES AND (NOT LAPACK_WORKS)) "TARGET_LINK_LIBRARIES(ltest ${LAPACK_LIBRARIES})\n") # Create a C source file which calls a Blas function (dcopy) and an Lapack function (dgetrf) - file(WRITE ${LapackTest_DIR}/ltest.c + file( + WRITE ${LapackTest_DIR}/ltest.c "${LAPACK_MANGLE_MACRO1}\n" "#define dcopy_f77 SUNDIALS_LAPACK_FUNC(dcopy, DCOPY)\n" "#define dgetrf_f77 SUNDIALS_LAPACK_FUNC(dgetrf, DGETRF)\n" @@ -329,8 +339,10 @@ if(LAPACK_LIBRARIES AND (NOT LAPACK_WORKS)) "}\n") # Attempt to build and link the "ltest" executable - try_compile(COMPILE_OK ${LapackTest_DIR} ${LapackTest_DIR} - ltest OUTPUT_VARIABLE COMPILE_OUTPUT) + try_compile( + COMPILE_OK ${LapackTest_DIR} + ${LapackTest_DIR} ltest + OUTPUT_VARIABLE COMPILE_OUTPUT) # To ensure we do not use stuff from the previous attempts, # we must remove the CMakeFiles directory. @@ -339,7 +351,9 @@ if(LAPACK_LIBRARIES AND (NOT LAPACK_WORKS)) # Process test result if(COMPILE_OK) message(STATUS "Checking if LAPACK works with SUNDIALS... OK") - set(LAPACK_WORKS TRUE CACHE BOOL "LAPACK works with SUNDIALS as configured" FORCE) + set(LAPACK_WORKS + TRUE + CACHE BOOL "LAPACK works with SUNDIALS as configured" FORCE) # get path to LAPACK library to use in generated makefiles for examples, if # LAPACK_LIBRARIES contains multiple items only use the path of the first entry @@ -351,7 +365,9 @@ if(LAPACK_LIBRARIES AND (NOT LAPACK_WORKS)) get_filename_component(LAPACK_LIBRARY_DIR ${TMP_LAPACK_LIBRARIES} PATH) endif() else(COMPILE_OK) - set(LAPACK_WORKS FALSE CACHE BOOL "LAPACK does not work with SUNDIALS as configured" FORCE) + set(LAPACK_WORKS + FALSE + CACHE BOOL "LAPACK does not work with SUNDIALS as configured" FORCE) message(STATUS "Checking if LAPACK works with SUNDIALS... FAILED") message(STATUS "Check output: ") message("${COMPILE_OUTPUT}") @@ -359,5 +375,8 @@ if(LAPACK_LIBRARIES AND (NOT LAPACK_WORKS)) endif() elseif(LAPACK_LIBRARIES AND LAPACK_WORKS) - message(STATUS "Skipped LAPACK tests, assuming LAPACK works with SUNDIALS. Set LAPACK_WORKS=FALSE to (re)run compatibility test.") + message( + STATUS + "Skipped LAPACK tests, assuming LAPACK works with SUNDIALS. Set LAPACK_WORKS=FALSE to (re)run compatibility test." + ) endif() diff --git a/cmake/tpl/SundialsMAGMA.cmake b/cmake/tpl/SundialsMAGMA.cmake index e821506c86..f89c4dfd7c 100644 --- a/cmake/tpl/SundialsMAGMA.cmake +++ b/cmake/tpl/SundialsMAGMA.cmake @@ -37,7 +37,8 @@ endif() # ----------------------------------------------------------------------------- if(SUNDIALS_PRECISION MATCHES "extended") - print_error("SUNDIALS MAGMA interface is not compatible with extended precision") + print_error( + "SUNDIALS MAGMA interface is not compatible with extended precision") endif() # ----------------------------------------------------------------------------- @@ -57,13 +58,19 @@ message(STATUS "SUNDIALS_MAGMA_BACKENDS: ${SUNDIALS_MAGMA_BACKENDS}") if(MAGMA_FOUND AND (NOT MAGMA_WORKS)) if(SUNDIALS_MAGMA_BACKENDS MATCHES "CUDA" AND NOT ENABLE_CUDA) - print_error("SUNDIALS_MAGMA_BACKENDS includes CUDA but CUDA is not enabled. Set ENABLE_CUDA=ON or change the backend.") + print_error( + "SUNDIALS_MAGMA_BACKENDS includes CUDA but CUDA is not enabled. Set ENABLE_CUDA=ON or change the backend." + ) endif() if(SUNDIALS_MAGMA_BACKENDS MATCHES "HIP" AND NOT ENABLE_HIP) - print_error("SUNDIALS_MAGMA_BACKENDS includes HIP but HIP is not enabled. Set ENABLE_HIP=ON or change the backend.") + print_error( + "SUNDIALS_MAGMA_BACKENDS includes HIP but HIP is not enabled. Set ENABLE_HIP=ON or change the backend." + ) endif() - set(MAGMA_WORKS TRUE CACHE BOOL "MAGMA works with SUNDIALS as configured" FORCE) + set(MAGMA_WORKS + TRUE + CACHE BOOL "MAGMA works with SUNDIALS as configured" FORCE) elseif(MAGMA_FOUND AND MAGMA_WORKS) message(STATUS "Skipped MAGMA tests, assuming MAGMA works with SUNDIALS.") endif() diff --git a/cmake/tpl/SundialsONEMKL.cmake b/cmake/tpl/SundialsONEMKL.cmake index 693474e523..8fe11a2207 100644 --- a/cmake/tpl/SundialsONEMKL.cmake +++ b/cmake/tpl/SundialsONEMKL.cmake @@ -38,14 +38,15 @@ endif() # oneMKL does not support extended precision if(SUNDIALS_PRECISION MATCHES "EXTENDED") - message(FATAL_ERROR - "oneMKL is not compatible with ${SUNDIALS_PRECISION} precision") + message( + FATAL_ERROR "oneMKL is not compatible with ${SUNDIALS_PRECISION} precision") endif() # oneMKL does not support 32-bit index sizes if(SUNDIALS_INDEX_SIZE MATCHES "32") - message(FATAL_ERROR - "oneMKL is not compatible with ${SUNDIALS_INDEX_SIZE}-bit indices") + message( + FATAL_ERROR + "oneMKL is not compatible with ${SUNDIALS_INDEX_SIZE}-bit indices") endif() # ----------------------------------------------------------------------------- @@ -59,10 +60,14 @@ if(ENABLE_SYCL) endif() # Look for CMake configuration file in oneMKL installation -find_package(MKL CONFIG - PATHS "${ONEMKL_DIR}" "${ONEMKL_DIR}/lib/cmake/mkl" - NO_DEFAULT_PATH - REQUIRED) +find_package( + MKL + CONFIG + PATHS + "${ONEMKL_DIR}" + "${ONEMKL_DIR}/lib/cmake/mkl" + NO_DEFAULT_PATH + REQUIRED) message(STATUS "MKL Version: ${MKL_VERSION}") message(STATUS "MKL Targets: ${MKL_IMPORTED_TARGETS}") @@ -73,7 +78,9 @@ message(STATUS "MKL Targets: ${MKL_IMPORTED_TARGETS}") if(MKL_FOUND AND (NOT ONEMKL_WORKS)) message(STATUS "Checking if oneMKL works... OK") - set(ONEMKL_WORKS TRUE CACHE BOOL "oneMKL works with SUNDIALS as configured" FORCE) + set(ONEMKL_WORKS + TRUE + CACHE BOOL "oneMKL works with SUNDIALS as configured" FORCE) else() message(STATUS "Skipped oneMKL tests, assuming oneMKL works with SUNDIALS.") endif() diff --git a/cmake/tpl/SundialsOpenMP.cmake b/cmake/tpl/SundialsOpenMP.cmake index aff73d42c4..853480bceb 100644 --- a/cmake/tpl/SundialsOpenMP.cmake +++ b/cmake/tpl/SundialsOpenMP.cmake @@ -57,9 +57,15 @@ find_package(OpenMP REQUIRED) # OpenMP version information is not stored in cache variables and is not set # on repeated calls to find OpenMP (i.e., when using ccmake). To ensure these # variables exist store copies of the values. -set(OpenMP_C_VERSION "${OpenMP_C_VERSION}" CACHE INTERNAL "" FORCE) -set(OpenMP_CXX_VERSION "${OpenMP_CXX_VERSION}" CACHE INTERNAL "" FORCE) -set(OpenMP_Fortran_VERSION "${OpenMP_Fortran_VERSION}" CACHE INTERNAL "" FORCE) +set(OpenMP_C_VERSION + "${OpenMP_C_VERSION}" + CACHE INTERNAL "" FORCE) +set(OpenMP_CXX_VERSION + "${OpenMP_CXX_VERSION}" + CACHE INTERNAL "" FORCE) +set(OpenMP_Fortran_VERSION + "${OpenMP_Fortran_VERSION}" + CACHE INTERNAL "" FORCE) # Check for OpenMP offloading support if(OPENMP_FOUND AND (ENABLE_OPENMP_DEVICE OR SUPERLUDIST_OpenMP)) @@ -69,24 +75,30 @@ if(OPENMP_FOUND AND (ENABLE_OPENMP_DEVICE OR SUPERLUDIST_OpenMP)) # The user has asked for checks to be skipped, assume offloading is supported set(OPENMP45_FOUND TRUE) set(OPENMP_SUPPORTS_DEVICE_OFFLOADING TRUE) - print_warning("Skipping OpenMP device/version check." "SUNDIALS OpenMP functionality dependent on OpenMP 4.5+ is not guaranteed.") + print_warning( + "Skipping OpenMP device/version check." + "SUNDIALS OpenMP functionality dependent on OpenMP 4.5+ is not guaranteed." + ) else() # Check the OpenMP version message(STATUS "Checking whether OpenMP supports device offloading") - if((OpenMP_C_VERSION VERSION_EQUAL 4.5) OR (OpenMP_C_VERSION VERSION_GREATER 4.5)) - message(STATUS "Checking whether OpenMP supports device offloading -- yes") + if((OpenMP_C_VERSION VERSION_EQUAL 4.5) OR (OpenMP_C_VERSION VERSION_GREATER + 4.5)) + message( + STATUS "Checking whether OpenMP supports device offloading -- yes") set(OPENMP45_FOUND TRUE) set(OPENMP_SUPPORTS_DEVICE_OFFLOADING TRUE) else() message(STATUS "Checking whether OpenMP supports device offloading -- no") set(OPENMP45_FOUND FALSE) set(OPENMP_SUPPORTS_DEVICE_OFFLOADING FALSE) - print_error("The found OpenMP version does not support device offloading.") + print_error( + "The found OpenMP version does not support device offloading.") endif() endif() -endif() \ No newline at end of file +endif() diff --git a/cmake/tpl/SundialsPETSC.cmake b/cmake/tpl/SundialsPETSC.cmake index 1dc42ce873..fd8ede4242 100644 --- a/cmake/tpl/SundialsPETSC.cmake +++ b/cmake/tpl/SundialsPETSC.cmake @@ -42,7 +42,9 @@ if(ENABLE_PETSC AND NOT ENABLE_MPI) endif() if(SUNDIALS_PRECISION MATCHES "EXTENDED") - print_error("SUNDIALS is not compatible with PETSc when using ${SUNDIALS_PRECISION} precision") + print_error( + "SUNDIALS is not compatible with PETSc when using ${SUNDIALS_PRECISION} precision" + ) endif() # ----------------------------------------------------------------------------- @@ -67,26 +69,33 @@ if(PETSC_FOUND AND (NOT PETSC_WORKS)) # does compile tests already. if(NOT ("${SUNDIALS_INDEX_SIZE}" MATCHES "${PETSC_INDEX_SIZE}")) - string(CONCAT _err_msg_string - "PETSc not functional due to index size mismatch:\n" - "SUNDIALS_INDEX_SIZE=${SUNDIALS_INDEX_SIZE}, " - "but PETSc was built with ${PETSC_INDEX_SIZE}-bit indices\n" - "PETSC_DIR: ${PETSC_DIR}\n") + string( + CONCAT _err_msg_string + "PETSc not functional due to index size mismatch:\n" + "SUNDIALS_INDEX_SIZE=${SUNDIALS_INDEX_SIZE}, " + "but PETSc was built with ${PETSC_INDEX_SIZE}-bit indices\n" + "PETSC_DIR: ${PETSC_DIR}\n") print_error("${_err_msg_string}") endif() string(TOUPPER "${PETSC_PRECISION}" _petsc_precision) string(TOUPPER "${SUNDIALS_PRECISION}" _sundials_precision) if(NOT ("${_sundials_precision}" MATCHES "${_petsc_precision}")) - string(CONCAT _err_msg_string - "PETSc not functional due to real type precision mismatch:\n" - "SUNDIALS_PRECISION=${_sundials_precision}, " - "but PETSc was built with ${_petsc_precision} precision\n" - "PETSC_DIR: ${PETSC_DIR}\n") + string( + CONCAT _err_msg_string + "PETSc not functional due to real type precision mismatch:\n" + "SUNDIALS_PRECISION=${_sundials_precision}, " + "but PETSc was built with ${_petsc_precision} precision\n" + "PETSC_DIR: ${PETSC_DIR}\n") print_error("${_err_msg_string}") endif() - set(PETSC_WORKS TRUE CACHE BOOL "PETSC works with SUNDIALS as configured" FORCE) + set(PETSC_WORKS + TRUE + CACHE BOOL "PETSC works with SUNDIALS as configured" FORCE) elseif(PETSC_FOUND AND PETSC_WORKS) - message(STATUS "Skipped PETSC tests, assuming PETSC works with SUNDIALS. Set PETSC_WORKS=FALSE to (re)run compatibility test.") + message( + STATUS + "Skipped PETSC tests, assuming PETSC works with SUNDIALS. Set PETSC_WORKS=FALSE to (re)run compatibility test." + ) endif() diff --git a/cmake/tpl/SundialsPOSIXTimers.cmake b/cmake/tpl/SundialsPOSIXTimers.cmake index 4670849ac5..42f41cfac4 100644 --- a/cmake/tpl/SundialsPOSIXTimers.cmake +++ b/cmake/tpl/SundialsPOSIXTimers.cmake @@ -17,20 +17,21 @@ macro(posix_timers_test) - set(options ) + set(options) set(oneValueArgs POSIX RT_LIB) - set(multiValueArgs ) + set(multiValueArgs) # parse keyword arguments/options - cmake_parse_arguments(posix_timers_test - "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + cmake_parse_arguments(posix_timers_test "${options}" "${oneValueArgs}" + "${multiValueArgs}" ${ARGN}) # Test timers with a simple program set(POSIX_TIMER_TEST_DIR ${PROJECT_BINARY_DIR}/POSIX_TIMER_TEST) file(MAKE_DIRECTORY ${POSIX_TIMER_TEST_DIR}) # Create a CMakeLists.txt file which will generate the test executable - file(WRITE ${POSIX_TIMER_TEST_DIR}/CMakeLists.txt + file( + WRITE ${POSIX_TIMER_TEST_DIR}/CMakeLists.txt "CMAKE_MINIMUM_REQUIRED(VERSION ${CMAKE_VERSION})\n" "PROJECT(ltest C)\n" "SET(CMAKE_VERBOSE_MAKEFILE ON)\n" @@ -48,7 +49,8 @@ macro(posix_timers_test) "TARGET_LINK_LIBRARIES(ltest \"${posix_timers_test_RT_LIB}\")\n") # Create a simple C source for testing - file(WRITE ${POSIX_TIMER_TEST_DIR}/ltest.c + file( + WRITE ${POSIX_TIMER_TEST_DIR}/ltest.c "#include \n" "#include \n" "int main(void) {\n" @@ -63,13 +65,14 @@ macro(posix_timers_test) file(REMOVE_RECURSE ${POSIX_TIMER_TEST_DIR}/CMakeFiles) # Use TRY_COMPILE to make the target - try_compile(COMPILE_OK ${POSIX_TIMER_TEST_DIR} ${POSIX_TIMER_TEST_DIR} ltest + try_compile( + COMPILE_OK ${POSIX_TIMER_TEST_DIR} + ${POSIX_TIMER_TEST_DIR} ltest OUTPUT_VARIABLE COMPILE_OUTPUT) endmacro() - -if (NOT SUNDIALS_POSIX_TIMERS) +if(NOT SUNDIALS_POSIX_TIMERS) # Test for timers without any modifications posix_timers_test() @@ -81,7 +84,8 @@ if (NOT SUNDIALS_POSIX_TIMERS) if(NOT COMPILE_OK) posix_timers_test(POSIX "_POSIX_C_SOURCE=200112L") if(COMPILE_OK) - message(STATUS "Looking for POSIX timers (setting _POSIX_C_SOURCE)... found") + message( + STATUS "Looking for POSIX timers (setting _POSIX_C_SOURCE)... found") set(POSIX_TIMERS_NEED_POSIX_C_SOURCE TRUE) endif() endif() @@ -109,9 +113,13 @@ if (NOT SUNDIALS_POSIX_TIMERS) # Test failed, try again linking to rt and with -D_POSIX_C_SOURCE=200112L if((NOT COMPILE_OK) AND SUNDIALS_RT_LIBRARY) - posix_timers_test(POSIX "_POSIX_C_SOURCE=200112L" RT_LIB "${SUNDIALS_RT_LIBRARY}") + posix_timers_test(POSIX "_POSIX_C_SOURCE=200112L" RT_LIB + "${SUNDIALS_RT_LIBRARY}") if(COMPILE_OK) - message(STATUS "Looking for POSIX timers (setting _POSIX_C_SOURCE and linking to rt)... found") + message( + STATUS + "Looking for POSIX timers (setting _POSIX_C_SOURCE and linking to rt)... found" + ) set(POSIX_TIMERS_NEED_POSIX_C_SOURCE TRUE) set(POSIX_TIMERS_NEED_RT_LIBRARY TRUE) set(EXE_EXTRA_LINK_LIBS ${EXE_EXTRA_LINK_LIBS} ${SUNDIALS_RT_LIBRARY}) diff --git a/cmake/tpl/SundialsPthread.cmake b/cmake/tpl/SundialsPthread.cmake index c520064d7b..009b91d3f8 100644 --- a/cmake/tpl/SundialsPthread.cmake +++ b/cmake/tpl/SundialsPthread.cmake @@ -54,4 +54,4 @@ else() set(PTHREADS_FOUND FALSE) message(STATUS "Checking if Pthreads is available... FAILED") print_error("Could not determine Pthreads compiler flags") -endif() \ No newline at end of file +endif() diff --git a/cmake/tpl/SundialsRAJA.cmake b/cmake/tpl/SundialsRAJA.cmake index 6f7ad51809..d6d077d4f6 100644 --- a/cmake/tpl/SundialsRAJA.cmake +++ b/cmake/tpl/SundialsRAJA.cmake @@ -53,27 +53,36 @@ endif() # ----------------------------------------------------------------------------- # find the library configuration file -find_file(RAJA_CONFIGHPP_PATH config.hpp - HINTS "${RAJA_DIR}" - PATH_SUFFIXES include include/RAJA - NO_DEFAULT_PATH) +find_file( + RAJA_CONFIGHPP_PATH config.hpp + HINTS "${RAJA_DIR}" + PATH_SUFFIXES include include/RAJA + NO_DEFAULT_PATH) mark_as_advanced(FORCE RAJA_CONFIGHPP_PATH) # Look for CMake configuration file in RAJA installation -find_package(RAJA CONFIG - PATHS "${RAJA_DIR}" "${RAJA_DIR}/share/raja/cmake" - NO_DEFAULT_PATH - REQUIRED) +find_package( + RAJA + CONFIG + PATHS + "${RAJA_DIR}" + "${RAJA_DIR}/share/raja/cmake" + NO_DEFAULT_PATH + REQUIRED) # determine the backends foreach(_backend CUDA HIP OPENMP TARGET_OPENMP SYCL) - file(STRINGS "${RAJA_CONFIGHPP_PATH}" _raja_has_backend REGEX "^#define RAJA_ENABLE_${_backend}\$") + file(STRINGS "${RAJA_CONFIGHPP_PATH}" _raja_has_backend + REGEX "^#define RAJA_ENABLE_${_backend}\$") if(_raja_has_backend) set(RAJA_BACKENDS "${_backend};${RAJA_BACKENDS}") endif() endforeach() -message(STATUS "RAJA Version: ${RAJA_VERSION_MAJOR}.${RAJA_VERSION_MINOR}.${RAJA_VERSION_PATCHLEVEL}") +message( + STATUS + "RAJA Version: ${RAJA_VERSION_MAJOR}.${RAJA_VERSION_MINOR}.${RAJA_VERSION_PATCHLEVEL}" +) message(STATUS "RAJA Backends: ${RAJA_BACKENDS}") set(RAJA_NEEDS_THREADS OFF) @@ -94,25 +103,34 @@ endif() # Section 4: Test the TPL # ----------------------------------------------------------------------------- -if((SUNDIALS_RAJA_BACKENDS MATCHES "CUDA") AND - (NOT RAJA_BACKENDS MATCHES "CUDA")) - print_error("Requested that SUNDIALS uses the CUDA RAJA backend, but RAJA was not built with the CUDA backend.") +if((SUNDIALS_RAJA_BACKENDS MATCHES "CUDA") AND (NOT RAJA_BACKENDS MATCHES "CUDA" + )) + print_error( + "Requested that SUNDIALS uses the CUDA RAJA backend, but RAJA was not built with the CUDA backend." + ) endif() -if((SUNDIALS_RAJA_BACKENDS MATCHES "HIP") AND - (NOT RAJA_BACKENDS MATCHES "HIP")) - print_error("Requested that SUNDIALS uses the HIP RAJA backend, but RAJA was not built with the HIP backend.") +if((SUNDIALS_RAJA_BACKENDS MATCHES "HIP") AND (NOT RAJA_BACKENDS MATCHES "HIP")) + print_error( + "Requested that SUNDIALS uses the HIP RAJA backend, but RAJA was not built with the HIP backend." + ) endif() if(NOT ENABLE_OPENMP AND RAJA_BACKENDS MATCHES "OPENMP") - print_error("RAJA was built with OpenMP, but OpenMP is not enabled. Set ENABLE_OPENMP to ON.") + print_error( + "RAJA was built with OpenMP, but OpenMP is not enabled. Set ENABLE_OPENMP to ON." + ) endif() if(NOT ENABLE_OPENMP_DEVICE AND RAJA_BACKENDS MATCHES "TARGET_OPENMP") - print_error("RAJA was built with OpenMP device offloading, but OpenMP with device offloading is not enabled. Set ENABLE_OPENMP_DEVICE to ON.") + print_error( + "RAJA was built with OpenMP device offloading, but OpenMP with device offloading is not enabled. Set ENABLE_OPENMP_DEVICE to ON." + ) endif() -if((SUNDIALS_RAJA_BACKENDS MATCHES "SYCL") AND - (NOT RAJA_BACKENDS MATCHES "SYCL")) - print_error("Requested that SUNDIALS uses the SYCL RAJA backend, but RAJA was not built with the SYCL backend.") +if((SUNDIALS_RAJA_BACKENDS MATCHES "SYCL") AND (NOT RAJA_BACKENDS MATCHES "SYCL" + )) + print_error( + "Requested that SUNDIALS uses the SYCL RAJA backend, but RAJA was not built with the SYCL backend." + ) endif() diff --git a/cmake/tpl/SundialsSuperLUDIST.cmake b/cmake/tpl/SundialsSuperLUDIST.cmake index c5699a87d5..b065e6c1e3 100644 --- a/cmake/tpl/SundialsSuperLUDIST.cmake +++ b/cmake/tpl/SundialsSuperLUDIST.cmake @@ -38,7 +38,8 @@ endif() # SuperLU_DIST only supports double precision if(SUNDIALS_PRECISION MATCHES "SINGLE" OR SUNDIALS_PRECISION MATCHES "EXTENDED") - print_error("SuperLU_DIST is not compatible with ${SUNDIALS_PRECISION} precision") + print_error( + "SuperLU_DIST is not compatible with ${SUNDIALS_PRECISION} precision") endif() # Using SUPERLUDIST requires building with MPI enabled @@ -47,8 +48,11 @@ if(ENABLE_SUPERLUDIST AND NOT ENABLE_MPI) endif() # Using SUPERLUDIST with OpenMP requires building with OpenMP enabled -if(ENABLE_SUPERLUDIST AND SUPERLUDIST_OpenMP AND NOT ENABLE_OPENMP) - print_error("OpenMP is required for SuperLU DIST support. Set ENABLE_OPENMP to ON.") +if(ENABLE_SUPERLUDIST + AND SUPERLUDIST_OpenMP + AND NOT ENABLE_OPENMP) + print_error( + "OpenMP is required for SuperLU DIST support. Set ENABLE_OPENMP to ON.") endif() # ----------------------------------------------------------------------------- @@ -77,25 +81,41 @@ message(STATUS "SUPERLUDIST_ROCM: ${SUPERLUDIST_ROCM}") if(SUPERLUDIST_FOUND AND (NOT SUPERLUDIST_WORKS)) if(SUPERLUDIST_CUDA AND (NOT ENABLE_CUDA)) - message(FATAL_ERROR "SuperLU_DIST was built with CUDA but SUNDIALS does not have CUDA enabled. Set ENABLE_CUDA=TRUE.") + message( + FATAL_ERROR + "SuperLU_DIST was built with CUDA but SUNDIALS does not have CUDA enabled. Set ENABLE_CUDA=TRUE." + ) endif() if(SUPERLUDIST_HIP AND (NOT ENABLE_HIP)) - message(FATAL_ERROR "SuperLU_DIST was built with HIP but SUNDIALS does not have HIP enabled. Set ENABLE_HIP=TRUE.") + message( + FATAL_ERROR + "SuperLU_DIST was built with HIP but SUNDIALS does not have HIP enabled. Set ENABLE_HIP=TRUE." + ) endif() # Check index size if(NOT (SUNDIALS_INDEX_SIZE STREQUAL SUPERLUDIST_INDEX_SIZE)) - set(_err_msg_string "SuperLU_DIST not functional due to index size mismatch:\n") - string(APPEND _err_msg_string "SUNDIALS_INDEX_SIZE=${SUNDIALS_INDEX_SIZE}, but SuperLU_DIST was built with ${SUPERLUDIST_INDEX_SIZE}-bit indices\n") - string(APPEND _err_msg_string "SUPERLUDIST_INCLUDE_DIRS: ${SUPERLUDIST_INCLUDE_DIRS}\n") + set(_err_msg_string + "SuperLU_DIST not functional due to index size mismatch:\n") + string( + APPEND + _err_msg_string + "SUNDIALS_INDEX_SIZE=${SUNDIALS_INDEX_SIZE}, but SuperLU_DIST was built with ${SUPERLUDIST_INDEX_SIZE}-bit indices\n" + ) + string(APPEND _err_msg_string + "SUPERLUDIST_INCLUDE_DIRS: ${SUPERLUDIST_INCLUDE_DIRS}\n") message(FATAL_ERROR "${_err_msg_string}") endif() - message(STATUS "Checking if SuperLU_DIST works with SUNDIALS... OK") - set(SUPERLUDIST_WORKS TRUE CACHE BOOL "SuperLU_DIST works with SUNDIALS as configured" FORCE) + set(SUPERLUDIST_WORKS + TRUE + CACHE BOOL "SuperLU_DIST works with SUNDIALS as configured" FORCE) elseif(SUPERLUDIST_FOUND AND SUPERLUDIST_WORKS) - message(STATUS "Skipped SuperLU_DIST tests, assuming SuperLU_DIST works with SUNDIALS. Set SUPERLUDIST_WORKS=FALSE to (re)run compatibility test.") + message( + STATUS + "Skipped SuperLU_DIST tests, assuming SuperLU_DIST works with SUNDIALS. Set SUPERLUDIST_WORKS=FALSE to (re)run compatibility test." + ) endif() diff --git a/cmake/tpl/SundialsSuperLUMT.cmake b/cmake/tpl/SundialsSuperLUMT.cmake index 4691e94544..ee435ee8de 100644 --- a/cmake/tpl/SundialsSuperLUMT.cmake +++ b/cmake/tpl/SundialsSuperLUMT.cmake @@ -38,7 +38,8 @@ endif() # SUPERLUMT does not support extended precision if(SUNDIALS_PRECISION MATCHES "EXTENDED") - print_error("SUPERLUMT is not compatible with ${SUNDIALS_PRECISION} precision") + print_error( + "SUPERLUMT is not compatible with ${SUNDIALS_PRECISION} precision") endif() # ----------------------------------------------------------------------------- @@ -61,7 +62,8 @@ if(SUPERLUMT_FOUND AND (NOT SUPERLUMT_WORKS)) file(MAKE_DIRECTORY ${SUPERLUMT_TEST_DIR}) # Create a CMakeLists.txt file - file(WRITE ${SUPERLUMT_TEST_DIR}/CMakeLists.txt + file( + WRITE ${SUPERLUMT_TEST_DIR}/CMakeLists.txt "CMAKE_MINIMUM_REQUIRED(VERSION ${CMAKE_VERSION})\n" "PROJECT(ltest C)\n" "SET(CMAKE_VERBOSE_MAKEFILE ON)\n" @@ -78,7 +80,8 @@ if(SUPERLUMT_FOUND AND (NOT SUPERLUMT_WORKS)) "TARGET_LINK_LIBRARIES(ltest ${SUPERLUMT_LIBRARIES})\n") # Create a C source file which calls a SUPERLUMT function - file(WRITE ${SUPERLUMT_TEST_DIR}/ltest.c + file( + WRITE ${SUPERLUMT_TEST_DIR}/ltest.c "\#include \"slu_mt_ddefs.h\"\n" "int main(void) {\n" "SuperMatrix *A;\n" @@ -89,19 +92,22 @@ if(SUPERLUMT_FOUND AND (NOT SUPERLUMT_WORKS)) "else return(0);\n" "}\n") - # Attempt to build and link the "ltest" executable - try_compile(COMPILE_OK ${SUPERLUMT_TEST_DIR} ${SUPERLUMT_TEST_DIR} ltest + try_compile( + COMPILE_OK ${SUPERLUMT_TEST_DIR} + ${SUPERLUMT_TEST_DIR} ltest OUTPUT_VARIABLE COMPILE_OUTPUT) # To ensure we do not use stuff from the previous attempts, # we must remove the CMakeFiles directory. file(REMOVE_RECURSE ${SUPERLUMT_TEST_DIR}/CMakeFiles) - # Process test result + # Process test result if(COMPILE_OK) message(STATUS "Checking if SuperLU_MT works with SUNDIALS... OK") - set(SUPERLUMT_WORKS TRUE CACHE BOOL "SuperLU_MT works with SUNDIALS as configured" FORCE) + set(SUPERLUMT_WORKS + TRUE + CACHE BOOL "SuperLU_MT works with SUNDIALS as configured" FORCE) else() message(STATUS "Checking if SuperLU_MT works with SUNDIALS... FAILED") message(STATUS "Check output: ") @@ -110,5 +116,8 @@ if(SUPERLUMT_FOUND AND (NOT SUPERLUMT_WORKS)) endif() elseif(SUPERLUMT_FOUND AND SUPERLUMT_WORKS) - message(STATUS "Skipped SuperLU_MT tests, assuming SuperLU_MT works with SUNDIALS. Set SUPERLUMT_WORKS=FALSE to (re)run compatibility test.") + message( + STATUS + "Skipped SuperLU_MT tests, assuming SuperLU_MT works with SUNDIALS. Set SUPERLUMT_WORKS=FALSE to (re)run compatibility test." + ) endif() diff --git a/cmake/tpl/SundialsTrilinos.cmake b/cmake/tpl/SundialsTrilinos.cmake index 4b8e7e4593..a3ee9461b3 100644 --- a/cmake/tpl/SundialsTrilinos.cmake +++ b/cmake/tpl/SundialsTrilinos.cmake @@ -67,30 +67,59 @@ endif() if(USE_XSDK_DEFAULTS) if(Trilinos_MPI AND MPI_CXX_FOUND) - force_variable(Trilinos_INTERFACE_CXX_COMPILER STRING "C++ compiler for Trilinos interface" "${MPI_CXX_COMPILER}") - set(Trilinos_INTERFACE_MPI_CXX_FOUND ${Trilinos_MPI} CACHE INTERNAL "Is Trilinos interface C++ compiler MPI") + force_variable(Trilinos_INTERFACE_CXX_COMPILER STRING + "C++ compiler for Trilinos interface" "${MPI_CXX_COMPILER}") + set(Trilinos_INTERFACE_MPI_CXX_FOUND + ${Trilinos_MPI} + CACHE INTERNAL "Is Trilinos interface C++ compiler MPI") else() - force_variable(Trilinos_INTERFACE_CXX_COMPILER STRING "C compiler for Trilinos interface" "${CMAKE_CXX_COMPILER}") - set(Trilinos_INTERFACE_MPI_CXX_FOUND FALSE CACHE INTERNAL "Is Trilinos interface C++ compiler MPI") + force_variable(Trilinos_INTERFACE_CXX_COMPILER STRING + "C compiler for Trilinos interface" "${CMAKE_CXX_COMPILER}") + set(Trilinos_INTERFACE_MPI_CXX_FOUND + FALSE + CACHE INTERNAL "Is Trilinos interface C++ compiler MPI") endif() if(Trilinos_MPI AND MPI_C_FOUND) - force_variable(Trilinos_INTERFACE_C_COMPILER STRING "C compiler for Trilinos interface" "${MPI_C_COMPILER}") - set(Trilinos_INTERFACE_MPI_C_FOUND ${Trilinos_MPI} CACHE INTERNAL "Is Trilinos interface C compiler MPI") + force_variable(Trilinos_INTERFACE_C_COMPILER STRING + "C compiler for Trilinos interface" "${MPI_C_COMPILER}") + set(Trilinos_INTERFACE_MPI_C_FOUND + ${Trilinos_MPI} + CACHE INTERNAL "Is Trilinos interface C compiler MPI") else() - force_variable(Trilinos_INTERFACE_C_COMPILER STRING "C compiler for Trilinos interface" "${CMAKE_C_COMPILER}") - set(Trilinos_INTERFACE_MPI_C_FOUND FALSE CACHE INTERNAL "Is Trilinos interface C compiler MPI") + force_variable(Trilinos_INTERFACE_C_COMPILER STRING + "C compiler for Trilinos interface" "${CMAKE_C_COMPILER}") + set(Trilinos_INTERFACE_MPI_C_FOUND + FALSE + CACHE INTERNAL "Is Trilinos interface C compiler MPI") endif() - force_variable(Trilinos_INTERFACE_CXX_COMPILER_FLAGS STRING "C++ compiler flags specific to Trilinos interface" "") - force_variable(Trilinos_INTERFACE_C_COMPILER_FLAGS STRING "C compiler flags specific to Trilinos interface" "") - force_variable(Trilinos_INTERFACE_MPIEXEC STRING "MPI executable for Trilinos interface" "${MPIEXEC_EXECUTABLE}") + force_variable(Trilinos_INTERFACE_CXX_COMPILER_FLAGS STRING + "C++ compiler flags specific to Trilinos interface" "") + force_variable(Trilinos_INTERFACE_C_COMPILER_FLAGS STRING + "C compiler flags specific to Trilinos interface" "") + force_variable( + Trilinos_INTERFACE_MPIEXEC STRING "MPI executable for Trilinos interface" + "${MPIEXEC_EXECUTABLE}") else() - force_variable(Trilinos_INTERFACE_CXX_COMPILER STRING "C++ compiler for Trilinos interface" "${Trilinos_CXX_COMPILER}") - force_variable(Trilinos_INTERFACE_C_COMPILER STRING "C compiler for Trilinos interface" "${Trilinos_C_COMPILER}") - force_variable(Trilinos_INTERFACE_CXX_COMPILER_FLAGS STRING "C++ compiler flags for Trilinos interface" "${Trilinos_CXX_COMPILER_FLAGS}") - force_variable(Trilinos_INTERFACE_C_COMPILER_FLAGS STRING "C compiler flags for Trilinos interface" "${Trilinos_C_COMPILER_FLAGS}") - force_variable(Trilinos_INTERFACE_MPIEXEC STRING "MPI executable for Trilinos interface" "${Trilinos_MPI_EXEC}") - set(Trilinos_INTERFACE_MPI_CXX_FOUND ${Trilinos_MPI} CACHE INTERNAL "Is Trilinos interface C++ compiler MPI") - set(Trilinos_INTERFACE_MPI_C_FOUND ${Trilinos_MPI} CACHE INTERNAL "Is Trilinos interface C compiler MPI") + force_variable( + Trilinos_INTERFACE_CXX_COMPILER STRING + "C++ compiler for Trilinos interface" "${Trilinos_CXX_COMPILER}") + force_variable(Trilinos_INTERFACE_C_COMPILER STRING + "C compiler for Trilinos interface" "${Trilinos_C_COMPILER}") + force_variable( + Trilinos_INTERFACE_CXX_COMPILER_FLAGS STRING + "C++ compiler flags for Trilinos interface" + "${Trilinos_CXX_COMPILER_FLAGS}") + force_variable( + Trilinos_INTERFACE_C_COMPILER_FLAGS STRING + "C compiler flags for Trilinos interface" "${Trilinos_C_COMPILER_FLAGS}") + force_variable(Trilinos_INTERFACE_MPIEXEC STRING + "MPI executable for Trilinos interface" "${Trilinos_MPI_EXEC}") + set(Trilinos_INTERFACE_MPI_CXX_FOUND + ${Trilinos_MPI} + CACHE INTERNAL "Is Trilinos interface C++ compiler MPI") + set(Trilinos_INTERFACE_MPI_C_FOUND + ${Trilinos_MPI} + CACHE INTERNAL "Is Trilinos interface C compiler MPI") endif() message(STATUS "Trilinos_MPI: ${Trilinos_MPI}") @@ -109,7 +138,8 @@ if(Trilinos_FOUND AND (NOT Trilinos_WORKS)) file(MAKE_DIRECTORY ${Trilinos_TEST_DIR}) # Create a CMakeLists.txt file - file(WRITE ${Trilinos_TEST_DIR}/CMakeLists.txt + file( + WRITE ${Trilinos_TEST_DIR}/CMakeLists.txt "CMAKE_MINIMUM_REQUIRED(VERSION ${CMAKE_VERSION})\n" "PROJECT(ltest CXX)\n" "SET(CMAKE_VERBOSE_MAKEFILE ON)\n" @@ -125,20 +155,21 @@ if(Trilinos_FOUND AND (NOT Trilinos_WORKS)) # Create a C++ source file which calls a Trilinos function file(WRITE ${Trilinos_TEST_DIR}/ltest.cpp - "#include \n" - "int main(void) {\n" - "std::cout << Tpetra::version() << std::endl;\n" - "return(0);\n" - "}\n") + "#include \n" "int main(void) {\n" + "std::cout << Tpetra::version() << std::endl;\n" "return(0);\n" "}\n") # Attempt to build and link the "ltest" executable - try_compile(COMPILE_OK ${Trilinos_TEST_DIR} ${Trilinos_TEST_DIR} ltest + try_compile( + COMPILE_OK ${Trilinos_TEST_DIR} + ${Trilinos_TEST_DIR} ltest OUTPUT_VARIABLE COMPILE_OUTPUT) # Process test result if(COMPILE_OK) message(STATUS "Checking if Trilinos works with SUNDIALS... OK") - set(Trilinos_WORKS TRUE CACHE BOOL "Trilinos works with SUNDIALS as configured" FORCE) + set(Trilinos_WORKS + TRUE + CACHE BOOL "Trilinos works with SUNDIALS as configured" FORCE) else() message(STATUS "Checking if Trilinos works with SUNDIALS... FAILED") message(STATUS "Check output: ") @@ -147,5 +178,8 @@ if(Trilinos_FOUND AND (NOT Trilinos_WORKS)) endif() elseif(Trilinos_FOUND AND Trilinos_WORKS) - message(STATUS "Skipped Trilinos tests, assuming Trilinos works with SUNDIALS. Set Trilinos_WORKS=FALSE to (re)run compatibility test.") + message( + STATUS + "Skipped Trilinos tests, assuming Trilinos works with SUNDIALS. Set Trilinos_WORKS=FALSE to (re)run compatibility test." + ) endif() diff --git a/cmake/tpl/SundialsXBRAID.cmake b/cmake/tpl/SundialsXBRAID.cmake index e8e8ceb941..6d5acbac6b 100644 --- a/cmake/tpl/SundialsXBRAID.cmake +++ b/cmake/tpl/SundialsXBRAID.cmake @@ -38,20 +38,21 @@ endif() # Using XBRAID requires building with MPI enabled if(NOT ENABLE_MPI) - message(FATAL_ERROR - "MPI is required for XBraid support. Set ENABLE_MPI to ON.") + message( + FATAL_ERROR "MPI is required for XBraid support. Set ENABLE_MPI to ON.") endif() # XBraid does not support single or extended precision if(SUNDIALS_PRECISION MATCHES "SINGLE" OR SUNDIALS_PRECISION MATCHES "EXTENDED") - message(FATAL_ERROR - "XBraid is not compatible with ${SUNDIALS_PRECISION} precision") + message( + FATAL_ERROR "XBraid is not compatible with ${SUNDIALS_PRECISION} precision") endif() # XBraid does not support 64-bit index sizes if(SUNDIALS_INDEX_SIZE MATCHES "64") - message(FATAL_ERROR - "XBraid is not compatible with ${SUNDIALS_INDEX_SIZE}-bit indices") + message( + FATAL_ERROR + "XBraid is not compatible with ${SUNDIALS_INDEX_SIZE}-bit indices") endif() # ----------------------------------------------------------------------------- @@ -76,7 +77,8 @@ if(XBRAID_FOUND AND (NOT XBRAID_WORKS)) file(MAKE_DIRECTORY ${XBRAID_TEST_DIR}) # Create a CMakeLists.txt file - file(WRITE ${XBRAID_TEST_DIR}/CMakeLists.txt + file( + WRITE ${XBRAID_TEST_DIR}/CMakeLists.txt "cmake_minimum_required(VERSION ${CMAKE_VERSION})\n" "project(ltest C)\n" "set(CMAKE_VERBOSE_MAKEFILE ON)\n" @@ -94,7 +96,8 @@ if(XBRAID_FOUND AND (NOT XBRAID_WORKS)) "target_link_libraries(ltest m)\n") # Create a C source file - file(WRITE ${XBRAID_TEST_DIR}/ltest.c + file( + WRITE ${XBRAID_TEST_DIR}/ltest.c "\#include \n" "\#include \"braid.h\"\n" "int main(void) {\n" @@ -109,13 +112,17 @@ if(XBRAID_FOUND AND (NOT XBRAID_WORKS)) file(REMOVE_RECURSE ${XBRAID_TEST_DIR}/CMakeFiles) # Attempt to build and link the "ltest" executable - try_compile(COMPILE_OK ${XBRAID_TEST_DIR} ${XBRAID_TEST_DIR} ltest + try_compile( + COMPILE_OK ${XBRAID_TEST_DIR} + ${XBRAID_TEST_DIR} ltest OUTPUT_VARIABLE COMPILE_OUTPUT) # Process test result if(COMPILE_OK) message(STATUS "Checking if XBRAID works... OK") - set(XBRAID_WORKS TRUE CACHE BOOL "XBRAID works as configured" FORCE) + set(XBRAID_WORKS + TRUE + CACHE BOOL "XBRAID works as configured" FORCE) else() message(STATUS "Checking if XBRAID works... FAILED") message(STATUS "Check output: ")