third_party.cmake 3.4 KB
Newer Older
W
willzhang4a58 已提交
1 2 3 4 5 6 7 8
if (NOT WIN32)
  find_package(Threads)
endif()

include(zlib)
include(protobuf)
include(googletest)
include(gflags)
W
willzhang4a58 已提交
9
include(glog)
W
willzhang4a58 已提交
10
include(grpc)
J
Jinhui Yuan 已提交
11
include(libjpeg-turbo)
L
Li Xinqi 已提交
12
include(opencv)
J
Jinhui Yuan 已提交
13
include(eigen)
W
willzhang4a58 已提交
14

W
willzhang4a58 已提交
15
if (BUILD_CUDA)
16
  set(CUDA_SEPARABLE_COMPILATION ON)
W
willzhang4a58 已提交
17 18
  find_package(CUDA REQUIRED)
  add_definitions(-DWITH_CUDA)
W
willzhang4a58 已提交
19 20 21 22 23 24 25
  foreach(cuda_lib_path ${CUDA_LIBRARIES})
    get_filename_component(cuda_lib_name ${cuda_lib_path} NAME)
    if (${cuda_lib_name} STREQUAL libcudart_static.a)
      get_filename_component(cuda_lib_dir ${cuda_lib_path} DIRECTORY)
      break()
    endif()
  endforeach()
L
Li Xinqi 已提交
26
  set(extra_cuda_libs libculibos.a libcublas_static.a libcurand_static.a)
W
willzhang4a58 已提交
27 28 29
  foreach(extra_cuda_lib ${extra_cuda_libs})
    list(APPEND CUDA_LIBRARIES ${cuda_lib_dir}/${extra_cuda_lib})
  endforeach()
W
willzhang4a58 已提交
30 31
  find_package(CuDNN REQUIRED)
endif()
W
willzhang4a58 已提交
32

33
if (NOT WIN32)
W
willzhang4a58 已提交
34
  set(BLA_STATIC ON)
35
  set(BLA_VENDOR "Intel10_64lp_seq")
W
Will Zhang 已提交
36 37 38 39 40
  find_package(BLAS)
  if (NOT BLAS_FOUND)
    set(BLA_VENDOR "All")
    find_package(BLAS)
  endif()
41 42 43 44
else()
  set(MKL_LIB_PATH "C:/Program Files (x86)/IntelSWTools/compilers_and_libraries_2017/windows/mkl/lib/intel64_win")
  set(BLAS_LIBRARIES ${MKL_LIB_PATH}/mkl_core_dll.lib ${MKL_LIB_PATH}/mkl_sequential_dll.lib ${MKL_LIB_PATH}/mkl_intel_lp64_dll.lib)
endif()
W
willzhang4a58 已提交
45
message(STATUS "Found Blas Lib: " ${BLAS_LIBRARIES})
W
willzhang4a58 已提交
46

W
willzhang4a58 已提交
47 48 49 50 51
set(oneflow_third_party_libs
    ${CMAKE_THREAD_LIBS_INIT}
    ${GLOG_STATIC_LIBRARIES}
    ${GFLAGS_STATIC_LIBRARIES}
    ${GOOGLETEST_STATIC_LIBRARIES}
J
Jinhui Yuan 已提交
52
    ${GOOGLEMOCK_STATIC_LIBRARIES}
W
willzhang4a58 已提交
53 54
    ${PROTOBUF_STATIC_LIBRARIES}
    ${GRPC_STATIC_LIBRARIES}
W
willzhang4a58 已提交
55
    ${ZLIB_STATIC_LIBRARIES}
J
jiyuan 已提交
56
    ${farmhash_STATIC_LIBRARIES}
W
willzhang4a58 已提交
57
    ${BLAS_LIBRARIES}
J
Jinhui Yuan 已提交
58
    ${LIBJPEG_STATIC_LIBRARIES}
L
Li Xinqi 已提交
59
    ${OPENCV_STATIC_LIBRARIES}
W
willzhang4a58 已提交
60
)
J
Jinhui Yuan 已提交
61

J
Jinhui Yuan 已提交
62
message(STATUS "oneflow_third_party_libs: " ${oneflow_third_party_libs})
W
willzhang4a58 已提交
63

64 65 66
if(WIN32)
  # static gflags lib requires "PathMatchSpecA" defined in "ShLwApi.Lib"
  list(APPEND oneflow_third_party_libs "ShLwApi.Lib")
67
  list(APPEND oneflow_third_party_libs "Ws2_32.lib")
68 69
endif()

W
willzhang4a58 已提交
70 71 72 73 74 75 76 77 78
set(oneflow_third_party_dependencies
  zlib_copy_headers_to_destination
  zlib_copy_libs_to_destination
  gflags_copy_headers_to_destination
  gflags_copy_libs_to_destination
  glog_copy_headers_to_destination
  glog_copy_libs_to_destination
  googletest_copy_headers_to_destination
  googletest_copy_libs_to_destination
J
Jinhui Yuan 已提交
79 80
  googlemock_copy_headers_to_destination
  googlemock_copy_libs_to_destination
W
willzhang4a58 已提交
81 82 83 84 85
  protobuf_copy_headers_to_destination
  protobuf_copy_libs_to_destination
  protobuf_copy_binary_to_destination
  grpc_copy_headers_to_destination
  grpc_copy_libs_to_destination
L
Li Xinqi 已提交
86 87
  opencv_copy_headers_to_destination
  opencv_copy_libs_to_destination
J
Jinhui Yuan 已提交
88
  eigen
W
willzhang4a58 已提交
89 90 91 92 93 94 95
)

include_directories(
    ${ZLIB_INCLUDE_DIR}
    ${GFLAGS_INCLUDE_DIR}
    ${GLOG_INCLUDE_DIR}
    ${GOOGLETEST_INCLUDE_DIR}
J
Jinhui Yuan 已提交
96
    ${GOOGLEMOCK_INCLUDE_DIR}
W
willzhang4a58 已提交
97 98
    ${PROTOBUF_INCLUDE_DIR}
    ${GRPC_INCLUDE_DIR}
J
Jinhui Yuan 已提交
99
    ${LIBJPEG_INCLUDE_DIR}
L
Li Xinqi 已提交
100
    ${OPENCV_INCLUDE_DIR}
J
Jinhui Yuan 已提交
101
    ${EIGEN_INCLUDE_DIR}
W
willzhang4a58 已提交
102
)
J
Jinhui Yuan 已提交
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121

if (BUILD_CUDA)
  include(cub)
  include(nccl)

  list(APPEND oneflow_third_party_libs ${CUDA_LIBRARIES})
  list(APPEND oneflow_third_party_libs ${CUDNN_LIBRARIES})
  list(APPEND oneflow_third_party_libs ${NCCL_STATIC_LIBRARIES})

  list(APPEND oneflow_third_party_dependencies cub_copy_headers_to_destination)
  list(APPEND oneflow_third_party_dependencies nccl_copy_headers_to_destination)
  list(APPEND oneflow_third_party_dependencies nccl_copy_libs_to_destination)

  include_directories(
    ${CUDNN_INCLUDE_DIRS}
    ${CUB_INCLUDE_DIR}
    ${NCCL_INCLUDE_DIR}
)
endif()