Skip to content

Commit cdafe5d

Browse files
authored
Merge branch 'egpbos:master' into master
2 parents 279351a + 32b86f1 commit cdafe5d

2 files changed

Lines changed: 187 additions & 0 deletions

File tree

.github/workflows/test.yml

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
name: Test findFFTW
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
workflow_dispatch:
9+
10+
jobs:
11+
test-apt:
12+
name: Test apt install
13+
runs-on: ubuntu-latest
14+
env:
15+
fftw_components: "DOUBLE_LIB;FLOAT_LIB;LONGDOUBLE_LIB;DOUBLE_THREADS_LIB;FLOAT_THREADS_LIB;LONGDOUBLE_THREADS_LIB;DOUBLE_OPENMP_LIB;FLOAT_OPENMP_LIB;LONGDOUBLE_OPENMP_LIB"
16+
steps:
17+
- uses: actions/checkout@v6
18+
19+
- name: Install FFTW
20+
run: sudo apt-get install -y libfftw3-dev
21+
22+
- name: Configure test
23+
run: |
24+
cmake -S test -B build \
25+
-DFFTW_TEST_COMPONENTS="${fftw_components}"
26+
27+
test-source:
28+
name: Test source install
29+
runs-on: ubuntu-latest
30+
env:
31+
fftw_components: "DOUBLE_LIB;DOUBLE_THREADS_LIB;DOUBLE_OPENMP_LIB;FLOAT_LIB;FLOAT_THREADS_LIB;FLOAT_OPENMP_LIB;LONGDOUBLE_LIB;LONGDOUBLE_THREADS_LIB;LONGDOUBLE_OPENMP_LIB"
32+
steps:
33+
- uses: actions/checkout@v6
34+
35+
- name: Cache FFTW build
36+
id: cache-fftw
37+
uses: actions/cache@v5
38+
with:
39+
path: ~/fftw_install
40+
key: fftw-3.3.10-${{ runner.os }}-double-float-longdouble-threads-openmp
41+
42+
- name: Build FFTW from source tarball
43+
if: steps.cache-fftw.outputs.cache-hit != 'true'
44+
run: |
45+
mkdir -p ~/fftw_build ~/fftw_install
46+
cd ~/fftw_build
47+
48+
wget -q https://www.fftw.org/fftw-3.3.10.tar.gz
49+
tar -xzf fftw-3.3.10.tar.gz
50+
51+
FFTW_SRC="$HOME/fftw_build/fftw-3.3.10"
52+
FFTW_INSTALL="$HOME/fftw_install"
53+
COMMON_FLAGS="--prefix=$FFTW_INSTALL --enable-shared --enable-threads --enable-openmp"
54+
55+
# Double precision (default)
56+
mkdir build_double && cd build_double
57+
$FFTW_SRC/configure $COMMON_FLAGS
58+
make -j$(nproc)
59+
make install
60+
cd ..
61+
62+
# Single (float) precision
63+
mkdir build_float && cd build_float
64+
$FFTW_SRC/configure $COMMON_FLAGS --enable-float
65+
make -j$(nproc)
66+
make install
67+
cd ..
68+
69+
# Long double precision
70+
mkdir build_longdouble && cd build_longdouble
71+
$FFTW_SRC/configure $COMMON_FLAGS --enable-long-double
72+
make -j$(nproc)
73+
make install
74+
cd ..
75+
76+
- name: Configure test
77+
run: |
78+
cmake -S test -B build \
79+
-DFFTW_ROOT="$HOME/fftw_install" \
80+
-DFFTW_TEST_COMPONENTS="${fftw_components}"
81+
82+
test-conda:
83+
name: Test conda-forge install
84+
runs-on: ubuntu-latest
85+
env:
86+
fftw_components: "DOUBLE_LIB;FLOAT_LIB;LONGDOUBLE_LIB;DOUBLE_THREADS_LIB;FLOAT_THREADS_LIB;LONGDOUBLE_THREADS_LIB"
87+
steps:
88+
- uses: actions/checkout@v6
89+
- name: Install FFTW with conda-forge (micromamba)
90+
uses: mamba-org/setup-micromamba@v3
91+
with:
92+
environment-name: fftw-test
93+
create-args: conda-forge::fftw
94+
init-shell: bash
95+
post-cleanup: none
96+
- name: Configure test
97+
shell: micromamba-shell {0}
98+
run: |
99+
cmake -S test -B build \
100+
-DFFTW_ROOT="$CONDA_PREFIX" \
101+
-DFFTW_TEST_COMPONENTS="${fftw_components}"

