CMakeLists.txt 5.9 KB
Newer Older
G
guru4elephant 已提交
1
# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
W
wangguibao 已提交
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License

cmake_minimum_required(VERSION 3.0)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
set(PADDLE_SERVING_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(PADDLE_SERVING_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
19
SET(PADDLE_SERVING_INSTALL_DIR ${CMAKE_BINARY_DIR}/output)
X
xulongteng 已提交
20
SET(CMAKE_INSTALL_RPATH "\$ORIGIN" "${CMAKE_INSTALL_RPATH}")
W
wangguibao 已提交
21 22 23 24 25 26
include(system)
project(paddle-serving CXX C)
message(STATUS "CXX compiler: ${CMAKE_CXX_COMPILER}, version: "
        "${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}")
message(STATUS "C compiler: ${CMAKE_C_COMPILER}, version: "
        "${CMAKE_C_COMPILER_ID} ${CMAKE_C_COMPILER_VERSION}")
H
HexToString 已提交
27

W
wangguibao 已提交
28 29
find_package(Git REQUIRED)
find_package(Threads REQUIRED)
W
wangguibao 已提交
30
find_package(CUDA QUIET)
W
wangguibao 已提交
31 32

include(simd)
T
ud cm  
Thomas Young 已提交
33
# SET(CMAKE_BUILD_TYPE "Debug")
W
wangguibao 已提交
34 35 36 37 38 39
# CMAKE_BUILD_TYPE
if(NOT CMAKE_BUILD_TYPE)
    set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING
      "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel"
      FORCE)
endif()
H
HexToString 已提交
40 41
SET(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -O0 -Wall -g2 -ggdb")
SET(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O3 -Wall")
W
wangguibao 已提交
42 43 44 45 46 47

set(THIRD_PARTY_PATH "${CMAKE_BINARY_DIR}/third_party" CACHE STRING
  "A path setting third party libraries download & build directories.")

set(THIRD_PARTY_BUILD_TYPE Release)

H
HexToString 已提交
48 49 50 51 52 53
option(WITH_AVX	            "Compile Paddle Serving with AVX intrinsics"        OFF)
option(WITH_MKL	            "Compile Paddle Serving with MKL support."          OFF)
option(WITH_GPU	            "Compile Paddle Serving with NVIDIA GPU"            OFF)
option(WITH_LITE            "Compile Paddle Serving with Paddle Lite Engine"    OFF)
option(WITH_XPU	            "Compile Paddle Serving with Baidu Kunlun"          OFF)
option(WITH_PYTHON          "Compile Paddle Serving with Python"                 ON)
H
HexToString 已提交
54 55 56
option(CLIENT  	            "Compile Paddle Serving Client"		                OFF)
option(SERVER	            "Compile Paddle Serving Server"		                OFF)
option(APP                  "Compile Paddle Serving App package"	            OFF)
H
HexToString 已提交
57 58 59 60
option(WITH_ELASTIC_CTR     "Compile ELASITC-CTR solution"                      OFF)
option(PACK                 "Compile for whl"                                   OFF)
option(WITH_TRT             "Compile Paddle Serving with TRT"                   OFF)
option(PADDLE_ON_INFERENCE  "Compile for encryption"                             ON)
H
HexToString 已提交
61
option(WITH_OPENCV	    "Compile Paddle Serving with OPENCV"                    OFF)
S
ShiningZhang 已提交
62
option(WITH_ROCM	    "Compile Paddle Serving with ROCM"                    OFF)
63
option(WITH_ASCEND_CL       "Compile PaddlePaddle with ASCEND CL"               OFF)
S
ShiningZhang 已提交
64
option(WITH_JETSON       "Compile PaddlePaddle with JETSON"               OFF)
H
HexToString 已提交
65

66 67 68 69 70 71 72
if(NOT DEFINED VERSION_TAG)
  set(VERSION_TAG "0.0.0")
endif()
if (WITH_PYTHON)
  message(STATUS "Compile Version Tag for wheel: ${VERSION_TAG}")
endif()

H
HexToString 已提交
73 74 75 76 77 78 79 80 81 82 83 84
if (WITH_OPENCV)
    SET(OPENCV_DIR "" CACHE PATH "Location of libraries")
    if(NOT DEFINED OPENCV_DIR)
        message(FATAL_ERROR "please set OPENCV_DIR with -DOPENCV_DIR=/path/opencv")
    endif()
    if (WIN32)
    find_package(OpenCV REQUIRED PATHS ${OPENCV_DIR}/build/ NO_DEFAULT_PATH)
    else ()
    find_package(OpenCV REQUIRED PATHS ${OPENCV_DIR}/share/OpenCV NO_DEFAULT_PATH)
    endif ()
    include_directories(${OpenCV_INCLUDE_DIRS})
endif()
W
wangguibao 已提交
85

H
HexToString 已提交
86 87 88 89
if (PADDLE_ON_INFERENCE)
    add_definitions(-DPADDLE_ON_INFERENCE)
    message(STATUS "Use PADDLE_ON_INFERENCE")
endif()
W
wangguibao 已提交
90 91 92 93 94 95 96 97 98 99
set(WITH_MKLML ${WITH_MKL})
if (NOT DEFINED WITH_MKLDNN)
    if (WITH_MKL AND AVX2_FOUND)
        set(WITH_MKLDNN ON)
    else()
        message(STATUS "Do not have AVX2 intrinsics and disabled MKL-DNN")
        set(WITH_MKLDNN OFF)
    endif()
endif()

G
guru4elephant 已提交
100

101
if (SERVER OR CLIENT)
Z
update  
zhangjun 已提交
102 103 104 105 106 107 108 109
    include(external/snappy)
    include(external/leveldb)
    include(external/zlib)
    include(external/boost)
    include(external/protobuf)
    include(external/brpc)
    include(external/gflags)
    include(external/glog)
W
wangjiawei04 已提交
110
    include(external/utf8proc)
Z
update  
zhangjun 已提交
111 112 113 114 115 116
    if (WITH_PYTHON)
        include(external/pybind11)
        include(external/python)
    endif()
    include(generic)
    include(flags)
117
endif()
W
wangguibao 已提交
118

D
dongdaxiang 已提交
119
if (APP)
Z
update  
zhangjun 已提交
120 121 122 123 124 125 126 127
    include(external/zlib)
    include(external/boost)
    include(external/protobuf)
    include(external/gflags)
    include(external/glog)
    include(external/pybind11)
    include(external/python)
    include(generic)
D
dongdaxiang 已提交
128 129
endif()

130
if (SERVER)
Z
zhangjun 已提交
131 132
    include(external/jsoncpp)
    #include(external/rocksdb)
Z
update  
zhangjun 已提交
133 134
    include(external/cudnn)
    include(paddlepaddle)
S
ShiningZhang 已提交
135
    include(external/prometheus)
136
endif()
W
wangguibao 已提交
137

G
guru4elephant 已提交
138
message("paddle serving source dir: " ${PADDLE_SERVING_SOURCE_DIR})
W
wangguibao 已提交
139 140
include_directories(${PADDLE_SERVING_SOURCE_DIR})
include_directories(${PADDLE_SERVING_BINARY_DIR})
W
wangguibao 已提交
141

142
if(SERVER)
G
guru4elephant 已提交
143 144 145 146 147 148 149 150 151 152
    set(EXTERNAL_LIBS
	jsoncpp
	gflags
	rocksdb
	glog
	protobuf
	paddlepaddle
	brpc)
endif()

W
wangguibao 已提交
153
set(EXTERNAL_LIBS
G
guru4elephant 已提交
154 155 156 157
	gflags
	glog
	protobuf
	brpc
W
wangguibao 已提交
158 159
)

160
if(SERVER)
Z
update  
zhangjun 已提交
161 162 163
    if(WITH_MKLML)
        list(APPEND EXTERNAL_LIBS ${MKLML_IOMP_LIB})
    endif()
W
wangguibao 已提交
164

Z
update  
zhangjun 已提交
165 166 167
    if(WITH_MKLDNN)
        list(APPEND EXTERNAL_LIBS ${MKLDNN_LIB})
    endif()
W
wangguibao 已提交
168

169
    list(APPEND EXTERNAL_LIBS paddlepaddle)
S
ShiningZhang 已提交
170 171 172
    if(WITH_ROCM)
        include(hip)
    endif()
S
ShiningZhang 已提交
173 174 175 176 177

    if(WITH_ASCEND_CL)
	    include(external/ascend)
	    list(APPEND EXTERNAL_LIBS ascend ascend_cl)
    endif()
178 179
endif()

Z
zhangjun 已提交
180

G
guru4elephant 已提交
181
add_subdirectory(core)
G
guru4elephant 已提交
182

183
if(SERVER)
Z
update  
zhangjun 已提交
184
    add_subdirectory(paddle_inference)
G
guru4elephant 已提交
185
endif()
G
guru4elephant 已提交
186

Z
zhangjun 已提交
187
if (WITH_PYTHON)
Z
update  
zhangjun 已提交
188
    add_subdirectory(python)
Z
zhangjun 已提交
189
endif()