# ############################################################################# # Copyright (c) 2020 - present Advanced Micro Devices, Inc. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. # ############################################################################ # This option only works for make/nmake and the ninja generators, but no reason it shouldn't be on # all the time. # This tells cmake to create a compile_commands.json file that can be used with clang tooling or vim set( CMAKE_EXPORT_COMPILE_COMMANDS ON ) # Print verbose compiler flags if( BUILD_VERBOSE ) include( ../cmake/verbose.cmake ) endif() find_package(HIP REQUIRED) set(HIP_INCLUDE_DIRS "${HIP_ROOT_DIR}/include") # Configure a header file to pass the hipFFT version configure_file( "${CMAKE_CURRENT_SOURCE_DIR}/include/hipfft-version.h.in" "${PROJECT_BINARY_DIR}/include/hipfft-version.h" ) # Public hipFFT headers set( hipfft_headers_public include/hipfft.h include/hipfftXt.h ${PROJECT_BINARY_DIR}/include/hipfft-version.h ) source_group( "Header Files\\Public" FILES ${hipfft_headers_public} ) include( GNUInstallDirs ) set( BIN_INSTALL_DIR ${CMAKE_INSTALL_BINDIR} ) set( LIB_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR} ) set( INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_INCLUDEDIR} ) # nvcc can not recognize shared libraray file name with suffix other than *.so when linking. #if (NOT BUILD_WITH_COMPILER STREQUAL "HIP-NVCC") # rocm_setsoversion(hipfft ${hipfft_SOVERSION}) #endif() # Include sources include( src/CMakeLists.txt ) # Create hipFFT library add_library( hipfft ${hipfft_source} ${hipfft_headers_public} ) add_library( hip::hipfft ALIAS hipfft ) # Target compile definitions if( BUILD_WITH_COMPILER STREQUAL "HOST-DEFAULT" ) if( BUILD_WITH_LIB STREQUAL "ROCM" ) target_compile_definitions( hipfft PRIVATE __HIP_PLATFORM_HCC__ ) elseif( BUILD_WITH_LIB STREQUAL "CUDA" ) target_compile_definitions( hipfft PRIVATE __HIP_PLATFORM_NVCC__ ) endif() endif() # Target include directories target_include_directories( hipfft PRIVATE $ PUBLIC $ $ $ $ ${HIP_INCLUDE_DIRS} ) if( BUILD_WITH_LIB STREQUAL "CUDA" ) target_include_directories( hipfft PUBLIC $ ) endif() # Target link libraries if( NOT BUILD_WITH_LIB STREQUAL "CUDA" ) target_link_libraries( hipfft PRIVATE roc::rocfft ) if( WIN32 ) target_link_libraries( hipfft PRIVATE hip::device hip::host ) endif() else() # static hipfft build should link against static cufft if( BUILD_SHARED_LIBS ) target_link_libraries( hipfft PRIVATE ${CUDA_cufft_LIBRARY} ) else() target_link_libraries( hipfft PRIVATE -lcufft_static -lculibos ) endif() endif() # Target properties set_target_properties( hipfft PROPERTIES CXX_EXTENSIONS NO ) set_target_properties( hipfft PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/staging" ) set_target_propertieS( hipfft PROPERTIES DEBUG_POSTFIX "-d" ) if (BUILD_WITH_COMPILER STREQUAL "HIP-NVCC" ) set_property(TARGET hipfft PROPERTY POSITION_INDEPENDENT_CODE ON) set ( CXX_FLAGS "${CXX_FLAGS} -Xcompiler=-fPIC" ) endif() #TODO: # hipcc(with nvcc backend) build has problem for share library visibility, # need to figure out the reason and enable visibility "hidden" for nvcc eventually. if( NOT BUILD_WITH_COMPILER STREQUAL "HIP-NVCC" ) set_target_properties( hipfft PROPERTIES CXX_VISIBILITY_PRESET "hidden" VISIBILITY_INLINES_HIDDEN ON ) endif() # Generate export header include( GenerateExportHeader ) generate_export_header( hipfft EXPORT_FILE_NAME ${PROJECT_BINARY_DIR}/include/hipfft-export.h ) # Packaging... if(WIN32) set(CPACK_SOURCE_GENERATOR "ZIP") set(CPACK_GENERATOR "ZIP") set(CMAKE_INSTALL_PREFIX "C:/hipSDK" CACHE PATH "Install path" FORCE) set(INSTALL_PREFIX "C:/hipSDK") set(CPACK_SET_DESTDIR OFF) set(CPACK_PACKAGE_INSTALL_DIRECTORY "C:/hipSDK") set(CPACK_PACKAGING_INSTALL_PREFIX "") set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY OFF) endif() if( ROCM_FOUND ) rocm_install_targets( TARGETS hipfft INCLUDE ${CMAKE_SOURCE_DIR}/library/include ${CMAKE_BINARY_DIR}/include PREFIX hipfft ) rocm_export_targets( TARGETS hip::hipfft PREFIX hipfft DEPENDS PACKAGE hip NAMESPACE hip:: ) rocm_install_symlink_subdir( hipfft ) # Package specific CPACK vars if( NOT BUILD_WITH_LIB STREQUAL "CUDA" ) set( CPACK_DEBIAN_PACKAGE_DEPENDS "rocfft (>= 1.0.0)" ) set( CPACK_RPM_PACKAGE_REQUIRES "rocfft >= 1.0.0" ) else() set( CPACK_DEBIAN_PACKAGE_DEPENDS "cufft (>= 10.0.0)" ) set( CPACK_RPM_PACKAGE_REQUIRES "cufft >= 10.0.0" ) endif() set( CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/../LICENSE.md" ) set( CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "\${CPACK_PACKAGING_INSTALL_PREFIX}" "\${CPACK_PACKAGING_INSTALL_PREFIX}/include" "\${CPACK_PACKAGING_INSTALL_PREFIX}/lib" ) # Give hipfft compiled for CUDA backend a different name if( BUILD_WITH_LIB STREQUAL "ROCM" ) set( package_name hipfft ) else() set( package_name hipfft-alt ) endif() set( HIPFFT_CONFIG_DIR "\${CPACK_PACKAGING_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}" CACHE PATH "Path placed into ldconfig file" ) rocm_create_package( NAME ${package_name} DESCRIPTION "ROCm FFT marshalling library" MAINTAINER "hipfft-maintainer@amd.com" LDCONFIG LDCONFIG_DIR ${HIPFFT_CONFIG_DIR} ) endif()