22# SPDX-License-Identifier: AGPL-3.0-or-later
33
44add_executable (tungsten tungsten.cpp)
5- find_package (Heffte REQUIRED)
6- target_link_libraries (tungsten PRIVATE OpenPFC nlohmann_json::nlohmann_json Heffte::Heffte)
5+ # Link HeFFTe if available; fallback to find_package
6+ if (TARGET Heffte::Heffte)
7+ target_link_libraries (tungsten PRIVATE OpenPFC nlohmann_json::nlohmann_json Heffte::Heffte)
8+ elseif (TARGET heffte)
9+ target_link_libraries (tungsten PRIVATE OpenPFC nlohmann_json::nlohmann_json heffte)
10+ else ()
11+ find_package (Heffte REQUIRED)
12+ target_link_libraries (tungsten PRIVATE OpenPFC nlohmann_json::nlohmann_json Heffte::Heffte)
13+ endif ()
714
815option (TUNGSTEN_REUSE_ARRAYS "Reuse some arrays" OFF )
916
@@ -24,7 +31,7 @@ if(OpenPFC_ENABLE_CUDA AND OpenPFC_CUDA_AVAILABLE)
2431 target_link_libraries (tungsten_cuda PRIVATE
2532 OpenPFC
2633 nlohmann_json::nlohmann_json
27- Heffte::Heffte
34+ $<IF:$<TARGET_EXISTS: Heffte::Heffte>,Heffte::Heffte,heffte>
2835 CUDA::cudart
2936 )
3037
@@ -50,7 +57,7 @@ if(OpenPFC_ENABLE_CUDA AND OpenPFC_CUDA_AVAILABLE)
5057 target_link_libraries (test_tungsten_cuda_vtk PRIVATE
5158 OpenPFC
5259 nlohmann_json::nlohmann_json
53- Heffte::Heffte
60+ $<IF:$<TARGET_EXISTS: Heffte::Heffte>,Heffte::Heffte,heffte>
5461 CUDA::cudart
5562 )
5663 set_target_properties (test_tungsten_cuda_vtk PROPERTIES
@@ -67,7 +74,14 @@ if(TUNGSTEN_ENABLE_TESTS)
6774 find_package (Catch2 REQUIRED)
6875 if (TARGET Catch2::Catch2)
6976 add_executable (test_tungsten test_tungsten.cpp)
70- target_link_libraries (test_tungsten PRIVATE OpenPFC nlohmann_json::nlohmann_json Heffte::Heffte Catch2::Catch2)
77+ if (TARGET Heffte::Heffte)
78+ target_link_libraries (test_tungsten PRIVATE OpenPFC nlohmann_json::nlohmann_json Heffte::Heffte Catch2::Catch2)
79+ elseif (TARGET heffte)
80+ target_link_libraries (test_tungsten PRIVATE OpenPFC nlohmann_json::nlohmann_json heffte Catch2::Catch2)
81+ else ()
82+ find_package (Heffte REQUIRED)
83+ target_link_libraries (test_tungsten PRIVATE OpenPFC nlohmann_json::nlohmann_json Heffte::Heffte Catch2::Catch2)
84+ endif ()
7185 include (CTest)
7286 # Run all tungsten tests in a single invocation to avoid per-test MPI overhead
7387 add_test (NAME tungsten-all -tests COMMAND test_tungsten)
@@ -76,11 +90,11 @@ if(TUNGSTEN_ENABLE_TESTS)
7690 if (OpenPFC_ENABLE_CUDA AND OpenPFC_CUDA_AVAILABLE)
7791 add_executable (test_tungsten_cpu_vs_cuda test_tungsten_cpu_vs_cuda.cpp)
7892 target_link_libraries (test_tungsten_cpu_vs_cuda PRIVATE
79- OpenPFC
80- nlohmann_json::nlohmann_json
81- Heffte::Heffte
82- Catch2::Catch2
83- CUDA::cudart
93+ OpenPFC
94+ nlohmann_json::nlohmann_json
95+ $<IF:$<TARGET_EXISTS: Heffte::Heffte>,Heffte::Heffte,heffte>
96+ Catch2::Catch2
97+ CUDA::cudart
8498 )
8599 target_sources (test_tungsten_cpu_vs_cuda PRIVATE
86100 tungsten_ops_kernels.cu
@@ -103,10 +117,10 @@ endif()
103117# Scalability study application
104118add_executable (tungsten_scalability tungsten_scalability.cpp)
105119target_link_libraries (tungsten_scalability PRIVATE
106- OpenPFC
107- nlohmann_json::nlohmann_json
108- Heffte::Heffte
109- MPI::MPI_CXX
120+ OpenPFC
121+ nlohmann_json::nlohmann_json
122+ $<IF:$<TARGET_EXISTS: Heffte::Heffte>,Heffte::Heffte,heffte>
123+ MPI::MPI_CXX
110124)
111125
112126# Add CUDA support to scalability app if available
0 commit comments