CMakeLists.txt 3.3 KB
Newer Older
Y
Yan Chunwei 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14
# Copyright (c) 2017 VisualDL Authors. All Rights Reserve.
#
# 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

S
up  
superjom 已提交
15
cmake_minimum_required(VERSION 3.2)
S
superjom 已提交
16 17
project(VisualDL)

S
superjom 已提交
18 19 20 21 22 23
find_program(CCACHE_FOUND ccache)
if(CCACHE_FOUND)
  set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
  set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
endif(CCACHE_FOUND)

Q
Qiao Longfei 已提交
24
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
S
superjom 已提交
25
set(CMAKE_CXX_STANDARD 11)
S
superjom 已提交
26
set(CMAKE_CXX_FLAGS "-fPIC")
27
set(VISUALDL_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
S
superjom 已提交
28

Q
Qiao Longfei 已提交
29 30 31 32
set(THIRD_PARTY_PATH "${CMAKE_BINARY_DIR}/third_party" CACHE STRING
        "A path setting third party libraries download & build directories.")

################################ Configurations #######################################
33
option(WITH_DOC         "Compile VisualDL with documentation"       OFF)
Q
Qiao Longfei 已提交
34
option(WITH_TESTING     "Compile VisualDL with unit testing"        ON)
O
Oraoto 已提交
35
option(WITH_PYTHON3     "Compile VisualDL with Python 3"            OFF)
Y
Yan Chunwei 已提交
36
option(ON_RELEASE       "RELEASE mode" ON)
S
superjom 已提交
37

S
superjom 已提交
38

Q
Qiao Longfei 已提交
39
include(external/zlib)      # download, build, install zlib
Q
Qiao Longfei 已提交
40 41 42 43
if (NOT ON_RELEASE)
  include(external/gflags)    # download, build, install gflags
  include(external/glog)      # download, build, install glog
endif(NOT ON_RELEASE)
Q
Qiao Longfei 已提交
44
include(external/gtest)     # download, build, install gtest
45
include(external/eigen)     # download eigen
Q
Qiao Longfei 已提交
46 47 48 49
include(external/pybind11)  # download pybind11
include(external/protobuf)  # download, build, install protobuf
include(external/python)    # find python and set path

Y
Yan Chunwei 已提交
50 51 52

if (NOT ON_RELEASE)
  message(STATUS "build on debug mode")
Q
Qiao Longfei 已提交
53
  add_definitions(-DVISUALDL_WITH_GLOG)
Y
Yan Chunwei 已提交
54 55
endif(NOT ON_RELEASE)

56 57 58 59 60
if (MSVC)
  add_definitions(-DPROTOBUF_USE_DLLS)
  add_definitions(-DNOMINMAX) # No min/max macros
endif(MSVC)

Q
Qiao Longfei 已提交
61 62
include_directories(${PROJECT_SOURCE_DIR})
include_directories(${CMAKE_CURRENT_BINARY_DIR})
S
superjom 已提交
63

S
superjom 已提交
64
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/visualdl/storage)
S
superjom 已提交
65
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/visualdl/logic)
S
Superjom 已提交
66
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/visualdl/python)
S
superjom 已提交
67

68
# compile test only in release mode
Y
Yan Chunwei 已提交
69
if (NOT ON_RELEASE)
S
superjom 已提交
70
add_executable(vl_test
S
superjom 已提交
71
        ${PROJECT_SOURCE_DIR}/visualdl/test.cc
S
superjom 已提交
72
        ${PROJECT_SOURCE_DIR}/visualdl/logic/sdk_test.cc
73
        ${PROJECT_SOURCE_DIR}/visualdl/logic/histogram_test.cc
74
        ${PROJECT_SOURCE_DIR}/visualdl/storage/storage_test.cc
75
        ${PROJECT_SOURCE_DIR}/visualdl/storage/test_binary_record.cc
S
superjom 已提交
76
        ${PROJECT_SOURCE_DIR}/visualdl/utils/test_concurrency.cc
77
        ${PROJECT_SOURCE_DIR}/visualdl/utils/test_image.cc
S
superjom 已提交
78 79
        ${PROJECT_SOURCE_DIR}/visualdl/utils/concurrency.h
        ${PROJECT_SOURCE_DIR}/visualdl/utils/filesystem.h
S
superjom 已提交
80
        )
T
Thuan Nguyen 已提交
81
target_link_libraries(vl_test sdk storage binary_record entry tablet im gtest glog protobuf gflags pthread eigen3)
S
superjom 已提交
82
enable_testing ()
S
Superjom 已提交
83
add_test(NAME vstest COMMAND ./vl_test)
Y
Yan Chunwei 已提交
84
endif(NOT ON_RELEASE)
85 86 87 88

if(WITH_DOC)
    add_subdirectory(docs)
endif()