Prechádzať zdrojové kódy

bin and lib for Rocky 8.1 + info

Pierre-Yves Barriat 2 mesiacov pred
rodič
commit
f93da1a10c

+ 33 - 0
README.md

@@ -1,3 +1,36 @@
 # LSDTopoTools
 
 This repository is a fork of instructions located [here](https://franz825.github.io/teaching/tecto/lsdtt-intro.html)
+
+## Binaries and libraries
+
+The `bin` and `lib` folder were built on **Rocky Linux release 8.10 (Green Obsidian)** (4.18.0-425.3.1.el8.x86_64)
+
+Use `bin/lsdtt_env.sh` to add them in your environment.
+
+## How to build LSDTopoTools2 and FFTW3 ?
+
+> You need `cmake` and `make` installed on your system (and `git` + `curl`)
+
+```bash
+git clone https://github.com/LSDtopotools/LSDTopoTools2
+cd LSDTopoTools2/src
+vi build.sh
+```
+
+Add `PREFIX="$(pwd)/.."` on the first line of `build.sh` file.
+
+```bash
+FFTW_VERSION=3.3.10
+curl -L http://www.fftw.org/fftw-${FFTW_VERSION}.tar.gz | tar xz
+mkdir build && cd $_
+cmake -DENABLE_OPENMP=ON -DENABLE_THREADS=ON -DCMAKE_INSTALL_PREFIX=../fftw3 ../fftw-${FFTW_VERSION}
+make install
+cd ..
+rm -rf build fftw-3.3.10
+cd ../..
+rsync -av tools/findFFTW LSDTopoTools2/src
+cp tools/CMakeLists.txt  LSDTopoTools2/src
+cd LSDTopoTools2/src
+sh build.sh
+```

BIN
bin/lsdtt-basic-metrics


BIN
bin/lsdtt-channel-extraction


BIN
bin/lsdtt-chi-mapping


BIN
bin/lsdtt-cosmo-tool


BIN
bin/lsdtt-hillslope-channel-coupling


+ 4 - 0
bin/lsdtt_env.sh

@@ -0,0 +1,4 @@
+#!/bin/sh
+export PATH="$(pwd):${PATH}"
+export LD_LIBRARY_PATH="$(pwd)/../lib/:${LD_LIBRARY_PATH}"
+

BIN
lib/libLSDTopoTools.a


+ 1 - 0
lib/libfftw3.so

@@ -0,0 +1 @@
+libfftw3.so.3.6.9

BIN
lib/libfftw3.so.3


+ 1 - 0
lib/libfftw3.so.3.6.9

@@ -0,0 +1 @@
+libfftw3.so.3

+ 1 - 0
lib/libfftw3_omp.so

@@ -0,0 +1 @@
+libfftw3_omp.so.3.6.9

BIN
lib/libfftw3_omp.so.3


+ 1 - 0
lib/libfftw3_omp.so.3.6.9

@@ -0,0 +1 @@
+libfftw3_omp.so.3

+ 1 - 0
lib/libfftw3_threads.so

@@ -0,0 +1 @@
+libfftw3_threads.so.3.6.9

BIN
lib/libfftw3_threads.so.3


+ 1 - 0
lib/libfftw3_threads.so.3.6.9

@@ -0,0 +1 @@
+libfftw3_threads.so.3

+ 158 - 0
tools/CMakeLists.txt

@@ -0,0 +1,158 @@
+cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR)
+project(LSDTopoTools)
+
+# Dependencies
+# ============
+set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "findFFTW")
+find_package(PkgConfig REQUIRED)
+pkg_search_module(FFTW REQUIRED fftw3 IMPORTED_TARGET)
+include_directories(PkgConfig::FFTW)
+link_libraries     (PkgConfig::FFTW)
+
+set(CMAKE_CXX_STANDARD 11)
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-invalid-offsetof -O3 -std=c++11")
+
+# We test if the open cv library is found. 
+# If not we compile without lsdtt-valley-width program
+# OpenCV
+find_package(OpenCV)
+if(OpenCV_FOUND)
+    message("I found OpenCV and am compiling the floodplain code")
+    include_directories( ${OpenCV_INCLUDE_DIRS})
+
+    # Build
+    # =====
+    set(LIB_HEADERS
+    LSDBasin.hpp
+    LSDChiTools.hpp
+    LSDChiNetwork.hpp
+    LSDChannel.hpp
+    LSDCosmoData.hpp
+    LSDCosmoRaster.hpp
+    LSDCRNParameters.hpp
+    LSDFlowInfo.hpp
+    LSDIndexChannel.hpp
+    LSDIndexChannelTree.hpp
+    LSDIndexRaster.hpp
+    LSDJunctionNetwork.hpp
+    LSDMostLikelyPartitionsFinder.hpp
+    LSDParameterParser.hpp
+    LSDParticle.hpp
+    LSDParticleColumn.hpp
+    LSDRaster.hpp
+    LSDRasterAggregator.hpp
+    LSDRasterInfo.hpp
+    LSDRasterMaker.hpp
+    LSDRasterSpectral.hpp
+    LSDSoilHydroRaster.hpp
+    LSDStatsTools.hpp
+    LSDShapeTools.hpp
+    LSDSpatialCSVReader.hpp
+    LSDStrahlerLinks.hpp
+    LSDFloodplain.hpp
+    LSDTerrace.hpp
+    )
+
+    string(REGEX REPLACE "([^;]+).hpp" "\\1.cpp" LIB_SOURCES "${LIB_HEADERS}")
+
+    set(EXE_SOURCES
+    lsdtt-drivers/lsdtt-basic-metrics.cpp
+    lsdtt-drivers/lsdtt-channel-extraction.cpp
+    lsdtt-drivers/lsdtt-chi-mapping.cpp
+    lsdtt-drivers/lsdtt-cosmo-tool.cpp
+    lsdtt-drivers/lsdtt-hillslope-channel-coupling.cpp
+    lsdtt-drivers/lsdtt-valley-metrics.cpp
+    )
+
+    set(EXE_FILES)
+
+    add_library(${PROJECT_NAME} ${LIB_SOURCES} ${LIB_HEADERS} )
+
+    foreach(src_file ${EXE_SOURCES})
+    string(REGEX REPLACE "([^;]+)/([^;]+).cpp" "\\2" exe_file ${src_file})
+    list(APPEND EXE_FILES ${exe_file})
+    add_executable(${exe_file} ${src_file})
+    target_link_libraries(${exe_file} ${PROJECT_NAME} PkgConfig::FFTW)
+    target_link_libraries(${exe_file} ${PROJECT_NAME} ${OpenCV_LIBS} )
+    endforeach(src_file ${EXE_SOURCES})
+
+
+    # Install
+    # =======
+    include(GNUInstallDirs)
+    include(CMakePackageConfigHelpers)
+
+    install(
+    TARGETS ${EXE_FILES} ${PROJECT_NAME}
+    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+    ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+    )
+else()
+    message("I am compiling without the openCV library")
+    
+    set(LIB_HEADERS
+    LSDBasin.hpp
+    LSDChiTools.hpp
+    LSDChiNetwork.hpp
+    LSDChannel.hpp
+    LSDCosmoData.hpp
+    LSDCosmoRaster.hpp
+    LSDCRNParameters.hpp
+    LSDFlowInfo.hpp
+    LSDIndexChannel.hpp
+    LSDIndexChannelTree.hpp
+    LSDIndexRaster.hpp
+    LSDJunctionNetwork.hpp
+    LSDMostLikelyPartitionsFinder.hpp
+    LSDParameterParser.hpp
+    LSDParticle.hpp
+    LSDParticleColumn.hpp
+    LSDRaster.hpp
+    LSDRasterAggregator.hpp
+    LSDRasterInfo.hpp
+    LSDRasterMaker.hpp
+    LSDRasterSpectral.hpp
+    LSDSoilHydroRaster.hpp
+    LSDStatsTools.hpp
+    LSDShapeTools.hpp
+    LSDSpatialCSVReader.hpp
+    LSDStrahlerLinks.hpp
+  )
+  
+  string(REGEX REPLACE "([^;]+).hpp" "\\1.cpp" LIB_SOURCES "${LIB_HEADERS}")
+  
+  set(EXE_SOURCES
+    lsdtt-drivers/lsdtt-basic-metrics.cpp
+    lsdtt-drivers/lsdtt-channel-extraction.cpp
+    lsdtt-drivers/lsdtt-chi-mapping.cpp
+    lsdtt-drivers/lsdtt-cosmo-tool.cpp
+    lsdtt-drivers/lsdtt-hillslope-channel-coupling.cpp
+  )
+  
+  set(EXE_FILES)
+  
+  add_library(${PROJECT_NAME} ${LIB_SOURCES} ${LIB_HEADERS} )
+  
+  foreach(src_file ${EXE_SOURCES})
+    string(REGEX REPLACE "([^;]+)/([^;]+).cpp" "\\2" exe_file ${src_file})
+    list(APPEND EXE_FILES ${exe_file})
+    add_executable(${exe_file} ${src_file})
+    target_link_libraries(${exe_file} ${PROJECT_NAME} PkgConfig::FFTW)
+  endforeach(src_file ${EXE_SOURCES})
+  
+  
+  # Install
+  # =======
+  include(GNUInstallDirs)
+  include(CMakePackageConfigHelpers)
+  
+  install(
+    TARGETS ${EXE_FILES} ${PROJECT_NAME}
+    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+    ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+  )
+  endif()
+  

