Strip newline when ingesting version.txt (#36002)

Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/36002

Test Plan: Run cmake and observe there are no warning in stdout nor in `CMakeCache.txt`

Differential Revision: D20872854

Pulled By: malfet

fbshipit-source-id: 8a61b63b3d564e597e7a62dd913c97bc64b183b9
This commit is contained in:
Nikita Shulga 2020-04-06 13:17:57 -07:00 committed by Facebook GitHub Bot
parent 4ef383d5db
commit 59ed0c5fd7

View file

@ -364,6 +364,8 @@ include(cmake/public/utils.cmake)
# ---[ Version numbers for generated libraries
file(READ version.txt TORCH_DEFAULT_VERSION)
# Strip trailing newline
string(REGEX REPLACE "\n$" "" TORCH_DEFAULT_VERSION "${TORCH_DEFAULT_VERSION}")
if("${TORCH_DEFAULT_VERSION} " STREQUAL " ")
message(WARNING "Could not get version from base 'version.txt'")
# If we can't get the version from the version file we should probably