Skip to content

Commit add6f6b

Browse files
committed
Move cpp install into cmake file
1 parent fd7b49b commit add6f6b

File tree

4 files changed

+17
-14
lines changed

4 files changed

+17
-14
lines changed

cpp/CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,5 @@ add_subdirectory(src/examples)
7171
add_subdirectory(test)
7272

7373
FILE(COPY src/resources/logging.yaml DESTINATION "${CMAKE_INSTALL_PREFIX}/resources")
74+
75+
install(SCRIPT "install.cmake")

cpp/build.sh

-13
Original file line numberDiff line numberDiff line change
@@ -95,18 +95,6 @@ function build() {
9595
fi
9696
}
9797

98-
function install_torchserve_cpp() {
99-
TARGET_DIR=`python -c "import ts; from pathlib import Path; print(Path(ts.__file__).parent / 'cpp')"`
100-
101-
if [ -d $TARGET_DIR ]; then
102-
rm -rf $TARGET_DIR
103-
fi
104-
mkdir $TARGET_DIR
105-
cp -rp $BASE_DIR/_build/bin $TARGET_DIR/bin
106-
cp -rp $BASE_DIR/_build/libs $TARGET_DIR/lib
107-
cp -rp $BASE_DIR/_build/resources $TARGET_DIR/resources
108-
}
109-
11098
# Parse args
11199
JOBS=8
112100
WITH_QUIC=false
@@ -168,4 +156,3 @@ cd $BASE_DIR
168156
git submodule update --init --recursive
169157

170158
build
171-
install_torchserve_cpp

cpp/install.cmake

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
execute_process(COMMAND python -c "import ts; from pathlib import Path; print(Path(ts.__file__).parent / 'cpp')"
2+
OUTPUT_VARIABLE TARGET_DIR
3+
OUTPUT_STRIP_TRAILING_WHITESPACE)
4+
5+
message("Installing cpp backend into ${TARGET_DIR}")
6+
7+
if(EXISTS ${TARGET_DIR})
8+
execute_process(COMMAND rm -rf ${TARGET_DIR})
9+
endif()
10+
11+
execute_process(COMMAND mkdir ${TARGET_DIR})
12+
execute_process(COMMAND cp -rp ${CMAKE_BINARY_DIR}/bin ${TARGET_DIR}/bin)
13+
execute_process(COMMAND cp -rp ${CMAKE_BINARY_DIR}/libs ${TARGET_DIR}/lib)
14+
execute_process(COMMAND cp -rp ${CMAKE_BINARY_DIR}/resources ${TARGET_DIR}/resources)

examples/cpp/babyllama/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ FetchContent_Declare(
1616

1717
FetchContent_MakeAvailable(tokenizer_bin stories15M_bin)
1818

19-
add_library(llama2_c STATIC ../../../cpp/third-party/llama2.c/run.c)
19+
add_library(llama2_c STATIC ${CMAKE_CURRENT_SOURCE_DIR}/../../../cpp/third-party/llama2.c/run.c)
2020
target_compile_options(llama2_c PRIVATE -Wall -Wextra -Ofast -fPIC)
2121

2222
add_library(babyllama_handler SHARED src/baby_llama_handler.cc)

0 commit comments

Comments
 (0)