Skip to content

Commit

Permalink
[Patch] Fix AMReX::FFTW Once
Browse files Browse the repository at this point in the history
  • Loading branch information
ax3l committed Jan 12, 2025
1 parent a154e62 commit 9de308d
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
43 changes: 43 additions & 0 deletions recipe/4293.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
From c6ee9704d892c18a21877920c43f07b542a03894 Mon Sep 17 00:00:00 2001
From: Axel Huebl <axel.huebl@plasma.ninja>
Date: Sat, 11 Jan 2025 17:23:29 -0800
Subject: [PATCH] Fix `AMReX::FFTW` Once

In situations like superbuilds or other downstream usage,
the `AMReX::FFTW` should only be created once.
---
Tools/CMake/FindAMReXFFTW.cmake | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/Tools/CMake/FindAMReXFFTW.cmake b/Tools/CMake/FindAMReXFFTW.cmake
index 64ce7183f3..1306ae77b8 100644
--- a/Tools/CMake/FindAMReXFFTW.cmake
+++ b/Tools/CMake/FindAMReXFFTW.cmake
@@ -102,9 +102,6 @@ if(NOT AMReX_FFTW_SEARCH IN_LIST AMReX_FFTW_SEARCH_VALUES)
endif()
mark_as_advanced(AMReX_FFTW_SEARCH)

-# Create imported target
-add_library(AMReX::FFTW INTERFACE IMPORTED GLOBAL)
-
function(fftw_find_precision HFFTWp)
if(AMReX_FFTW_SEARCH STREQUAL CMAKE)
find_package(FFTW3${HFFTWp} CONFIG REQUIRED)
@@ -138,9 +135,14 @@ function(fftw_find_precision HFFTWp)
endif()
endfunction()

-# floating point precision suffixes: we request float and double precision
-fftw_find_precision("")
-fftw_find_precision("f")
+if(NOT TARGET AMReX::FFTW)
+ # Create imported target
+ add_library(AMReX::FFTW INTERFACE IMPORTED GLOBAL)
+
+ # floating point precision suffixes: we request float and double precision
+ fftw_find_precision("")
+ fftw_find_precision("f")
+endif()

# Vars for CMake config
include(FindPackageHandleStandardArgs)
6 changes: 5 additions & 1 deletion recipe/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% set name = "amrex" %}
{% set version = "25.01" %}
{% set build = 0 %}
{% set build = 1 %}

# ensure mpi is defined (needed for conda-smithy recipe-lint)
{% set mpi = mpi or 'nompi' %}
Expand All @@ -17,6 +17,10 @@ package:
source:
url: https://github.com/AMReX-Codes/amrex/archive/refs/tags/{{ version }}.tar.gz
sha256: e774ae6813b8a5dcbebdff1e7e052ac35059096f2542d61ef9bd161fd6fa6b1e
patches:
# Fix AMReX::FFTW Once
# https://github.com/AMReX-Codes/amrex/pull/4293
- 4293.patch

build:
number: {{ build }}
Expand Down

0 comments on commit 9de308d

Please sign in to comment.