+ 419 - 0
tools/findFFTW/FindFFTW.cmake

@@ -0,0 +1,419 @@
+# - Find the FFTW library
+#
+# Original version of this file:
+#   Copyright (c) 2015, Wenzel Jakob
+#   https://github.com/wjakob/layerlab/blob/master/cmake/FindFFTW.cmake, commit 4d58bfdc28891b4f9373dfe46239dda5a0b561c6
+# Modifications:
+#   Copyright (c) 2017, Patrick Bos
+#
+# Usage:
+#   find_package(FFTW [REQUIRED] [QUIET] [COMPONENTS component1 ... componentX] )
+#
+# It sets the following variables:
+#   FFTW_FOUND                  ... true if fftw is found on the system
+#   FFTW_[component]_LIB_FOUND  ... true if the component is found on the system (see components below)
+#   FFTW_LIBRARIES              ... full paths to all found fftw libraries
+#   FFTW_[component]_LIB        ... full path to one of the components (see below)
+#   FFTW_INCLUDE_DIRS           ... fftw include directory paths
+#
+# The following variables will be checked by the function
+#   FFTW_USE_STATIC_LIBS        ... if true, only static libraries are found, otherwise both static and shared.
+#   FFTW_ROOT                   ... if set, the libraries are exclusively searched
+#                                   under this path
+#
+# This package supports the following components:
+#   FLOAT_LIB
+#   DOUBLE_LIB
+#   LONGDOUBLE_LIB
+#   FLOAT_THREADS_LIB
+#   DOUBLE_THREADS_LIB
+#   LONGDOUBLE_THREADS_LIB
+#   FLOAT_OPENMP_LIB
+#   DOUBLE_OPENMP_LIB
+#   LONGDOUBLE_OPENMP_LIB
+#
+
+# TODO (maybe): extend with ExternalProject download + build option
+# TODO: put on conda-forge
+
+
+if( NOT FFTW_ROOT AND DEFINED ENV{FFTWDIR} )
+    set( FFTW_ROOT $ENV{FFTWDIR} )
+endif()
+
+# Check if we can use PkgConfig
+find_package(PkgConfig)
+
+#Determine from PKG
+if( PKG_CONFIG_FOUND AND NOT FFTW_ROOT )
+    pkg_check_modules( PKG_FFTW QUIET "fftw3" )
+endif()
+
+#Check whether to search static or dynamic libs
+set( CMAKE_FIND_LIBRARY_SUFFIXES_SAV ${CMAKE_FIND_LIBRARY_SUFFIXES} )
+
+if( ${FFTW_USE_STATIC_LIBS} )
+    set( CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_STATIC_LIBRARY_SUFFIX} )
+else()
+    set( CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES_SAV} )
+endif()
+
+if( FFTW_ROOT )
+    # find libs
+
+    find_library(
+        FFTW_DOUBLE_LIB
+        NAMES "fftw3" libfftw3-3
+        PATHS ${FFTW_ROOT}
+        PATH_SUFFIXES "lib" "lib64"
+        NO_DEFAULT_PATH
+        )
+
+    find_library(
+        FFTW_DOUBLE_THREADS_LIB
+        NAMES "fftw3_threads"
+        PATHS ${FFTW_ROOT}
+        PATH_SUFFIXES "lib" "lib64"
+        NO_DEFAULT_PATH
+        )
+
+    find_library(
+        FFTW_DOUBLE_OPENMP_LIB
+        NAMES "fftw3_omp"
+        PATHS ${FFTW_ROOT}
+        PATH_SUFFIXES "lib" "lib64"
+        NO_DEFAULT_PATH
+        )
+
+    find_library(
+        FFTW_DOUBLE_MPI_LIB
+        NAMES "fftw3_mpi"
+        PATHS ${FFTW_ROOT}
+        PATH_SUFFIXES "lib" "lib64"
+        NO_DEFAULT_PATH
+        )
+
+    find_library(
+        FFTW_FLOAT_LIB
+        NAMES "fftw3f" libfftw3f-3
+        PATHS ${FFTW_ROOT}
+        PATH_SUFFIXES "lib" "lib64"
+        NO_DEFAULT_PATH
+        )
+
+    find_library(
+        FFTW_FLOAT_THREADS_LIB
+        NAMES "fftw3f_threads"
+        PATHS ${FFTW_ROOT}
+        PATH_SUFFIXES "lib" "lib64"
+        NO_DEFAULT_PATH
+        )
+
+    find_library(
+        FFTW_FLOAT_OPENMP_LIB
+        NAMES "fftw3f_omp"
+        PATHS ${FFTW_ROOT}
+        PATH_SUFFIXES "lib" "lib64"
+        NO_DEFAULT_PATH
+        )
+
+    find_library(
+        FFTW_FLOAT_MPI_LIB
+        NAMES "fftw3f_mpi"
+        PATHS ${FFTW_ROOT}
+        PATH_SUFFIXES "lib" "lib64"
+        NO_DEFAULT_PATH
+        )
+
+    find_library(
+        FFTW_LONGDOUBLE_LIB
+        NAMES "fftw3l" libfftw3l-3
+        PATHS ${FFTW_ROOT}
+        PATH_SUFFIXES "lib" "lib64"
+        NO_DEFAULT_PATH
+        )
+
+    find_library(
+        FFTW_LONGDOUBLE_THREADS_LIB
+        NAMES "fftw3l_threads"
+        PATHS ${FFTW_ROOT}
+        PATH_SUFFIXES "lib" "lib64"
+        NO_DEFAULT_PATH
+        )
+
+    find_library(
+        FFTW_LONGDOUBLE_OPENMP_LIB
+        NAMES "fftw3l_omp"
+        PATHS ${FFTW_ROOT}
+        PATH_SUFFIXES "lib" "lib64"
+        NO_DEFAULT_PATH
+        )
+
+    find_library(
+        FFTW_LONGDOUBLE_MPI_LIB
+        NAMES "fftw3l_mpi"
+        PATHS ${FFTW_ROOT}
+        PATH_SUFFIXES "lib" "lib64"
+        NO_DEFAULT_PATH
+        )
+
+    #find includes
+    find_path(FFTW_INCLUDE_DIRS
+        NAMES "fftw3.h"
+        PATHS ${FFTW_ROOT}
+        PATH_SUFFIXES "include"
+        NO_DEFAULT_PATH
+        )
+
+else()
+
+    find_library(
+        FFTW_DOUBLE_LIB
+        NAMES "fftw3"
+        PATHS ${PKG_FFTW_LIBRARY_DIRS} ${LIB_INSTALL_DIR}
+        )
+
+    find_library(
+        FFTW_DOUBLE_THREADS_LIB
+        NAMES "fftw3_threads"
+        PATHS ${PKG_FFTW_LIBRARY_DIRS} ${LIB_INSTALL_DIR}
+        )
+
+    find_library(
+        FFTW_DOUBLE_OPENMP_LIB
+        NAMES "fftw3_omp"
+        PATHS ${PKG_FFTW_LIBRARY_DIRS} ${LIB_INSTALL_DIR}
+        )
+
+    find_library(
+        FFTW_DOUBLE_MPI_LIB
+        NAMES "fftw3_mpi"
+        PATHS ${PKG_FFTW_LIBRARY_DIRS} ${LIB_INSTALL_DIR}
+        )
+
+    find_library(
+        FFTW_FLOAT_LIB
+        NAMES "fftw3f"
+        PATHS ${PKG_FFTW_LIBRARY_DIRS} ${LIB_INSTALL_DIR}
+        )
+
+    find_library(
+        FFTW_FLOAT_THREADS_LIB
+        NAMES "fftw3f_threads"
+        PATHS ${PKG_FFTW_LIBRARY_DIRS} ${LIB_INSTALL_DIR}
+        )
+
+    find_library(
+        FFTW_FLOAT_OPENMP_LIB
+        NAMES "fftw3f_omp"
+        PATHS ${PKG_FFTW_LIBRARY_DIRS} ${LIB_INSTALL_DIR}
+        )
+
+    find_library(
+        FFTW_FLOAT_MPI_LIB
+        NAMES "fftw3f_mpi"
+        PATHS ${PKG_FFTW_LIBRARY_DIRS} ${LIB_INSTALL_DIR}
+        )
+
+    find_library(
+        FFTW_LONGDOUBLE_LIB
+        NAMES "fftw3l"
+        PATHS ${PKG_FFTW_LIBRARY_DIRS} ${LIB_INSTALL_DIR}
+        )
+
+    find_library(
+        FFTW_LONGDOUBLE_THREADS_LIB
+        NAMES "fftw3l_threads"
+        PATHS ${PKG_FFTW_LIBRARY_DIRS} ${LIB_INSTALL_DIR}
+        )
+
+    find_library(FFTW_LONGDOUBLE_OPENMP_LIB
+        NAMES "fftw3l_omp"
+        PATHS ${PKG_FFTW_LIBRARY_DIRS} ${LIB_INSTALL_DIR}
+        )
+
+    find_library(FFTW_LONGDOUBLE_MPI_LIB
+        NAMES "fftw3l_mpi"
+        PATHS ${PKG_FFTW_LIBRARY_DIRS} ${LIB_INSTALL_DIR}
+        )
+
+    find_path(FFTW_INCLUDE_DIRS
+        NAMES "fftw3.h"
+        PATHS ${PKG_FFTW_INCLUDE_DIRS} ${INCLUDE_INSTALL_DIR}
+        )
+
+endif( FFTW_ROOT )
+
+#--------------------------------------- components
+
+if (FFTW_DOUBLE_LIB)
+    set(FFTW_DOUBLE_LIB_FOUND TRUE)
+    set(FFTW_LIBRARIES ${FFTW_LIBRARIES} ${FFTW_DOUBLE_LIB})
+    add_library(FFTW::Double INTERFACE IMPORTED)
+    set_target_properties(FFTW::Double
+        PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${FFTW_INCLUDE_DIRS}"
+        INTERFACE_LINK_LIBRARIES "${FFTW_DOUBLE_LIB}"
+        )
+else()
+    set(FFTW_DOUBLE_LIB_FOUND FALSE)
+endif()
+
+if (FFTW_FLOAT_LIB)
+    set(FFTW_FLOAT_LIB_FOUND TRUE)
+    set(FFTW_LIBRARIES ${FFTW_LIBRARIES} ${FFTW_FLOAT_LIB})
+    add_library(FFTW::Float INTERFACE IMPORTED)
+    set_target_properties(FFTW::Float
+        PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${FFTW_INCLUDE_DIRS}"
+        INTERFACE_LINK_LIBRARIES "${FFTW_FLOAT_LIB}"
+        )
+else()
+    set(FFTW_FLOAT_LIB_FOUND FALSE)
+endif()
+
+if (FFTW_LONGDOUBLE_LIB)
+    set(FFTW_LONGDOUBLE_LIB_FOUND TRUE)
+    set(FFTW_LIBRARIES ${FFTW_LIBRARIES} ${FFTW_LONGDOUBLE_LIB})
+    add_library(FFTW::LongDouble INTERFACE IMPORTED)
+    set_target_properties(FFTW::LongDouble
+        PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${FFTW_INCLUDE_DIRS}"
+        INTERFACE_LINK_LIBRARIES "${FFTW_LONGDOUBLE_LIB}"
+        )
+else()
+    set(FFTW_LONGDOUBLE_LIB_FOUND FALSE)
+endif()
+
+if (FFTW_DOUBLE_THREADS_LIB)
+    set(FFTW_DOUBLE_THREADS_LIB_FOUND TRUE)
+    set(FFTW_LIBRARIES ${FFTW_LIBRARIES} ${FFTW_DOUBLE_THREADS_LIB})
+    add_library(FFTW::DoubleThreads INTERFACE IMPORTED)
+    set_target_properties(FFTW::DoubleThreads
+        PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${FFTW_INCLUDE_DIRS}"
+        INTERFACE_LINK_LIBRARIES "${FFTW_DOUBLE_THREADS_LIB}"
+        )
+else()
+    set(FFTW_DOUBLE_THREADS_LIB_FOUND FALSE)
+endif()
+
+if (FFTW_FLOAT_THREADS_LIB)
+    set(FFTW_FLOAT_THREADS_LIB_FOUND TRUE)
+    set(FFTW_LIBRARIES ${FFTW_LIBRARIES} ${FFTW_FLOAT_THREADS_LIB})
+    add_library(FFTW::FloatThreads INTERFACE IMPORTED)
+    set_target_properties(FFTW::FloatThreads
+        PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${FFTW_INCLUDE_DIRS}"
+        INTERFACE_LINK_LIBRARIES "${FFTW_FLOAT_THREADS_LIB}"
+        )
+else()
+    set(FFTW_FLOAT_THREADS_LIB_FOUND FALSE)
+endif()
+
+if (FFTW_LONGDOUBLE_THREADS_LIB)
+    set(FFTW_LONGDOUBLE_THREADS_LIB_FOUND TRUE)
+    set(FFTW_LIBRARIES ${FFTW_LIBRARIES} ${FFTW_LONGDOUBLE_THREADS_LIB})
+    add_library(FFTW::LongDoubleThreads INTERFACE IMPORTED)
+    set_target_properties(FFTW::LongDoubleThreads
+        PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${FFTW_INCLUDE_DIRS}"
+        INTERFACE_LINK_LIBRARIES "${FFTW_LONGDOUBLE_THREADS_LIB}"
+        )
+else()
+    set(FFTW_LONGDOUBLE_THREADS_LIB_FOUND FALSE)
+endif()
+
+if (FFTW_DOUBLE_OPENMP_LIB)
+    set(FFTW_DOUBLE_OPENMP_LIB_FOUND TRUE)
+    set(FFTW_LIBRARIES ${FFTW_LIBRARIES} ${FFTW_DOUBLE_OPENMP_LIB})
+    add_library(FFTW::DoubleOpenMP INTERFACE IMPORTED)
+    set_target_properties(FFTW::DoubleOpenMP
+        PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${FFTW_INCLUDE_DIRS}"
+        INTERFACE_LINK_LIBRARIES "${FFTW_DOUBLE_OPENMP_LIB}"
+        )
+else()
+    set(FFTW_DOUBLE_OPENMP_LIB_FOUND FALSE)
+endif()
+
+if (FFTW_FLOAT_OPENMP_LIB)
+    set(FFTW_FLOAT_OPENMP_LIB_FOUND TRUE)
+    set(FFTW_LIBRARIES ${FFTW_LIBRARIES} ${FFTW_FLOAT_OPENMP_LIB})
+    add_library(FFTW::FloatOpenMP INTERFACE IMPORTED)
+    set_target_properties(FFTW::FloatOpenMP
+        PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${FFTW_INCLUDE_DIRS}"
+        INTERFACE_LINK_LIBRARIES "${FFTW_FLOAT_OPENMP_LIB}"
+        )
+else()
+    set(FFTW_FLOAT_OPENMP_LIB_FOUND FALSE)
+endif()
+
+if (FFTW_LONGDOUBLE_OPENMP_LIB)
+    set(FFTW_LONGDOUBLE_OPENMP_LIB_FOUND TRUE)
+    set(FFTW_LIBRARIES ${FFTW_LIBRARIES} ${FFTW_LONGDOUBLE_OPENMP_LIB})
+    add_library(FFTW::LongDoubleOpenMP INTERFACE IMPORTED)
+    set_target_properties(FFTW::LongDoubleOpenMP
+        PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${FFTW_INCLUDE_DIRS}"
+        INTERFACE_LINK_LIBRARIES "${FFTW_LONGDOUBLE_OPENMP_LIB}"
+        )
+else()
+    set(FFTW_LONGDOUBLE_OPENMP_LIB_FOUND FALSE)
+endif()
+
+if (FFTW_DOUBLE_MPI_LIB)
+    set(FFTW_DOUBLE_MPI_LIB_FOUND TRUE)
+    set(FFTW_LIBRARIES ${FFTW_LIBRARIES} ${FFTW_DOUBLE_MPI_LIB})
+    add_library(FFTW::DoubleMPI INTERFACE IMPORTED)
+    set_target_properties(FFTW::DoubleMPI
+        PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${FFTW_INCLUDE_DIRS}"
+        INTERFACE_LINK_LIBRARIES "${FFTW_DOUBLE_MPI_LIB}"
+        )
+else()
+    set(FFTW_DOUBLE_MPI_LIB_FOUND FALSE)
+endif()
+
+if (FFTW_FLOAT_MPI_LIB)
+    set(FFTW_FLOAT_MPI_LIB_FOUND TRUE)
+    set(FFTW_LIBRARIES ${FFTW_LIBRARIES} ${FFTW_FLOAT_MPI_LIB})
+    add_library(FFTW::FloatMPI INTERFACE IMPORTED)
+    set_target_properties(FFTW::FloatMPI
+        PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${FFTW_INCLUDE_DIRS}"
+        INTERFACE_LINK_LIBRARIES "${FFTW_FLOAT_MPI_LIB}"
+        )
+else()
+    set(FFTW_FLOAT_MPI_LIB_FOUND FALSE)
+endif()
+
+if (FFTW_LONGDOUBLE_MPI_LIB)
+    set(FFTW_LONGDOUBLE_MPI_LIB_FOUND TRUE)
+    set(FFTW_LIBRARIES ${FFTW_LIBRARIES} ${FFTW_LONGDOUBLE_MPI_LIB})
+    add_library(FFTW::LongDoubleMPI INTERFACE IMPORTED)
+    set_target_properties(FFTW::LongDoubleMPI
+        PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${FFTW_INCLUDE_DIRS}"
+        INTERFACE_LINK_LIBRARIES "${FFTW_LONGDOUBLE_MPI_LIB}"
+        )
+else()
+    set(FFTW_LONGDOUBLE_MPI_LIB_FOUND FALSE)
+endif()
+
+#--------------------------------------- end components
+
+set( CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES_SAV} )
+
+include(FindPackageHandleStandardArgs)
+
+find_package_handle_standard_args(FFTW
+    REQUIRED_VARS FFTW_INCLUDE_DIRS
+    HANDLE_COMPONENTS
+    )
+
+mark_as_advanced(
+    FFTW_INCLUDE_DIRS
+    FFTW_LIBRARIES
+    FFTW_FLOAT_LIB
+    FFTW_DOUBLE_LIB
+    FFTW_LONGDOUBLE_LIB
+    FFTW_FLOAT_THREADS_LIB
+    FFTW_DOUBLE_THREADS_LIB
+    FFTW_LONGDOUBLE_THREADS_LIB
+    FFTW_FLOAT_OPENMP_LIB
+    FFTW_DOUBLE_OPENMP_LIB
+    FFTW_LONGDOUBLE_OPENMP_LIB
+    FFTW_FLOAT_MPI_LIB
+    FFTW_DOUBLE_MPI_LIB
+    FFTW_LONGDOUBLE_MPI_LIB
+    )

