|
7 | 7 | # Copyright (c) 2017, Patrick Bos |
8 | 8 | # |
9 | 9 | # Usage: |
10 | | -# find_package(FFTW [REQUIRED] [QUIET] [COMPONENTS component1 ... componentX] ) |
| 10 | +# find_package(FFTW [<version>] [REQUIRED] [QUIET] [COMPONENTS component1 ... componentX] ) |
11 | 11 | # |
12 | 12 | # It sets the following variables: |
13 | 13 | # FFTW_FOUND ... true if fftw is found on the system |
14 | 14 | # FFTW_[component]_LIB_FOUND ... true if the component is found on the system (see components below) |
15 | 15 | # FFTW_LIBRARIES ... full paths to all found fftw libraries |
16 | 16 | # FFTW_[component]_LIB ... full path to one of the components (see below) |
17 | 17 | # FFTW_INCLUDE_DIRS ... fftw include directory paths |
| 18 | +# FFTW_VERSION ... version of the found fftw library |
18 | 19 | # |
19 | 20 | # The following variables will be checked by the function |
20 | 21 | # FFTW_USE_STATIC_LIBS ... if true, only static libraries are found, otherwise both static and shared. |
@@ -44,9 +45,31 @@ endif() |
44 | 45 | # Check if we can use PkgConfig |
45 | 46 | find_package(PkgConfig) |
46 | 47 |
|
47 | | -#Determine from PKG |
| 48 | +# Determine from PKG |
48 | 49 | if( PKG_CONFIG_FOUND AND NOT FFTW_ROOT ) |
49 | 50 | pkg_check_modules( PKG_FFTW QUIET "fftw3" ) |
| 51 | + set( FFTW_VERSION ${PKG_FFTW_VERSION} ) |
| 52 | +else() |
| 53 | + # If pkg-config was skipped, there seems no way to get the version directly. |
| 54 | + # Try to deduce the version from fftw-wisdom-to-conf instead. |
| 55 | + # (From @kprussing. See https://github.com/egpbos/findFFTW/pull/8) |
| 56 | + execute_process(COMMAND ${FFTW_ROOT}/bin/fftw-wisdom-to-conf -V |
| 57 | + RESULT_VARIABLE _fftw_wtc_success |
| 58 | + OUTPUT_VARIABLE _fftw_wtc_stdout |
| 59 | + ERROR_VARIABLE _fftw_wtc_stderr) |
| 60 | + if (_fftw_wtc_success EQUAL 0) |
| 61 | + string(REGEX MATCH "FFTW *version *([0-9]+([.][0-9]+([.][0-9]+)?)?)" |
| 62 | + _fftw_wtc_version ${_fftw_wtc_stdout}) |
| 63 | + string(REPLACE " " ";" _fftw_wtc_version_list ${_fftw_wtc_version}) |
| 64 | + list(GET _fftw_wtc_version_list -1 FFTW_VERSION) |
| 65 | + else() |
| 66 | + message(WARNING "Error running ${FFTW_ROOT}/bin/fftw-wisdom-to-conf. " |
| 67 | + "Could not determine FFTW version. |
| 68 | +Output: |
| 69 | +${_fftw_wtc_stdout} |
| 70 | +Error: |
| 71 | +${_fftw_wtc_stderr}") |
| 72 | + endif() |
50 | 73 | endif() |
51 | 74 |
|
52 | 75 | #Check whether to search static or dynamic libs |
@@ -398,6 +421,7 @@ include(FindPackageHandleStandardArgs) |
398 | 421 |
|
399 | 422 | find_package_handle_standard_args(FFTW |
400 | 423 | REQUIRED_VARS FFTW_INCLUDE_DIRS |
| 424 | + VERSION_VAR FFTW_VERSION |
401 | 425 | HANDLE_COMPONENTS |
402 | 426 | ) |
403 | 427 |
|
|
0 commit comments