# ----------------------------------------------------------------------------- # Programmer(s): Cody J. Balos @ LLNL # ----------------------------------------------------------------------------- # SUNDIALS Copyright Start # Copyright (c) 2002-2024, Lawrence Livermore National Security # and Southern Methodist University. # All rights reserved. # # See the top-level LICENSE and NOTICE files for details. # # SPDX-License-Identifier: BSD-3-Clause # SUNDIALS Copyright End # ----------------------------------------------------------------------------- # Module to find and setup correctly. # Created from the SundialsTPL.cmake template. # All SUNDIALS modules that find and setup a TPL must: # # 1. Check to make sure the SUNDIALS configuration and the TPL is compatible. # 2. Find the TPL. # 3. Check if the TPL works with SUNDIALS, UNLESS the override option # TPL_WORKS is TRUE - in this case the tests should not be performed and it # should be assumed that the TPL works with SUNDIALS. # ----------------------------------------------------------------------------- # ----------------------------------------------------------------------------- # Section 1: Include guard # ----------------------------------------------------------------------------- if(NOT DEFINED SUNDIALS__INCLUDED) set(SUNDIALS__INCLUDED) else() return() endif() # ----------------------------------------------------------------------------- # Section 2: Check to make sure options are compatible # ----------------------------------------------------------------------------- # ----------------------------------------------------------------------------- # Section 3: Find the TPL # ----------------------------------------------------------------------------- find_package( REQUIRED) # ----------------------------------------------------------------------------- # Section 4: Test the TPL # ----------------------------------------------------------------------------- if(_FOUND AND (NOT _WORKS)) # Do any checks which don't require compilation first. # Create the _TEST directory set(_TEST_DIR ${PROJECT_BINARY_DIR}/_TEST) file(MAKE_DIRECTORY ${_TEST_DIR}) # Create a CMakeLists.txt file file(WRITE ${_TEST_DIR}/CMakeLists.txt "") # Create a C source file file(WRITE ${_TEST_DIR}/ltest.c "") # To ensure we do not use stuff from the previous attempts, # we must remove the CMakeFiles directory. file(REMOVE_RECURSE ${_TEST_DIR}/CMakeFiles) # Attempt to build and link the "ltest" executable try_compile(COMPILE_OK ${_TEST_DIR} ${_TEST_DIR} ltest OUTPUT_VARIABLE COMPILE_OUTPUT) # Process test result if(COMPILE_OK) message(STATUS "Checking if works with SUNDIALS... OK") set(_WORKS TRUE CACHE BOOL " works with SUNDIALS as configured" FORCE) else() message(STATUS "Checking if works with SUNDIALS... FAILED") message(STATUS "Check output: ") message("${COMPILE_OUTPUT}") message(FATAL_ERROR "SUNDIALS interface to is not functional.") endif() elseif(_FOUND AND _WORKS) message(STATUS "Skipped tests, assuming works with SUNDIALS.") endif()