CMakeLists.txt 5.3 KB
Newer Older
J
jinhai 已提交
1 2 3 4 5 6
#-------------------------------------------------------------------------------
# Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved
# Unauthorized copying of this file, via any medium is strictly prohibited.
# Proprietary and confidential.
#-------------------------------------------------------------------------------

Z
zhiru 已提交
7 8
cmake_minimum_required(VERSION 3.14)
message(STATUS "Building using CMake version: ${CMAKE_VERSION}")
J
jinhai 已提交
9

10 11 12 13 14 15 16 17 18 19 20 21 22
MACRO (GET_CURRENT_TIME CURRENT_TIME)
    execute_process(COMMAND "date" +"%Y-%m-%d %H:%M.%S" OUTPUT_VARIABLE ${CURRENT_TIME})
ENDMACRO (GET_CURRENT_TIME)

GET_CURRENT_TIME(BUILD_TIME)
string(REGEX REPLACE "\n" "" BUILD_TIME ${BUILD_TIME})
message(STATUS "Build time = ${BUILD_TIME}")

MACRO (GET_GIT_BRANCH_NAME GIT_BRANCH_NAME)
    execute_process(COMMAND "git" symbolic-ref --short HEAD OUTPUT_VARIABLE ${GIT_BRANCH_NAME})
ENDMACRO (GET_GIT_BRANCH_NAME)

GET_GIT_BRANCH_NAME(GIT_BRANCH_NAME)
G
groot 已提交
23 24 25
if(NOT GIT_BRANCH_NAME STREQUAL "")
    string(REGEX REPLACE "\n" "" GIT_BRANCH_NAME ${GIT_BRANCH_NAME})
endif()
26

G
groot 已提交
27 28
set(MILVUS_VERSION "${GIT_BRANCH_NAME}")
string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]" MILVUS_VERSION "${MILVUS_VERSION}")
29 30 31 32 33 34 35 36

if(CMAKE_BUILD_TYPE STREQUAL "Release")
    set(BUILD_TYPE "release")
else()
    set(BUILD_TYPE "debug")
endif()
message(STATUS "Build type = ${BUILD_TYPE}")

G
groot 已提交
37 38
project(milvus VERSION "${MILVUS_VERSION}")
project(milvus_engine LANGUAGES CUDA CXX)
X
xj.lin 已提交
39

Z
zhiru 已提交
40 41 42 43 44 45 46
# Ensure that a default make is set
if("${MAKE}" STREQUAL "")
    if(NOT MSVC)
        find_program(MAKE make)
    endif()
endif()

G
groot 已提交
47 48 49
set(MILVUS_VERSION_MAJOR "${milvus_VERSION_MAJOR}")
set(MILVUS_VERSION_MINOR "${milvus_VERSION_MINOR}")
set(MILVUS_VERSION_PATCH "${milvus_VERSION_PATCH}")
Z
zhiru 已提交
50

G
groot 已提交
51 52 53
if(MILVUS_VERSION_MAJOR STREQUAL ""
        OR MILVUS_VERSION_MINOR STREQUAL ""
        OR MILVUS_VERSION_PATCH STREQUAL "")
G
groot 已提交
54
    message(WARNING "Failed to determine Milvus version from git branch name")
J
jinhai 已提交
55
    set(MILVUS_VERSION "0.3.1")
Z
zhiru 已提交
56 57
endif()

G
groot 已提交
58
message(STATUS "Build version = ${MILVUS_VERSION}")
G
groot 已提交
59 60
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/version.h.macro ${CMAKE_CURRENT_SOURCE_DIR}/version.h)

G
groot 已提交
61 62 63
message(STATUS "Milvus version: "
        "${MILVUS_VERSION_MAJOR}.${MILVUS_VERSION_MINOR}.${MILVUS_VERSION_PATCH} "
        "(full: '${MILVUS_VERSION}')")
Z
zhiru 已提交
64

G
groot 已提交
65 66
set(MILVUS_SOURCE_DIR ${PROJECT_SOURCE_DIR})
set(MILVUS_BINARY_DIR ${PROJECT_BINARY_DIR})
Z
zhiru 已提交
67

X
xj.lin 已提交
68 69 70 71 72
find_package(CUDA)
set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} -Xcompiler -fPIC -std=c++11 -D_FORCE_INLINES -arch sm_60 --expt-extended-lambda")
set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} -O0 -g")
message("CUDA_TOOLKIT_ROOT_DIR=${CUDA_TOOLKIT_ROOT_DIR}")
message("CUDA_NVCC_FLAGS=${CUDA_NVCC_FLAGS}")
J
jinhai 已提交
73

74
set(GPU_VERSION "ON")
75
add_definitions("-DGPU_VERSION")
X
xj.lin 已提交
76

