forked from egpbos/findFFTW
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
101 lines (88 loc) · 4.26 KB
/
Copy pathCMakeLists.txt
File metadata and controls
101 lines (88 loc) · 4.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
cmake_minimum_required(VERSION 3.10)
project(test_findFFTW NONE)
# Add the parent directory (repo root) to the module path so CMake can find FindFFTW.cmake
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/..")
# Find FFTW. If FFTW_TEST_COMPONENTS is given (semicolon-separated list), those
# components are required; otherwise we just require that FFTW itself is found.
if(FFTW_TEST_COMPONENTS)
find_package(FFTW ${FFTW_TEST_VERSION} REQUIRED COMPONENTS ${FFTW_TEST_COMPONENTS})
else()
find_package(FFTW ${FFTW_TEST_VERSION} REQUIRED)
endif()
# ---------------------------------------------------------------------------
# Check that the basic variables are set
# ---------------------------------------------------------------------------
if(NOT FFTW_FOUND)
message(FATAL_ERROR "FFTW_FOUND is not TRUE after find_package(FFTW REQUIRED)")
endif()
if(NOT FFTW_INCLUDE_DIRS)
message(FATAL_ERROR "FFTW_INCLUDE_DIRS is empty after find_package(FFTW REQUIRED)")
endif()
if(NOT FFTW_LIBRARIES)
message(FATAL_ERROR "FFTW_LIBRARIES is empty after find_package(FFTW REQUIRED)")
endif()
if(NOT FFTW_VERSION)
message(FATAL_ERROR "FFTW_VERSION is empty after find_package(FFTW REQUIRED)")
endif()
# ---------------------------------------------------------------------------
# Version checks
# ---------------------------------------------------------------------------
if(FFTW_TEST_VERSION)
if(NOT "${FFTW_VERSION}" VERSION_GREATER_EQUAL "${FFTW_TEST_VERSION}")
message(FATAL_ERROR
"Expected FFTW_VERSION >= ${FFTW_TEST_VERSION} but got ${FFTW_VERSION}")
endif()
endif()
# ---------------------------------------------------------------------------
# Map component names to their CMake imported target names
# ---------------------------------------------------------------------------
set(FFTW_DOUBLE_LIB_TARGET FFTW::Double)
set(FFTW_FLOAT_LIB_TARGET FFTW::Float)
set(FFTW_LONGDOUBLE_LIB_TARGET FFTW::LongDouble)
set(FFTW_DOUBLE_THREADS_LIB_TARGET FFTW::DoubleThreads)
set(FFTW_FLOAT_THREADS_LIB_TARGET FFTW::FloatThreads)
set(FFTW_LONGDOUBLE_THREADS_LIB_TARGET FFTW::LongDoubleThreads)
set(FFTW_DOUBLE_OPENMP_LIB_TARGET FFTW::DoubleOpenMP)
set(FFTW_FLOAT_OPENMP_LIB_TARGET FFTW::FloatOpenMP)
set(FFTW_LONGDOUBLE_OPENMP_LIB_TARGET FFTW::LongDoubleOpenMP)
set(FFTW_DOUBLE_MPI_LIB_TARGET FFTW::DoubleMPI)
set(FFTW_FLOAT_MPI_LIB_TARGET FFTW::FloatMPI)
set(FFTW_LONGDOUBLE_MPI_LIB_TARGET FFTW::LongDoubleMPI)
# ---------------------------------------------------------------------------
# Check per-component variables and targets for each expected component
# ---------------------------------------------------------------------------
foreach(component IN LISTS FFTW_TEST_COMPONENTS)
if(NOT FFTW_${component}_FOUND)
message(FATAL_ERROR
"Expected FFTW component ${component} was not found: "
"FFTW_${component}_FOUND is not TRUE")
endif()
# The library variable name is FFTW_<component>, e.g. FFTW_DOUBLE_LIB
if(NOT FFTW_${component})
message(FATAL_ERROR
"FFTW_${component} is empty for found component ${component}")
endif()
set(_target "${FFTW_${component}_TARGET}")
if(_target AND NOT TARGET ${_target})
message(FATAL_ERROR
"CMake imported target ${_target} was not created for component ${component}")
endif()
endforeach()
# ---------------------------------------------------------------------------
# Informational output (also shows status of all optional components)
# ---------------------------------------------------------------------------
message(STATUS "FindFFTW test passed!")
message(STATUS " FFTW_FOUND: ${FFTW_FOUND}")
message(STATUS " FFTW_VERSION: ${FFTW_VERSION}")
message(STATUS " FFTW_INCLUDE_DIRS: ${FFTW_INCLUDE_DIRS}")
message(STATUS " FFTW_LIBRARIES: ${FFTW_LIBRARIES}")
set(_all_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
DOUBLE_MPI_LIB FLOAT_MPI_LIB LONGDOUBLE_MPI_LIB
)
message(STATUS " Component status:")
foreach(_comp IN LISTS _all_components)
message(STATUS " FFTW_${_comp}_FOUND=${FFTW_${_comp}_FOUND} lib=${FFTW_${_comp}}")
endforeach()