diff --git a/cmake/FindPFFT.cmake b/cmake/FindPFFT.cmake index 199587f..34e73e2 100644 --- a/cmake/FindPFFT.cmake +++ b/cmake/FindPFFT.cmake @@ -1,84 +1,84 @@ # - Find the PFFT library # # Usage: # find_package(PFFT [REQUIRED] [QUIET] ) # # It sets the following variables: # PFFT_FOUND ... true if PFFT is found on the system # PFFT_LIBRARIES ... full path to PFFT library # PFFT_INCLUDES ... PFFT include directory # # The following variables will be checked by the function # PFFT_USE_STATIC_LIBS ... if true, only static libraries are found # PFFT_ROOT ... if set, the libraries are exclusively searched # under this path # PFFT_LIBRARY ... PFFT library to use # PFFT_INCLUDE_DIR ... PFFT include directory # #If environment variable PFFTDIR is specified, it has same effect as PFFT_ROOT if( NOT PFFT_ROOT AND ENV{PFFTDIR} ) set( PFFT_ROOT $ENV{PFFTDIR} ) endif() # Check if we can use PkgConfig find_package(PkgConfig) #Determine from PKG if( PKG_CONFIG_FOUND AND NOT PFFT_ROOT ) pkg_check_modules( PKG_PFFT QUIET "PFFT" ) endif() #Check whether to search static or dynamic libs set( CMAKE_FIND_LIBRARY_SUFFIXES_SAV ${CMAKE_FIND_LIBRARY_SUFFIXES} ) if( ${PFFT_USE_STATIC_LIBS} ) set( CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_STATIC_LIBRARY_SUFFIX} ) else() set( CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_SHARED_LIBRARY_SUFFIX} ) endif() if( PFFT_ROOT ) #find libs find_library( PFFT_LIBRARIES NAMES "pfft" PATHS ${PFFT_ROOT} PATH_SUFFIXES "lib" "lib64" NO_DEFAULT_PATH ) #find includes find_path( PFFT_INCLUDES - NAMES "fftw3.h" - PATHS ${FFTW_ROOT} + NAMES "pfft.h" + PATHS ${PFFT_ROOT} PATH_SUFFIXES "include" NO_DEFAULT_PATH ) else() find_library( PFFT_LIBRARIES NAMES "pfft" PATHS ${PKG_PFFT_LIBRARY_DIRS} ${LIB_INSTALL_DIR} ) find_path( PFFT_INCLUDES NAMES "pfft.h" PATHS ${PKG_PFFT_INCLUDE_DIRS} ${INCLUDE_INSTALL_DIR} ) endif( PFFT_ROOT ) set( CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES_SAV} ) include(FindPackageHandleStandardArgs) find_package_handle_standard_args(PFFT DEFAULT_MSG PFFT_INCLUDES PFFT_LIBRARIES) mark_as_advanced(PFFT_INCLUDES PFFT_LIBRARIES) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e55c138..445c4da 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,85 +1,97 @@ # ============================================================================= # file CMakeLists.txt # # @author Till Junge # # @date 08 Jan 2018 # # @brief Configuration for libmuSpectre # # @section LICENSE # # Copyright © 2018 Till Junge # # µSpectre is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as # published by the Free Software Foundation, either version 3, or (at # your option) any later version. # # µSpectre is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with GNU Emacs; see the file COPYING. If not, write to the # Free Software Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA. # ============================================================================= include_directories( common materials cell ) set (muSpectre_SRC ) add_subdirectory(common) add_subdirectory(materials) add_subdirectory(fft) add_subdirectory(cell) add_subdirectory(solver) find_package(MPI) find_package(FFTW REQUIRED) find_package(FFTWMPI) +find_package(PFFT) # The following checks whether std::optional exists and replaces it by # boost::optional if necessary include(CheckCXXSourceCompiles) check_cxx_source_compiles( "#include int main() { std::experimental::optional A{}; }" HAS_STD_OPTIONAL) if( NOT HAS_STD_OPTIONAL) add_definitions(-DNO_EXPERIMENTAL) endif() file(GLOB_RECURSE _headers RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "*.hh") list(APPEND muSpectre_SRC ${_headers}) add_library(muSpectre ${muSpectre_SRC}) +set(muSpectre_INCLUDES ${FFTW_INCLUDES}) set(muSpectre_LIBRARIES Eigen3::Eigen ${FFTW_LIBRARIES}) if(FFTWMPI_FOUND) + set(muSpectre_INCLUDES + ${muSpectre_INCLUDES} + ${FFTWMPI_INCLUDES}) set(muSpectre_LIBRARIES ${muSpectre_LIBRARIES} ${FFTWMPI_LIBRARIES}) endif() if(PFFT_FOUND) + set(muSpectre_INCLUDES + ${muSpectre_INCLUDES} + ${PFFT_INCLUDES}) set(muSpectre_LIBRARIES ${muSpectre_LIBRARIES} ${PFFT_LIBRARIES}) endif() if(FFTWMPI_FOUND OR PFFT_FOUND) + set(muSpectre_INCLUDES + ${muSpectre_INCLUDES} + ${MPI_INCLUDES}) set(muSpectre_LIBRARIES ${muSpectre_LIBRARIES} ${MPI_LIBRARIES}) endif() +target_include_directories(muSpectre INTERFACE ${muSpectre_INCLUDES}) target_link_libraries(muSpectre ${muSpectre_LIBRARIES}) set_property(TARGET muSpectre PROPERTY PUBLIC_HEADER ${_headers}) diff --git a/src/fft/CMakeLists.txt b/src/fft/CMakeLists.txt index 5f50856..2d0e368 100644 --- a/src/fft/CMakeLists.txt +++ b/src/fft/CMakeLists.txt @@ -1,58 +1,61 @@ # ============================================================================= # file CMakeLists.txt # # @author Till Junge # # @date 08 Jan 2018 # # @brief configuration for fft-related files # # @section LICENSE # # Copyright © 2018 Till Junge # # µSpectre is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as # published by the Free Software Foundation, either version 3, or (at # your option) any later version. # # µSpectre is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with GNU Emacs; see the file COPYING. If not, write to the # Free Software Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA. # ============================================================================= +find_package(FFTWMPI) +find_package(PFFT) + set (fft_engine_SRC ${CMAKE_CURRENT_SOURCE_DIR}/fft_utils.cc ${CMAKE_CURRENT_SOURCE_DIR}/fft_engine_base.cc ${CMAKE_CURRENT_SOURCE_DIR}/fftw_engine.cc ${CMAKE_CURRENT_SOURCE_DIR}/projection_base.cc ${CMAKE_CURRENT_SOURCE_DIR}/projection_default.cc ${CMAKE_CURRENT_SOURCE_DIR}/projection_finite_strain.cc ${CMAKE_CURRENT_SOURCE_DIR}/projection_small_strain.cc ${CMAKE_CURRENT_SOURCE_DIR}/projection_finite_strain_fast.cc ) if(FFTWMPI_FOUND) set(fft_engine_SRC ${fft_engine_SRC} ${CMAKE_CURRENT_SOURCE_DIR}/fftwmpi_engine.cc ) endif() if (PFFT_FOUND) set(fft_engine_SRC ${fft_engine_SRC} ${CMAKE_CURRENT_SOURCE_DIR}/pfft_engine.cc ) endif() set (muSpectre_SRC ${muSpectre_SRC} ${fft_engine_SRC} PARENT_SCOPE)