diff --git a/CMakeLists.txt b/CMakeLists.txt index 56eec8185..9c96a0363 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,7 +26,7 @@ option (ENABLE_SSE2 "Compile with SSE2 instruction set support" OFF) option (ENABLE_AVX "Compile with AVX instruction set support" OFF) option (ENABLE_AVX2 "Compile with AVX2 instruction set support" OFF) -set (LIBRARY_PATH lib${LIB_SUFFIX}) +include(GNUInstallDirs) include (CheckIncludeFile) @@ -241,7 +241,7 @@ set (fftw_threads_SOURCE ${fftw_par_SOURCE} threads/threads.c) set (fftw_omp_SOURCE ${fftw_par_SOURCE} threads/openmp.c) -include_directories(.) +include_directories (.) if (WITH_COMBINED_THREADS) @@ -338,14 +338,19 @@ endif () foreach(subtarget ${subtargets}) set_target_properties (${subtarget} PROPERTIES SOVERSION 3.5.7 VERSION 3) install (TARGETS ${subtarget} - RUNTIME DESTINATION bin - LIBRARY DESTINATION ${LIBRARY_PATH} - ARCHIVE DESTINATION ${LIBRARY_PATH}) + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) endforeach () +install(TARGETS ${fftw3_lib} + EXPORT FFTW3LibraryDepends + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) -install (FILES api/fftw3.h DESTINATION include RENAME fftw3${PREC_SUFFIX}.h) +install (FILES api/fftw3.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) if (EXISTS api/fftw3.f) - install (FILES api/fftw3.f DESTINATION include RENAME fftw3${PREC_SUFFIX}.f) + install (FILES api/fftw3.f DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) endif () if (BUILD_TESTS) @@ -376,20 +381,27 @@ 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 (libdir ${CMAKE_INSTALL_FULL_LIBDIR}) +set (includedir ${CMAKE_INSTALL_FULL_INCLUDEDIR}) 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 + DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig COMPONENT Development) # cmake file +set (FFTW3_LIBRARIES "FFTW3::${fftw3_lib}") 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 + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/fftw3${PREC_SUFFIX} COMPONENT Development) + +export (TARGETS ${fftw3_lib} NAMESPACE FFTW3:: FILE ${PROJECT_BINARY_DIR}/FFTW3LibraryDepends.cmake) +install(EXPORT FFTW3LibraryDepends + NAMESPACE FFTW3:: + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/fftw3${PREC_SUFFIX} + COMPONENT Development) diff --git a/FFTW3Config.cmake.in b/FFTW3Config.cmake.in index 26cd81211..6b1fbc2e1 100644 --- a/FFTW3Config.cmake.in +++ b/FFTW3Config.cmake.in @@ -3,6 +3,15 @@ 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) +# Allows loading FFTW3 settings from another project +set (FFTW3_CONFIG_FILE "${CMAKE_CURRENT_LIST_FILE}") + +set (FFTW3@PREC_SUFFIX@_LIBRARIES fftw3@PREC_SUFFIX@) +set (FFTW3@PREC_SUFFIX@_LIBRARY_DIRS @CMAKE_INSTALL_FULL_LIBDIR@) +set (FFTW3@PREC_SUFFIX@_INCLUDE_DIRS @CMAKE_INSTALL_FULL_INCLUDEDIR@) + +include ("${CMAKE_CURRENT_LIST_DIR}/FFTW3LibraryDepends.cmake") + +if (CMAKE_VERSION VERSION_LESS 2.8.3) + set (CMAKE_CURRENT_LIST_DIR) +endif () diff --git a/Makefile.am b/Makefile.am index d56081d26..d89dc2fba 100644 --- a/Makefile.am +++ b/Makefile.am @@ -145,11 +145,15 @@ pkgconfig_DATA = fftw3@PREC_SUFFIX@.pc 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' \ + -e 's|[@]CMAKE_INSTALL_FULL_LIBDIR@|$(libdir)|g' \ + -e 's|[@]CMAKE_INSTALL_FULL_INCLUDEDIR@|$(includedir)|g' \ $(top_srcdir)/FFTW3Config.cmake.in > $@ +FFTW3@PREC_SUFFIX@ConfigVersion.cmake: $(top_srcdir)/FFTW3ConfigVersion.cmake.in + $(SED) \ + -e 's|[@]FFTW_VERSION@|@PACKAGE_VERSION@|g' \ + $(top_srcdir)/FFTW3ConfigVersion.cmake.in > $@ cmakedir = $(libdir)/cmake/fftw3 -cmake_DATA = FFTW3@PREC_SUFFIX@Config.cmake +cmake_DATA = FFTW3@PREC_SUFFIX@Config.cmake FFTW3@PREC_SUFFIX@ConfigVersion.cmake WISDOM_DIR = /etc/fftw WISDOM = wisdom@PREC_SUFFIX@