Skip to content

Commit

Permalink
use CMake_Fortran_MODULE_DIRECTORY before creating executable
Browse files Browse the repository at this point in the history
  • Loading branch information
balos1 committed Jun 17, 2024
1 parent 948caa6 commit 476b4c1
Show file tree
Hide file tree
Showing 21 changed files with 63 additions and 46 deletions.
2 changes: 1 addition & 1 deletion examples/arkode/F2003_custom/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 5 additions & 4 deletions examples/arkode/F2003_serial/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion examples/nvector/C_openmp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,16 @@ 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
${SUNDIALS_SOURCE_DIR}/examples/nvector/test_nvector.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} ${SUNDIALS_LIBS})
Expand Down
4 changes: 3 additions & 1 deletion examples/nvector/manyvector/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,16 @@ 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
${SUNDIALS_SOURCE_DIR}/examples/nvector/test_nvector.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} ${SUNDIALS_LIBS})
Expand Down
4 changes: 3 additions & 1 deletion examples/nvector/mpimanyvector/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,16 @@ 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
${SUNDIALS_SOURCE_DIR}/examples/nvector/test_nvector.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} ${SUNDIALS_LIBS})
Expand Down
4 changes: 3 additions & 1 deletion examples/nvector/mpiplusx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,16 @@ 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
${SUNDIALS_SOURCE_DIR}/examples/nvector/test_nvector.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} ${SUNDIALS_LIBS})
Expand Down
4 changes: 3 additions & 1 deletion examples/nvector/parallel/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,16 @@ 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
${SUNDIALS_SOURCE_DIR}/examples/nvector/test_nvector.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}
Expand Down
4 changes: 3 additions & 1 deletion examples/nvector/pthreads/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,16 @@ 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
${SUNDIALS_SOURCE_DIR}/examples/nvector/test_nvector.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} ${SUNDIALS_LIBS} ${CMAKE_THREAD_LIBS_INIT})
Expand Down
6 changes: 3 additions & 3 deletions examples/nvector/serial/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand Down
6 changes: 3 additions & 3 deletions examples/sunlinsol/band/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions examples/sunlinsol/dense/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions examples/sunlinsol/klu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions examples/sunlinsol/lapackdense/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions examples/sunlinsol/pcg/serial/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions examples/sunlinsol/spbcgs/serial/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions examples/sunlinsol/spfgmr/serial/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions examples/sunlinsol/spgmr/serial/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions examples/sunlinsol/sptfqmr/serial/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions examples/sunmatrix/band/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 3 additions & 1 deletion examples/sunmatrix/dense/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
Loading

0 comments on commit 476b4c1

Please sign in to comment.