forked from modelbox-ai/modelbox-book
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
49 lines (40 loc) · 1.71 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved.
cmake_minimum_required(VERSION 2.8.1)
project(modelbox-book)
find_program(NPM npm)
if(NOT NPM)
message("Skip build modelbox-book")
return()
endif()
set(NODE_MODULES_PATH ${CMAKE_CURRENT_BINARY_DIR})
set(GITBOOK ${NODE_MODULES_PATH}/node_modules/.bin/gitbook)
if (NOT BOOK_OUTPUT_DIR)
set(BOOK_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/help)
endif()
if (NOT BOOK_INSTALL_DIR)
set(BOOK_INSTALL_DIR "/usr/local/share/modelbox/www")
endif()
set(BOOK_INSTALL_FLAG ${CMAKE_CURRENT_BINARY_DIR}/bookinstalled)
add_custom_target(modelbox-book ALL)
add_custom_command(TARGET modelbox-book
COMMENT "Building modelbox book package.."
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
COMMAND mkdir -p ${NODE_MODULES_PATH}/node_modules
COMMAND rm -f ${CMAKE_CURRENT_LIST_DIR}/node_modules
COMMAND ln -s ${NODE_MODULES_PATH}/node_modules ${CMAKE_CURRENT_LIST_DIR}/node_modules
COMMAND [ -e ${BOOK_INSTALL_FLAG} ] || ${NPM} install gitbook-cli
# patch graceful-fs
COMMAND [ -e ${BOOK_INSTALL_FLAG} ] || sed -i "'/stat = statFix/d'" ${NODE_MODULES_PATH}/node_modules/npm/node_modules/graceful-fs/polyfills.js
COMMAND [ -e ${BOOK_INSTALL_FLAG} ] || ${GITBOOK} install ${CMAKE_CURRENT_LIST_DIR}
COMMAND touch ${BOOK_INSTALL_FLAG}
COMMAND ${GITBOOK} build ${CMAKE_CURRENT_LIST_DIR} ${BOOK_OUTPUT_DIR}
COMMAND rm -f ${BOOK_OUTPUT_DIR}/assets/*.vsdx
COMMAND rm -f ${CMAKE_CURRENT_LIST_DIR}/package-lock.json
COMMAND rm -f ${CMAKE_CURRENT_LIST_DIR}/node_modules
BYPRODUCTS ${BOOK_INSTALL_FLAG} ${BOOK_OUTPUT_DIR}
)
install(DIRECTORY
${BOOK_OUTPUT_DIR}
DESTINATION ${BOOK_INSTALL_DIR}
COMPONENT document
)