mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 12:54:11 +08:00
Summary: I successfully built caffe2 using MSVC 2015 and the Ninja Generator. I use vcpkg to build glfags, glog, lmdb and protobuf. Here is my build procedure: 1. Install vcpkg and set it up according to vcpkg docs 2. Install dependencies ``` $> vcpkg install gflags glog lmdb protobuf eigen3 --triplet x64-windows-static ``` 3. Run CMake with this batch file ```Batch setlocal if NOT DEFINED VCPKG_DIR ( echo "Please defined VCPKG_DIR" && exit /b 1 ) if NOT DEFINED CMAKE_BUILD_TYPE set CMAKE_BUILD_TYPE=Release if NOT DEFINED BUILD_DIR set BUILD_DIR=build_%CMAKE_BUILD_TYPE% if NOT DEFINED USE_CUDA set USE_CUDA=OFF call "%VS140COMNTOOLS%\..\..\VC\vcvarsall.bat" amd64 if NOT EXIST %BUILD_DIR% (mkdir %BUILD_DIR%) pushd %BUILD_DIR% set CMAKE_GENERATOR=Ninja set ZLIB_LIBRARY=%VCPKG_DIR%\installed\x64-windows-static\lib\zlib.lib cmake -G"%CMAKE_GENERATOR%" ^ -DBUILD_SHARED_LIBS=OFF ^ -DCMAKE_VERBOSE_MAKEFILE=1 ^ -DBUILD_TEST=OFF ^ -DBUILD_SHARED_LIBS=OFF ^ -DCMAKE_BUILD_TYPE=%CMAKE_BUILD_TYPE% ^ -DUSE_CUDA=%USE_CUDA% ^ -DZLIB_LIBRARY:FILEPATH="%ZLIB_LIBRARY%" ^ -DVCPKG_TARGET_TRIPLET=x64-windows-static ^ -DVCPKG_APPLOCAL_DEPS:BOOL=OFF ^ -DCMAKE_TOOLCHAIN_FILE:FILEPATH=%VCPKG_DIR%\scripts\buildsystems\vcpkg.cmake ^ -DPROTOBUF_PROTOC_EXECUTABLE:FILEPATH=%VCPKG_DIR%\installed\x64-windows-static\tools\protoc.exe ^ ..\ ninja popd endlocal ``` Closes https://github.com/caffe2/caffe2/pull/880 Differential Revision: D5497384 Pulled By: Yangqing fbshipit-source-id: e0d81d3dbd3286ab925eddef0e6fbf99eb6375a5
33 lines
1.2 KiB
CMake
33 lines
1.2 KiB
CMake
# Try to find the LMBD libraries and headers
|
|
# LMDB_FOUND - system has LMDB lib
|
|
# LMDB_INCLUDE_DIR - the LMDB include directory
|
|
# LMDB_LIBRARIES - Libraries needed to use LMDB
|
|
|
|
# FindCWD based on FindGMP by:
|
|
# Copyright (c) 2006, Laurent Montel, <montel@kde.org>
|
|
#
|
|
# Redistribution and use is allowed according to the terms of the BSD license.
|
|
|
|
# Adapted from FindCWD by:
|
|
# Copyright 2013 Conrad Steenberg <conrad.steenberg@gmail.com>
|
|
# Aug 31, 2013
|
|
|
|
if(MSVC)
|
|
find_package(LMDB NO_MODULE)
|
|
else()
|
|
find_path(LMDB_INCLUDE_DIR NAMES lmdb.h PATHS "$ENV{LMDB_DIR}/include")
|
|
find_library(LMDB_LIBRARIES NAMES lmdb PATHS "$ENV{LMDB_DIR}/lib" )
|
|
endif()
|
|
|
|
include(FindPackageHandleStandardArgs)
|
|
find_package_handle_standard_args(LMDB DEFAULT_MSG LMDB_INCLUDE_DIR LMDB_LIBRARIES)
|
|
|
|
if(LMDB_FOUND)
|
|
message(STATUS "Found lmdb (include: ${LMDB_INCLUDE_DIR}, library: ${LMDB_LIBRARIES})")
|
|
mark_as_advanced(LMDB_INCLUDE_DIR LMDB_LIBRARIES)
|
|
|
|
caffe_parse_header(${LMDB_INCLUDE_DIR}/lmdb.h
|
|
LMDB_VERSION_LINES MDB_VERSION_MAJOR MDB_VERSION_MINOR MDB_VERSION_PATCH)
|
|
set(LMDB_VERSION "${MDB_VERSION_MAJOR}.${MDB_VERSION_MINOR}.${MDB_VERSION_PATCH}")
|
|
endif()
|