+ 110 - 0
tools/findFFTW/README.md

@@ -0,0 +1,110 @@
+CMake module for finding FFTW 3 using find_package
+
+# Usage
+
+Once added to your project, this module allows you to find FFTW libraries and headers using the CMake `find_package` command:
+
+```cmake
+find_package(FFTW [REQUIRED] [QUIET] [COMPONENTS component1 ... componentX] )
+```
+
+This module sets the following variables:
+- `FFTW_FOUND`                  ... true if fftw is found on the system
+- `FFTW_[component]_LIB_FOUND`  ... true if the component is found on the system (see components below)
+- `FFTW_LIBRARIES`              ... full paths to all found fftw libraries
+- `FFTW_[component]_LIB`        ... full path to one of the components (see below)
+- `FFTW_INCLUDE_DIRS`           ... fftw include directory paths
+
+The following variables will be checked by the module:
+- `FFTW_USE_STATIC_LIBS`        ... if true, only static libraries are found, otherwise both static and shared.
+- `FFTW_ROOT`                   ... if set, the libraries are exclusively searched under this path.
+
+This package supports the following components:
+- `FLOAT_LIB`
+- `DOUBLE_LIB`
+- `LONGDOUBLE_LIB`
+- `FLOAT_THREADS_LIB`
+- `DOUBLE_THREADS_LIB`
+- `LONGDOUBLE_THREADS_LIB`
+- `FLOAT_OPENMP_LIB`
+- `DOUBLE_OPENMP_LIB`
+- `LONGDOUBLE_OPENMP_LIB`
+- `FLOAT_MPI_LIB`
+- `DOUBLE_MPI_LIB`
+- `LONGDOUBLE_MPI_LIB`
+
+and the following linking targets
+
+- `FFTW::Float`
+- `FFTW::Double`
+- `FFTW::LongDouble`
+- `FFTW::FloatThreads`
+- `FFTW::DoubleThreads`
+- `FFTW::LongDoubleThreads`
+- `FFTW::FloatOpenMP`
+- `FFTW::DoubleOpenMP`
+- `FFTW::LongDoubleOpenMP`
+- `FFTW::FloatMPI`
+- `FFTW::DoubleMPI`
+- `FFTW::LongDoubleMPI`
+
+# Adding to your project
+
+## Automatic download from CMake project
+
+Copy the following into the `CMakeLists.txt` file of the project you want to use FindFFTW in:
+```cmake
+configure_file(downloadFindFFTW.cmake.in findFFTW-download/CMakeLists.txt)
+execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
+        RESULT_VARIABLE result
+        WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/findFFTW-download )
+if(result)
+    message(FATAL_ERROR "CMake step for findFFTW failed: ${result}")
+    else()
+    message("CMake step for findFFTW completed (${result}).")
+endif()
+execute_process(COMMAND ${CMAKE_COMMAND} --build .
+        RESULT_VARIABLE result
+        WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/findFFTW-download )
+if(result)
+    message(FATAL_ERROR "Build step for findFFTW failed: ${result}")
+endif()
+
+set(findFFTW_DIR ${CMAKE_CURRENT_BINARY_DIR}/findFFTW-src)
+
+set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${findFFTW_DIR}")
+```
+
+And add a file called `downloadFindFFTW.cmake.in` to your project containing the following:
+```cmake
+cmake_minimum_required(VERSION 2.8.2)
+
+project(findFFTW-download NONE)
+
+include(ExternalProject)
+
+ExternalProject_Add(findFFTW_download
+    GIT_REPOSITORY    "https://github.com/egpbos/findfftw.git"
+    CONFIGURE_COMMAND ""
+    BUILD_COMMAND     ""
+    INSTALL_COMMAND   ""
+    TEST_COMMAND      ""
+    SOURCE_DIR        "${CMAKE_CURRENT_BINARY_DIR}/findFFTW-src"
+    BINARY_DIR        ""
+    INSTALL_DIR       ""
+)
+```
+
+After this, `find_package(FFTW)` can be used in the `CMakeLists.txt` file.
+
+## Manual
+
+Clone the repository into directory `PREFIX/findFFTW`:
+```sh
+git clone https://github.com/egpbos/findfftw.git PREFIX/findFFTW
+```
+
+Then add the following to your `CMakeLists.txt` to allow CMake to find the module:
+```cmake
+set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "PREFIX/findFFTW")
+```