Skip to content

Commit

Permalink
Use the newer one of cmake and cmake3. (pytorch#12916)
Browse files Browse the repository at this point in the history
Summary:
On my devgpu, `cmake` is newer than `cmake3`. Using `cmake3` causes compilation to fail. Instead of blindly using `cmake3`, we pick the newer of the two.
Pull Request resolved: pytorch#12916

Differential Revision: D10481922

Pulled By: SsnL

fbshipit-source-id: 8340136c459e25da9f5fc4f420c7e67cadc28aff
  • Loading branch information
ssnl authored and facebook-github-bot committed Oct 22, 2018
1 parent 5e8e199 commit df06fba
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions tools/build_pytorch_libs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,22 @@ if [ -x "$(command -v rsync)" ]; then
fi

# We test the presence of cmake3 (for platforms like CentOS and Ubuntu 14.04)
# and use that if so.
# and use the newer of cmake and cmake3 if so.
CMAKE_COMMAND="cmake"
if [[ -x "$(command -v cmake3)" ]]; then
CMAKE_COMMAND="cmake3"
if [[ -x "$(command -v cmake)" ]]; then
# have both cmake and cmake3, compare versions
CMAKE_VERSION=$(cmake --version | grep 'cmake version' | awk '{print $NF}')
CMAKE3_VERSION=$(cmake3 --version | grep 'cmake version' | awk '{print $NF}')
CMAKE3_IS_NEWER=$($PYTORCH_PYTHON -c "from distutils.version import StrictVersion; print(1 if StrictVersion(\"${CMAKE3_VERSION}\") >= StrictVersion(\"${CMAKE_VERSION}\") else 0)")
else
# don't have cmake
CMAKE3_IS_NEWER=1
fi
if [[ $CMAKE3_IS_NEWER == "1" ]]; then
CMAKE_COMMAND="cmake3"
fi
unset CMAKE_VERSION CMAKE3_VERSION CMAKE3_IS_NEWER
fi

# Options for building only a subset of the libraries
Expand Down

0 comments on commit df06fba

Please sign in to comment.