CMakeLists.txt 2.4 KB
Newer Older
S
up  
superjom 已提交
1
cmake_minimum_required(VERSION 3.2)
S
superjom 已提交
2 3
project(VisualDL)

S
superjom 已提交
4 5 6 7 8 9
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 已提交
10
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
S
superjom 已提交
11
set(CMAKE_CXX_STANDARD 11)
S
superjom 已提交
12
set(CMAKE_CXX_FLAGS "-fPIC")
S
superjom 已提交
13 14


Q
Qiao Longfei 已提交
15 16 17 18 19
set(THIRD_PARTY_PATH "${CMAKE_BINARY_DIR}/third_party" CACHE STRING
        "A path setting third party libraries download & build directories.")

################################ Configurations #######################################
option(WITH_TESTING     "Compile VisualDL with unit testing"        ON)
Y
Yan Chunwei 已提交
20
option(ON_RELEASE       "RELEASE mode" ON)
S
superjom 已提交
21

S
superjom 已提交
22

Q
Qiao Longfei 已提交
23
include(external/zlib)      # download, build, install zlib
Q
Qiao Longfei 已提交
24 25 26 27
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 已提交
28
include(external/gtest)     # download, build, install gtest
29
include(external/eigen)     # download eigen
Q
Qiao Longfei 已提交
30 31 32 33
include(external/pybind11)  # download pybind11
include(external/protobuf)  # download, build, install protobuf
include(external/python)    # find python and set path

Y
Yan Chunwei 已提交
34 35 36

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

Q
Qiao Longfei 已提交
40 41
include_directories(${PROJECT_SOURCE_DIR})
include_directories(${CMAKE_CURRENT_BINARY_DIR})
S
superjom 已提交
42

S
superjom 已提交
43
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/visualdl/storage)
S
superjom 已提交
44
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/visualdl/logic)
S
Superjom 已提交
45
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/visualdl/python)
S
superjom 已提交
46

47
# compile test only in release mode
Y
Yan Chunwei 已提交
48
if (NOT ON_RELEASE)
S
superjom 已提交
49
add_executable(vl_test
S
superjom 已提交
50
        ${PROJECT_SOURCE_DIR}/visualdl/test.cc
S
superjom 已提交
51
        ${PROJECT_SOURCE_DIR}/visualdl/logic/sdk_test.cc
52
        ${PROJECT_SOURCE_DIR}/visualdl/logic/histogram_test.cc
53
        ${PROJECT_SOURCE_DIR}/visualdl/storage/storage_test.cc
54
        ${PROJECT_SOURCE_DIR}/visualdl/storage/test_binary_record.cc
S
superjom 已提交
55
        ${PROJECT_SOURCE_DIR}/visualdl/utils/test_concurrency.cc
56
        ${PROJECT_SOURCE_DIR}/visualdl/utils/test_image.cc
S
superjom 已提交
57 58
        ${PROJECT_SOURCE_DIR}/visualdl/utils/concurrency.h
        ${PROJECT_SOURCE_DIR}/visualdl/utils/filesystem.h
S
superjom 已提交
59
        )
60
target_link_libraries(vl_test sdk storage entry tablet im gtest glog protobuf gflags pthread eigen3)
S
superjom 已提交
61
enable_testing ()
S
Superjom 已提交
62
add_test(NAME vstest COMMAND ./vl_test)
Y
Yan Chunwei 已提交
63
endif(NOT ON_RELEASE)