J
jinhai 已提交
77
set(CMAKE_CXX_STANDARD 14)
Z
zhiru 已提交
78
set(CMAKE_CXX_STANDARD_REQUIRED on)
J
jinhai 已提交
79 80

if(CMAKE_SYSTEM_PROCESSOR MATCHES "(x86)|(X86)|(amd64)|(AMD64)")
G
groot 已提交
81 82
    message("building milvus_engine on x86 architecture")
    set(MILVUS_BUILD_ARCH x86_64)
J
jinhai 已提交
83
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "(ppc)")
G
groot 已提交
84 85
    message("building milvus_engine on ppc architecture")
    set(MILVUS_BUILD_ARCH ppc64le)
J
jinhai 已提交
86 87 88
else()
    message("unknown processor type")
    message("CMAKE_SYSTEM_PROCESSOR=${CMAKE_SYSTEM_PROCESSOR}")
G
groot 已提交
89
    set(MILVUS_BUILD_ARCH unknown)
J
jinhai 已提交
90 91 92
endif()

if(CMAKE_BUILD_TYPE STREQUAL "Release")
Z
zhiru 已提交
93
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -fPIC -DELPP_THREAD_SAFE -fopenmp")
94
     if (CMAKE_LICENSE_CHECK STREQUAL "ON")
G
groot 已提交
95 96 97
         set(ENABLE_LICENSE "ON")
         add_definitions("-DENABLE_LICENSE")
     endif ()
J
jinhai 已提交
98
else()
Z
zhiru 已提交
99
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -g -fPIC -DELPP_THREAD_SAFE -fopenmp")
J
jinhai 已提交
100 101
endif()

Z
zhiru 已提交
102 103 104 105 106 107 108
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")

include(ExternalProject)
include(DefineOptions)
include(BuildUtils)
include(ThirdPartyPackages)

G
groot 已提交
109 110
include_directories(${MILVUS_SOURCE_DIR})
link_directories(${MILVUS_BINARY_DIR})
Z
zhiru 已提交
111 112

## Following should be check
J
jinhai 已提交
113

G
groot 已提交
114 115
set(MILVUS_ENGINE_INCLUDE ${PROJECT_SOURCE_DIR}/include)
set(MILVUS_ENGINE_SRC ${PROJECT_SOURCE_DIR}/src)
J
jinhai 已提交
116 117 118

add_compile_definitions(PROFILER=${PROFILER})

119 120 121 122 123
message("MILVUS_ENABLE_PROFILING = ${MILVUS_ENABLE_PROFILING}")
if (MILVUS_ENABLE_PROFILING STREQUAL "ON")
    ADD_DEFINITIONS(-DMILVUS_ENABLE_PROFILING)
endif()

G
groot 已提交
124 125
include_directories(${MILVUS_ENGINE_INCLUDE})
include_directories(${MILVUS_ENGINE_SRC})
J
jinhai 已提交
126

G
groot 已提交
127
link_directories(${CMAKE_CURRRENT_BINARY_DIR})
J
jinhai 已提交
128

Z
zhiru 已提交
129
add_subdirectory(src)
J
jinhai 已提交
130

Z
zhenxiang.li 已提交
131 132 133 134 135
if (BUILD_COVERAGE STREQUAL "ON")
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
endif()


G
groot 已提交
136
if (BUILD_UNIT_TEST STREQUAL "ON")
J
jinhai 已提交
137
    add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/unittest)
G
groot 已提交
138
endif()
Y
yu yunfeng 已提交
139

G
groot 已提交
140
add_custom_target(Clean-All COMMAND ${CMAKE_BUILD_TOOL} clean)
141

G
groot 已提交
142

G
groot 已提交
143 144
if("${MILVUS_DB_PATH}" STREQUAL "")
    set(MILVUS_DB_PATH "/tmp/milvus")
G
groot 已提交
145
endif()
G
groot 已提交
146 147 148
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/conf/server_config.template ${CMAKE_CURRENT_SOURCE_DIR}/conf/server_config.yaml)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/conf/log_config.template ${CMAKE_CURRENT_SOURCE_DIR}/conf/log_config.conf)

149
#install
150
install(DIRECTORY scripts/
151
        DESTINATION scripts
152
        FILE_PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ
153 154 155
        GROUP_EXECUTE GROUP_READ
        WORLD_EXECUTE WORLD_READ
        FILES_MATCHING PATTERN "*.sh")
156 157
install(FILES
        conf/server_config.yaml
G
groot 已提交
158
        conf/log_config.conf
159 160
        DESTINATION
        conf)
J
jinhai 已提交
161 162 163 164 165 166
install(FILES
        ./Milvus-EULA-cn.md
        ./Milvus-EULA-en.md
        DESTINATION
        license
        )
G
groot 已提交
167 168


Z
zhiru 已提交
169
config_summary()