mirror of
https://github.com/saymrwulf/pytorch.git
synced 2026-05-14 20:57:59 +00:00
directly add_subdirectory(nanopb) from torch CMakeLists (#8870)
currently torch/CMakeLists doesn't know how to find nanopb without some higher-level script (setup.py or build_all.sh) telling it where to look, which is an obstacle towards fully CMake-ifying libtorch.so. This change removes that dependency.
This commit is contained in:
parent
47492ed451
commit
8ef5d37ac5
4 changed files with 5 additions and 29 deletions
|
|
@ -3,5 +3,4 @@
|
|||
set -ex
|
||||
SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
|
||||
source $SCRIPTPATH/build_caffe2.sh
|
||||
source $SCRIPTPATH/build_nanopb.sh
|
||||
source $SCRIPTPATH/build_libtorch.sh
|
||||
|
|
|
|||
|
|
@ -22,6 +22,8 @@ cmake -DUSE_CUDA:BOOL=$USE_CUDA \
|
|||
-DCMAKE_BUILD_TYPE:STRING=$BUILD_TYPE \
|
||||
-DCMAKE_INSTALL_PREFIX:STRING=$INSTALL_PREFIX \
|
||||
-DCMAKE_INSTALL_MESSAGE=NEVER \
|
||||
-Dnanopb_BUILD_GENERATOR:BOOL=OFF \
|
||||
-DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON \
|
||||
-DVERBOSE:BOOL=${VERBOSE:-0} \
|
||||
-G "$GENERATE" \
|
||||
$PYTORCHPATH/torch
|
||||
|
|
|
|||
|
|
@ -1,25 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -ex
|
||||
|
||||
SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
|
||||
|
||||
pushd $SCRIPTPATH
|
||||
source ./build_common.sh
|
||||
|
||||
echo "Building nanopb"
|
||||
|
||||
mkdir -p $NANOPB_BUILDPATH
|
||||
pushd $NANOPB_BUILDPATH
|
||||
|
||||
cmake -DCMAKE_BUILD_TYPE:STRING=Release \
|
||||
-DCMAKE_INSTALL_PREFIX:STRING=$INSTALL_PREFIX \
|
||||
-DCMAKE_INSTALL_MESSAGE=NEVER \
|
||||
-Dnanopb_BUILD_GENERATOR:BOOL=OFF \
|
||||
-DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON \
|
||||
-G "$GENERATE" \
|
||||
$PYTORCHPATH/third_party/nanopb
|
||||
$MAKE -j "$JOBS"
|
||||
|
||||
popd
|
||||
popd
|
||||
|
|
@ -37,8 +37,8 @@ find_library(CAFFE2_GPU_LIBRARY caffe2_gpu
|
|||
find_library(PROTOBUF_LIBRARY protobuf
|
||||
NAMES libprotobuf.a libprotobufd.a libprotobuf.lib libprotobufd.lib
|
||||
PATHS ${CAFFE2_BUILD_LIB_DIR} NO_DEFAULT_PATH)
|
||||
find_library(NANOPB_LIBRARY protobuf-nanopb
|
||||
PATHS ${NANOPB_BUILD_PATH} NO_DEFAULT_PATH)
|
||||
|
||||
add_subdirectory(../third_party/nanopb protobuf-nanopb)
|
||||
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
||||
|
|
@ -291,7 +291,7 @@ target_link_libraries(torch
|
|||
${TORCH_CUDA_LIBRARIES}
|
||||
${CAFFE2_LIBRARY}
|
||||
${PROTOBUF_LIBRARY}
|
||||
${NANOPB_LIBRARY}
|
||||
protobuf-nanopb
|
||||
)
|
||||
if(USE_CUDA)
|
||||
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
|
||||
|
|
|
|||
Loading…
Reference in a new issue