test/CMakeLists.txt

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
cmake_minimum_required(VERSION 3.10)
2+
project(test_findFFTW NONE)
3+
4+
# Add the parent directory (repo root) to the module path so CMake can find FindFFTW.cmake
5+
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/..")
6+
7+
# Find FFTW. If FFTW_TEST_COMPONENTS is given (semicolon-separated list), those
8+
# components are required; otherwise we just require that FFTW itself is found.
9+
if(DEFINED FFTW_TEST_COMPONENTS)
10+
find_package(FFTW REQUIRED COMPONENTS ${FFTW_TEST_COMPONENTS})
11+
else()
12+
find_package(FFTW REQUIRED)
13+
endif()
14+
15+
# ---------------------------------------------------------------------------
16+
# Check that the basic variables are set
17+
# ---------------------------------------------------------------------------
18+
if(NOT FFTW_FOUND)
19+
message(FATAL_ERROR "FFTW_FOUND is not TRUE after find_package(FFTW REQUIRED)")
20+
endif()
21+
22+
if(NOT FFTW_INCLUDE_DIRS)
23+
message(FATAL_ERROR "FFTW_INCLUDE_DIRS is empty after find_package(FFTW REQUIRED)")
24+
endif()
25+
26+
if(NOT FFTW_LIBRARIES)
27+
message(FATAL_ERROR "FFTW_LIBRARIES is empty after find_package(FFTW REQUIRED)")
28+
endif()
29+
30+
# ---------------------------------------------------------------------------
31+
# Map component names to their CMake imported target names
32+
# ---------------------------------------------------------------------------
33+
set(FFTW_DOUBLE_LIB_TARGET FFTW::Double)
34+
set(FFTW_FLOAT_LIB_TARGET FFTW::Float)
35+
set(FFTW_LONGDOUBLE_LIB_TARGET FFTW::LongDouble)
36+
set(FFTW_DOUBLE_THREADS_LIB_TARGET FFTW::DoubleThreads)
37+
set(FFTW_FLOAT_THREADS_LIB_TARGET FFTW::FloatThreads)
38+
set(FFTW_LONGDOUBLE_THREADS_LIB_TARGET FFTW::LongDoubleThreads)
39+
set(FFTW_DOUBLE_OPENMP_LIB_TARGET FFTW::DoubleOpenMP)
40+
set(FFTW_FLOAT_OPENMP_LIB_TARGET FFTW::FloatOpenMP)
41+
set(FFTW_LONGDOUBLE_OPENMP_LIB_TARGET FFTW::LongDoubleOpenMP)
42+
set(FFTW_DOUBLE_MPI_LIB_TARGET FFTW::DoubleMPI)
43+
set(FFTW_FLOAT_MPI_LIB_TARGET FFTW::FloatMPI)
44+
set(FFTW_LONGDOUBLE_MPI_LIB_TARGET FFTW::LongDoubleMPI)
45+
46+
# ---------------------------------------------------------------------------
47+
# Check per-component variables and targets for each expected component
48+
# ---------------------------------------------------------------------------
49+
foreach(component IN LISTS FFTW_TEST_COMPONENTS)
50+
if(NOT FFTW_${component}_FOUND)
51+
message(FATAL_ERROR
52+
"Expected FFTW component ${component} was not found: "
53+
"FFTW_${component}_FOUND is not TRUE")
54+
endif()
55+
56+
# The library variable name is FFTW_<component>, e.g. FFTW_DOUBLE_LIB
57+
if(NOT FFTW_${component})
58+
message(FATAL_ERROR
59+
"FFTW_${component} is empty for found component ${component}")
60+
endif()
61+
62+
set(_target "${FFTW_${component}_TARGET}")
63+
if(_target AND NOT TARGET ${_target})
64+
message(FATAL_ERROR
65+
"CMake imported target ${_target} was not created for component ${component}")
66+
endif()
67+
endforeach()
68+
69+
# ---------------------------------------------------------------------------
70+
# Informational output (also shows status of all optional components)
71+
# ---------------------------------------------------------------------------
72+
message(STATUS "FindFFTW test passed!")
73+
message(STATUS " FFTW_FOUND: ${FFTW_FOUND}")
74+
message(STATUS " FFTW_INCLUDE_DIRS: ${FFTW_INCLUDE_DIRS}")
75+
message(STATUS " FFTW_LIBRARIES: ${FFTW_LIBRARIES}")
76+
77+
set(_all_components
78+
DOUBLE_LIB FLOAT_LIB LONGDOUBLE_LIB
79+
DOUBLE_THREADS_LIB FLOAT_THREADS_LIB LONGDOUBLE_THREADS_LIB
80+
DOUBLE_OPENMP_LIB FLOAT_OPENMP_LIB LONGDOUBLE_OPENMP_LIB
81+
DOUBLE_MPI_LIB FLOAT_MPI_LIB LONGDOUBLE_MPI_LIB
82+
)
83+
message(STATUS " Component status:")
84+
foreach(_comp IN LISTS _all_components)
85+
message(STATUS " FFTW_${_comp}_FOUND=${FFTW_${_comp}_FOUND} lib=${FFTW_${_comp}}")
86+
endforeach()

0 commit comments

Comments
 (0)