From 476b4c12335d6388836164394c68e5f16da65c03 Mon Sep 17 00:00:00 2001 From: "Balos, Cody, J" Date: Mon, 17 Jun 2024 08:44:27 -0700 Subject: [PATCH] use CMake_Fortran_MODULE_DIRECTORY before creating executable --- examples/arkode/F2003_custom/CMakeLists.txt | 2 +- examples/arkode/F2003_serial/CMakeLists.txt | 9 +++++---- examples/nvector/C_openmp/CMakeLists.txt | 4 +++- examples/nvector/manyvector/CMakeLists.txt | 4 +++- examples/nvector/mpimanyvector/CMakeLists.txt | 4 +++- examples/nvector/mpiplusx/CMakeLists.txt | 4 +++- examples/nvector/parallel/CMakeLists.txt | 4 +++- examples/nvector/pthreads/CMakeLists.txt | 4 +++- examples/nvector/serial/CMakeLists.txt | 6 +++--- examples/sunlinsol/band/CMakeLists.txt | 6 +++--- examples/sunlinsol/dense/CMakeLists.txt | 6 +++--- examples/sunlinsol/klu/CMakeLists.txt | 6 +++--- examples/sunlinsol/lapackdense/CMakeLists.txt | 6 +++--- examples/sunlinsol/pcg/serial/CMakeLists.txt | 6 +++--- examples/sunlinsol/spbcgs/serial/CMakeLists.txt | 6 +++--- examples/sunlinsol/spfgmr/serial/CMakeLists.txt | 6 +++--- examples/sunlinsol/spgmr/serial/CMakeLists.txt | 6 +++--- examples/sunlinsol/sptfqmr/serial/CMakeLists.txt | 6 +++--- examples/sunmatrix/band/CMakeLists.txt | 6 +++--- examples/sunmatrix/dense/CMakeLists.txt | 4 +++- examples/sunmatrix/sparse/CMakeLists.txt | 4 +++- 21 files changed, 63 insertions(+), 46 deletions(-) diff --git a/examples/arkode/F2003_custom/CMakeLists.txt b/examples/arkode/F2003_custom/CMakeLists.txt index 7aac6173a6..98abe2d887 100644 --- a/examples/arkode/F2003_custom/CMakeLists.txt +++ b/examples/arkode/F2003_custom/CMakeLists.txt @@ -56,7 +56,7 @@ foreach(example_tuple ${FARKODE_examples}) list(GET example_tuple 0 example) list(GET example_tuple 1 example_type) - # Install fortran modules to a unique directory to avoid naming collisions + # build fortran modules into a unique directory to avoid naming collisions set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${example}.dir) # example source files diff --git a/examples/arkode/F2003_serial/CMakeLists.txt b/examples/arkode/F2003_serial/CMakeLists.txt index c54b72c6c7..8062b44597 100644 --- a/examples/arkode/F2003_serial/CMakeLists.txt +++ b/examples/arkode/F2003_serial/CMakeLists.txt @@ -125,11 +125,12 @@ if(BUILD_SUNLINSOL_KLU) list(GET example_tuple 0 example) list(GET example_tuple 1 example_type) - # example source files - add_executable(${example} ${example}.f90) + # build fortran modules into a unique directory to avoid naming collisions + set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${example}.dir) + # create the cmake executable target + add_executable(${example} ${example}.f90) set_target_properties(${example} PROPERTIES FOLDER "Examples") - set_target_properties(${example} PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${example}.dir) # add example to regression tests sundials_add_test(${example} ${example} @@ -140,7 +141,7 @@ if(BUILD_SUNLINSOL_KLU) # libraries to link against target_link_libraries(${example} ${SUNDIALS_LIBS} ${SUNLINSOLKLU_LIBS}) - # install example source and out files + # install example source and out files if(EXAMPLES_INSTALL) install(FILES ${example}.f90 ${example}.out DESTINATION ${EXAMPLES_INSTALL_PATH}/arkode/F2003_serial) diff --git a/examples/nvector/C_openmp/CMakeLists.txt b/examples/nvector/C_openmp/CMakeLists.txt index 309a22f4a9..b332f20064 100644 --- a/examples/nvector/C_openmp/CMakeLists.txt +++ b/examples/nvector/C_openmp/CMakeLists.txt @@ -108,6 +108,9 @@ foreach(example_tuple ${nvector_openmp_fortran_examples}) # check if this example has already been added, only need to add # example source files once for testing with different inputs if(NOT TARGET ${example}) + # build fortran modules into a unique directory to avoid naming collisions + set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${example}.dir) + # example source files add_executable(${example} ${example}.f90 ${SUNDIALS_SOURCE_DIR}/examples/utilities/test_utilities.f90 @@ -115,7 +118,6 @@ foreach(example_tuple ${nvector_openmp_fortran_examples}) # folder to organize targets in an IDE set_target_properties(${example} PROPERTIES FOLDER "Examples") - set_target_properties(${example} PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${example}.dir) # libraries to link against target_link_libraries(${example} ${SUNDIALS_LIBS}) diff --git a/examples/nvector/manyvector/CMakeLists.txt b/examples/nvector/manyvector/CMakeLists.txt index 973760be09..a43d1e4c15 100644 --- a/examples/nvector/manyvector/CMakeLists.txt +++ b/examples/nvector/manyvector/CMakeLists.txt @@ -105,6 +105,9 @@ foreach(example_tuple ${nvector_manyvector_fortran_examples}) # check if this example has already been added, only need to add # example source files once for testing with different inputs if(NOT TARGET ${example}) + # build fortran modules into a unique directory to avoid naming collisions + set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${example}.dir) + # example source files add_executable(${example} ${example}.f90 ${SUNDIALS_SOURCE_DIR}/examples/utilities/test_utilities.f90 @@ -112,7 +115,6 @@ foreach(example_tuple ${nvector_manyvector_fortran_examples}) # folder to organize targets in an IDE set_target_properties(${example} PROPERTIES FOLDER "Examples") - set_target_properties(${example} PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${example}.dir) # libraries to link against target_link_libraries(${example} ${SUNDIALS_LIBS}) diff --git a/examples/nvector/mpimanyvector/CMakeLists.txt b/examples/nvector/mpimanyvector/CMakeLists.txt index c91f5c6bf5..66c7253bc9 100644 --- a/examples/nvector/mpimanyvector/CMakeLists.txt +++ b/examples/nvector/mpimanyvector/CMakeLists.txt @@ -146,6 +146,9 @@ foreach(example_tuple ${nvector_mpimanyvector_fortran_examples}) # check if this example has already been added, only need to add # example source files once for testing with different inputs if(NOT TARGET ${example}) + # build fortran modules into a unique directory to avoid naming collisions + set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${example}.dir) + # example source files add_executable(${example} ${example}.f90 ${SUNDIALS_SOURCE_DIR}/examples/utilities/test_utilities.f90 @@ -153,7 +156,6 @@ foreach(example_tuple ${nvector_mpimanyvector_fortran_examples}) # folder to organize targets in an IDE set_target_properties(${example} PROPERTIES FOLDER "Examples") - set_target_properties(${example} PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${example}.dir) # libraries to link against target_link_libraries(${example} ${SUNDIALS_LIBS}) diff --git a/examples/nvector/mpiplusx/CMakeLists.txt b/examples/nvector/mpiplusx/CMakeLists.txt index 6f4dd11f13..195bcb6868 100644 --- a/examples/nvector/mpiplusx/CMakeLists.txt +++ b/examples/nvector/mpiplusx/CMakeLists.txt @@ -144,6 +144,9 @@ foreach(example_tuple ${nvector_mpiplusx_fortran_examples}) # check if this example has already been added, only need to add # example source files once for testing with different inputs if(NOT TARGET ${example}) + # build fortran modules into a unique directory to avoid naming collisions + set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${example}.dir) + # example source files add_executable(${example} ${example}.f90 ${SUNDIALS_SOURCE_DIR}/examples/utilities/test_utilities.f90 @@ -151,7 +154,6 @@ foreach(example_tuple ${nvector_mpiplusx_fortran_examples}) # folder to organize targets in an IDE set_target_properties(${example} PROPERTIES FOLDER "Examples") - set_target_properties(${example} PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${example}.dir) # libraries to link against target_link_libraries(${example} ${SUNDIALS_LIBS}) diff --git a/examples/nvector/parallel/CMakeLists.txt b/examples/nvector/parallel/CMakeLists.txt index 9a75dc752b..bfdf74eec8 100644 --- a/examples/nvector/parallel/CMakeLists.txt +++ b/examples/nvector/parallel/CMakeLists.txt @@ -133,6 +133,9 @@ foreach(example_tuple ${nvector_parallel_fortran_examples}) # check if this example has already been added, only need to add # example source files once for testing with different inputs if(NOT TARGET ${example}) + # build fortran modules into a unique directory to avoid naming collisions + set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${example}.dir) + # example source files add_executable(${example} ${example}.f90 ${SUNDIALS_SOURCE_DIR}/examples/utilities/test_utilities.f90 @@ -140,7 +143,6 @@ foreach(example_tuple ${nvector_parallel_fortran_examples}) # folder to organize targets in an IDE set_target_properties(${example} PROPERTIES FOLDER "Examples") - set_target_properties(${example} PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${example}.dir) # libraries to link against target_link_libraries(${example} diff --git a/examples/nvector/pthreads/CMakeLists.txt b/examples/nvector/pthreads/CMakeLists.txt index 3c53bed971..e9fefd7191 100644 --- a/examples/nvector/pthreads/CMakeLists.txt +++ b/examples/nvector/pthreads/CMakeLists.txt @@ -108,6 +108,9 @@ foreach(example_tuple ${nvector_pthreads_fortran_examples}) # check if this example has already been added, only need to add # example source files once for testing with different inputs if(NOT TARGET ${example}) + # build fortran modules into a unique directory to avoid naming collisions + set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${example}.dir) + # example source files add_executable(${example} ${example}.f90 ${SUNDIALS_SOURCE_DIR}/examples/utilities/test_utilities.f90 @@ -115,7 +118,6 @@ foreach(example_tuple ${nvector_pthreads_fortran_examples}) # folder to organize targets in an IDE set_target_properties(${example} PROPERTIES FOLDER "Examples") - set_target_properties(${example} PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${example}.dir) # libraries to link against target_link_libraries(${example} ${SUNDIALS_LIBS} ${CMAKE_THREAD_LIBS_INIT}) diff --git a/examples/nvector/serial/CMakeLists.txt b/examples/nvector/serial/CMakeLists.txt index a5d5bbe01f..6807562188 100644 --- a/examples/nvector/serial/CMakeLists.txt +++ b/examples/nvector/serial/CMakeLists.txt @@ -100,6 +100,9 @@ foreach(example_tuple ${nvector_serial_fortran_examples}) # check if this example has already been added, only need to add # example source files once for testing with different inputs if(NOT TARGET ${example}) + # build fortran modules into a unique directory to avoid naming collisions + set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${example}.dir) + # example source files add_executable(${example} ${example}.f90 ${SUNDIALS_SOURCE_DIR}/examples/utilities/test_utilities.f90 @@ -108,9 +111,6 @@ foreach(example_tuple ${nvector_serial_fortran_examples}) # folder to organize targets in an IDE set_target_properties(${example} PROPERTIES FOLDER "Examples") - # folder where fortran .mod files are - set_target_properties(${example} PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${example}.dir) - # libraries to link against target_link_libraries(${example} ${SUNDIALS_LIBS}) endif() diff --git a/examples/sunlinsol/band/CMakeLists.txt b/examples/sunlinsol/band/CMakeLists.txt index 37287f8379..8a6d09997e 100644 --- a/examples/sunlinsol/band/CMakeLists.txt +++ b/examples/sunlinsol/band/CMakeLists.txt @@ -97,6 +97,9 @@ foreach(example_tuple ${sunlinsol_band_fortran_examples}) # check if this example has already been added, only need to add # example source files once for testing with different inputs if(NOT TARGET ${example}) + # build fortran modules into a unique directory to avoid naming collisions + set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${example}.dir) + # example source files add_executable(${example} ${example}.f90 ${SUNDIALS_SOURCE_DIR}/examples/utilities/test_utilities.f90 @@ -105,9 +108,6 @@ foreach(example_tuple ${sunlinsol_band_fortran_examples}) # folder to organize targets in an IDE set_target_properties(${example} PROPERTIES FOLDER "Examples") - # set fortran module directory to avoid name collisions - set_target_properties(${example} PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${example}.dir) - # libraries to link against target_link_libraries(${example} sundials_nvecserial diff --git a/examples/sunlinsol/dense/CMakeLists.txt b/examples/sunlinsol/dense/CMakeLists.txt index f13e44adbb..03b6155811 100644 --- a/examples/sunlinsol/dense/CMakeLists.txt +++ b/examples/sunlinsol/dense/CMakeLists.txt @@ -97,6 +97,9 @@ foreach(example_tuple ${sunlinsol_dense_fortran_examples}) # check if this example has already been added, only need to add # example source files once for testing with different inputs if(NOT TARGET ${example}) + # build fortran modules into a unique directory to avoid naming collisions + set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${example}.dir) + # example source files add_executable(${example} ${example}.f90 ${SUNDIALS_SOURCE_DIR}/examples/utilities/test_utilities.f90 @@ -105,9 +108,6 @@ foreach(example_tuple ${sunlinsol_dense_fortran_examples}) # folder to organize targets in an IDE set_target_properties(${example} PROPERTIES FOLDER "Examples") - # set fortran module directory to avoid name collisions - set_target_properties(${example} PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${example}.dir) - # libraries to link against target_link_libraries(${example} sundials_nvecserial diff --git a/examples/sunlinsol/klu/CMakeLists.txt b/examples/sunlinsol/klu/CMakeLists.txt index c540f00800..664ec266a1 100644 --- a/examples/sunlinsol/klu/CMakeLists.txt +++ b/examples/sunlinsol/klu/CMakeLists.txt @@ -98,6 +98,9 @@ foreach(example_tuple ${sunlinsol_klu_fortran_examples}) # check if this example has already been added, only need to add # example source files once for testing with different inputs if(NOT TARGET ${example}) + # build fortran modules into a unique directory to avoid naming collisions + set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${example}.dir) + # example source files add_executable(${example} ${example}.f90 ${SUNDIALS_SOURCE_DIR}/examples/utilities/test_utilities.f90 @@ -106,9 +109,6 @@ foreach(example_tuple ${sunlinsol_klu_fortran_examples}) # folder to organize targets in an IDE set_target_properties(${example} PROPERTIES FOLDER "Examples") - # set fortran module directory to avoid name collisions - set_target_properties(${example} PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${example}.dir) - # libraries to link against target_link_libraries(${example} sundials_nvecserial diff --git a/examples/sunlinsol/lapackdense/CMakeLists.txt b/examples/sunlinsol/lapackdense/CMakeLists.txt index bd9b0d294c..0dd6ea947e 100644 --- a/examples/sunlinsol/lapackdense/CMakeLists.txt +++ b/examples/sunlinsol/lapackdense/CMakeLists.txt @@ -103,6 +103,9 @@ foreach(example_tuple ${sunlinsol_lapackdense_fortran_examples}) # check if this example has already been added, only need to add # example source files once for testing with different inputs if(NOT TARGET ${example}) + # build fortran modules into a unique directory to avoid naming collisions + set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${example}.dir) + # example source files add_executable(${example} ${example}.f90 ${SUNDIALS_SOURCE_DIR}/examples/utilities/test_utilities.f90 @@ -111,9 +114,6 @@ foreach(example_tuple ${sunlinsol_lapackdense_fortran_examples}) # folder to organize targets in an IDE set_target_properties(${example} PROPERTIES FOLDER "Examples") - # set fortran module directory to avoid name collisions - set_target_properties(${example} PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${example}.dir) - # libraries to link against target_link_libraries(${example} sundials_nvecserial diff --git a/examples/sunlinsol/pcg/serial/CMakeLists.txt b/examples/sunlinsol/pcg/serial/CMakeLists.txt index 42d59da8e9..4d6be609ee 100644 --- a/examples/sunlinsol/pcg/serial/CMakeLists.txt +++ b/examples/sunlinsol/pcg/serial/CMakeLists.txt @@ -104,6 +104,9 @@ foreach(example_tuple ${sunlinsol_pcg_fortran_examples}) # check if this example has already been added, only need to add # example source files once for testing with different inputs if(NOT TARGET ${example}) + # build fortran modules into a unique directory to avoid naming collisions + set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${example}.dir) + # example source files add_executable(${example} ${example}.f90 ${SUNDIALS_SOURCE_DIR}/examples/utilities/test_utilities.f90 @@ -112,9 +115,6 @@ foreach(example_tuple ${sunlinsol_pcg_fortran_examples}) # folder to organize targets in an IDE set_target_properties(${example} PROPERTIES FOLDER "Examples") - # set fortran module directory to avoid name collisions - set_target_properties(${example} PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${example}.dir) - # libraries to link against target_link_libraries(${example} sundials_nvecserial diff --git a/examples/sunlinsol/spbcgs/serial/CMakeLists.txt b/examples/sunlinsol/spbcgs/serial/CMakeLists.txt index c95abe1268..005f743cdf 100644 --- a/examples/sunlinsol/spbcgs/serial/CMakeLists.txt +++ b/examples/sunlinsol/spbcgs/serial/CMakeLists.txt @@ -104,6 +104,9 @@ foreach(example_tuple ${sunlinsol_spbcgs_fortran_examples}) # check if this example has already been added, only need to add # example source files once for testing with different inputs if(NOT TARGET ${example}) + # build fortran modules into a unique directory to avoid naming collisions + set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${example}.dir) + # example source files add_executable(${example} ${example}.f90 ${SUNDIALS_SOURCE_DIR}/examples/utilities/test_utilities.f90 @@ -112,9 +115,6 @@ foreach(example_tuple ${sunlinsol_spbcgs_fortran_examples}) # folder to organize targets in an IDE set_target_properties(${example} PROPERTIES FOLDER "Examples") - # set fortran module directory to avoid name collisions - set_target_properties(${example} PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${example}.dir) - # libraries to link against target_link_libraries(${example} sundials_nvecserial diff --git a/examples/sunlinsol/spfgmr/serial/CMakeLists.txt b/examples/sunlinsol/spfgmr/serial/CMakeLists.txt index 2e59fa1955..daa7d9fca3 100644 --- a/examples/sunlinsol/spfgmr/serial/CMakeLists.txt +++ b/examples/sunlinsol/spfgmr/serial/CMakeLists.txt @@ -103,6 +103,9 @@ foreach(example_tuple ${sunlinsol_spfgmr_fortran_examples}) # check if this example has already been added, only need to add # example source files once for testing with different inputs if(NOT TARGET ${example}) + # build fortran modules into a unique directory to avoid naming collisions + set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${example}.dir) + # example source files add_executable(${example} ${example}.f90 ${SUNDIALS_SOURCE_DIR}/examples/utilities/test_utilities.f90 @@ -111,9 +114,6 @@ foreach(example_tuple ${sunlinsol_spfgmr_fortran_examples}) # folder to organize targets in an IDE set_target_properties(${example} PROPERTIES FOLDER "Examples") - # set fortran module directory to avoid name collisions - set_target_properties(${example} PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${example}.dir) - # libraries to link against target_link_libraries(${example} sundials_nvecserial diff --git a/examples/sunlinsol/spgmr/serial/CMakeLists.txt b/examples/sunlinsol/spgmr/serial/CMakeLists.txt index f708630e6e..3353f2a829 100644 --- a/examples/sunlinsol/spgmr/serial/CMakeLists.txt +++ b/examples/sunlinsol/spgmr/serial/CMakeLists.txt @@ -106,6 +106,9 @@ foreach(example_tuple ${sunlinsol_spgmr_fortran_examples}) # check if this example has already been added, only need to add # example source files once for testing with different inputs if(NOT TARGET ${example}) + # build fortran modules into a unique directory to avoid naming collisions + set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${example}.dir) + # example source files add_executable(${example} ${example}.f90 ${SUNDIALS_SOURCE_DIR}/examples/utilities/test_utilities.f90 @@ -114,9 +117,6 @@ foreach(example_tuple ${sunlinsol_spgmr_fortran_examples}) # folder to organize targets in an IDE set_target_properties(${example} PROPERTIES FOLDER "Examples") - # set fortran module directory to avoid name collisions - set_target_properties(${example} PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${example}.dir) - # libraries to link against target_link_libraries(${example} sundials_nvecserial diff --git a/examples/sunlinsol/sptfqmr/serial/CMakeLists.txt b/examples/sunlinsol/sptfqmr/serial/CMakeLists.txt index 7817c84763..c985445c51 100644 --- a/examples/sunlinsol/sptfqmr/serial/CMakeLists.txt +++ b/examples/sunlinsol/sptfqmr/serial/CMakeLists.txt @@ -104,6 +104,9 @@ foreach(example_tuple ${sunlinsol_sptfqmr_fortran_examples}) # check if this example has already been added, only need to add # example source files once for testing with different inputs if(NOT TARGET ${example}) + # build fortran modules into a unique directory to avoid naming collisions + set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${example}.dir) + # example source files add_executable(${example} ${example}.f90 ${SUNDIALS_SOURCE_DIR}/examples/utilities/test_utilities.f90 @@ -112,9 +115,6 @@ foreach(example_tuple ${sunlinsol_sptfqmr_fortran_examples}) # folder to organize targets in an IDE set_target_properties(${example} PROPERTIES FOLDER "Examples") - # set fortran module directory to avoid name collisions - set_target_properties(${example} PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${example}.dir) - # libraries to link against target_link_libraries(${example} sundials_nvecserial diff --git a/examples/sunmatrix/band/CMakeLists.txt b/examples/sunmatrix/band/CMakeLists.txt index c5a7fa6a20..1db5a837a3 100644 --- a/examples/sunmatrix/band/CMakeLists.txt +++ b/examples/sunmatrix/band/CMakeLists.txt @@ -98,6 +98,9 @@ foreach(example_tuple ${sunmatrix_band_fortran_examples}) # check if this example has already been added, only need to add # example source files once for testing with different inputs if(NOT TARGET ${example}) + # build fortran modules into a unique directory to avoid naming collisions + set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${example}.dir) + # example source files add_executable(${example} ${example}.f90 ${SUNDIALS_SOURCE_DIR}/examples/utilities/test_utilities.f90 @@ -106,9 +109,6 @@ foreach(example_tuple ${sunmatrix_band_fortran_examples}) # folder to organize targets in an IDE set_target_properties(${example} PROPERTIES FOLDER "Examples") - # set fortran module directory to avoid name collisions - set_target_properties(${example} PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${example}.dir) - # libraries to link against target_link_libraries(${example} sundials_nvecserial diff --git a/examples/sunmatrix/dense/CMakeLists.txt b/examples/sunmatrix/dense/CMakeLists.txt index e14f0fce80..e5e5f9a346 100644 --- a/examples/sunmatrix/dense/CMakeLists.txt +++ b/examples/sunmatrix/dense/CMakeLists.txt @@ -97,13 +97,15 @@ foreach(example_tuple ${sunmatrix_dense_fortran_examples}) # check if this example has already been added, only need to add # example source files once for testing with different inputs if(NOT TARGET ${example}) + # build fortran modules into a unique directory to avoid naming collisions + set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${example}.dir) + add_executable(${example} ${example}.f90 ${SUNDIALS_SOURCE_DIR}/examples/utilities/test_utilities.f90 ${SUNDIALS_SOURCE_DIR}/examples/sunmatrix/test_sunmatrix.f90) # folder to organize targets in an IDE set_target_properties(${example} PROPERTIES FOLDER "Examples") - set_target_properties(${example} PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${example}.dir) # libraries to link against target_link_libraries(${example} diff --git a/examples/sunmatrix/sparse/CMakeLists.txt b/examples/sunmatrix/sparse/CMakeLists.txt index 2eb1f9114c..ee04a96b8d 100644 --- a/examples/sunmatrix/sparse/CMakeLists.txt +++ b/examples/sunmatrix/sparse/CMakeLists.txt @@ -102,13 +102,15 @@ foreach(example_tuple ${sunmatrix_sparse_fortran_examples}) # check if this example has already been added, only need to add # example source files once for testing with different inputs if(NOT TARGET ${example}) + # build fortran modules into a unique directory to avoid naming collisions + set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${example}.dir) + add_executable(${example} ${example}.f90 ${SUNDIALS_SOURCE_DIR}/examples/utilities/test_utilities.f90 ${SUNDIALS_SOURCE_DIR}/examples/sunmatrix/test_sunmatrix.f90) # folder to organize targets in an IDE set_target_properties(${example} PROPERTIES FOLDER "Examples") - set_target_properties(${example} PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${example}.dir) # libraries to link against target_link_libraries(${example}