Skip to content

Commit

Permalink
[cmake] Add and export Modules_CUDA_fix (pytorch#8271)
Browse files Browse the repository at this point in the history
* Add and export Modules_CUDA_fix

* actually, need to include before finding cuda
  • Loading branch information
Yangqing authored Jun 8, 2018
1 parent 49593a6 commit 1a03ba5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 15 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,10 @@ if (BUILD_SHARED_LIBS)
${PROJECT_SOURCE_DIR}/cmake/public/utils.cmake
DESTINATION share/cmake/Caffe2/public
COMPONENT dev)
install(DIRECTORY
${PROJECT_SOURCE_DIR}/cmake/Modules_CUDA_fix
DESTINATION share/cmake/Caffe2/
COMPONENT dev)
install(EXPORT Caffe2Targets DESTINATION share/cmake/Caffe2
FILE Caffe2Targets.cmake
COMPONENT dev)
Expand Down
15 changes: 0 additions & 15 deletions cmake/MiscCheck.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -261,21 +261,6 @@ endif()
# ---[ Create CAFFE2_BUILD_SHARED_LIBS for macros.h.in usage.
set(CAFFE2_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS})

# ---[ Check if we will need to include the local Modules_CUDA_fix folder.
# Add your conditions here if needed.
if (MSVC)
# We know that VS2017 needs the new FindCUDA functionality, so we will
# simply enable it for the whole Windows build.
set(CAFFE2_CMAKE_USE_LOCAL_FINDCUDA ON)
else (${CMAKE_VERSION} VERSION_LESS 3.12 AND ${USE_CUDA})
set(CAFFE2_CMAKE_USE_LOCAL_FINDCUDA ON)
endif()

if (${CAFFE2_CMAKE_USE_LOCAL_FINDCUDA})
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/Modules_CUDA_fix)
include(CMakeInitializeConfigs)
endif()

if (USE_NATIVE_ARCH)
check_cxx_compiler_flag("-march=native" COMPILER_SUPPORTS_MARCH_NATIVE)
if (COMPILER_SUPPORTS_MARCH_NATIVE)
Expand Down
8 changes: 8 additions & 0 deletions cmake/public/cuda.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# ---[ cuda

# Check if we need to use the new FindCUDA functionalities, which are included
# since 3.7.0. Also, we know that VS2017 needs the new FindCUDA functionality,
# so we will simply enable it for the whole Windows build.
if (MSVC OR ${CMAKE_VERSION} VERSION_LESS 3.7.0)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/../Modules_CUDA_fix)
include(CMakeInitializeConfigs)
endif()

# Find CUDA.
find_package(CUDA 7.0)
if(NOT CUDA_FOUND)
Expand Down

0 comments on commit 1a03ba5

Please sign in to comment.