diff --git a/CMakeLists.txt b/CMakeLists.txt index 0f8fa7933f..c994d76555 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,12 +31,13 @@ endif() project(SUNDIALS C) # Specify the location of additional CMAKE modules -set(CMAKE_MODULE_PATH +set( + CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake ${PROJECT_SOURCE_DIR}/cmake/macros ${PROJECT_SOURCE_DIR}/cmake/tpl - ) +) # MACRO definitions include(SundialsCMakeMacros) @@ -44,7 +45,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") @@ -62,12 +62,14 @@ set(PACKAGE_VERSION_PATCH "0") set(PACKAGE_VERSION_LABEL "") if(PACKAGE_VERSION_LABEL) - set(PACKAGE_VERSION - "${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR}.${PACKAGE_VERSION_PATCH}-${PACKAGE_VERSION_LABEL}" + set( + PACKAGE_VERSION + "${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR}.${PACKAGE_VERSION_PATCH}-${PACKAGE_VERSION_LABEL}" ) else() - set(PACKAGE_VERSION - "${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR}.${PACKAGE_VERSION_PATCH}" + set( + PACKAGE_VERSION + "${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR}.${PACKAGE_VERSION_PATCH}" ) endif() @@ -106,8 +108,9 @@ set(sunlinsollib_SOVERSION "5") set(sunnonlinsollib_VERSION "4.1.0") set(sunnonlinsollib_SOVERSION "4") -set(sundialslib_VERSION - "${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR}.${PACKAGE_VERSION_PATCH}" +set( + sundialslib_VERSION + "${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR}.${PACKAGE_VERSION_PATCH}" ) set(sundialslib_SOVERSION "${PACKAGE_VERSION_MAJOR}") @@ -121,7 +124,12 @@ if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}") endif() # Organize targets into folders when using an IDE -set_property(GLOBAL PROPERTY USE_FOLDERS ON) +set_property( + GLOBAL + PROPERTY + USE_FOLDERS + ON +) # Get correct build paths automatically, but expose LIBDIR and # INCLUDEDIR as a regular cache variable so that a user can more @@ -131,25 +139,36 @@ mark_as_advanced(CLEAR CMAKE_INSTALL_LIBDIR) mark_as_advanced(CLEAR CMAKE_INSTALL_INCLUDEDIR) # Suffixes to use for static and shared targets. -set(_STATIC_LIB_SUFFIX - "_static" - CACHE INTERNAL "" FORCE -) -set(_SHARED_LIB_SUFFIX - "_shared" - CACHE INTERNAL "" FORCE -) +set(_STATIC_LIB_SUFFIX "_static" CACHE INTERNAL "" FORCE) +set(_SHARED_LIB_SUFFIX "_shared" CACHE INTERNAL "" FORCE) # A list of all the alias targets created. -set(_SUNDIALS_ALIAS_TARGETS "" - CACHE INTERNAL "" FORCE) +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() @@ -230,13 +249,17 @@ endif() # =============================================================== # install sundials_export header file -install(FILES "${PROJECT_BINARY_DIR}/include/sundials/sundials_export.h" - DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/sundials" +install( + FILES + "${PROJECT_BINARY_DIR}/include/sundials/sundials_export.h" + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/sundials" ) # install configured header file -install(FILES "${PROJECT_BINARY_DIR}/include/sundials/sundials_config.h" - DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/sundials" +install( + FILES + "${PROJECT_BINARY_DIR}/include/sundials/sundials_config.h" + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/sundials" ) # install shared Fortran 2003 modules @@ -245,22 +268,30 @@ if(BUILD_FORTRAN_MODULE_INTERFACE) # libraries, they are identical. So only install one set # of the .mod files. if(BUILD_STATIC_LIBS) - install(DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}_STATIC/ - DESTINATION ${Fortran_INSTALL_MODDIR} + install( + DIRECTORY + ${CMAKE_Fortran_MODULE_DIRECTORY}_STATIC/ + DESTINATION ${Fortran_INSTALL_MODDIR} ) else() - install(DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}_SHARED/ - DESTINATION ${Fortran_INSTALL_MODDIR} + install( + DIRECTORY + ${CMAKE_Fortran_MODULE_DIRECTORY}_SHARED/ + DESTINATION ${Fortran_INSTALL_MODDIR} ) endif() endif() # install license and notice files -install(FILES "${PROJECT_SOURCE_DIR}/LICENSE" - DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/sundials" +install( + FILES + "${PROJECT_SOURCE_DIR}/LICENSE" + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/sundials" ) -install(FILES "${PROJECT_SOURCE_DIR}/NOTICE" - DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/sundials" +install( + FILES + "${PROJECT_SOURCE_DIR}/NOTICE" + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/sundials" ) # create package version file @@ -285,9 +316,11 @@ configure_package_config_file( "${CMAKE_CURRENT_BINARY_DIR}/SUNDIALSConfig.cmake" INSTALL_DESTINATION "${SUNDIALS_INSTALL_CMAKEDIR}" ) -install(FILES "${CMAKE_CURRENT_BINARY_DIR}/SUNDIALSConfig.cmake" - "${CMAKE_CURRENT_BINARY_DIR}/SUNDIALSConfigVersion.cmake" - DESTINATION "${SUNDIALS_INSTALL_CMAKEDIR}" +install( + FILES + "${CMAKE_CURRENT_BINARY_DIR}/SUNDIALSConfig.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/SUNDIALSConfigVersion.cmake" + DESTINATION "${SUNDIALS_INSTALL_CMAKEDIR}" ) # Export targets so build directory can be used directly diff --git a/cmake/SundialsBuildOptionsPost.cmake b/cmake/SundialsBuildOptionsPost.cmake index 01d6969bc6..c32b582e58 100644 --- a/cmake/SundialsBuildOptionsPost.cmake +++ b/cmake/SundialsBuildOptionsPost.cmake @@ -26,9 +26,16 @@ 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 +45,179 @@ 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 +234,80 @@ 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 +330,131 @@ 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 +465,14 @@ 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..eba5d42306 100644 --- a/cmake/SundialsBuildOptionsPre.cmake +++ b/cmake/SundialsBuildOptionsPre.cmake @@ -33,7 +33,12 @@ 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 +70,10 @@ 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 +86,47 @@ 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 +134,21 @@ 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 +162,10 @@ 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 +228,9 @@ 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,44 +244,74 @@ 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 # --------------------------------------------------------------- set(DOCSTR "Path to SUNDIALS cmake files") -sundials_option(SUNDIALS_INSTALL_CMAKEDIR STRING "${DOCSTR}" - "${CMAKE_INSTALL_LIBDIR}/cmake/sundials") +sundials_option( + SUNDIALS_INSTALL_CMAKEDIR + STRING + "${DOCSTR}" + "${CMAKE_INSTALL_LIBDIR}/cmake/sundials" +) # --------------------------------------------------------------- # 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) +sundials_option( + ENABLE_WARNINGS_AS_ERRORS + BOOL + "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 # --------------------------------------------------------------- # List of debugging options (used to add preprocessor directives) -set(_SUNDIALS_DEBUG_OPTIONS +set( + _SUNDIALS_DEBUG_OPTIONS SUNDIALS_DEBUG SUNDIALS_DEBUG_ASSERT SUNDIALS_DEBUG_CUDA_LASTERROR SUNDIALS_DEBUG_HIP_LASTERROR - SUNDIALS_DEBUG_PRINTVEC) + SUNDIALS_DEBUG_PRINTVEC +) -sundials_option(SUNDIALS_DEBUG BOOL - "Enable additional debugging output and options" OFF - ADVANCED) +sundials_option( + SUNDIALS_DEBUG + BOOL + "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") @@ -241,25 +319,47 @@ if(SUNDIALS_DEBUG AND SUNDIALS_LOGGING_LEVEL LESS 4) 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 - ADVANCED) - -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 - ADVANCED) - -sundials_option(SUNDIALS_DEBUG_PRINTVEC BOOL - "Enable vector printing when debugging" OFF - DEPENDS_ON SUNDIALS_DEBUG - ADVANCED) +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 + ADVANCED +) + +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 + ADVANCED +) if(SUNDIALS_DEBUG_PRINTVEC AND SUNDIALS_LOGGING_LEVEL LESS 5) set(DOCSTR "SUNDIALS_DEBUG_PRINTVEC=ON forced the logging level to 5") @@ -271,65 +371,160 @@ endif() # Options for SUNDIALS external # --------------------------------------------------------------- -sundials_option(SUNDIALS_ENABLE_EXTERNAL_ADDONS BOOL - "Enables including EXTERNALLY MAINTAINED addons in the SUNDIALS build." OFF) +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 - "Precision for floating point comparisons (number of digits)" "-1" ADVANCED) - -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) - -sundials_option(SUNDIALS_TEST_ANSWER_DIR PATH - "Location of testing answer files" "" ADVANCED) - -sundials_option(SUNDIALS_TEST_PROFILE BOOL - "Use Caliper to profile SUNDIALS tests" OFF ADVANCED) - -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_RUN_EXTRA_ARGS STRING - "Extra arguments to pass to docker/podman run command" "--tls-verify=false" ADVANCED) - -sundials_option(SUNDIALS_TEST_CONTAINER_MNT STRING - "Path to project root inside the container" "/sundials" ADVANCED) +sundials_option( + SUNDIALS_TEST_FLOAT_PRECISION + STRING + "Precision for floating point comparisons (number of digits)" + "-1" + ADVANCED +) + +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 +) + +sundials_option( + SUNDIALS_TEST_ANSWER_DIR + PATH + "Location of testing answer files" + "" + ADVANCED +) + +sundials_option( + SUNDIALS_TEST_PROFILE + BOOL + "Use Caliper to profile SUNDIALS tests" + OFF + ADVANCED +) + +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_RUN_EXTRA_ARGS + STRING + "Extra arguments to pass to docker/podman run command" + "--tls-verify=false" + ADVANCED +) + +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) +sundials_option( + SUNDIALS_TEST_DEVTESTS + BOOL + "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_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_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_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_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_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_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_GPUS + STRING + "Number of GPUs to run benchmarks with" + "4" + ADVANCED +) diff --git a/cmake/SundialsDeprecated.cmake b/cmake/SundialsDeprecated.cmake index 702ee00aa5..a872400366 100644 --- a/cmake/SundialsDeprecated.cmake +++ b/cmake/SundialsDeprecated.cmake @@ -17,10 +17,17 @@ # 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") + 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" + ) endif() unset(F2003_INTERFACE_ENABLE CACHE) @@ -30,120 +37,209 @@ unset(F2003_INTERFACE_ENABLE CACHE) # if(DEFINED MPI_ENABLE) - print_warning("The CMake option MPI_ENABLE is deprecated" "Use ENABLE_MPI instead" - MODE DEPRECATION) + 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) + 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) + 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 + ) 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) + 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 + ) 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) + 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) + 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) + 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 + ) 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) + 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 + ) 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) + 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 + ) 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) + 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) + 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) + 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) + 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 +249,19 @@ 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..bc1548fec2 100644 --- a/cmake/SundialsExampleOptions.cmake +++ b/cmake/SundialsExampleOptions.cmake @@ -22,9 +22,27 @@ 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) @@ -42,27 +60,35 @@ if(BUILD_FORTRAN_MODULE_INTERFACE) # 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() - endif() # ----------------------------------------------------------------------------- # Options for CUDA Examples # ----------------------------------------------------------------------------- -sundials_option(EXAMPLES_ENABLE_CUDA BOOL "Build SUNDIALS CUDA examples" ON - DEPENDS_ON ENABLE_CUDA) +sundials_option( + EXAMPLES_ENABLE_CUDA + BOOL + "Build SUNDIALS CUDA examples" + ON + DEPENDS_ON + ENABLE_CUDA +) # ----------------------------------------------------------------------------- # Options for installing examples @@ -71,24 +97,41 @@ 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) + 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 + ) endif() # ----------------------------------------------------------------------------- # Internal variables. # ----------------------------------------------------------------------------- -if(EXAMPLES_ENABLE_C OR - EXAMPLES_ENABLE_CXX OR - EXAMPLES_ENABLE_CUDA OR - EXAMPLES_ENABLE_F2003) +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 "") diff --git a/cmake/SundialsIndexSize.cmake b/cmake/SundialsIndexSize.cmake index 88c676b41b..35ce0c888a 100644 --- a/cmake/SundialsIndexSize.cmake +++ b/cmake/SundialsIndexSize.cmake @@ -25,15 +25,22 @@ 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) + set( + POSSIBLE_INT64 + int64_t;__int64;long + long;long + ) endif() foreach(INT64_TYPE ${POSSIBLE_INT64}) string(REPLACE " " "_" INT64_TYPE_NOSPACE ${INT64_TYPE}) - check_type_size("${INT64_TYPE}" HAS_${INT64_TYPE_NOSPACE}) + check_type_size( + "${INT64_TYPE}" + HAS_${INT64_TYPE_NOSPACE} + ) if(HAS_${INT64_TYPE_NOSPACE} EQUAL "8") set(SUNDIALS_CINDEX_TYPE ${INT64_TYPE}) message(STATUS "Using ${INT64_TYPE} for indices") @@ -42,9 +49,11 @@ 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.") + Try setting the advanced option SUNDIALS_INDEX_TYPE." + ) endif() # set Fortran integer size too @@ -53,7 +62,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) @@ -61,7 +70,10 @@ elseif(SUNDIALS_INDEX_SIZE MATCHES "32") foreach(INT32_TYPE ${POSSIBLE_INT32}) string(REPLACE " " "_" INT32_TYPE_NOSPACE ${INT32_TYPE}) - check_type_size("${INT32_TYPE}" HAS_${INT32_TYPE_NOSPACE}) + check_type_size( + "${INT32_TYPE}" + HAS_${INT32_TYPE_NOSPACE} + ) if(HAS_${INT32_TYPE_NOSPACE} EQUAL "4") set(SUNDIALS_CINDEX_TYPE ${INT32_TYPE}) message(STATUS "Using ${INT32_TYPE} for indices") @@ -70,9 +82,11 @@ 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.") + Try setting the advanced option SUNDIALS_INDEX_TYPE." + ) endif() # set Fortran integer size too diff --git a/cmake/SundialsSetupCXX.cmake b/cmake/SundialsSetupCXX.cmake index 32a6a9b003..4258fc5758 100644 --- a/cmake/SundialsSetupCXX.cmake +++ b/cmake/SundialsSetupCXX.cmake @@ -26,17 +26,19 @@ 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..1efa449dcf 100644 --- a/cmake/SundialsSetupCompilers.cmake +++ b/cmake/SundialsSetupCompilers.cmake @@ -38,7 +38,10 @@ 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 +64,12 @@ 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 +90,19 @@ 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 +128,10 @@ 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 +145,25 @@ 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 +174,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 +185,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 +197,17 @@ 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 +223,14 @@ 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 +239,22 @@ 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 +263,24 @@ 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,24 +289,37 @@ 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 ) # =============================================================== @@ -281,30 +347,39 @@ endif() # ------------------------------------------------------------------------------ # The case to use in the name-mangling scheme -sundials_option(SUNDIALS_LAPACK_CASE STRING - "case of LAPACK function names (lower/upper)" - "" - ADVANCED) +sundials_option( + SUNDIALS_LAPACK_CASE + STRING + "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.") + print_error( + "If SUNDIALS_LAPACK_UNDERSCORES is 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.") + print_error( + "If SUNDIALS_LAPACK_CASE is set, " + "SUNDIALS_LAPACK_UNDERSCORES must also be set." + ) endif() # Did the user provide a name-mangling scheme? if(SUNDIALS_LAPACK_CASE AND SUNDIALS_LAPACK_UNDERSCORES) - string(TOUPPER ${SUNDIALS_LAPACK_CASE} SUNDIALS_LAPACK_CASE) string(TOUPPER ${SUNDIALS_LAPACK_UNDERSCORES} SUNDIALS_LAPACK_UNDERSCORES) @@ -318,11 +393,23 @@ 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 +418,23 @@ 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() @@ -350,12 +449,10 @@ if(SUNDIALS_LAPACK_CASE AND SUNDIALS_LAPACK_UNDERSCORES) ${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 +460,33 @@ 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() @@ -428,10 +541,13 @@ foreach(lang ${_SUNDIALS_ENABLED_LANGS}) endif() endforeach() # show the language compiler and flags - mark_as_advanced(CLEAR CMAKE_${lang}_COMPILER CMAKE_${lang}_FLAGS) + mark_as_advanced( + CLEAR + CMAKE_${lang}_COMPILER + CMAKE_${lang}_FLAGS + ) endforeach() - # =============================================================== # Configure compilers for installed examples # =============================================================== @@ -439,14 +555,23 @@ 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,20 +581,33 @@ 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}") make_directory(${SUNDIALS_DEV_CLANG_TIDY_DIR}) if(SUNDIALS_DEV_CLANG_TIDY_FIX_ERRORS) - set(CMAKE_C_CLANG_TIDY ${CLANG_TIDY_PATH} -format-style='file' --fix) - set(CMAKE_CXX_CLANG_TIDY ${CLANG_TIDY_PATH} -format-style='file' --fix) + 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} + 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 + set( + CMAKE_CXX_CLANG_TIDY ${CLANG_TIDY_PATH} -format-style='file' --export-fixes=${SUNDIALS_DEV_CLANG_TIDY_DIR}/clang-tidy-cxx-fixes.yaml @@ -478,15 +616,30 @@ if(SUNDIALS_DEV_CLANG_TIDY) endif() if(SUNDIALS_DEV_IWYU) - find_program(IWYU_PATH NAMES include-what-you-use iwyu) + find_program( + IWYU_PATH + NAMES + include-what-you-use + iwyu + ) if(NOT IWYU_PATH) 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..0f3897718b 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. @@ -97,4 +96,4 @@ endif() 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..524807007c 100644 --- a/cmake/SundialsSetupCuda.cmake +++ b/cmake/SundialsSetupCuda.cmake @@ -21,7 +21,12 @@ 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() # =============================================================== @@ -30,21 +35,53 @@ 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) +sundials_option( + CMAKE_CUDA_STANDARD_REQUIRED + BOOL + "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") +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") - -if( (CMAKE_CXX_COMPILER_ID MATCHES GNU) - OR (CMAKE_CXX_COMPILER_ID MATCHES Clang) - AND (CMAKE_SYSTEM_PROCESSOR MATCHES ppc64le) ) +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 + ) +) include(CheckCXXCompilerFlag) - check_cxx_compiler_flag(-mno-float128 _hasflag) + check_cxx_compiler_flag( + -mno-float128 + _hasflag + ) if(_hasflag) set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Xcompiler=-mno-float128") endif() @@ -75,15 +112,27 @@ 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..e3e834a5cd 100644 --- a/cmake/SundialsSetupFortran.cmake +++ b/cmake/SundialsSetupFortran.cmake @@ -39,7 +39,9 @@ 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" @@ -50,33 +52,59 @@ if(BUILD_FORTRAN_MODULE_INTERFACE) "SET(CMAKE_Fortran_FLAGS_DEBUG \"${CMAKE_Fortran_FLAGS_DEBUG}\")\n" "SET(CMAKE_Fortran_FLAGS_RELWITHDEBUGINFO \"${CMAKE_Fortran_FLAGS_RELWITHDEBUGINFO}\")\n" "SET(CMAKE_Fortran_FLAGS_MINSIZE \"${CMAKE_Fortran_FLAGS_MINSIZE}\")\n" - "ADD_EXECUTABLE(ftest ftest.f90)\n") + "ADD_EXECUTABLE(ftest ftest.f90)\n" + ) # Create a Fortran source file which tries to use iso_c_binding - file(WRITE ${F2003Test_DIR}/ftest.f90 + file( + WRITE + ${F2003Test_DIR}/ftest.f90 "program main\n" "use, intrinsic :: iso_c_binding\n" - "end program main\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..f1353ce6fe 100644 --- a/cmake/SundialsSetupHIP.cmake +++ b/cmake/SundialsSetupHIP.cmake @@ -16,17 +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() @@ -34,7 +54,12 @@ if(NOT DEFINED HIP_PLATFORM) if(NOT DEFINED ENV{HIP_PLATFORM}) 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..cc4b3e3858 100644 --- a/cmake/SundialsSetupTesting.cmake +++ b/cmake/SundialsSetupTesting.cmake @@ -18,23 +18,23 @@ 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) 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 "") - endif() # Check if development tests are enabled if(SUNDIALS_TEST_DEVTESTS) - message("SUNDIALS Development testing") # Create the default test output directory @@ -46,7 +46,10 @@ 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 +57,10 @@ 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 +68,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 +79,17 @@ 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,36 +100,86 @@ 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 + add_custom_target( + setup_local_ci ${CMAKE_COMMAND} -E cmake_echo_color --cyan - "Pulled SUNDIALS CI containers.") + "Pulled SUNDIALS CI containers." + ) - add_custom_target(test_local_ci + add_custom_target( + test_local_ci ${CMAKE_COMMAND} -E cmake_echo_color --cyan - "All testing with SUNDIALS CI containers complete.") + "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_}) + COMMAND + ${SUNDIALS_TEST_CONTAINER_EXE} ${container_exe_args} + ) + 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} - VERBATIM) + COMMAND + ${SUNDIALS_TEST_CONTAINER_EXE} ${container_exe_args} + VERBATIM + ) add_dependencies(test_local_ci test_local_ci_${index_size}_${precision_}) unset(container) @@ -125,7 +190,6 @@ if(SUNDIALS_TEST_DEVTESTS) add_local_ci_target(${SUNDIALS_INDEX_SIZE} ${SUNDIALS_PRECISION} latest) endif() - endif() # Check if unit tests are enabled @@ -135,7 +199,8 @@ if(SUNDIALS_TEST_UNITTESTS AND SUNDIALS_TEST_ENABLE_GTEST) include(FetchContent) FetchContent_Declare( googletest - URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip + URL + https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip GIT_TAG v1.14.0 ) if(WIN32) @@ -149,7 +214,6 @@ endif() # If examples are installed, create post install smoke test targets if(EXAMPLES_INSTALL) - # Directories for installation testing set(TEST_INSTALL_DIR ${PROJECT_BINARY_DIR}/Testing_Install) set(TEST_INSTALL_ALL_DIR ${PROJECT_BINARY_DIR}/Testing_Install_All) @@ -164,24 +228,26 @@ if(EXAMPLES_INSTALL) endif() # Create test_install and test_install_all targets - add_custom_target(test_install + add_custom_target( + test_install ${CMAKE_COMMAND} -E cmake_echo_color --cyan - "All installation tests complete.") + "All installation tests complete." + ) - add_custom_target(test_install_all + add_custom_target( + test_install_all ${CMAKE_COMMAND} -E cmake_echo_color --cyan - "All installation tests complete.") - + "All installation tests complete." + ) endif() # If benchmarks are enabled, set up `make benchmark` 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..4e61ab7b7c 100644 --- a/cmake/SundialsTPLOptions.cmake +++ b/cmake/SundialsTPLOptions.cmake @@ -27,15 +27,23 @@ sundials_option(ENABLE_OPENMP BOOL "Enable OpenMP support" OFF) # --------------------------------------------------------------- # Enable OpenMP target offloading support? # --------------------------------------------------------------- -sundials_option(ENABLE_OPENMP_DEVICE BOOL - "Enable OpenMP device offloading support" OFF) +sundials_option( + ENABLE_OPENMP_DEVICE + BOOL + "Enable OpenMP device offloading support" + OFF +) # Advanced option to skip OpenMP device offloading support check. # 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) +sundials_option( + OPENMP_DEVICE_WORKS + BOOL + "Skip the OpenMP device offloading support check" + OFF + ADVANCED +) # --------------------------------------------------------------- # Enable Pthread support? @@ -48,8 +56,14 @@ sundials_option(ENABLE_PTHREAD BOOL "Enable Pthreads support" OFF) sundials_option(ENABLE_CUDA BOOL "Enable CUDA support" OFF) # CMake 3.18 adds this option. -sundials_option(CMAKE_CUDA_ARCHITECTURES STRING "Target CUDA architecture" "70" - DEPENDS_ON ENABLE_CUDA) +sundials_option( + CMAKE_CUDA_ARCHITECTURES + STRING + "Target CUDA architecture" + "70" + DEPENDS_ON + ENABLE_CUDA +) # ------------------------------------------------------------- # Enable HIP support? @@ -61,130 +75,286 @@ 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_WORKS BOOL "Set to ON to force CMake to accept a given LAPACK configuration" OFF - DEPENDS_ON ENABLE_LAPACK - ADVANCED) +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 +) # --------------------------------------------------------------- # 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(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_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( + 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_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_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_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_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_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_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_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_WORKS + BOOL + "Set to ON to force CMake to accept a given KLU configuration" + OFF + DEPENDS_ON + ENABLE_KLU + ADVANCED +) # --------------------------------------------------------------- # Enable hypre support? # --------------------------------------------------------------- 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_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_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_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 +) # --------------------------------------------------------------- # Enable PETSc support? @@ -192,72 +362,152 @@ 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? # ------------------------------------------------------------- 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( + 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 +) # --------------------------------------------------------------- # 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 +515,44 @@ 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 +560,98 @@ 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(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( + 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_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 +659,22 @@ 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 +682,20 @@ 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..b31ded9beb 100644 --- a/cmake/macros/SundialsAddBenchmark.cmake +++ b/cmake/macros/SundialsAddBenchmark.cmake @@ -15,29 +15,44 @@ # --------------------------------------------------------------- macro(sundials_add_benchmark NAME EXECUTABLE BASE_BENCHMARK_NAME) - # Define single value parameters the macro takes in to set up the test runner # # NUM_CORES = number of cores (GPU count or CPU count) to run on/number of resource sets # BENCHMARK_ARGS = arguments to pass to the executable # IDENTIFIER = suffix to append to end of benchmark name - set(oneValueArgs NUM_CORES BENCHMARK_ARGS IDENTIFIER) + 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 +61,15 @@ 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 @@ -62,35 +83,60 @@ macro(sundials_add_benchmark NAME EXECUTABLE BASE_BENCHMARK_NAME) endif() # command line arguments for the test runner script - set(TEST_RUNNER_ARGS + set( + TEST_RUNNER_ARGS "--profile" "--verbose" "--executablename=$" "--outputdir=${SUNDIALS_BENCHMARK_OUTPUT_DIR}/output" "--calidir=${SUNDIALS_BENCHMARK_OUTPUT_DIR}/${TARGET_NAME}" - "--nodiff") + "--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}") string(STRIP "${RUN_COMMAND}" RUN_COMMAND) - set(RUN_COMMAND ${SCHEDULER_COMMAND_ARGS} ${SCHEDULER_ARGS}) + 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}) + COMMAND + ${PYTHON_EXECUTABLE} ${TESTRUNNER} ${TEST_RUNNER_ARGS} + ) add_dependencies(benchmark ${TARGET_NAME}) - endmacro() diff --git a/cmake/macros/SundialsAddExamplesGinkgo.cmake b/cmake/macros/SundialsAddExamplesGinkgo.cmake index 1e23dfdb58..58f7b43f53 100644 --- a/cmake/macros/SundialsAddExamplesGinkgo.cmake +++ b/cmake/macros/SundialsAddExamplesGinkgo.cmake @@ -34,18 +34,25 @@ # Add the build targets for each CVODE example macro(sundials_add_examples_ginkgo EXAMPLES_VAR) - set(options UNIT_TEST) set(oneValueArgs) - set(multiValueArgs TARGETS BACKENDS) + 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}) - # parse the example tuple list(GET example_tuple 0 example) list(GET example_tuple 1 example_args) @@ -57,11 +64,21 @@ macro(sundials_add_examples_ginkgo EXAMPLES_VAR) set(float_precision "default") if(backend MATCHES "CUDA") - set_source_files_properties(${example} PROPERTIES LANGUAGE CUDA) + set_source_files_properties( + ${example} + PROPERTIES + LANGUAGE + CUDA + ) set(vector nveccuda) set(float_precision "4") elseif(backend MATCHES "HIP") - set_source_files_properties(${example} PROPERTIES LANGUAGE CXX) + set_source_files_properties( + ${example} + PROPERTIES + LANGUAGE + CXX + ) set(vector nvechip) elseif(backend MATCHES "SYCL") set(vector nvecsycl) @@ -76,54 +93,74 @@ macro(sundials_add_examples_ginkgo EXAMPLES_VAR) set(example_target "${example_target}.${backend}") if(NOT TARGET ${example_target}) - # create target add_executable(${example_target} ${example}) # folder for IDEs - set_target_properties(${example_target} PROPERTIES FOLDER "Examples") + set_target_properties( + ${example_target} + PROPERTIES + FOLDER + "Examples" + ) # which backend to use target_compile_definitions(${example_target} PRIVATE USE_${backend}) # directories to include - target_include_directories(${example_target} + target_include_directories( + ${example_target} PRIVATE - "${PROJECT_SOURCE_DIR}/examples/utilities") + "${PROJECT_SOURCE_DIR}/examples/utilities" + ) # libraries to link against - target_link_libraries(${example_target} + target_link_libraries( + ${example_target} PRIVATE - ${arg_TARGETS} - sundials_${vector} - Ginkgo::ginkgo - ${EXTRA_LINK_LIBS}) - + ${arg_TARGETS} + sundials_${vector} + Ginkgo::ginkgo + ${EXTRA_LINK_LIBS} + ) endif() # check if example args are provided and set the test name 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} + SUNDIALS_ADD_TEST( + ${test_name} + ${example_target} EXAMPLE_TYPE ${example_type} - TEST_ARGS ${example_args} - NODIFF) + TEST_ARGS + ${example_args} + NODIFF + ) else() - sundials_add_test(${test_name} ${example_target} + SUNDIALS_ADD_TEST( + ${test_name} + ${example_target} EXAMPLE_TYPE ${example_type} - TEST_ARGS ${example_args} + TEST_ARGS + ${example_args} ANSWER_DIR ${CMAKE_CURRENT_SOURCE_DIR} ANSWER_FILE ${test_name}.out - FLOAT_PRECISION ${float_precision}) + FLOAT_PRECISION ${float_precision} + ) endif() - endforeach() endforeach() - endmacro() diff --git a/cmake/macros/SundialsAddExecutable.cmake b/cmake/macros/SundialsAddExecutable.cmake index a2582a3485..ba6fd2f5d6 100644 --- a/cmake/macros/SundialsAddExecutable.cmake +++ b/cmake/macros/SundialsAddExecutable.cmake @@ -15,31 +15,53 @@ # --------------------------------------------------------------- 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} + add_executable( + ${NAME} ${BENCHMARKS_DIR}/nvector/test_nvector_performance.c - ${arg_SOURCES}) - - set_target_properties(${NAME} PROPERTIES FOLDER "Benchmarks") + ${arg_SOURCES} + ) - target_include_directories(${NAME} PRIVATE - ${BENCHMARKS_DIR}/nvector) + set_target_properties( + ${NAME} + PROPERTIES + FOLDER + "Benchmarks" + ) - target_link_libraries(${NAME} PRIVATE - ${arg_SUNDIALS_TARGETS} ${arg_LINK_LIBRARIES} -lm) + target_include_directories(${NAME} PRIVATE ${BENCHMARKS_DIR}/nvector) - install(TARGETS ${NAME} - DESTINATION "${BENCHMARKS_INSTALL_PATH}/${arg_INSTALL_SUBDIR}") + target_link_libraries( + ${NAME} + PRIVATE + ${arg_SUNDIALS_TARGETS} + ${arg_LINK_LIBRARIES} + -lm + ) + install( + TARGETS + ${NAME} + 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..6a7f6eea68 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( @@ -109,16 +108,40 @@ # The option OBJECT_LIB_ONLY will cause the macro to only create the object # library targets. 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( + 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 + ) # 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 "") @@ -131,7 +154,6 @@ macro(sundials_add_library target) endif() foreach(_libtype ${_libtypes}) - # library suffix if(${_libtype} MATCHES "STATIC") set(_lib_suffix "${_STATIC_LIB_SUFFIX}") @@ -150,14 +172,27 @@ 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") + 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}) + target_link_libraries( + ${obj_target} + PRIVATE + ${sundials_add_library_OBJECT_LIBRARIES} + ) endif() # add all link libraries to object library @@ -184,7 +219,10 @@ 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 +232,32 @@ 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} + 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 +270,45 @@ 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() @@ -248,7 +318,6 @@ macro(sundials_add_library target) # now create the real library if(NOT sundials_add_library_OBJECT_LIB_ONLY) - # set target name set(_actual_target_name ${target}${_lib_suffix}) @@ -264,19 +333,40 @@ 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") + 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,98 +374,166 @@ 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() # install phase install(TARGETS ${_actual_target_name} EXPORT sundials-targets) - endif() - endforeach() # -------------------------------------------------------------------------- @@ -383,8 +541,12 @@ 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 +557,39 @@ 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,41 +599,74 @@ 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(oneValueArgs OUTPUT_NAME VERSION SOVERSION) - set(multiValueArgs SOURCES OBJECT_LIBRARIES LINK_LIBRARIES INCLUDE_DIRECTORIES - COMPILE_DEFINITIONS COMPILE_OPTIONS PROPERTIES) + set(options) + set( + oneValueArgs + OUTPUT_NAME + VERSION + SOVERSION + ) + 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 + set( + _includes PUBLIC - $ - $ + $ + $ + ) + set( + _properties + PROPERTIES + Fortran_MODULE_DIRECTORY + "${CMAKE_Fortran_MODULE_DIRECTORY}_{{libtype}}" + WINDOWS_EXPORT_ALL_SYMBOLS + ON ) - set(_properties PROPERTIES - Fortran_MODULE_DIRECTORY "${CMAKE_Fortran_MODULE_DIRECTORY}_{{libtype}}" - WINDOWS_EXPORT_ALL_SYMBOLS ON) else() - set(_includes + set( + _includes PUBLIC - $ - $ + $ + $ + ) + set( + _properties + PROPERTIES + Fortran_MODULE_DIRECTORY + "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${target}.dir" + WINDOWS_EXPORT_ALL_SYMBOLS + ON ) - set(_properties PROPERTIES - Fortran_MODULE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${target}.dir" - WINDOWS_EXPORT_ALL_SYMBOLS ON) endif() # get the name of the C library which the fortran library interfaces to @@ -462,22 +675,31 @@ 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 + 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} + 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} @@ -485,7 +707,6 @@ macro(sundials_add_f2003_library target) ) 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..557b7e695d 100644 --- a/cmake/macros/SundialsAddTest.cmake +++ b/cmake/macros/SundialsAddTest.cmake @@ -51,7 +51,6 @@ # ------------------------------------------------------------------------------ macro(SUNDIALS_ADD_TEST NAME EXECUTABLE) - # macro options # NODIFF = do not diff the test output against an answer file set(options "NODIFF") @@ -65,41 +64,72 @@ macro(SUNDIALS_ADD_TEST NAME EXECUTABLE) # ANSWER_DIR = path to the directory containing the test answer file # 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") + set( + oneValueArgs + "MPI_NPROCS" + "FLOAT_PRECISION" + "INTEGER_PRECISION" + "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") + 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) ) - - message(STATUS "Skipped test ${NAME} because it had type ${SUNDIALS_ADD_TEST_EXAMPLE_TYPE}") - + 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}" + ) else() - if(SUNDIALS_TEST_DEVTESTS) - # run all tests (standard and develop) with the test runner # command line arguments for the test runner script - set(TEST_ARGS + 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 +160,79 @@ 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 +252,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,10 +260,12 @@ 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) - # if a test type was not set then it is a standard test that returns pass/fail # convert string to list @@ -190,22 +274,55 @@ 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}) + add_test( + NAME ${NAME} + COMMAND + $ ${TEST_ARGS} + ) endif() - endif() - endif() - endmacro() diff --git a/cmake/macros/SundialsAddTestInstall.cmake b/cmake/macros/SundialsAddTestInstall.cmake index cf2a6fb76b..10daaa7334 100644 --- a/cmake/macros/SundialsAddTestInstall.cmake +++ b/cmake/macros/SundialsAddTestInstall.cmake @@ -18,44 +18,53 @@ # --------------------------------------------------------------- macro(SUNDIALS_ADD_TEST_INSTALL PACKAGE TESTDIR) - # required macro args # PACKAGE = Sundials package name (e.g., cvode, arkode, etc.) # 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) - # create testing directory if necessary if(NOT EXISTS ${TEST_INSTALL_DIR}/${PACKAGE}/${TESTDIR}) file(MAKE_DIRECTORY ${TEST_INSTALL_DIR}/${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}) - endif() # Possible extensions: @@ -68,17 +77,22 @@ 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. # make test_install_all depend on test_install_all_package add_dependencies(test_install_all test_install_all_${PACKAGE}_${TESTDIR}) - endmacro() diff --git a/cmake/macros/SundialsCMakeMacros.cmake b/cmake/macros/SundialsCMakeMacros.cmake index c7800393ba..6d7fa17654 100644 --- a/cmake/macros/SundialsCMakeMacros.cmake +++ b/cmake/macros/SundialsCMakeMacros.cmake @@ -25,7 +25,7 @@ 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 +33,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 +43,18 @@ 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}) @@ -56,24 +62,35 @@ macro(print_warning message action) set(_mode WARNING) endif() - set(MSG - "------------------------------------------------------------------------\n" - "WARNING: ${message}\n" - "${action}\n" - "------------------------------------------------------------------------") - - message(${_mode} ${MSG}) + set( + MSG + "------------------------------------------------------------------------\n" + "WARNING: ${message}\n" + "${action}\n" + "------------------------------------------------------------------------" + ) + + message( + ${_mode} + ${MSG} + ) 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}) @@ -81,12 +98,17 @@ macro(print_error message) set(_mode FATAL_ERROR) endif() - set(MSG - "************************************************************************\n" - "ERROR: ${message}\n" - "************************************************************************") - - message(${_mode} ${MSG}) + set( + MSG + "************************************************************************\n" + "ERROR: ${message}\n" + "************************************************************************" + ) + + message( + ${_mode} + ${MSG} + ) endmacro() # Returns an unquoted string. Note that CMake will readily turn such @@ -95,7 +117,7 @@ endmacro() macro(list2string alist astring) foreach(elem ${${alist}}) - set(${astring} "${${astring}} ${elem}") + set(${astring} "${${astring}} ${elem}") endforeach(elem) endmacro(LIST2STRING) @@ -119,9 +141,12 @@ 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() diff --git a/cmake/macros/SundialsInstallExamples.cmake b/cmake/macros/SundialsInstallExamples.cmake index 7f40b7af6e..c53b895e4d 100644 --- a/cmake/macros/SundialsInstallExamples.cmake +++ b/cmake/macros/SundialsInstallExamples.cmake @@ -71,20 +71,42 @@ # ------------------------------------------------------------------------------ macro(sundials_install_examples MODULE EXAMPLES_VAR) - - set(options ) - set(oneValueArgs SOLVER_LIBRARY DESTINATION CMAKE_TEMPLATE MAKE_TEMPLATE - TEST_INSTALL) - set(multiValueArgs SUNDIALS_TARGETS SUNDIALS_COMPONENTS OTHER_TARGETS - EXAMPLES_DEPENDENCIES EXTRA_FILES EXTRA_INCLUDES) + set(options) + set( + oneValueArgs + SOLVER_LIBRARY + DESTINATION + CMAKE_TEMPLATE + MAKE_TEMPLATE + TEST_INSTALL + ) + set( + multiValueArgs + SUNDIALS_TARGETS + SUNDIALS_COMPONENTS + OTHER_TARGETS + 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 @@ -93,14 +115,23 @@ macro(sundials_install_examples MODULE EXAMPLES_VAR) 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) @@ -137,12 +168,14 @@ macro(sundials_install_examples MODULE EXAMPLES_VAR) ${PROJECT_SOURCE_DIR}/examples/templates/${sundials_install_examples_CMAKE_TEMPLATE} ${PROJECT_BINARY_DIR}/examples/${sundials_install_examples_DESTINATION}/CMakeLists.txt @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 @@ -154,18 +187,22 @@ macro(sundials_install_examples MODULE EXAMPLES_VAR) ${PROJECT_SOURCE_DIR}/examples/templates/${sundials_install_examples_MAKE_TEMPLATE} ${PROJECT_BINARY_DIR}/examples/${sundials_install_examples_DESTINATION}/Makefile_ex @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} + 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..97aa003f5e 100644 --- a/cmake/macros/SundialsInstallExamplesGinkgo.cmake +++ b/cmake/macros/SundialsInstallExamplesGinkgo.cmake @@ -47,20 +47,31 @@ # ------------------------------------------------------------------------------ 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) foreach(example_tuple ${${arg_${example_type}_EXAMPLES_VAR}}) - # filename must be the first item in the list of example tuples list(GET example_tuple 0 example) @@ -72,16 +83,24 @@ macro(sundials_install_examples_ginkgo MODULE) file(GLOB example_out ${example_noext}*.out) # install files - install(FILES ${example} ${example_header} ${example_out} - DESTINATION ${EXAMPLES_INSTALL_PATH}/${arg_DESTINATION}) - + install( + FILES + ${example} + ${example_header} + ${example_out} + DESTINATION ${EXAMPLES_INSTALL_PATH}/${arg_DESTINATION} + ) endforeach() endforeach() # 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}) + install( + FILES + ${arg_EXTRA_FILES} + ${arg_DEPENDENCIES} + DESTINATION ${EXAMPLES_INSTALL_PATH}/${arg_DESTINATION} + ) endif() # Prepare substitution variables for CMakeLists and/or Makefile templates @@ -117,15 +136,15 @@ macro(sundials_install_examples_ginkgo MODULE) ${PROJECT_SOURCE_DIR}/examples/templates/cmakelists_CXX_ginkgo_ex.in ${PROJECT_BINARY_DIR}/examples/${arg_DESTINATION}/CMakeLists.txt @ONLY - ) + ) # Install CMakelists.txt install( - FILES ${PROJECT_BINARY_DIR}/examples/${arg_DESTINATION}/CMakeLists.txt + 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) - + SUNDIALS_ADD_TEST_INSTALL(${MODULE} ginkgo) endmacro() diff --git a/cmake/macros/SundialsOption.cmake b/cmake/macros/SundialsOption.cmake index 252db50f69..11dca40874 100644 --- a/cmake/macros/SundialsOption.cmake +++ b/cmake/macros/SundialsOption.cmake @@ -35,14 +35,26 @@ # --------------------------------------------------------------------------- macro(sundials_option NAME TYPE DOCSTR DEFAULT_VALUE) - # macro options and keyword inputs followed by multiple values - set(options DEPENDS_ON_THROW_ERROR ADVANCED) - set(multiValueArgs OPTIONS DEPENDS_ON) + set( + options + DEPENDS_ON_THROW_ERROR + ADVANCED + ) + set( + multiValueArgs + OPTIONS + DEPENDS_ON + ) # parse inputs and create variables sundials_option_ - cmake_parse_arguments(sundials_option "${options}" "${oneValueArgs}" - "${multiValueArgs}" ${ARGN} ) + cmake_parse_arguments( + sundials_option + "${options}" + "${oneValueArgs}" + "${multiValueArgs}" + ${ARGN} + ) # check if dependencies for this option have been met set(all_depends_on_dependencies_met TRUE) @@ -56,7 +68,6 @@ macro(sundials_option NAME TYPE DOCSTR DEFAULT_VALUE) endif() if(all_depends_on_dependencies_met) - if(NOT DEFINED ${NAME}) set(${NAME} "${DEFAULT_VALUE}" CACHE ${TYPE} ${DOCSTR}) else() @@ -67,17 +78,17 @@ macro(sundials_option NAME TYPE DOCSTR DEFAULT_VALUE) if(sundials_option_ADVANCED) mark_as_advanced(FORCE ${NAME}) endif() - else() - # 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 + 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}") @@ -85,7 +96,6 @@ macro(sundials_option NAME TYPE DOCSTR DEFAULT_VALUE) print_warning("${_warn_msg_string}" "Unsetting ${NAME}") endif() endif() - endif() # check for valid option choices @@ -98,12 +108,17 @@ macro(sundials_option NAME TYPE DOCSTR DEFAULT_VALUE) endforeach() get_property(is_in_cache CACHE ${NAME} PROPERTY TYPE) if(is_in_cache) - set_property(CACHE ${NAME} PROPERTY STRINGS ${sundials_option_OPTIONS}) + set_property( + CACHE + ${NAME} + PROPERTY + STRINGS + ${sundials_option_OPTIONS} + ) endif() unset(is_in_cache) endif() unset(all_depends_on_dependencies_met) unset(depends_on_dependencies_not_met) - endmacro() diff --git a/cmake/macros/SundialsTryCompileExecute.cmake b/cmake/macros/SundialsTryCompileExecute.cmake index 81e972b92d..a51970ea4a 100644 --- a/cmake/macros/SundialsTryCompileExecute.cmake +++ b/cmake/macros/SundialsTryCompileExecute.cmake @@ -27,21 +27,42 @@ # ----------------------------------------------------------------------------- macro(sundials_trycompile_execute EXECUTABLE CWD COMPILE_OK RUN_OK) - - set(options ) - set(oneValueArgs COMPILE_OUTPUT RUN_OUTPUT) - set(multiValueArgs ) + set(options) + set( + oneValueArgs + COMPILE_OUTPUT + RUN_OUTPUT + ) + 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() @@ -62,5 +83,4 @@ macro(sundials_trycompile_execute EXECUTABLE CWD COMPILE_OK RUN_OK) # unset variables we don't want to leak unset(COMPILE_OUTPUT) unset(RUN_OUTPUT) - endmacro() diff --git a/cmake/tpl/FindHYPRE.cmake b/cmake/tpl/FindHYPRE.cmake index 691647544a..1af3869baf 100644 --- a/cmake/tpl/FindHYPRE.cmake +++ b/cmake/tpl/FindHYPRE.cmake @@ -33,63 +33,93 @@ # --------------------------------------------------------------- ### 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 +find_package_handle_standard_args( + HYPRE REQUIRED_VARS HYPRE_LIBRARY HYPRE_LIBRARIES HYPRE_INCLUDE_DIR - FAIL_MESSAGE - "${HYPRE_NOT_FOUND_MESSAGE}" - ) + FAIL_MESSAGE "${HYPRE_NOT_FOUND_MESSAGE}" +) # Create target for HYPRE if(HYPRE_FOUND) - if(NOT TARGET SUNDIALS::HYPRE) 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..4e3ae8b640 100644 --- a/cmake/tpl/FindKLU.cmake +++ b/cmake/tpl/FindKLU.cmake @@ -30,7 +30,7 @@ # 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) @@ -47,80 +47,129 @@ endif() # Set library prefixes for Windows if(MSVC OR ("${CMAKE_C_SIMULATE_ID}" STREQUAL "MSVC")) - set(CMAKE_FIND_LIBRARY_PREFIXES lib ${CMAKE_FIND_LIBRARY_PREFIXES}) - set(CMAKE_FIND_LIBRARY_SUFFIXES d.lib ${CMAKE_FIND_LIBRARY_SUFFIXES}) + set( + CMAKE_FIND_LIBRARY_PREFIXES + lib + ${CMAKE_FIND_LIBRARY_PREFIXES} + ) + set( + CMAKE_FIND_LIBRARY_SUFFIXES + d.lib + ${CMAKE_FIND_LIBRARY_SUFFIXES} + ) elseif(APPLE) - set(CMAKE_FIND_LIBRARY_SUFFIXES d.a ${CMAKE_FIND_LIBRARY_SUFFIXES}) + set( + CMAKE_FIND_LIBRARY_SUFFIXES + d.a + ${CMAKE_FIND_LIBRARY_SUFFIXES} + ) 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) - -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 () + # 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() 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 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 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 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 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 +find_package_handle_standard_args( + KLU REQUIRED_VARS KLU_LIBRARY KLU_LIBRARIES - KLU_INCLUDE_DIR) + KLU_INCLUDE_DIR +) # Create target for KLU if(KLU_FOUND) - if(NOT TARGET SUNDIALS::KLU) 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..55d699052a 100644 --- a/cmake/tpl/FindMAGMA.cmake +++ b/cmake/tpl/FindMAGMA.cmake @@ -15,44 +15,67 @@ # ----------------------------------------------------------------------------- # find the MAGMA include path -find_path(MAGMA_INCLUDE_DIR magma_v2.h - NAMES magma_v2.h - HINTS ${MAGMA_DIR} $ENV{MAGMA_DIR} - PATH_SUFFIXES include +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" ) # find the main MAGMA library -find_library(MAGMA_LIBRARY - NAMES magma - HINTS ${MAGMA_DIR} $ENV{MAGMA_DIR} - PATH_SUFFIXES lib lib64 +find_library( + MAGMA_LIBRARY + NAMES + magma + HINTS + ${MAGMA_DIR} + $ENV{MAGMA_DIR} + PATH_SUFFIXES + lib + lib64 NO_DEFAULT_PATH - DOC "The MAGMA library.") + DOC "The 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 - NAMES magma_sparse - HINTS ${MAGMA_DIR} $ENV{MAGMA_DIR} - PATH_SUFFIXES lib lib64 + 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.") + DOC "The MAGMA sparse library." + ) else() - set(_sparse_required ) + set(_sparse_required) endif() # Determine MAGMA version and libraries it depends on if(MAGMA_LIBRARY AND MAGMA_INCLUDE_DIR) - get_filename_component(libdir ${MAGMA_LIBRARY} DIRECTORY) find_file(MAGMA_PKG_CONFIG_PATH magma.pc PATHS "${libdir}/pkgconfig") 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 +88,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,15 +102,32 @@ 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") # Replace cublas, cusparse with the CMake targets because the library path in @@ -104,43 +144,52 @@ if(MAGMA_LIBRARY AND MAGMA_INCLUDE_DIR) list(APPEND _interface_libraires ${lib}) endif() endforeach() - endif() endif() set(MAGMA_LIBRARIES "${MAGMA_LIBRARY};${_interface_libraires}") -find_package_handle_standard_args(MAGMA +find_package_handle_standard_args( + MAGMA REQUIRED_VARS MAGMA_LIBRARY MAGMA_LIBRARIES MAGMA_INCLUDE_DIR ${_sparse_required} - VERSION_VAR - MAGMA_VERSION - ) + VERSION_VAR MAGMA_VERSION +) # Create target for MAGMA if(MAGMA_FOUND) - if(NOT TARGET SUNDIALS::MAGMA) 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..1b10d0d145 100644 --- a/cmake/tpl/FindPETSC.cmake +++ b/cmake/tpl/FindPETSC.cmake @@ -34,13 +34,22 @@ if(DEFINED PETSC_FIND_VERSION) set(_pkg_version_spec ">=${PETSC_FIND_VERSION}") endif() endif() -pkg_check_modules(PKG_PETSC "PETSc${_pkg_version_spec}") +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 +65,27 @@ 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() @@ -88,9 +107,24 @@ if(PKG_PETSC_VERSION) 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_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 +132,33 @@ if(PKG_PETSC_VERSION) unset(_petsc_version_patch) endif() -include (FindPackageHandleStandardArgs) -find_package_handle_standard_args (PETSC - REQUIRED_VARS PETSC_FOUND PETSC_INCLUDE_DIRS PETSC_LIBRARIES +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args( + PETSC + REQUIRED_VARS + PETSC_FOUND + PETSC_INCLUDE_DIRS + PETSC_LIBRARIES 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..a2cbf4fdf3 100644 --- a/cmake/tpl/FindSUPERLUDIST.cmake +++ b/cmake/tpl/FindSUPERLUDIST.cmake @@ -47,39 +47,109 @@ 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_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 +157,44 @@ 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() @@ -111,34 +204,49 @@ if(SUPERLUDIST_OpenMP) endif() # add libraries for GPU support if(SUPERLUDIST_CUDA) - list(APPEND SUPERLUDIST_LINK_LIBRARIES CUDA::cudart CUDA::cublas) + list( + APPEND + SUPERLUDIST_LINK_LIBRARIES + CUDA::cudart + CUDA::cublas + ) endif() 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 +find_package_handle_standard_args( + SUPERLUDIST REQUIRED_VARS SUPERLUDIST_LINK_LIBRARIES SUPERLUDIST_INCLUDE_DIRS SUPERLUDIST_INDEX_SIZE - VERSION_VAR - SUPERLUDIST_VERSION - ) + VERSION_VAR SUPERLUDIST_VERSION +) # Create target for SuperLU_DIST if(SUPERLUDIST_FOUND) - if(NOT TARGET SUNDIALS::SUPERLUDIST) 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..fd140cb6ad 100644 --- a/cmake/tpl/FindSUPERLUMT.cmake +++ b/cmake/tpl/FindSUPERLUMT.cmake @@ -33,12 +33,30 @@ # 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 @@ -65,7 +83,11 @@ endif() set(SUPERLUMT_LIBRARY_NAME superlu_mt_${SUPERLUMT_THREAD_TYPE}) if(MSVC) - set(CMAKE_FIND_LIBRARY_PREFIXES lib ${CMAKE_FIND_LIBRARY_PREFIXES}) + set( + CMAKE_FIND_LIBRARY_PREFIXES + lib + ${CMAKE_FIND_LIBRARY_PREFIXES} + ) endif() # Check if SUPERLUMT_LIBRARIES contains the superlu_mt @@ -82,8 +104,13 @@ 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,7 +120,13 @@ 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 @@ -104,40 +137,57 @@ 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 +find_package_handle_standard_args( + SUPERLUMT REQUIRED_VARS SUPERLUMT_LIBRARY SUPERLUMT_LIBRARIES SUPERLUMT_INCLUDE_DIR SUPERLUMT_THREAD_TYPE - FAIL_MESSAGE - "${SUPERLUMT_NOT_FOUND_MESSAGE}" - ) + FAIL_MESSAGE "${SUPERLUMT_NOT_FOUND_MESSAGE}" +) # Create target for SuperLU_MT if(SUPERLUMT_FOUND) - if(NOT TARGET SUNDIALS::SUPERLUMT) 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) - endif() diff --git a/cmake/tpl/FindTrilinos.cmake b/cmake/tpl/FindTrilinos.cmake index af4dff69b3..1a761cc7cf 100644 --- a/cmake/tpl/FindTrilinos.cmake +++ b/cmake/tpl/FindTrilinos.cmake @@ -16,30 +16,38 @@ # ----------------------------------------------------------------------------- # 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} NO_DEFAULT_PATH - QUIET) + QUIET +) # set package variables including Trilinos_FOUND -find_package_handle_standard_args(Trilinos +find_package_handle_standard_args( + Trilinos REQUIRED_VARS - Trilinos_LIBRARIES # defined in TrilinosConfig.cmake - Trilinos_INCLUDE_DIRS # defined in TrilinosConfig.cmake - ) + Trilinos_LIBRARIES # defined in TrilinosConfig.cmake + Trilinos_INCLUDE_DIRS # defined in TrilinosConfig.cmake +) # Create Trilinos target if(Trilinos_FOUND) - if(NOT TARGET SUNDIALS::TRILINOS) 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..e0fbdf48b7 100644 --- a/cmake/tpl/FindXBRAID.cmake +++ b/cmake/tpl/FindXBRAID.cmake @@ -29,28 +29,41 @@ # 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 AND XBRAID_LIBRARIES) - - set(XBRAID_DIR "" CACHE PATH "Path to the root of XBraid installation" FORCE) - - else () - - string(CONCAT msg +if(XBRAID_INCLUDES OR XBRAID_LIBRARIES) + if(XBRAID_INCLUDES AND XBRAID_LIBRARIES) + set( + XBRAID_DIR + "" + CACHE PATH + "Path to the root of XBraid installation" + FORCE + ) + else() + string( + CONCAT + msg "Both XBRAID_INCLUDES and XBRAID_LIBRARIES must be provided:\n" " XBRAID_INCLUDES=${XBRAID_INCLUDES}\n" - " XBRAID_LIBRARIES=${XBRAID_LIBRARIES}") + " XBRAID_LIBRARIES=${XBRAID_LIBRARIES}" + ) message(FATAL_ERROR ${msg}) - - endif () - -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) - -endif () + endif() +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 + ) +endif() # unset cache values for multiple passes unset(XBRAID_INCLUDE_DIR CACHE) @@ -59,138 +72,172 @@ 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") + 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 + if(NOT XBRAID_INCLUDE_DIR) + string( + CONCAT + msg "Could not determine XBraid include directory from XBRAID_INCLUDES:\n" - " XBRAID_INCLUDES=${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") + 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) - string(CONCAT msg + if(NOT XBRAID_LIBRARY) + string( + CONCAT + msg "Could not determine XBraid library from XBRAID_LIBRARIES:\n" - " XBRAID_LIBRARIES=${XBRAID_LIBRARIES}") + " XBRAID_LIBRARIES=${XBRAID_LIBRARIES}" + ) message(FATAL_ERROR ${msg}) - endif () - -else () - + endif() +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) - - string(CONCAT msg + 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.") + " - XBRAID_INCLUDES and XBRAID_LIBRARIES." + ) message(FATAL_ERROR ${msg}) - - endif () + endif() # Find the include dir - find_path(XBRAID_INCLUDE_DIR braid.h + find_path( + XBRAID_INCLUDE_DIR + braid.h PATHS - ${XBRAID_DIR} + ${XBRAID_DIR} PATH_SUFFIXES - include braid - DOC - "XBraid include directory" - NO_DEFAULT_PATH) + include + braid + DOC "XBraid include directory" + NO_DEFAULT_PATH + ) # check if the include directory was found - if (NOT XBRAID_INCLUDE_DIR) - string(CONCAT msg + if(NOT XBRAID_INCLUDE_DIR) + string( + CONCAT + msg "Could not determine XBraid include directory from XBRAID_DIR:\n" - " XBRAID_DIR=${XBRAID_DIR}\n") + " XBRAID_DIR=${XBRAID_DIR}\n" + ) message(FATAL_ERROR ${msg}) - endif () + endif() # Find the library - find_library(XBRAID_LIBRARY braid + find_library( + XBRAID_LIBRARY + braid PATHS - ${XBRAID_DIR} + ${XBRAID_DIR} PATH_SUFFIXES - lib braid - DOC - "XBraid library" - NO_DEFAULT_PATH) + lib + braid + DOC "XBraid library" + NO_DEFAULT_PATH + ) # check if the library was found - if (NOT XBRAID_LIBRARY) - string(CONCAT msg + if(NOT XBRAID_LIBRARY) + string( + CONCAT + msg "Could not determine XBraid library from XBRAID_DIR:\n" - " XBRAID_DIR=${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 +find_package_handle_standard_args( + XBRAID REQUIRED_VARS - XBRAID_INCLUDE_DIR - XBRAID_LIBRARY - ) + 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..2533990e9d 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,35 +56,49 @@ 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}) + 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: ") message("${COMPILE_OUTPUT}") print_error("SUNDIALS interface to adiak is not functional.") endif() - elseif(adiak_FOUND AND adiak_WORKS) message(STATUS "Skipped adiak tests, assuming adiak works with SUNDIALS.") endif() diff --git a/cmake/tpl/SundialsCaliper.cmake b/cmake/tpl/SundialsCaliper.cmake index 8a665a3f05..fe6e3352a9 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,9 @@ 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" @@ -74,37 +74,51 @@ if(CALIPER_FOUND AND (NOT CALIPER_WORKS)) "add_executable(ltest ltest.c)\n" "target_include_directories(ltest PRIVATE \"${caliper_INCLUDE_DIR}\")\n" "target_link_libraries(ltest \"-L${caliper_LIB_DIR}\")\n" - "target_link_libraries(ltest caliper)\n") + "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 - OUTPUT_VARIABLE COMPILE_OUTPUT) + 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: ") message("${COMPILE_OUTPUT}") print_error("SUNDIALS interface to CALIPER is not functional.") endif() - elseif(CALIPER_FOUND AND CALIPER_WORKS) message(STATUS "Skipped CALIPER tests, assuming CALIPER works with SUNDIALS.") endif() diff --git a/cmake/tpl/SundialsGinkgo.cmake b/cmake/tpl/SundialsGinkgo.cmake index 595c96aa5a..54e25eda7b 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,43 @@ 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..5de160e0f3 100644 --- a/cmake/tpl/SundialsHypre.cmake +++ b/cmake/tpl/SundialsHypre.cmake @@ -68,53 +68,72 @@ 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 - OUTPUT_VARIABLE COMPILE_OUTPUT) + 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: ") message("${COMPILE_OUTPUT}") print_error("SUNDIALS interface to HYPRE is not functional.") 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..3f3eb7a4c1 100644 --- a/cmake/tpl/SundialsKLU.cmake +++ b/cmake/tpl/SundialsKLU.cmake @@ -64,12 +64,17 @@ if(KLU_FOUND AND (NOT KLU_WORKS)) list(APPEND CMAKE_EXTRA_INCLUDE_FILES "klu.h") set(save_CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES}) list(APPEND CMAKE_REQUIRED_INCLUDES ${KLU_INCLUDE_DIR}) - check_type_size("SuiteSparse_long" SIZEOF_SUITESPARSE_LONG) + check_type_size( + "SuiteSparse_long" + SIZEOF_SUITESPARSE_LONG + ) set(CMAKE_EXTRA_INCLUDE_FILES ${save_CMAKE_EXTRA_INCLUDE_FILES}) 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,38 +83,49 @@ 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") + 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" + ) # 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 - OUTPUT_VARIABLE COMPILE_OUTPUT) + try_compile( + COMPILE_OK + ${KLU_TEST_DIR} + ${KLU_TEST_DIR} + ltest + OUTPUT_VARIABLE COMPILE_OUTPUT + ) # Process test result if(COMPILE_OK) @@ -121,7 +137,9 @@ if(KLU_FOUND AND (NOT KLU_WORKS)) message("${COMPILE_OUTPUT}") print_error("SUNDIALS interface to KLU is not functional.") 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..4e8b24a39e 100644 --- a/cmake/tpl/SundialsKokkos.cmake +++ b/cmake/tpl/SundialsKokkos.cmake @@ -36,18 +36,19 @@ 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 +58,13 @@ 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..9440312831 100644 --- a/cmake/tpl/SundialsKokkosKernels.cmake +++ b/cmake/tpl/SundialsKokkosKernels.cmake @@ -36,13 +36,16 @@ 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 +55,16 @@ 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..f4ae5fa5bf 100644 --- a/cmake/tpl/SundialsLapack.cmake +++ b/cmake/tpl/SundialsLapack.cmake @@ -84,7 +84,6 @@ message(STATUS "LAPACK_LIBRARIES: ${LAPACK_LIBRARIES}") # contain the mangled names for "mysub" and "my_sub", respectively. # --------------------------------------------------------------- if(NEED_FORTRAN_NAME_MANGLING) - set(CMAKE_Fortran_SCHEME_NO_UNDERSCORES "") set(CMAKE_Fortran_SCHEME_WITH_UNDERSCORES "") @@ -94,7 +93,9 @@ 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" @@ -107,27 +108,39 @@ if(NEED_FORTRAN_NAME_MANGLING) "SET(CMAKE_Fortran_FLAGS_MINSIZE \"${CMAKE_Fortran_FLAGS_MINSIZE}\")\n" "ADD_LIBRARY(flib flib.f)\n" "ADD_EXECUTABLE(ftest ftest.f)\n" - "TARGET_LINK_LIBRARIES(ftest flib)\n") + "TARGET_LINK_LIBRARIES(ftest flib)\n" + ) # Create the Fortran source flib.f which defines two subroutines, "mysub" and "my_sub" - file(WRITE ${FortranTest_DIR}/flib.f + file( + WRITE + ${FortranTest_DIR}/flib.f " SUBROUTINE mysub\n" " RETURN\n" " END\n" " SUBROUTINE my_sub\n" " RETURN\n" - " END\n") + " END\n" + ) # Create the Fortran source ftest.f which calls "mysub" and "my_sub" - file(WRITE ${FortranTest_DIR}/ftest.f + file( + WRITE + ${FortranTest_DIR}/ftest.f " PROGRAM ftest\n" " CALL mysub()\n" " CALL my_sub()\n" - " END\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. @@ -135,10 +148,11 @@ if(NEED_FORTRAN_NAME_MANGLING) # Proceed based on test results if(FTEST_OK) - # 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" @@ -151,11 +165,20 @@ if(NEED_FORTRAN_NAME_MANGLING) "SET(CMAKE_C_FLAGS_MINSIZE \"${CMAKE_C_FLAGS_MINSIZE}\")\n" "ADD_EXECUTABLE(ctest1 ctest1.c)\n" "FIND_LIBRARY(FLIB flib \"${FortranTest_DIR}\")\n" - "TARGET_LINK_LIBRARIES(ctest1 \${FLIB})\n") + "TARGET_LINK_LIBRARIES(ctest1 \${FLIB})\n" + ) # Define the list "options" of all possible schemes that we want to consider # Get its length and initialize the counter "iopt" to zero - set(options mysub mysub_ mysub__ MYSUB MYSUB_ MYSUB__) + set( + options + mysub + mysub_ + mysub__ + MYSUB + MYSUB_ + MYSUB__ + ) list(LENGTH options imax) set(iopt 0) @@ -165,13 +188,21 @@ if(NEED_FORTRAN_NAME_MANGLING) # Get the current list entry (current scheme) list(GET options ${iopt} opt) # Generate C source which calls the "mysub" function using the current scheme - file(WRITE ${FortranTest_DIR}/ctest1.c + file( + WRITE + ${FortranTest_DIR}/ctest1.c "extern void ${opt}();\n" - "int main(void){${opt}();return(0);}\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 +222,9 @@ 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" @@ -204,18 +237,35 @@ if(NEED_FORTRAN_NAME_MANGLING) "SET(CMAKE_C_FLAGS_MINSIZE \"${CMAKE_C_FLAGS_MINSIZE}\")\n" "ADD_EXECUTABLE(ctest2 ctest2.c)\n" "FIND_LIBRARY(FLIB flib \"${FortranTest_DIR}\")\n" - "TARGET_LINK_LIBRARIES(ctest2 \${FLIB})\n") + "TARGET_LINK_LIBRARIES(ctest2 \${FLIB})\n" + ) - set(options my_sub my_sub_ my_sub__ MY_SUB MY_SUB_ MY_SUB__) + set( + options + my_sub + my_sub_ + my_sub__ + MY_SUB + MY_SUB_ + MY_SUB__ + ) list(LENGTH options imax) set(iopt 0) while(${iopt} LESS ${imax}) list(GET options ${iopt} opt) - file(WRITE ${FortranTest_DIR}/ctest2.c + 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) + "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 +278,11 @@ 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 +295,31 @@ 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,19 +327,31 @@ 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 @@ -283,11 +361,9 @@ if(NEED_FORTRAN_NAME_MANGLING) ${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") endif() - endif() # If we have the LAPACK libraries, determine if they work. @@ -297,7 +373,9 @@ 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" @@ -310,10 +388,13 @@ if(LAPACK_LIBRARIES AND (NOT LAPACK_WORKS)) "SET(CMAKE_C_FLAGS_RELWITHDEBUGINFO \"${CMAKE_C_FLAGS_RELWITHDEBUGINFO}\")\n" "SET(CMAKE_C_FLAGS_MINSIZE \"${CMAKE_C_FLAGS_MINSIZE}\")\n" "ADD_EXECUTABLE(ltest ltest.c)\n" - "TARGET_LINK_LIBRARIES(ltest ${LAPACK_LIBRARIES})\n") + "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" @@ -326,11 +407,17 @@ if(LAPACK_LIBRARIES AND (NOT LAPACK_WORKS)) "dcopy_f77(&n, &x, &n, &y, &n);\n" "dgetrf_f77(&n, &n, &x, &n, &n, &n);\n" "return(0);\n" - "}\n") + "}\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 +426,13 @@ 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,13 +444,21 @@ 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}") print_error("SUNDIALS interface to LAPACK is not functional.") 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..7dcdffec99 100644 --- a/cmake/tpl/SundialsMAGMA.cmake +++ b/cmake/tpl/SundialsMAGMA.cmake @@ -37,7 +37,9 @@ 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 +59,23 @@ 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..971a20ec05 100644 --- a/cmake/tpl/SundialsONEMKL.cmake +++ b/cmake/tpl/SundialsONEMKL.cmake @@ -38,14 +38,18 @@ 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 +63,15 @@ 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 +82,13 @@ 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..b0a0e8bf5c 100644 --- a/cmake/tpl/SundialsOpenMP.cmake +++ b/cmake/tpl/SundialsOpenMP.cmake @@ -63,30 +63,44 @@ 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)) - if(OPENMP_DEVICE_WORKS) - # 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..e28da4014c 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,41 @@ 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..f6b976d5d6 100644 --- a/cmake/tpl/SundialsPOSIXTimers.cmake +++ b/cmake/tpl/SundialsPOSIXTimers.cmake @@ -16,21 +16,31 @@ # ------------------------------------------------------------------------------ macro(posix_timers_test) - - set(options ) - set(oneValueArgs POSIX RT_LIB) - set(multiValueArgs ) + set(options) + set( + oneValueArgs + POSIX + RT_LIB + ) + 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" @@ -45,10 +55,13 @@ macro(posix_timers_test) "SET(CMAKE_C_FLAGS_MINSIZE \"${CMAKE_C_FLAGS_MINSIZE}\")\n" "ADD_EXECUTABLE(ltest ltest.c)\n" "TARGET_COMPILE_DEFINITIONS(ltest PRIVATE \"${posix_timers_test_POSIX}\")\n" - "TARGET_LINK_LIBRARIES(ltest \"${posix_timers_test_RT_LIB}\")\n") + "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" @@ -56,21 +69,24 @@ macro(posix_timers_test) "clock_gettime(CLOCK_MONOTONIC, &spec);\n" "clock_getres(CLOCK_MONOTONIC, &spec);\n" "return(0);\n" - "}\n") + "}\n" + ) # To ensure we do not use stuff from the previous attempts, # we must remove the CMakeFiles directory. 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 - OUTPUT_VARIABLE COMPILE_OUTPUT) - + 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() if(COMPILE_OK) @@ -81,14 +97,16 @@ 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() # Test failed, try again linking to rt if(NOT COMPILE_OK) - # Locate rt library and hide cache variable find_library(SUNDIALS_RT_LIBRARY NAMES rt) mark_as_advanced(SUNDIALS_RT_LIBRARY) @@ -99,22 +117,35 @@ if (NOT SUNDIALS_POSIX_TIMERS) if(COMPILE_OK) message(STATUS "Looking for POSIX timers (linking to rt)... found") set(POSIX_TIMERS_NEED_RT_LIBRARY TRUE) - set(EXE_EXTRA_LINK_LIBS ${EXE_EXTRA_LINK_LIBS} ${SUNDIALS_RT_LIBRARY}) + set( + EXE_EXTRA_LINK_LIBS + ${EXE_EXTRA_LINK_LIBS} + ${SUNDIALS_RT_LIBRARY} + ) endif() else() message(STATUS "Looking for rt library... FAILED") endif() - endif() # 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}) + set( + EXE_EXTRA_LINK_LIBS + ${EXE_EXTRA_LINK_LIBS} + ${SUNDIALS_RT_LIBRARY} + ) endif() endif() @@ -125,5 +156,4 @@ if (NOT SUNDIALS_POSIX_TIMERS) message(STATUS "Looking for POSIX timers... FAILED") set(SUNDIALS_POSIX_TIMERS FALSE) endif() - endif() 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..999f33e538 100644 --- a/cmake/tpl/SundialsRAJA.cmake +++ b/cmake/tpl/SundialsRAJA.cmake @@ -53,27 +53,53 @@ 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}\$") +foreach( + _backend + CUDA + HIP + OPENMP + TARGET_OPENMP + SYCL +) + 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 +120,58 @@ 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..0dbd67d045 100644 --- a/cmake/tpl/SundialsSuperLUDIST.cmake +++ b/cmake/tpl/SundialsSuperLUDIST.cmake @@ -38,7 +38,9 @@ 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 @@ -48,7 +50,9 @@ 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.") + print_error( + "OpenMP is required for SuperLU DIST support. Set ENABLE_OPENMP to ON." + ) endif() # ----------------------------------------------------------------------------- @@ -75,27 +79,50 @@ message(STATUS "SUPERLUDIST_ROCM: ${SUPERLUDIST_ROCM}") # If we have the SuperLU_DIST libraries, test them 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..2e58cefa51 100644 --- a/cmake/tpl/SundialsSuperLUMT.cmake +++ b/cmake/tpl/SundialsSuperLUMT.cmake @@ -38,7 +38,9 @@ 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() # ----------------------------------------------------------------------------- @@ -55,13 +57,14 @@ message(STATUS "SUPERLUMT_INCLUDE_DIR: ${SUPERLUMT_INCLUDE_DIR}") # ----------------------------------------------------------------------------- if(SUPERLUMT_FOUND AND (NOT SUPERLUMT_WORKS)) - # Create the SUPERLUMT_TEST directory set(SUPERLUMT_TEST_DIR ${PROJECT_BINARY_DIR}/SUPERLUMT_TEST) 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" @@ -75,10 +78,13 @@ if(SUPERLUMT_FOUND AND (NOT SUPERLUMT_WORKS)) "SET(CMAKE_C_FLAGS_MINSIZE \"${CMAKE_C_FLAGS_MINSIZE}\")\n" "ADD_EXECUTABLE(ltest ltest.c)\n" "TARGET_INCLUDE_DIRECTORIES(ltest PRIVATE ${SUPERLUMT_INCLUDE_DIR})\n" - "TARGET_LINK_LIBRARIES(ltest ${SUPERLUMT_LIBRARIES})\n") + "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" @@ -87,28 +93,41 @@ if(SUPERLUMT_FOUND AND (NOT SUPERLUMT_WORKS)) "Astore = NULL;\n" "if (A != NULL || Astore != NULL) return(1);\n" "else return(0);\n" - "}\n") - + "}\n" + ) # Attempt to build and link the "ltest" executable - try_compile(COMPILE_OK ${SUPERLUMT_TEST_DIR} ${SUPERLUMT_TEST_DIR} ltest - OUTPUT_VARIABLE COMPILE_OUTPUT) + 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: ") message("${COMPILE_OUTPUT}") print_error("SUNDIALS interface to SuperLU_MT is not functional.") 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..8fa305f57f 100644 --- a/cmake/tpl/SundialsTrilinos.cmake +++ b/cmake/tpl/SundialsTrilinos.cmake @@ -67,30 +67,120 @@ 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 +199,9 @@ 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" @@ -121,31 +213,48 @@ if(Trilinos_FOUND AND (NOT Trilinos_WORKS)) "INCLUDE(FindPackageHandleStandardArgs)\n" "INCLUDE(${PROJECT_SOURCE_DIR}/cmake/tpl/FindTrilinos.cmake)\n" "ADD_EXECUTABLE(ltest ltest.cpp)\n" - "TARGET_LINK_LIBRARIES(ltest SUNDIALS::TRILINOS)\n") + "TARGET_LINK_LIBRARIES(ltest SUNDIALS::TRILINOS)\n" + ) # 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") + file( + WRITE + ${Trilinos_TEST_DIR}/ltest.cpp + "#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 - OUTPUT_VARIABLE COMPILE_OUTPUT) + 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: ") message("${COMPILE_OUTPUT}") print_error("SUNDIALS interface to Trilinos is not functional.") 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..501cfc78d6 100644 --- a/cmake/tpl/SundialsXBRAID.cmake +++ b/cmake/tpl/SundialsXBRAID.cmake @@ -38,20 +38,26 @@ 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() # ----------------------------------------------------------------------------- @@ -70,13 +76,14 @@ message(STATUS "XBRAID_INCLUDES: ${XBRAID_INCS}") # Add works variable if(XBRAID_FOUND AND (NOT XBRAID_WORKS)) - # Create the XBRAID_TEST directory set(XBRAID_TEST_DIR ${PROJECT_BINARY_DIR}/XBRAID_TEST) 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" @@ -91,10 +98,13 @@ if(XBRAID_FOUND AND (NOT XBRAID_WORKS)) "add_executable(ltest ltest.c)\n" "target_include_directories(ltest PRIVATE \"${XBRAID_INCS}\")\n" "target_link_libraries(ltest \"${XBRAID_LIBS}\")\n" - "target_link_libraries(ltest m)\n") + "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" @@ -102,15 +112,21 @@ if(XBRAID_FOUND AND (NOT XBRAID_WORKS)) "rand = braid_Rand();\n" "if (rand < 0) return 1;\n" "return 0;\n" - "}\n") + "}\n" + ) # To ensure we do not use stuff from the previous attempts, # we must remove the CMakeFiles directory. 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 - OUTPUT_VARIABLE COMPILE_OUTPUT) + try_compile( + COMPILE_OK + ${XBRAID_TEST_DIR} + ${XBRAID_TEST_DIR} + ltest + OUTPUT_VARIABLE COMPILE_OUTPUT + ) # Process test result if(COMPILE_OK) @@ -124,7 +140,6 @@ if(XBRAID_FOUND AND (NOT XBRAID_WORKS)) endif() message(STATUS "XBRAID tests passed") - else() message(STATUS "Skipped XBRAID tests, assuming XBRAID works with SUNDIALS.") endif()