Detect system RocksDB installation with CMake config files. (#7315)

Summary:
On Windows, the FindRocksDB script doesn't detect rocksdb installation built by cmake.
And it doesn't include/link the RocksDB dependencies either, like:
  * `Snappy`
  * `Shlwapi.lib`
  * `Rpcrt4.lib`

This PR try to detect in config mode first before using private find module.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/7315

Differential Revision: D9287587

Pulled By: Yangqing

fbshipit-source-id: 314a36a14bfe04aa45013349c5537163fb4c5c00
This commit is contained in:
Tongliang Liao
2018-08-12 18:14:49 -07:00
committed by Facebook Github Bot
parent 82d11b847e
commit 3cbe8f0c3e

View File

@ -37,12 +37,18 @@ endif()
# cmake. Note that for modules that are located in the Caffe2 repository,
# cmake related files, such as FindRocksDB in this case, should live in the
# cmake/ folder under root.
find_package(RocksDB)
if(NOT ROCKSDB_FOUND)
message(
FATAL_ERROR
"RocksDB not found. If you do not need caffe2_rocksdb, set "
"-DUSE_ROCKSDB=OFF to solve this error.")
find_package(RocksDB CONFIG)
if((DEFINED RocksDB_DIR) AND RocksDB_DIR)
list(APPEND RocksDB_LIBRARIES RocksDB::rocksdb)
else()
message("RocksDB config not found. Fallback to legacy find.")
find_package(RocksDB)
if(NOT ROCKSDB_FOUND)
message(
FATAL_ERROR
"RocksDB not found. If you do not need caffe2_rocksdb, set "
"-DUSE_ROCKSDB=OFF to solve this error.")
endif()
endif()
# ---[ Third, create the CMake target.