Skip to content

Commit

Permalink
Use cmake config mode
Browse files Browse the repository at this point in the history
Installs FFTW3Config.cmake instead of a FindFFTW3.cmake
Also configures the pkgconfig file from cmake
  • Loading branch information
xantares committed Sep 20, 2017
1 parent 6076339 commit 82cec28
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 41 deletions.
37 changes: 31 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,6 @@ set (fftw_omp_SOURCE ${fftw_par_SOURCE} threads/openmp.c)

include_directories(.)

install (FILES api/fftw3.h api/fftw3.f DESTINATION include)


if (WITH_COMBINED_THREADS)
list (APPEND SOURCEFILES ${fftw_threads_SOURCE})
Expand All @@ -265,24 +263,25 @@ endif ()

set (FFTW_VERSION 3.3.7)

set (fftw3_lib fftw3)
set (PREC_SUFFIX)
if (ENABLE_FLOAT)
set (FFTW_SINGLE TRUE)
set (BENCHFFT_SINGLE TRUE)
set (fftw3_lib fftw3f)
set (PREC_SUFFIX f)
endif ()

if (ENABLE_LONG_DOUBLE)
set (FFTW_LDOUBLE TRUE)
set (BENCHFFT_LDOUBLE TRUE)
set(fftw3_lib fftw3l)
set (PREC_SUFFIX l)
endif ()

if (ENABLE_QUAD_PRECISION)
set (FFTW_QUAD TRUE)
set (BENCHFFT_QUAD TRUE)
set (fftw3_lib fftw3q)
set (PREC_SUFFIX q)
endif ()
set (fftw3_lib fftw3${PREC_SUFFIX})

configure_file (cmake.config.h.in config.h @ONLY)
include_directories (${CMAKE_CURRENT_BINARY_DIR})
Expand Down Expand Up @@ -344,6 +343,11 @@ foreach(subtarget ${subtargets})
ARCHIVE DESTINATION ${LIBRARY_PATH})
endforeach ()

install (FILES api/fftw3.h DESTINATION include RENAME fftw3${PREC_SUFFIX}.h)
if (EXISTS api/fftw3.f)
install (FILES api/fftw3.f DESTINATION include RENAME fftw3${PREC_SUFFIX}.f)
endif ()

add_executable (bench ${fftw_libbench2_SOURCE} tests/bench.c tests/hook.c tests/fftw-bench.c)

if (ENABLE_THREADS AND NOT WITH_COMBINED_THREADS)
Expand All @@ -365,3 +369,24 @@ if (Threads_FOUND AND BUILD_TESTS)
fftw_add_test (ib256)

endif ()

# pkgconfig file
set (prefix ${CMAKE_INSTALL_PREFIX})
set (exec_prefix ${CMAKE_INSTALL_PREFIX})
set (libdir ${CMAKE_INSTALL_PREFIX}/${LIBRARY_PATH})
set (includedir ${CMAKE_INSTALL_PREFIX}/include)
set (VERSION ${FFTW_VERSION})
configure_file (fftw.pc.in fftw${PREC_SUFFIX}.pc @ONLY)
install (FILES
${CMAKE_CURRENT_BINARY_DIR}/fftw${PREC_SUFFIX}.pc
DESTINATION ${LIBRARY_PATH}/pkgconfig
COMPONENT Development)

# cmake file
configure_file (FFTW3Config.cmake.in FFTW3${PREC_SUFFIX}Config.cmake @ONLY)
configure_file (FFTW3ConfigVersion.cmake.in FFTW3${PREC_SUFFIX}ConfigVersion.cmake @ONLY)
install (FILES
${CMAKE_CURRENT_BINARY_DIR}/FFTW3${PREC_SUFFIX}Config.cmake
${CMAKE_CURRENT_BINARY_DIR}/FFTW3${PREC_SUFFIX}ConfigVersion.cmake
DESTINATION ${LIBRARY_PATH}/cmake/fftw3
COMPONENT Development)
8 changes: 8 additions & 0 deletions FFTW3Config.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# defined since 2.8.3
if (CMAKE_VERSION VERSION_LESS 2.8.3)
get_filename_component (CMAKE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_FILE} PATH)
endif ()

set (FFTW3@PREC_SUFFIX@_LIBRARIES @fftw3_lib@)
set (FFTW3@PREC_SUFFIX@_LIBRARY_DIRS @CMAKE_INSTALL_PREFIX@/@LIBRARY_PATH@)
set (FFTW3@PREC_SUFFIX@_INCLUDE_DIRS @CMAKE_INSTALL_PREFIX@/include)
12 changes: 12 additions & 0 deletions FFTW3ConfigVersion.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

set (PACKAGE_VERSION "@FFTW_VERSION@")

# Check whether the requested PACKAGE_FIND_VERSION is compatible
if ("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}")
set (PACKAGE_VERSION_COMPATIBLE FALSE)
else ()
set (PACKAGE_VERSION_COMPATIBLE TRUE)
if ("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}")
set (PACKAGE_VERSION_EXACT TRUE)
endif ()
endif ()
30 changes: 0 additions & 30 deletions FindFFTW3.cmake.in

This file was deleted.

10 changes: 5 additions & 5 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ endif
SUBDIRS=support $(GENFFT) kernel simd-support dft rdft reodft api \
libbench2 $(CHICKEN_EGG) tests mpi $(DOCDIR) tools m4
EXTRA_DIST=COPYRIGHT bootstrap.sh CONVENTIONS fftw.pc.in \
CMakeLists.txt cmake.config.h.in FindFFTW3.cmake.in
CMakeLists.txt cmake.config.h.in FFTW3Config.cmake.in FFTW3ConfigVersion.cmake.in

SIMD_LIBS = simd-support/libsimd_support.la

Expand Down Expand Up @@ -142,14 +142,14 @@ fftw3@[email protected]: fftw.pc
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = fftw3@[email protected]

FindFFTW3@[email protected]: $(top_srcdir)/FindFFTW3.cmake.in
FFTW3@PREC_SUFFIX@Config.cmake: $(top_srcdir)/FFTW3Config.cmake.in
$(SED) \
-e 's|[@]PREC_SUFFIX@|@PREC_SUFFIX@|g' \
-e 's|[@]libdir@|$(libdir)|g' \
-e 's|[@]includedir@|$(includedir)|g' \
$(top_srcdir)/FindFFTW3.cmake.in > $@
cmakedir = $(datarootdir)/cmake/Modules
cmake_DATA = FindFFTW3@[email protected]
$(top_srcdir)/FFTW3Config.cmake.in > $@
cmakedir = $(libdir)/cmake/fftw3
cmake_DATA = FFTW3@PREC_SUFFIX@Config.cmake

WISDOM_DIR = /etc/fftw
WISDOM = wisdom@PREC_SUFFIX@
Expand Down

0 comments on commit 82cec28

Please sign in to comment.