Skip to content

Commit

Permalink
apply cmake-format
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuuichi Asahi committed Feb 21, 2025
1 parent 3fc3736 commit 1890cc3
Show file tree
Hide file tree
Showing 14 changed files with 482 additions and 648 deletions.
131 changes: 48 additions & 83 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,15 @@ project(KokkosFFT VERSION 0.2.1 LANGUAGES CXX)
list(PREPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")

# Options
option(
KokkosFFT_ENABLE_HOST_AND_DEVICE
"Enable FFT on both host and device"
OFF
)
option(
KokkosFFT_ENABLE_INTERNAL_KOKKOS
"Build internal Kokkos instead of relying on external one"
OFF
)
option(KokkosFFT_ENABLE_HOST_AND_DEVICE "Enable FFT on both host and device" OFF)
option(KokkosFFT_ENABLE_INTERNAL_KOKKOS "Build internal Kokkos instead of relying on external one" OFF)
option(KokkosFFT_ENABLE_EXAMPLES "Build KokkosFFT examples" OFF)
option(KokkosFFT_ENABLE_TESTS "Build KokkosFFT tests" OFF)
option(KokkosFFT_ENABLE_BENCHMARK "Build benchmarks for KokkosFFT" OFF)
option(KokkosFFT_ENABLE_DOCS "Build KokkosFFT documentaion/website" OFF)

# Device specific options
option(
KokkosFFT_ENABLE_ROCFFT
"Enable rocfft as a KokkosFFT backend on AMD GPUs"
OFF
)
option(KokkosFFT_ENABLE_ROCFFT "Enable rocfft as a KokkosFFT backend on AMD GPUs" OFF)

# Version information
set(KOKKOSFFT_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
Expand All @@ -43,14 +31,14 @@ set(KOKKOSFFT_VERSION_PATCH ${PROJECT_VERSION_PATCH})
set(KOKKOS_REQUIRED_VERSION 4.4.0)

if(NOT KokkosFFT_ENABLE_INTERNAL_KOKKOS)
# First check, Kokkos is added as subdirectory or not
if(NOT TARGET Kokkos::kokkos)
find_package(Kokkos ${KOKKOS_REQUIRED_VERSION} REQUIRED)
# Check the alignment of complex numbers
kokkos_check(OPTIONS COMPLEX_ALIGN)
endif()
# First check, Kokkos is added as subdirectory or not
if(NOT TARGET Kokkos::kokkos)
find_package(Kokkos ${KOKKOS_REQUIRED_VERSION} REQUIRED)
# Check the alignment of complex numbers
kokkos_check(OPTIONS COMPLEX_ALIGN)
endif()
else()
add_subdirectory(tpls/kokkos)
add_subdirectory(tpls/kokkos)
endif()

# Set tpls
Expand All @@ -64,62 +52,55 @@ get_tpls_list(KOKKOSFFT_TPL_LIST KOKKOSFFT_BACKEND_LIST)
# ==================================================================

message("")
message(
STATUS
"KokkosFFT version: ${KOKKOSFFT_VERSION_MAJOR}.${KOKKOSFFT_VERSION_MINOR}.${KOKKOSFFT_VERSION_PATCH}"
)
message(STATUS "KokkosFFT version: ${KOKKOSFFT_VERSION_MAJOR}.${KOKKOSFFT_VERSION_MINOR}.${KOKKOSFFT_VERSION_PATCH}")
message(STATUS "KokkosFFT TPLs:")
if(KOKKOSFFT_TPL_LIST)
include(KokkosFFT_utils)
foreach(BACKEND TPL IN ZIP_LISTS KOKKOSFFT_BACKEND_LIST KOKKOSFFT_TPL_LIST)
# [TO DO] show more information about the library (like location)
pad_string(BACKEND_PADDED "${BACKEND}" 13)
message(STATUS " ${BACKEND_PADDED}: ${TPL}")
endforeach()
include(KokkosFFT_utils)
foreach(BACKEND TPL IN ZIP_LISTS KOKKOSFFT_BACKEND_LIST KOKKOSFFT_TPL_LIST)
# [TO DO] show more information about the library (like location)
pad_string(BACKEND_PADDED "${BACKEND}" 13)
message(STATUS " ${BACKEND_PADDED}: ${TPL}")
endforeach()
else()
message(STATUS " (None)")
message(STATUS " (None)")
endif()
message("")

# Googletest
if(KokkosFFT_ENABLE_TESTS)
include(CTest)
find_package(GTest CONFIG)
if(NOT GTest_FOUND)
add_subdirectory(tpls/googletest)
endif()
include(CTest)
find_package(GTest CONFIG)
if(NOT GTest_FOUND)
add_subdirectory(tpls/googletest)
endif()
endif()

# Build documentation with Doxygen and Sphinx
if(KokkosFFT_ENABLE_DOCS)
find_package(Doxygen REQUIRED)
find_package(Sphinx REQUIRED)
add_subdirectory(docs)
find_package(Doxygen REQUIRED)
find_package(Sphinx REQUIRED)
add_subdirectory(docs)
endif()

# Benchmark
if(KokkosFFT_ENABLE_BENCHMARK)
option(
BENCHMARK_ENABLE_TESTING
"Enable testing of the benchmark library."
OFF
)
add_subdirectory(tpls/benchmark)
include(KokkosFFT_Git_Hash)

# [TO DO] Fix this, it detects benchmark not a googlebench
#find_package(benchmark QUIET)
#if(NOT benchmark_FOUND)
# add_subdirectory(tpls/benchmark)
#endif()
option(BENCHMARK_ENABLE_TESTING "Enable testing of the benchmark library." OFF)
add_subdirectory(tpls/benchmark)
include(KokkosFFT_Git_Hash)

# [TO DO] Fix this, it detects benchmark not a googlebench
#find_package(benchmark QUIET)
#if(NOT benchmark_FOUND)
# add_subdirectory(tpls/benchmark)
#endif()
endif()

# Configure files to display configuration
# Configure the library
set(PACKAGE_NAME_CONFIG_FILES KokkosFFT_config.h KokkosFFT_Version_Info.hpp)

foreach(CONFIG_FILE ${PACKAGE_NAME_CONFIG_FILES})
configure_file(cmake/${CONFIG_FILE}.in ${CMAKE_BINARY_DIR}/${CONFIG_FILE})
configure_file(cmake/${CONFIG_FILE}.in ${CMAKE_BINARY_DIR}/${CONFIG_FILE})
endforeach()

# Set directories used for install
Expand All @@ -132,49 +113,33 @@ set(KokkosFFT_EXPORT_TARGET "${PROJECT_NAME}-Targets")
add_subdirectory(common)
add_subdirectory(fft)
if(KokkosFFT_ENABLE_EXAMPLES)
add_subdirectory(examples)
add_subdirectory(examples)
endif()

# Installation
include(CMakePackageConfigHelpers)

install(TARGETS common fft EXPORT ${KokkosFFT_EXPORT_TARGET})
install(EXPORT ${KokkosFFT_EXPORT_TARGET} NAMESPACE KokkosFFT:: DESTINATION ${INSTALL_LIBDIR})

install(
EXPORT ${KokkosFFT_EXPORT_TARGET}
NAMESPACE KokkosFFT::
DESTINATION ${INSTALL_LIBDIR}
)

install(
DIRECTORY
${CMAKE_CURRENT_SOURCE_DIR}/common/src/
${CMAKE_CURRENT_SOURCE_DIR}/fft/src/
DESTINATION ${INSTALL_INCLUDEDIR}
FILES_MATCHING
PATTERN "*.hpp"
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/common/src/ ${CMAKE_CURRENT_SOURCE_DIR}/fft/src/
DESTINATION ${INSTALL_INCLUDEDIR}
FILES_MATCHING
PATTERN "*.hpp"
)

install(
FILES ${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindFFTW.cmake
DESTINATION ${INSTALL_LIBDIR}
)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindFFTW.cmake DESTINATION ${INSTALL_LIBDIR})

configure_package_config_file(
cmake/KokkosFFTConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/KokkosFFTConfig.cmake
INSTALL_DESTINATION ${INSTALL_LIBDIR}
cmake/KokkosFFTConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/KokkosFFTConfig.cmake
INSTALL_DESTINATION ${INSTALL_LIBDIR}
)

write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/KokkosFFTConfigVersion.cmake
VERSION ${KokkosFFT_VERSION}
COMPATIBILITY SameMajorVersion
${CMAKE_CURRENT_BINARY_DIR}/KokkosFFTConfigVersion.cmake VERSION ${KokkosFFT_VERSION} COMPATIBILITY SameMajorVersion
)

install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/KokkosFFTConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/KokkosFFTConfigVersion.cmake
DESTINATION ${INSTALL_LIBDIR}
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/KokkosFFTConfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/KokkosFFTConfigVersion.cmake
DESTINATION ${INSTALL_LIBDIR}
)
Loading

0 comments on commit 1890cc3

Please sign in to comment.