From e4f44bec27bc458c5dc8021ed87f0e6fae904ef4 Mon Sep 17 00:00:00 2001 From: Peter Bell Date: Mon, 23 Aug 2021 17:39:50 -0700 Subject: [PATCH] Fix pocketfft include path in mobile build (#63714) Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/63714 PocketFFT was disabled for CMake < 3.9 but CMake 3.11 is the first version to support `INCLUDE_DIRECTORIES` as a target property. So updating to CMake 3.10 causes the mobile builds to fail. Instead of limiting the CMake support, this just adds the include directory to the entire target, Test Plan: Imported from OSS Reviewed By: bdhirsh Differential Revision: D30498369 Pulled By: malfet fbshipit-source-id: 83372e29c477c97e7015763b7c29d6d7e456bcef --- caffe2/CMakeLists.txt | 16 +++++++++++----- cmake/Dependencies.cmake | 7 ++++--- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/caffe2/CMakeLists.txt b/caffe2/CMakeLists.txt index 523fea8..67ab08f 100644 --- a/caffe2/CMakeLists.txt +++ b/caffe2/CMakeLists.txt @@ -529,11 +529,6 @@ if(NOT INTERN_BUILD_MOBILE OR NOT BUILD_CAFFE2_MOBILE) set_source_files_properties(${TORCH_SRC_DIR}/csrc/jit/tensorexpr/llvm_codegen.cpp PROPERTIES COMPILE_FLAGS -Wno-init-list-lifetime) endif() - # Pass path to PocketFFT - if(AT_POCKETFFT_ENABLED) - set_source_files_properties(${CMAKE_CURRENT_LIST_DIR}/../aten/src/ATen/native/mkl/SpectralOps.cpp PROPERTIES INCLUDE_DIRECTORIES "${POCKETFFT_INCLUDE_DIR}") - endif() - if(NOT INTERN_DISABLE_MOBILE_INTERP) set(MOBILE_SRCS ${TORCH_SRC_DIR}/csrc/jit/mobile/function.cpp @@ -795,6 +790,17 @@ if(USE_PRECOMPILED_HEADERS) PROPERTIES SKIP_PRECOMPILE_HEADERS ON) endif() +# Pass path to PocketFFT +if(AT_POCKETFFT_ENABLED) + if(CMAKE_VERSION VERSION_LESS "3.11") + target_include_directories(torch_cpu PRIVATE "${POCKETFFT_INCLUDE_DIR}") + else() + set_source_files_properties( + "${PROJECT_SOURCE_DIR}/aten/src/ATen/native/mkl/SpectralOps.cpp" + PROPERTIES INCLUDE_DIRECTORIES "${POCKETFFT_INCLUDE_DIR}") + endif() +endif() + if(CMAKE_COMPILER_IS_GNUCXX AND BUILD_LIBTORCH_CPU_WITH_DEBUG) # To enable debug fission we need to build libtorch_cpu with debug info on, # but this increases link time and peak memory usage if we use the diff --git a/cmake/Dependencies.cmake b/cmake/Dependencies.cmake index 3e37c35..b3cc23c 100644 --- a/cmake/Dependencies.cmake +++ b/cmake/Dependencies.cmake @@ -242,14 +242,15 @@ endif() # --- [ PocketFFT set(AT_POCKETFFT_ENABLED 0) -if(NOT MKL_FOUND) +if(NOT AT_MKL_ENABLED) find_path(POCKETFFT_INCLUDE_DIR NAMES pocketfft_hdronly.h PATHS /usr/local/include - "$ENV{POCKETFFT_HOME}" + ENV POCKETFFT_HOME "${PROJECT_SOURCE_DIR}/third_party/pocketfft" ) - if(POCKETFFT_INCLUDE_DIR AND CMAKE_VERSION VERSION_GREATER "3.9") + if(POCKETFFT_INCLUDE_DIR) set(AT_POCKETFFT_ENABLED 1) + message(STATUS "Using pocketfft in directory: ${POCKETFFT_INCLUDE_DIR}") endif() endif() -- 2.7.4