CMakeLists.txt 3.7 KB
Newer Older
朔-望's avatar
朔-望 已提交
1 2
cmake_minimum_required(VERSION 3.0)
project(paddle-mobile)
W
wangliu 已提交
3

W
wangliu 已提交
4
option(DEBUGING "enable debug mode" OFF)
W
wangliu 已提交
5
option(USE_OPENMP "openmp support" OFF)
W
wangliu 已提交
6
option(USE_EXCEPTION "use std exception" OFF)
W
wangliu 已提交
7 8

if (DEBUGING)
L
liuruilong 已提交
9
    set(CMAKE_BUILD_TYPE Debug)
W
wangliu 已提交
10
else()
L
liuruilong 已提交
11
    set(CMAKE_BUILD_TYPE Release)
W
wangliu 已提交
12 13
endif ()

L
liuruilong 已提交
14 15 16
if(DEBUGING)
    message(STATUS "debuging")
    add_definitions(-DPADDLE_MOBILE_DEBUG)
W
wangliu 已提交
17 18 19 20
    if(ANDROID)
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -llog")
    endif()

W
wangliu 已提交
21
else()
L
liuruilong 已提交
22 23
    message(STATUS "releasing")
    add_definitions(-fvisibility=hidden -fvisibility-inlines-hidden)
W
wangliu 已提交
24
endif()
朔-望's avatar
朔-望 已提交
25

W
wangliu 已提交
26 27 28 29 30 31 32
if (USE_EXCEPTION)
    add_definitions(-DENABLE_EXCEPTION)
    add_definitions(-fexceptions)
else()
    add_definitions(-fno-exceptions)
endif ()

33 34 35 36 37 38 39 40
if(IS_MAC)
    add_definitions(-DX86)
elseif(IS_IOS)
    add_definitions(-DIOS)
elseif(V7)
    add_definitions(-DARMV7)
elseif(V8)
    add_definitions(-DARMV8)
41 42 43
else ()
    add_definitions(-DX86)
endif()
Z
zhaojiaying01 已提交
44

45
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
朔-望's avatar
朔-望 已提交
46 47
set(CMAKE_VERBOSE_MAKEFILE ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
朔-望's avatar
朔-望 已提交
48 49 50 51
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY build)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY build)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY build)

L
liuruilong 已提交
52
file(GLOB_RECURSE PADDLE_MOBILE_CC src/*.cc src/*.cpp src/*.c)
朔-望's avatar
朔-望 已提交
53 54
file(GLOB_RECURSE PADDLE_MOBILE_H src/*.h)

W
wangliu 已提交
55 56 57 58 59 60
if (NOT ANDROID)
list(REMOVE_ITEM PADDLE_MOBILE_CC ${CMAKE_CURRENT_SOURCE_DIR}/src/jni/*.cpp)
list(REMOVE_ITEM PADDLE_MOBILE_CC ${CMAKE_CURRENT_SOURCE_DIR}/src/jni/*.h)
list(REMOVE_ITEM PADDLE_MOBILE_CC ${CMAKE_CURRENT_SOURCE_DIR}/src/operators/math/math_func_neon.h)
endif ()

朔-望's avatar
朔-望 已提交
61 62
include_directories(src/)

H
Haipeng Wang 已提交
63 64
if(USE_OPENMP)
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")
H
Haipeng Wang 已提交
65 66 67
    add_definitions(-DPADDLE_MOBILE_USE_OPENMP)
endif()

L
liuruilong 已提交
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
if (googlenet)
    add_definitions(-DCONCAT_OP)
    add_definitions(-DCONV_OP)
    add_definitions(-DLRN_OP)
    add_definitions(-DMUL_OP)
    add_definitions(-DELEMENTWISEADD_OP)
    add_definitions(-DFUSION_FC_OP)
    add_definitions(-DPOOL_OP)
    add_definitions(-DRELU_OP)
elseif (mobilenet)
    add_definitions(-DCONV_OP)
    add_definitions(-DELEMENTWISEADD_OP)
    add_definitions(-DRELU_OP)
    add_definitions(-DSOFTMAX_OP)
    add_definitions(-DSOFTMAX_OP)
    add_definitions(-DDEPTHWISECONV_OP)
    add_definitions(-DBATCHNORM_OP)
    add_definitions(-DPOOL_OP)
    add_definitions(-DRESHAPE_OP)
elseif (yolo)
    add_definitions(-DBATCHNORM_OP)
    add_definitions(-DCONV_OP)
    add_definitions(-DRELU_OP)
    add_definitions(-DELEMENTWISEADD_OP)
elseif (squeezenet)
    add_definitions(-DCONCAT_OP)
    add_definitions(-DCONV_OP)
    add_definitions(-DRELU_OP)
    add_definitions(-DELEMENTWISEADD_OP)
    add_definitions(-DPOOL_OP)
    add_definitions(-DRESHAPE_OP)
    add_definitions(-DSOFTMAX_OP)
elseif(resnet)
    add_definitions(-DCONV_OP)
    add_definitions(-DBATCHNORM_OP)
    add_definitions(-DELEMENTWISEADD_OP)
    add_definitions(-DSOFTMAX_OP)
    add_definitions(-DMUL_OP)
    add_definitions(-DPOOL_OP)
    add_definitions(-DRELU_OP)
else ()
    add_definitions(-DBATCHNORM_OP)
    add_definitions(-DBOXCODER_OP)
    add_definitions(-DCONCAT_OP)
    add_definitions(-DCONV_OP)
    add_definitions(-DDEPTHWISECONV_OP)
    add_definitions(-DELEMENTWISEADD_OP)
    add_definitions(-DFUSIONCONVADD_OP)
    add_definitions(-DCONVADDRELU_OP)
    add_definitions(-DFUSION_FC_OP)
    add_definitions(-DLRN_OP)
    add_definitions(-DMUL_OP)
    add_definitions(-DMULTICLASSNMS_OP)
    add_definitions(-DPOOL_OP)
    add_definitions(-DPRIORBOX_OP)
    add_definitions(-DRELU_OP)
    add_definitions(-DRESHAPE_OP)
    add_definitions(-DSIGMOID_OP)
    add_definitions(-DSOFTMAX_OP)
    add_definitions(-DTRANSPOSE_OP)
H
Haipeng Wang 已提交
128 129
endif()

W
wangliu 已提交
130

Y
Yi Wang 已提交
131
add_library(paddle-mobile SHARED ${PADDLE_MOBILE_CC} ${PADDLE_MOBILE_H})
朔-望's avatar
朔-望 已提交
132

W
wangliu 已提交
133
if(DEBUGING)
L
liuruilong 已提交
134
    add_subdirectory(test)
W
wangliu 已提交
135
endif()
W
wangliu 已提交
136 137