Skip to content

Commit

Permalink
cmake wrapper (pytorch#8797)
Browse files Browse the repository at this point in the history
  • Loading branch information
ssnl committed Jun 22, 2018
1 parent d3ec956 commit 675b579
Show file tree
Hide file tree
Showing 17 changed files with 2,064 additions and 2,049 deletions.
3 changes: 0 additions & 3 deletions aten/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ list(APPEND CMAKE_LIBRARY_PATH /usr/lib/x86_64-linux-gnu/)

cmake_policy(SET CMP0012 NEW)

# Polyfill for upstream FindCUDA
include(CMakeInitializeConfigs)

#############################################

set(ATen_CPU_SRCS)
Expand Down
2,030 changes: 9 additions & 2,021 deletions cmake/Modules_CUDA_fix/FindCUDA.cmake

Large diffs are not rendered by default.

27 changes: 27 additions & 0 deletions cmake/Modules_CUDA_fix/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
This `./upstream` subdolder contains fixes for `FindCUDA` that are introduced in
later versions of cmake but cause generator expression errors in earlier CMake
versions. Specifically:

1. a problem where a generator expression for include directories was
passed to NVCC, where the generator expression itself was prefixed by `-I`.
As the NNPACK include directory generator expression expands to multiple
directories, the second and later ones were not prefixed by `-I`, causing
NVCC to return an error. First fixed in CMake 3.7 (see
[Kitware/CMake@7ded655f](https://github.com/Kitware/CMake/commit/7ded655f)).

2. Windows VS2017 fixes that allows one to define the ccbin path
differently between earlier versions of Visual Studio and VS2017. First
introduced after 3.10.1 master version (see
[Kitware/CMake@bc88329e](https://github.com/Kitware/CMake/commit/bc88329e)).

The downside of using these fixes is that `./upstream/CMakeInitializeConfigs.cmake`,
defining some new CMake variables (added in
[Kitware/CMake@48f7e2d3](https://github.com/Kitware/CMake/commit/48f7e2d3)),
must be included before `./upstream/FindCUDA.cmake` to support older CMake
versions. A wrapper `./FindCUDA.cmake` is created to do this automatically, and
to allow submodules to use these fixes because we can't patch their
`CMakeList.txt`.

If you need to update files under `./upstream` folder, we recommend you issue PRs
against [the CMake mainline branch](https://github.com/Kitware/CMake/blob/master/Modules/FindCUDA.cmake),
and then backport it here for earlier CMake compatibility.
17 changes: 0 additions & 17 deletions cmake/Modules_CUDA_fix/README.txt

This file was deleted.

2,023 changes: 2,023 additions & 0 deletions cmake/Modules_CUDA_fix/upstream/FindCUDA.cmake

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions cmake/Modules_CUDA_fix/upstream/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
If you need to update files under this folder, we recommend you issue PRs
against [the CMake mainline branch](https://github.com/Kitware/CMake/blob/master/Modules/FindCUDA.cmake),
and then backport it here for earlier CMake compatibility.

See [this](../README.md) for more details.
1 change: 0 additions & 1 deletion cmake/public/cuda.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# sccache is only supported in CMake master and not in the newest official
# release (3.11.3) yet. Hence we need our own Modules_CUDA_fix to enable sccache.
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/../Modules_CUDA_fix)
include(CMakeInitializeConfigs)

# Find CUDA.
find_package(CUDA 7.0)
Expand Down
1 change: 0 additions & 1 deletion third_party/nccl/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.8 FATAL_ERROR)
CMAKE_POLICY(VERSION 2.8)

include(CMakeInitializeConfigs)
IF(NOT CUDA_FOUND)
FIND_PACKAGE(CUDA 7.0 REQUIRED)
ENDIF()
Expand Down
3 changes: 0 additions & 3 deletions torch/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@ if(USE_CUDA)
${CMAKE_MODULE_PATH})
set(CMAKE_LIBRARY_PATH /usr/lib/x86_64-linux-gnu/ ${CMAKE_LIBRARY_PATH})

# Polyfill for upstream FindCUDA
include(CMakeInitializeConfigs)

if(NOT CUDA_FOUND)
find_package(CUDA 7.0)
endif()
Expand Down
3 changes: 0 additions & 3 deletions torch/lib/c10d/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ list(APPEND CMAKE_MODULE_PATH
${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/Modules
${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/Modules_CUDA_fix)

# Polyfill for upstream FindCUDA
include(CMakeInitializeConfigs)

# Relies on CMAKE_INSTALL_PREFIX to be set to ../tmp_install.
# It then finds $PREFIX/share/cmake/ATen/ATenConfig.cmake,
# which defines ATEN_INCLUDE_DIR and ATEN_LIBRARIES.
Expand Down

0 comments on commit 675b579

Please sign in to comment.