1# --------------------------------------------------------------- 2# Programmer(s): Cody J. Balos @ LLNL 3# --------------------------------------------------------------- 4# SUNDIALS Copyright Start 5# Copyright (c) 2002-2021, Lawrence Livermore National Security 6# and Southern Methodist University. 7# All rights reserved. 8# 9# See the top-level LICENSE and NOTICE files for details. 10# 11# SPDX-License-Identifier: BSD-3-Clause 12# SUNDIALS Copyright End 13# --------------------------------------------------------------- 14# Options for SUNDIALS examples. 15# --------------------------------------------------------------- 16 17# ----------------------------------------------------------------------------- 18# Options for C/C++ examples 19# ----------------------------------------------------------------------------- 20 21sundials_option(EXAMPLES_ENABLE_C BOOL "Build SUNDIALS C examples" ON) 22 23# Some TPLs only have C++ examples. Default the C++ examples to ON if any of 24# these are enabled on the initial configuration pass. 25if (ENABLE_TRILINOS OR ENABLE_SUPERLUDIST OR ENABLE_XBRAID OR ENABLE_HIP OR ENABLE_MAGMA) 26 sundials_option(EXAMPLES_ENABLE_CXX BOOL "Build SUNDIALS C++ examples" ON) 27else() 28 sundials_option(EXAMPLES_ENABLE_CXX BOOL "Build SUNDIALS C++ examples" OFF) 29endif() 30 31# ----------------------------------------------------------------------------- 32# Options for Fortran Examples 33# ----------------------------------------------------------------------------- 34 35set(DOCSTR "Build SUNDIALS FORTRAN 77 examples") 36if(BUILD_FORTRAN77_INTERFACE) 37 38 sundials_option(EXAMPLES_ENABLE_F77 BOOL "${DOCSTR}" ON) 39 40 # Fortran 77 examples do not support single or extended precision 41 if(EXAMPLES_ENABLE_F77 AND (SUNDIALS_PRECISION MATCHES "EXTENDED" OR SUNDIALS_PRECISION MATCHES "SINGLE")) 42 print_warning("F77 examples are not compatible with ${SUNDIALS_PRECISION} precision. " 43 "Setting EXAMPLES_ENABLE_F77 to OFF.") 44 force_variable(EXAMPLES_ENABLE_F77 BOOL "${DOCSTR}" OFF) 45 endif() 46 47 sundials_option(EXAMPLES_ENABLE_F90 BOOL "Build SUNDIALS FORTRAN 90 examples" ON) 48 49 # Fortran 90 examples do not support extended precision 50 if(EXAMPLES_ENABLE_F90 AND (SUNDIALS_PRECISION MATCHES "EXTENDED")) 51 print_warning("F90 examples are not compatible with ${SUNDIALS_PRECISION} precision. " 52 "Setting EXAMPLES_ENABLE_F90 to OFF.") 53 force_variable(EXAMPLES_ENABLE_F90 BOOL "${DOCSTR}" OFF) 54 endif() 55 56else() 57 58 # set back to OFF (in case it was ON) 59 if(EXAMPLES_ENABLE_F77) 60 print_warning("EXAMPLES_ENABLE_F77 is ON but BUILD_FORTRAN77_INTERFACE is OFF. " 61 "Setting EXAMPLES_ENABLE_F77 to OFF.") 62 force_variable(EXAMPLES_ENABLE_F77 BOOL "${DOCSTR}" OFF) 63 endif() 64 65endif() 66 67# F2003 examples (on by default) are an option only if the 68# Fortran 2003 interface is enabled. 69set(DOCSTR "Build SUNDIALS Fortran 2003 examples") 70if(BUILD_FORTRAN_MODULE_INTERFACE) 71 72 sundials_option(EXAMPLES_ENABLE_F2003 BOOL "${DOCSTR}" ON) 73 74 # Fortran 2003 examples only support double precision 75 if(EXAMPLES_ENABLE_F2003 AND (NOT (SUNDIALS_PRECISION MATCHES "DOUBLE"))) 76 print_warning("F2003 examples are not compatible with ${SUNDIALS_PRECISION} precision. " 77 "Setting EXAMPLES_ENABLE_F2003 to OFF.") 78 force_variable(EXAMPLES_ENABLE_F2003 BOOL "${DOCSTR}" OFF) 79 endif() 80 81 # Fortran 2003 examples only support 64-bit indices 82 if(EXAMPLES_ENABLE_F2003 AND (NOT (SUNDIALS_INDEX_SIZE MATCHES "64"))) 83 print_warning("F2003 examples are not compatible with ${SUNDIALS_INDEX_SIZE}-bit indices. " 84 "Setting EXAMPLES_ENABLE_F2003 to OFF.") 85 force_variable(EXAMPLES_ENABLE_F2003 BOOL "${DOCSTR}" OFF) 86 endif() 87 88else() 89 90 # set back to OFF (in case it was ON) 91 if(EXAMPLES_ENABLE_F2003) 92 print_warning("EXAMPLES_ENABLE_F2003 is ON but BUILD_FORTRAN_MODULE_INTERFACE is OFF. " 93 "Setting EXAMPLES_ENABLE_F2003 to OFF.") 94 force_variable(EXAMPLES_ENABLE_F2003 BOOL "${DOCSTR}" OFF) 95 endif() 96 97endif() 98 99# ----------------------------------------------------------------------------- 100# Options for CUDA Examples 101# ----------------------------------------------------------------------------- 102 103sundials_option(EXAMPLES_ENABLE_CUDA BOOL "Build SUNDIALS CUDA examples" ON 104 DEPENDS_ON ENABLE_CUDA 105 SHOW_IF ENABLE_CUDA) 106 107 108# ----------------------------------------------------------------------------- 109# Options for installing examples 110# ----------------------------------------------------------------------------- 111 112# Enable installing examples by default 113sundials_option(EXAMPLES_INSTALL BOOL "Install SUNDIALS examples" ON) 114 115sundials_option(EXAMPLES_INSTALL_PATH PATH "Output directory for installing example files" "${CMAKE_INSTALL_PREFIX}/examples") 116 117# If examples are to be exported, check where we should install them. 118if(EXAMPLES_INSTALL AND NOT EXAMPLES_INSTALL_PATH) 119 print_warning("The example installation path is empty. " 120 "Example installation path was reset to its default value") 121 set(EXAMPLES_INSTALL_PATH "${CMAKE_INSTALL_PREFIX}/examples" CACHE STRING 122 "Output directory for installing example files" FORCE) 123endif() 124 125# ----------------------------------------------------------------------------- 126# Internal variables. 127# ----------------------------------------------------------------------------- 128 129if(EXAMPLES_ENABLE_C OR 130 EXAMPLES_ENABLE_CXX OR 131 EXAMPLES_ENABLE_CUDA OR 132 EXAMPLES_ENABLE_F77 OR 133 EXAMPLES_ENABLE_F90 OR 134 EXAMPLES_ENABLE_F2003) 135 set(_BUILD_EXAMPLES TRUE CACHE INTERNAL "") 136else() 137 set(_BUILD_EXAMPLES FALSE CACHE INTERNAL "") 138endif() 139