### Build and Install Examples (Bash) Source: https://github.com/nek5000/nekrs/blob/master/3rd_party/cvode/doc/shared/Install.rst Command to build and install SUNDIALS examples. This requires enabling example compilation for a specific language and setting EXAMPLES_INSTALL to ON. The installation path can be specified using EXAMPLES_INSTALL_PATH. ```bash make ``` -------------------------------- ### Install Example Build Files (CMake & Make) Source: https://github.com/nek5000/nekrs/blob/master/3rd_party/cvode/examples/sunlinsol/band/CMakeLists.txt This section details the installation process for example build files when the EXAMPLES_INSTALL flag is set. It covers installing a README file, preparing substitution variables for templates, generating and installing a CMakeLists.txt file, and conditionally generating and installing a Makefile for UNIX-type platforms. This allows users to easily build examples. ```cmake if(EXAMPLES_INSTALL) # Install the README file install(FILES DESTINATION ${EXAMPLES_INSTALL_PATH}/sunlinsol/band) # Prepare substitution variables for Makefile and/or CMakeLists templates set(SOLVER_LIB "sundials_sunlinsolband") set(LIBS "${LIBS} -lsundials_sunmatrixband") # Set the link directory for the band sunmatrix library # The generated CMakeLists.txt does not use find_library() locate it set(EXTRA_LIBS_DIR "${libdir}") examples2string(sunlinsol_band_examples EXAMPLES) examples2string(sunlinsol_band_dependencies EXAMPLES_DEPENDENCIES) # Regardless of the platform we're on, we will generate and install # CMakeLists.txt file for building the examples. This file can then # be used as a template for the user's own programs. # generate CMakelists.txt in the binary directory configure_file( ${PROJECT_SOURCE_DIR}/examples/templates/cmakelists_serial_C_ex.in ${PROJECT_BINARY_DIR}/examples/sunlinsol/band/CMakeLists.txt @ONLY ) # install CMakelists.txt install( FILES ${PROJECT_BINARY_DIR}/examples/sunlinsol/band/CMakeLists.txt DESTINATION ${EXAMPLES_INSTALL_PATH}/sunlinsol/band ) # On UNIX-type platforms, we also generate and install a makefile for # building the examples. This makefile can then be used as a template # for the user's own programs. if(UNIX) # generate Makefile and place it in the binary dir configure_file( ${PROJECT_SOURCE_DIR}/examples/templates/makefile_serial_C_ex.in ${PROJECT_BINARY_DIR}/examples/sunlinsol/band/Makefile_ex @ONLY ) # install the configured Makefile_ex as Makefile install( FILES ${PROJECT_BINARY_DIR}/examples/sunlinsol/band/Makefile_ex DESTINATION ${EXAMPLES_INSTALL_PATH}/sunlinsol/band RENAME Makefile ) endif() endif() ``` -------------------------------- ### Install and Configure Example Build Files Source: https://github.com/nek5000/nekrs/blob/master/3rd_party/cvode/examples/sunnonlinsol/fixedpoint/CMakeLists.txt This section handles the installation and configuration of build files for examples when installation is enabled. It includes installing a README file, preparing substitution variables for templates, and generating/installing CMakeLists.txt and Makefiles for serial C examples. ```cmake if(EXAMPLES_INSTALL) # Install the README file install(FILES DESTINATION ${EXAMPLES_INSTALL_PATH}/sunnonlinsol/fixedpoint) # Prepare substitution variables for Makefile and/or CMakeLists templates set(SOLVER_LIB "sundials_sunnonlinsolfixedpoint") set(LIBS "${LIBS} -lsundials_sunmatrixdense -lsundials_sunlinsoldense") # Set the link directory for the dense sunmatrix and linear solver library # The generated CMakeLists.txt does not use find_library() locate it set(EXTRA_LIBS_DIR "${libdir}") examples2string(examples EXAMPLES) # Regardless of the platform we're on, we will generate and install # CMakeLists.txt file for building the examples. This file can then # be used as a template for the user's own programs. # generate CMakelists.txt in the binary directory configure_file( ${PROJECT_SOURCE_DIR}/examples/templates/cmakelists_serial_C_ex.in ${PROJECT_BINARY_DIR}/examples/sunnonlinsol/fixedpoint/CMakeLists.txt @ONLY ) # install CMakelists.txt install( FILES ${PROJECT_BINARY_DIR}/examples/sunnonlinsol/fixedpoint/CMakeLists.txt DESTINATION ${EXAMPLES_INSTALL_PATH}/sunnonlinsol/fixedpoint ) # On UNIX-type platforms, we also generate and install a makefile for # building the examples. This makefile can then be used as a template # for the user's own programs. if(UNIX) # generate Makefile and place it in the binary dir configure_file( ${PROJECT_SOURCE_DIR}/examples/templates/makefile_serial_C_ex.in ${PROJECT_BINARY_DIR}/examples/sunnonlinsol/fixedpoint/Makefile_ex @ONLY ) # install the configured Makefile_ex as Makefile install( FILES ${PROJECT_BINARY_DIR}/examples/sunnonlinsol/fixedpoint/Makefile_ex DESTINATION ${EXAMPLES_INSTALL_PATH}/sunnonlinsol/fixedpoint RENAME Makefile ) endif() endif() ``` -------------------------------- ### Install Example Files and Templates (CMake) Source: https://github.com/nek5000/nekrs/blob/master/3rd_party/cvode/examples/nvector/manyvector/CMakeLists.txt This section details the installation process for example-related files when the EXAMPLES_INSTALL flag is set. It includes installing a README file, preparing substitution variables for templates, generating and installing a CMakeLists.txt file for building examples, and conditionally generating and installing a Makefile for UNIX-type platforms. ```cmake if(EXAMPLES_INSTALL) # Install the README file install(FILES DESTINATION ${EXAMPLES_INSTALL_PATH}/nvector/manyvector) # Prepare substitution variables for Makefile and/or CMakeLists templates set(SOLVER_LIB "sundials_nvecmanyvector") examples2string(nvector_manyvector_examples EXAMPLES) examples2string(nvector_examples_dependencies EXAMPLES_DEPENDENCIES) # Regardless of the platform we're on, we will generate and install # CMakeLists.txt file for building the examples. This file can then # be used as a template for the user's own programs. # generate CMakelists.txt in the binary directory configure_file( ${PROJECT_SOURCE_DIR}/examples/templates/cmakelists_serial_C_ex.in ${PROJECT_BINARY_DIR}/examples/nvector/manyvector/CMakeLists.txt @ONLY ) # install CMakelists.txt install( FILES ${PROJECT_BINARY_DIR}/examples/nvector/manyvector/CMakeLists.txt DESTINATION ${EXAMPLES_INSTALL_PATH}/nvector/manyvector ) # On UNIX-type platforms, we also generate and install a makefile for # building the examples. This makefile can then be used as a template # for the user's own programs. if(UNIX) # generate Makefile and place it in the binary dir configure_file( ${PROJECT_SOURCE_DIR}/examples/templates/makefile_serial_C_ex.in ${PROJECT_BINARY_DIR}/examples/nvector/manyvector/Makefile_ex @ONLY ) # install the configured Makefile_ex as Makefile install( FILES ${PROJECT_BINARY_DIR}/examples/nvector/manyvector/Makefile_ex DESTINATION ${EXAMPLES_INSTALL_PATH}/nvector/manyvector RENAME Makefile ) endif() endif() ``` -------------------------------- ### Install Example Build Configuration Files (CMake) Source: https://github.com/nek5000/nekrs/blob/master/3rd_party/cvode/examples/sunlinsol/pcg/serial/CMakeLists.txt This CMake code block handles the installation of build configuration files for examples when the EXAMPLES_INSTALL variable is set. It installs a README file, prepares substitution variables, generates a CMakeLists.txt file for serial C examples from a template, and installs it. On UNIX systems, it also generates and installs a Makefile for building the examples. ```cmake if(EXAMPLES_INSTALL) # Install the README file install(FILES DESTINATION ${EXAMPLES_INSTALL_PATH}/sunlinsol/pcg/serial) # Prepare substitution variables for Makefile and/or CMakeLists templates set(SOLVER_LIB "sundials_sunlinsolpcg") examples2string(sunlinsol_pcg_examples EXAMPLES) examples2string(sunlinsol_pcg_dependencies EXAMPLES_DEPENDENCIES) # Regardless of the platform we're on, we will generate and install # CMakeLists.txt file for building the examples. This file can then # be used as a template for the user's own programs. # generate CMakelists.txt in the binary directory configure_file( ${PROJECT_SOURCE_DIR}/examples/templates/cmakelists_serial_C_ex.in ${PROJECT_BINARY_DIR}/examples/sunlinsol/pcg/serial/CMakeLists.txt @ONLY ) # install CMakelists.txt install( FILES ${PROJECT_BINARY_DIR}/examples/sunlinsol/pcg/serial/CMakeLists.txt DESTINATION ${EXAMPLES_INSTALL_PATH}/sunlinsol/pcg/serial ) # On UNIX-type platforms, we also generate and install a makefile for # building the examples. This makefile can then be used as a template # for the user's own programs. if(UNIX) # generate Makefile and place it in the binary dir configure_file( ${PROJECT_SOURCE_DIR}/examples/templates/makefile_serial_C_ex.in ${PROJECT_BINARY_DIR}/examples/sunlinsol/pcg/serial/Makefile_ex @ONLY ) # install the configured Makefile_ex as Makefile install( FILES ${PROJECT_BINARY_DIR}/examples/sunlinsol/pcg/serial/Makefile_ex DESTINATION ${EXAMPLES_INSTALL_PATH}/sunlinsol/pcg/serial RENAME Makefile ) endif() endif() ``` -------------------------------- ### Install Example Build Files (CMake and Makefile) Source: https://github.com/nek5000/nekrs/blob/master/3rd_party/cvode/examples/sunlinsol/spfgmr/serial/CMakeLists.txt This snippet handles the installation of build files for examples when the EXAMPLES_INSTALL flag is set. It installs a README file, prepares substitution variables, and generates/installs a CMakeLists.txt file. For UNIX-like systems, it also generates and installs a Makefile. ```cmake if(EXAMPLES_INSTALL) # Install the README file install(FILES DESTINATION ${EXAMPLES_INSTALL_PATH}/sunlinsol/spfgmr/serial) # Prepare substitution variables for Makefile and/or CMakeLists templates set(SOLVER_LIB "sundials_sunlinsolspfgmr") examples2string(sunlinsol_spfgmr_examples EXAMPLES) examples2string(sunlinsol_spfgmr_dependencies EXAMPLES_DEPENDENCIES) # Regardless of the platform we're on, we will generate and install # CMakeLists.txt file for building the examples. This file can then # be used as a template for the user's own programs. # generate CMakelists.txt in the binary directory configure_file( ${PROJECT_SOURCE_DIR}/examples/templates/cmakelists_serial_C_ex.in ${PROJECT_BINARY_DIR}/examples/sunlinsol/spfgmr/serial/CMakeLists.txt @ONLY ) # install CMakelists.txt install( FILES ${PROJECT_BINARY_DIR}/examples/sunlinsol/spfgmr/serial/CMakeLists.txt DESTINATION ${EXAMPLES_INSTALL_PATH}/sunlinsol/spfgmr/serial ) # On UNIX-type platforms, we also generate and install a makefile for # building the examples. This makefile can then be used as a template # for the user's own programs. if(UNIX) # generate Makefile and place it in the binary dir configure_file( ${PROJECT_SOURCE_DIR}/examples/templates/makefile_serial_C_ex.in ${PROJECT_BINARY_DIR}/examples/sunlinsol/spfgmr/serial/Makefile_ex @ONLY ) # install the configured Makefile_ex as Makefile install( FILES ${PROJECT_BINARY_DIR}/examples/sunlinsol/spfgmr/serial/Makefile_ex DESTINATION ${EXAMPLES_INSTALL_PATH}/sunlinsol/spfgmr/serial RENAME Makefile ) endif() endif() ``` -------------------------------- ### Install Build Files for SUNMatrix Dense Fortran Examples Source: https://github.com/nek5000/nekrs/blob/master/3rd_party/cvode/examples/sunmatrix/dense/CMakeLists.txt This section handles the installation of build-related files for the SUNMatrix dense Fortran examples when installation is enabled. It installs a README, configures and installs a CMakeLists.txt file, and conditionally configures and installs a Makefile for UNIX-like systems. ```cmake if(EXAMPLES_INSTALL) # Install the README file install(FILES DESTINATION ${EXAMPLES_INSTALL_PATH}/sunmatrix/dense) # Prepare substitution variables for Makefile and/or CMakeLists templates set(SOLVER_LIB "sundials_sunmatrixdense") examples2string(sunmatrix_dense_examples EXAMPLES) examples2string(sunmatrix_dense_dependencies EXAMPLES_DEPENDENCIES) # Regardless of the platform we're on, we will generate and install # CMakeLists.txt file for building the examples. This file can then # be used as a template for the user's own programs. # generate CMakelists.txt in the binary directory configure_file( ${PROJECT_SOURCE_DIR}/examples/templates/cmakelists_serial_C_ex.in ${PROJECT_BINARY_DIR}/examples/sunmatrix/dense/CMakeLists.txt @ONLY ) # install CMakelists.txt install( FILES ${PROJECT_BINARY_DIR}/examples/sunmatrix/dense/CMakeLists.txt DESTINATION ${EXAMPLES_INSTALL_PATH}/sunmatrix/dense ) # On UNIX-type platforms, we also generate and install a makefile for # building the examples. This makefile can then be used as a template # for the user's own programs. if(UNIX) # generate Makefile and place it in the binary dir configure_file( ${PROJECT_SOURCE_DIR}/examples/templates/makefile_serial_C_ex.in ${PROJECT_BINARY_DIR}/examples/sunmatrix/dense/Makefile_ex @ONLY ) # install the configured Makefile_ex as Makefile install( FILES ${PROJECT_BINARY_DIR}/examples/sunmatrix/dense/Makefile_ex DESTINATION ${EXAMPLES_INSTALL_PATH}/sunmatrix/dense RENAME Makefile ) endif() endif() ``` -------------------------------- ### Install SYCL nvector Examples Source: https://github.com/nek5000/nekrs/blob/master/3rd_party/cvode/examples/nvector/sycl/CMakeLists.txt This snippet handles the installation of SYCL nvector examples. It uses a CMake function to copy the necessary files and configure the installation path, making the examples available after the build. ```cmake if(EXAMPLES_INSTALL) sundials_install_examples(nvector_sycl nvector_sycl_examples EXAMPLES_DEPENDENCIES test_nvector.c EXTRA_FILES ${SUNDIALS_SOURCE_DIR}/examples/nvector/test_nvector.c ${SUNDIALS_SOURCE_DIR}/examples/nvector/test_nvector.h ${SUNDIALS_SOURCE_DIR}/examples/utilities/custom_memory_helper_sycl.h CMAKE_TEMPLATE cmakelists_CXX_ex.in SUNDIALS_TARGETS nvecsycl DESTINATION nvector/sycl ) endif() ``` -------------------------------- ### Install README and Extra Files for CVODE Examples (CMake) Source: https://github.com/nek5000/nekrs/blob/master/3rd_party/cvode/examples/cvode/CXX_parhyp/CMakeLists.txt Installs the README file and additional extra files specified in CVODE_extras for the CVODE/CXX_parhyp examples. These files are copied to the designated installation path. ```cmake if(EXAMPLES_INSTALL) # Install the README file install(FILES README DESTINATION ${EXAMPLES_INSTALL_PATH}/cvode/CXX_parhyp) # Install the extra files foreach(extrafile ${CVODE_extras}) install(FILES ${extrafile} DESTINATION ${EXAMPLES_INSTALL_PATH}/cvode/CXX_parhyp) endforeach() # ... other configurations ... endif(EXAMPLES_INSTALL) ``` -------------------------------- ### Install Example Build Files for NVector Module Source: https://github.com/nek5000/nekrs/blob/master/3rd_party/cvode/examples/nvector/mpimanyvector/CMakeLists.txt This section handles the installation of build-related files for the NVector module examples when the EXAMPLES_INSTALL flag is set. It includes installing a README, preparing substitution variables, and generating/installing CMakeLists.txt and a Makefile for parallel C examples. ```cmake if(EXAMPLES_INSTALL) # Install the README file install(FILES DESTINATION ${EXAMPLES_INSTALL_PATH}/nvector/mpimanyvector) # Prepare substitution variables for Makefile and/or CMakeLists templates set(SOLVER_LIB "sundials_nvecmpimanyvector") examples2string(nvector_mpimanyvector_examples EXAMPLES) examples2string(nvector_examples_dependencies EXAMPLES_DEPENDENCIES) # Regardless of the platform we're on, we will generate and install # CMakeLists.txt file for building the examples. This file can then # be used as a template for the user's own programs. # generate CMakelists.txt in the binary directory configure_file( ${PROJECT_SOURCE_DIR}/examples/templates/cmakelists_parallel_C_ex.in ${PROJECT_BINARY_DIR}/examples/nvector/mpimanyvector/CMakeLists.txt @ONLY ) # install CMakelists.txt install( FILES ${PROJECT_BINARY_DIR}/examples/nvector/mpimanyvector/CMakeLists.txt DESTINATION ${EXAMPLES_INSTALL_PATH}/nvector/mpimanyvector ) # On UNIX-type platforms, we also generate and install a makefile for # building the examples. This makefile can then be used as a template # for the user's own programs. if(UNIX) # generate Makefile and place it in the binary dir configure_file( ${PROJECT_SOURCE_DIR}/examples/templates/makefile_parallel_C_ex.in ${PROJECT_BINARY_DIR}/examples/nvector/mpimanyvector/Makefile_ex @ONLY ) # install the configured Makefile_ex as Makefile install( FILES ${PROJECT_BINARY_DIR}/examples/nvector/mpimanyvector/Makefile_ex DESTINATION ${EXAMPLES_INSTALL_PATH}/nvector/mpimanyvector RENAME Makefile ) endif() endif() ``` -------------------------------- ### Install Example Build Files and Templates Source: https://github.com/nek5000/nekrs/blob/master/3rd_party/cvode/examples/nvector/mpiplusx/CMakeLists.txt This section handles the installation of example-related files when the EXAMPLES_INSTALL option is enabled. It installs a README, prepares substitution variables, generates and installs CMakeLists.txt for parallel C examples, and conditionally generates and installs a Makefile for UNIX-like systems. ```cmake if(EXAMPLES_INSTALL) # Install the README file install(FILES DESTINATION ${EXAMPLES_INSTALL_PATH}/nvector/mpiplusx) # Prepare substitution variables for Makefile and/or CMakeLists templates set(SOLVER_LIB "sundials_nvecmpiplusx") examples2string(nvector_mpiplusx_examples EXAMPLES) examples2string(nvector_examples_dependencies EXAMPLES_DEPENDENCIES) # Regardless of the platform we're on, we will generate and install # CMakeLists.txt file for building the examples. This file can then # be used as a template for the user's own programs. # generate CMakelists.txt in the binary directory configure_file( ${PROJECT_SOURCE_DIR}/examples/templates/cmakelists_parallel_C_ex.in ${PROJECT_BINARY_DIR}/examples/nvector/mpiplusx/CMakeLists.txt @ONLY ) # install CMakelists.txt install( FILES ${PROJECT_BINARY_DIR}/examples/nvector/mpiplusx/CMakeLists.txt DESTINATION ${EXAMPLES_INSTALL_PATH}/nvector/mpiplusx ) # On UNIX-type platforms, we also generate and install a makefile for # building the examples. This makefile can then be used as a template # for the user's own programs. if(UNIX) # generate Makefile and place it in the binary dir configure_file( ${PROJECT_SOURCE_DIR}/examples/templates/makefile_parallel_C_ex.in ${PROJECT_BINARY_DIR}/examples/nvector/mpiplusx/Makefile_ex @ONLY ) # install the configured Makefile_ex as Makefile install( FILES ${PROJECT_BINARY_DIR}/examples/nvector/mpiplusx/Makefile_ex DESTINATION ${EXAMPLES_INSTALL_PATH}/nvector/mpiplusx RENAME Makefile ) endif() endif() ``` -------------------------------- ### Install Example Build Files and Templates (CMake) Source: https://github.com/nek5000/nekrs/blob/master/3rd_party/cvode/examples/sunlinsol/dense/CMakeLists.txt This CMake code block handles the installation of example-related files when the EXAMPLES_INSTALL option is enabled. It installs a README file, prepares substitution variables for template files, generates CMakeLists.txt and Makefile templates for serial C examples, and installs them to the appropriate destination directories. This allows users to easily build and adapt the examples for their own programs. ```cmake if(EXAMPLES_INSTALL) # Install the README file install(FILES DESTINATION ${EXAMPLES_INSTALL_PATH}/sunlinsol/dense) # Prepare substitution variables for Makefile and/or CMakeLists templates set(SOLVER_LIB "sundials_sunlinsoldense") set(LIBS "${LIBS} -lsundials_sunmatrixdense") # Set the link directory for the dense sunmatrix library # The generated CMakeLists.txt does not use find_library() locate it set(EXTRA_LIBS_DIR "${libdir}") examples2string(sunlinsol_dense_examples EXAMPLES) examples2string(sunlinsol_dense_dependencies EXAMPLES_DEPENDENCIES) # Regardless of the platform we're on, we will generate and install # CMakeLists.txt file for building the examples. This file can then # be used as a template for the user's own programs. # generate CMakelists.txt in the binary directory configure_file( ${PROJECT_SOURCE_DIR}/examples/templates/cmakelists_serial_C_ex.in ${PROJECT_BINARY_DIR}/examples/sunlinsol/dense/CMakeLists.txt @ONLY ) # install CMakelists.txt install( FILES ${PROJECT_BINARY_DIR}/examples/sunlinsol/dense/CMakeLists.txt DESTINATION ${EXAMPLES_INSTALL_PATH}/sunlinsol/dense ) # On UNIX-type platforms, we also generate and install a makefile for # building the examples. This makefile can then be used as a template # for the user's own programs. if(UNIX) # generate Makefile and place it in the binary dir configure_file( ${PROJECT_SOURCE_DIR}/examples/templates/makefile_serial_C_ex.in ${PROJECT_BINARY_DIR}/examples/sunlinsol/dense/Makefile_ex @ONLY ) # install the configured Makefile_ex as Makefile install( FILES ${PROJECT_BINARY_DIR}/examples/sunlinsol/dense/Makefile_ex DESTINATION ${EXAMPLES_INSTALL_PATH}/sunlinsol/dense RENAME Makefile ) endif() endif() ``` -------------------------------- ### Install CVODE Examples Source: https://github.com/nek5000/nekrs/blob/master/3rd_party/cvode/examples/cvode/CXX_onemkl/CMakeLists.txt This CMake code snippet handles the installation of CVODE examples if the EXAMPLES_INSTALL option is enabled. It uses a helper function to install the executables and related SUNDIALS/MKL components to a specified destination directory. ```cmake if(EXAMPLES_INSTALL) sundials_install_examples(cvode CVODE_examples CMAKE_TEMPLATE cmakelists_CXX_ex.in SUNDIALS_TARGETS cvode nvecsycl sunlinsolonemkldense OTHER_TARGETS MKL::MKL_DPCPP DESTINATION cvode/CXX_onemkl ) endif() ``` -------------------------------- ### Install C OpenMP Example Build Files Source: https://github.com/nek5000/nekrs/blob/master/3rd_party/cvode/examples/nvector/C_openmp/CMakeLists.txt This section handles the installation of build files for C OpenMP examples. It installs a README file, prepares substitution variables, generates a CMakeLists.txt file for building examples, and installs it. On UNIX-type platforms, it also generates and installs a Makefile. ```cmake if(EXAMPLES_INSTALL) # Install the README file install(FILES DESTINATION ${EXAMPLES_INSTALL_PATH}/nvector/C_openmp) # Prepare substitution variables for Makefile and/or CMakeLists templates set(SOLVER_LIB "sundials_nvecopenmp") examples2string(nvector_openmp_examples EXAMPLES) examples2string(nvector_examples_dependencies EXAMPLES_DEPENDENCIES) # Regardless of the platform we're on, we will generate and install # CMakeLists.txt file for building the examples. This file can then # be used as a template for the user's own programs. # generate CMakelists.txt in the binary directory configure_file( ${PROJECT_SOURCE_DIR}/examples/templates/cmakelists_openmp_C_ex.in ${PROJECT_BINARY_DIR}/examples/nvector/C_openmp/CMakeLists.txt @ONLY ) # install CMakelists.txt install( FILES ${PROJECT_BINARY_DIR}/examples/nvector/C_openmp/CMakeLists.txt DESTINATION ${EXAMPLES_INSTALL_PATH}/nvector/C_openmp ) # On UNIX-type platforms, we also generate and install a makefile for # building the examples. This makefile can then be used as a template # for the user's own programs. if(UNIX) # generate Makefile and place it in the binary dir configure_file( ${PROJECT_SOURCE_DIR}/examples/templates/makefile_openmp_C_ex.in ${PROJECT_BINARY_DIR}/examples/nvector/C_openmp/Makefile_ex @ONLY ) # install the configured Makefile_ex as Makefile install( FILES ${PROJECT_BINARY_DIR}/examples/nvector/C_openmp/Makefile_ex DESTINATION ${EXAMPLES_INSTALL_PATH}/nvector/C_openmp RENAME Makefile ) endif() endif() ``` -------------------------------- ### Install CVODE RAJA Examples Source: https://github.com/nek5000/nekrs/blob/master/3rd_party/cvode/examples/cvode/raja/CMakeLists.txt Handles the installation of CVODE RAJA examples if the 'EXAMPLES_INSTALL' flag is set. It conditionally sets up find_package commands for OpenMP and Threads, and then uses 'sundials_install_examples' to generate CMakeLists.txt and Makefile templates, link necessary libraries, and specify installation destinations and test configurations. ```cmake if(EXAMPLES_INSTALL) if(SUNDIALS_BUILD_PACKAGE_FUSED_KERNELS) set(_fused_stubs_target cvode_fused_stubs) set(LIBS "-lsundials_cvode_fused_stubs ${LIBS}") endif() if((RAJA_BACKENDS MATCHES "TARGET_OPENMP") OR (RAJA_BACKENDS MATCHES "OPENMP")) set(EXAMPLES_FIND_PACKAGE "find_package(OpenMP REQUIRED)\n") set(_openmp_target OpenMP::OpenMP_CXX) endif() if(RAJA_NEEDS_THREADS) set(EXAMPLES_FIND_PACKAGE "${EXAMPLES_FIND_PACKAGE}find_package(Threads REQUIRED)\n") endif() sundials_install_examples(cvode CVODE_examples CMAKE_TEMPLATE cmakelists_${_lang}_ex.in MAKE_TEMPLATE makefile_serial_RAJA_ex.in SOLVER_LIBRARY sundials_cvode SUNDIALS_TARGETS cvode nvecraja ${_fused_stubs_target} OTHER_TARGETS ${_openmp_target} DESTINATION cvode/raja EXTRA_FILES README TEST_INSTALL raja ) endif() ``` -------------------------------- ### Configure SUNDIALS with MPI and Examples Source: https://github.com/nek5000/nekrs/blob/master/3rd_party/cvode/doc/shared/Install.rst Example of configuring SUNDIALS with MPI enabled, specifying installation paths for libraries and example sources. This command sets up the build environment for parallel execution and includes example files in the installation. ```bash % cmake \ > -DCMAKE_INSTALL_PREFIX=/home/myname/sundials/instdir \ > -DEXAMPLES_INSTALL_PATH=/home/myname/sundials/instdir/examples \ > -DENABLE_MPI=ON \ > /home/myname/sundials/srcdir % make install ``` -------------------------------- ### Install Example Build Files with CMake Source: https://github.com/nek5000/nekrs/blob/master/3rd_party/cvode/examples/nvector/serial/CMakeLists.txt This section of the CMake script handles the installation of example build configurations. It installs a README file, prepares substitution variables for template files, and generates/installs CMakeLists.txt and Makefile files for users to build examples. This ensures users can easily replicate the build process for the provided examples. ```cmake if(EXAMPLES_INSTALL) # Install the README file install(FILES DESTINATION ${EXAMPLES_INSTALL_PATH}/nvector/serial) # Prepare substitution variables for Makefile and/or CMakeLists templates set(SOLVER_LIB "sundials_nvecserial") examples2string(nvector_serial_examples EXAMPLES) set(nvector_serial_dependencies test_nvector.c) examples2string(nvector_serial_dependencies EXAMPLES_DEPENDENCIES) # Regardless of the platform we're on, we will generate and install # CMakeLists.txt file for building the examples. This file can then # be used as a template for the user's own programs. # generate CMakelists.txt in the binary directory configure_file( ${PROJECT_SOURCE_DIR}/examples/templates/cmakelists_serial_C_ex.in ${PROJECT_BINARY_DIR}/examples/nvector/serial/CMakeLists.txt @ONLY ) # install CMakelists.txt install( FILES ${PROJECT_BINARY_DIR}/examples/nvector/serial/CMakeLists.txt DESTINATION ${EXAMPLES_INSTALL_PATH}/nvector/serial ) # On UNIX-type platforms, we also generate and install a makefile for # building the examples. This makefile can then be used as a template # for the user's own programs. set(EXAMPLES_DEPENDENCIES ) set(nvector_serial_dependencies test_nvector) examples2string(nvector_serial_dependencies EXAMPLES_DEPENDENCIES) if(UNIX) # generate Makefile and place it in the binary dir configure_file( ${PROJECT_SOURCE_DIR}/examples/templates/makefile_serial_C_ex.in ${PROJECT_BINARY_DIR}/examples/nvector/serial/Makefile_ex @ONLY ) # install the configured Makefile_ex as Makefile install( FILES ${PROJECT_BINARY_DIR}/examples/nvector/serial/Makefile_ex DESTINATION ${EXAMPLES_INSTALL_PATH}/nvector/serial RENAME Makefile ) endif() endif() ``` -------------------------------- ### Install Example Build Files (CMake) Source: https://github.com/nek5000/nekrs/blob/master/3rd_party/cvode/examples/sunlinsol/klu/CMakeLists.txt This CMake script handles the installation of build files for the sunlinsol_klu examples when the EXAMPLES_INSTALL option is enabled. It installs a README file, configures and installs a CMakeLists.txt file for building examples, and conditionally generates and installs a Makefile for UNIX-like systems. ```cmake if(EXAMPLES_INSTALL) # Install the README file install(FILES DESTINATION ${EXAMPLES_INSTALL_PATH}/sunlinsol/klu) # Prepare substitution variables for Makefile and/or CMakeLists templates set(SOLVER_LIB "sundials_sunlinsolklu") set(LIBS "${LIBS} -lsundials_sunmatrixsparse -lsundials_sunmatrixdense") # Set the link directory for the sparse and dense sunmatrix libraries # The generated CMakeLists.txt does not use find_library() locate them set(EXTRA_LIBS_DIR "${libdir}") examples2string(sunlinsol_klu_examples EXAMPLES_KLU) examples2string(sunlinsol_klu_dependencies EXAMPLES_DEPENDENCIES_KLU) # Regardless of the platform we're on, we will generate and install # CMakeLists.txt file for building the examples. This file can then # be used as a template for the user's own programs. # generate CMakelists.txt in the binary directory configure_file( ${PROJECT_SOURCE_DIR}/examples/templates/cmakelists_serial_C_ex.in ${PROJECT_BINARY_DIR}/examples/sunlinsol/klu/CMakeLists.txt @ONLY ) # install CMakelists.txt install( FILES ${PROJECT_BINARY_DIR}/examples/sunlinsol/klu/CMakeLists.txt DESTINATION ${EXAMPLES_INSTALL_PATH}/sunlinsol/klu ) # On UNIX-type platforms, we also generate and install a makefile for # building the examples. This makefile can then be used as a template # for the user's own programs. if(UNIX) # generate Makefile and place it in the binary dir configure_file( ${PROJECT_SOURCE_DIR}/examples/templates/makefile_serial_C_ex.in ${PROJECT_BINARY_DIR}/examples/sunlinsol/klu/Makefile_ex @ONLY ) # install the configured Makefile_ex as Makefile install( FILES ${PROJECT_BINARY_DIR}/examples/sunlinsol/klu/Makefile_ex DESTINATION ${EXAMPLES_INSTALL_PATH}/sunlinsol/klu RENAME Makefile ) endif() endif() ``` -------------------------------- ### Install SUNMATRIX_CUSPARSE Examples Source: https://github.com/nek5000/nekrs/blob/master/3rd_party/cvode/examples/sunmatrix/cusparse/CMakeLists.txt Installs the SUNMATRIX_CUSPARSE examples if the EXAMPLES_INSTALL option is enabled. This includes specifying dependencies, extra files, a CMake template, SUNDIALS targets, and the destination directory. ```cmake sundials_install_examples(sunmatrix_cusparse examples_list EXAMPLES_DEPENDENCIES test_sunmatrix.c test_sunmatrix.h dreadrb.c dreadrb.h EXTRA_FILES ${SUNDIALS_SOURCE_DIR}/examples/sunmatrix/test_sunmatrix.c ${SUNDIALS_SOURCE_DIR}/examples/sunmatrix/test_sunmatrix.h ${SUNDIALS_SOURCE_DIR}/examples/sunmatrix/dreadrb.c ${SUNDIALS_SOURCE_DIR}/examples/sunmatrix/dreadrb.h CMAKE_TEMPLATE cmakelists_CUDA_ex.in SUNDIALS_TARGETS nveccuda nvecserial sunmatrixdense sunmatrixsparse sunmatrixcusparse DESTINATION sunmatrix/cusparse ) ``` -------------------------------- ### Install Example CMakeLists and Makefile (CMake) Source: https://github.com/nek5000/nekrs/blob/master/3rd_party/cvode/examples/sunlinsol/sptfqmr/parallel/CMakeLists.txt This CMake snippet handles the installation of build-related files for the SPTFQMR parallel examples. It installs the README, configures and installs a CMakeLists.txt file for users to template their own projects, and conditionally installs a Makefile for UNIX-like systems. ```cmake if(EXAMPLES_INSTALL) # Install the README file install(FILES DESTINATION ${EXAMPLES_INSTALL_PATH}/sunlinsol/sptfqmr/parallel) # Prepare substitution variables for Makefile and/or CMakeLists templates set(SOLVER_LIB "sundials_sunlinsolsptfqmr") examples2string(sunlinsol_sptfqmr_examples EXAMPLES) examples2string(sunlinsol_sptfqmr_dependencies EXAMPLES_DEPENDENCIES) # Regardless of the platform we're on, we will generate and install # CMakeLists.txt file for building the examples. This file can then # be used as a template for the user's own programs. # generate CMakelists.txt in the binary directory configure_file( ${PROJECT_SOURCE_DIR}/examples/templates/cmakelists_parallel_C_ex.in ${PROJECT_BINARY_DIR}/examples/sunlinsol/sptfqmr/parallel/CMakeLists.txt @ONLY ) # install CMakelists.txt install( FILES ${PROJECT_BINARY_DIR}/examples/sunlinsol/sptfqmr/parallel/CMakeLists.txt DESTINATION ${EXAMPLES_INSTALL_PATH}/sunlinsol/sptfqmr/parallel ) # On UNIX-type platforms, we also generate and install a makefile for # building the examples. This makefile can then be used as a template # for the user's own programs. if(UNIX) # generate Makefile and place it in the binary dir configure_file( ${PROJECT_SOURCE_DIR}/examples/templates/makefile_parallel_C_ex.in ${PROJECT_BINARY_DIR}/examples/sunlinsol/sptfqmr/parallel/Makefile_ex @ONLY ) # install the configured Makefile_ex as Makefile install( FILES ${PROJECT_BINARY_DIR}/examples/sunlinsol/sptfqmr/parallel/Makefile_ex DESTINATION ${EXAMPLES_INSTALL_PATH}/sunlinsol/sptfqmr/parallel RENAME Makefile ) endif() endif() ``` -------------------------------- ### Install Example Build Files (CMake) Source: https://github.com/nek5000/nekrs/blob/master/3rd_party/cvode/examples/nvector/mpicuda/CMakeLists.txt This CMake snippet handles the installation of example build files, including the main CMakeLists.txt and Makefiles. It conditionally installs these files based on the EXAMPLES_INSTALL flag and generates platform-specific build scripts for user convenience. ```cmake if(EXAMPLES_INSTALL) # Install the README file install(FILES DESTINATION ${EXAMPLES_INSTALL_PATH}/nvector/mpicuda) examples2string(nvector_cuda_examples EXAMPLES) examples2string(nvector_examples_dependencies EXAMPLES_DEPENDENCIES) # Regardless of the platform we're on, we will generate and install # CMakeLists.txt file for building the examples. This file can then # be used as a template for the user's own programs. # generate CMakelists.txt in the binary directory configure_file( ${PROJECT_SOURCE_DIR}/examples/templates/cmakelists_parallel_CUDA_ex.in ${PROJECT_BINARY_DIR}/examples/nvector/mpicuda/CMakeLists.txt @ONLY ) # install CMakelists.txt install( FILES ${PROJECT_BINARY_DIR}/examples/nvector/mpicuda/CMakeLists.txt DESTINATION ${EXAMPLES_INSTALL_PATH}/nvector/mpicuda ) # On UNIX-type platforms, we also generate and install a makefile for # building the examples. This makefile can then be used as a template # for the user's own programs. if(UNIX) # generate Makefile and place it in the binary dir configure_file( ${PROJECT_SOURCE_DIR}/examples/templates/makefile_parallel_CUDA_ex.in ${PROJECT_BINARY_DIR}/examples/nvector/mpicuda/Makefile_ex @ONLY ) # install the configured Makefile_ex as Makefile install( FILES ${PROJECT_BINARY_DIR}/examples/nvector/mpicuda/Makefile_ex DESTINATION ${EXAMPLES_INSTALL_PATH}/nvector/mpicuda RENAME Makefile ) endif() endif() ``` -------------------------------- ### Install SUNDIALS Example Build Files (CMake) Source: https://github.com/nek5000/nekrs/blob/master/3rd_party/cvode/examples/sunlinsol/spbcgs/serial/CMakeLists.txt This section handles the installation of build files for SUNDIALS examples when the EXAMPLES_INSTALL variable is true. It installs a README file, generates and installs a CMakeLists.txt file for building examples, and conditionally generates and installs a Makefile for UNIX-type platforms. ```cmake if(EXAMPLES_INSTALL) # Install the README file install(FILES DESTINATION ${EXAMPLES_INSTALL_PATH}/sunlinsol/spbcgs/serial) # Prepare substitution variables for Makefile and/or CMakeLists templates set(SOLVER_LIB "sundials_sunlinsolspbcgs") examples2string(sunlinsol_spbcgs_examples EXAMPLES) examples2string(sunlinsol_spbcgs_dependencies EXAMPLES_DEPENDENCIES) # Regardless of the platform we're on, we will generate and install # CMakeLists.txt file for building the examples. This file can then # be used as a template for the user's own programs. # generate CMakelists.txt in the binary directory configure_file( ${PROJECT_SOURCE_DIR}/examples/templates/cmakelists_serial_C_ex.in ${PROJECT_BINARY_DIR}/examples/sunlinsol/spbcgs/serial/CMakeLists.txt @ONLY ) # install CMakelists.txt install( FILES ${PROJECT_BINARY_DIR}/examples/sunlinsol/spbcgs/serial/CMakeLists.txt DESTINATION ${EXAMPLES_INSTALL_PATH}/sunlinsol/spbcgs/serial ) # On UNIX-type platforms, we also generate and install a makefile for # building the examples. This makefile can then be used as a template # for the user's own programs. if(UNIX) # generate Makefile and place it in the binary dir configure_file( ${PROJECT_SOURCE_DIR}/examples/templates/makefile_serial_C_ex.in ${PROJECT_BINARY_DIR}/examples/sunlinsol/spbcgs/serial/Makefile_ex @ONLY ) # install the configured Makefile_ex as Makefile install( FILES ${PROJECT_BINARY_DIR}/examples/sunlinsol/spbcgs/serial/Makefile_ex DESTINATION ${EXAMPLES_INSTALL_PATH}/sunlinsol/spbcgs/serial RENAME Makefile ) endif() endif() ``` -------------------------------- ### CMake: Install Example Source Files Source: https://github.com/nek5000/nekrs/blob/master/3rd_party/cvode/examples/nvector/parhyp/CMakeLists.txt This CMake snippet handles the installation of example source files and related header files to a specified destination directory. This is conditional on the `EXAMPLES_INSTALL` flag being set, ensuring that examples are only installed when explicitly requested. ```cmake # install example source files if(EXAMPLES_INSTALL) install(FILES ${example}.c ../test_nvector.c ../test_nvector.h ../test_mpinvector.c DESTINATION ${EXAMPLES_INSTALL_PATH}/nvector/parhyp) endif() ``` -------------------------------- ### Install Examples with Source Tree Check Source: https://github.com/nek5000/nekrs/blob/master/CMakeLists.txt This CMake code installs example files. It first uses `file(GLOB_RECURSE ...)` to find all example files. Then, it configures an `install_examples.cmake` script from a template and executes it. This script likely contains logic to only copy examples if the source tree is newer than the installed version, ensuring examples are up-to-date. ```cmake file(GLOB_RECURSE EXAMPLE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/examples/*) configure_file(${CMAKE_CURRENT_LIST_DIR}/cmake/install_examples.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/install_examples.cmake @ONLY) install(SCRIPT ${CMAKE_CURRENT_BINARY_DIR}/install_examples.cmake) ``` -------------------------------- ### Install Example Build Files (CMake) Source: https://github.com/nek5000/nekrs/blob/master/3rd_party/cvode/examples/sunnonlinsol/newton/CMakeLists.txt This CMake code block handles the installation of build-related files for examples when the EXAMPLES_INSTALL option is enabled. It configures and installs CMakeLists.txt and, on UNIX-like systems, a Makefile, serving as templates for users to build their own programs. ```cmake if(EXAMPLES_INSTALL) # Install the README file install(FILES DESTINATION ${EXAMPLES_INSTALL_PATH}/sunnonlinsol/newton) # Prepare substitution variables for Makefile and/or CMakeLists templates set(SOLVER_LIB "sundials_sunnonlinsolnewton") set(LIBS "${LIBS} -lsundials_sunmatrixdense -lsundials_sunlinsoldense") # Set the link directory for the dense sunmatrix and linear solver library # The generated CMakeLists.txt does not use find_library() locate it set(EXTRA_LIBS_DIR "${libdir}") examples2string(examples EXAMPLES) # Regardless of the platform we're on, we will generate and install # CMakeLists.txt file for building the examples. This file can then # be used as a template for the user's own programs. # generate CMakelists.txt in the binary directory configure_file( ${PROJECT_SOURCE_DIR}/examples/templates/cmakelists_serial_C_ex.in ${PROJECT_BINARY_DIR}/examples/sunnonlinsol/newton/CMakeLists.txt @ONLY ) # install CMakelists.txt install( FILES ${PROJECT_BINARY_DIR}/examples/sunnonlinsol/newton/CMakeLists.txt DESTINATION ${EXAMPLES_INSTALL_PATH}/sunnonlinsol/newton ) # On UNIX-type platforms, we also generate and install a makefile for # building the examples. This makefile can then be used as a template # for the user's own programs. if(UNIX) # generate Makefile and place it in the binary dir configure_file( ${PROJECT_SOURCE_DIR}/examples/templates/makefile_serial_C_ex.in ${PROJECT_BINARY_DIR}/examples/sunnonlinsol/newton/Makefile_ex @ONLY ) # install the configured Makefile_ex as Makefile install( FILES ${PROJECT_BINARY_DIR}/examples/sunnonlinsol/newton/Makefile_ex DESTINATION ${EXAMPLES_INSTALL_PATH}/sunnonlinsol/newton RENAME Makefile ) endif() endif() ``` -------------------------------- ### Install CVODE SYCL Examples with CMake Source: https://github.com/nek5000/nekrs/blob/master/3rd_party/cvode/examples/cvode/CXX_sycl/CMakeLists.txt This CMake snippet handles the installation of CVODE SYCL examples. It uses the `sundials_install_examples` macro to copy example files and associated build configurations to a specified destination directory, making them available for use after the build process. ```cmake # Install the targets if(EXAMPLES_INSTALL) sundials_install_examples(cvode CVODE_examples CMAKE_TEMPLATE cmakelists_CXX_ex.in SUNDIALS_TARGETS cvode nvecsycl DESTINATION cvode/CXX_sycl) endif() ```