third_party.cmake 2.7 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(eigen)
W
willzhang4a58 已提交
12 13 14
if (BUILD_CUDA)
  include(cub)
endif()
W
willzhang4a58 已提交
15

W
willzhang4a58 已提交
16
if (BUILD_CUDA)
17
  set(CUDA_SEPARABLE_COMPILATION ON)
W
willzhang4a58 已提交
18 19
  find_package(CUDA REQUIRED)
  add_definitions(-DWITH_CUDA)
W
willzhang4a58 已提交
20 21 22 23 24 25 26 27 28 29 30
  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()
  set(extra_cuda_libs libculibos.a libcublas_static.a)
  foreach(extra_cuda_lib ${extra_cuda_libs})
    list(APPEND CUDA_LIBRARIES ${cuda_lib_dir}/${extra_cuda_lib})
  endforeach()
W
willzhang4a58 已提交
31 32
  find_package(CuDNN REQUIRED)
endif()
W
willzhang4a58 已提交
33

34
if (NOT WIN32)
W
willzhang4a58 已提交
35
  set(BLA_STATIC ON)
36
  set(BLA_VENDOR "Intel10_64lp_seq")
W
Will Zhang 已提交
37 38 39 40 41
  find_package(BLAS)
  if (NOT BLAS_FOUND)
    set(BLA_VENDOR "All")
    find_package(BLAS)
  endif()
42 43 44 45
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 已提交
46
message(STATUS "Found Blas Lib: " ${BLAS_LIBRARIES})
W
willzhang4a58 已提交
47

W
willzhang4a58 已提交
48 49 50 51 52
set(oneflow_third_party_libs
    ${CMAKE_THREAD_LIBS_INIT}
    ${GLOG_STATIC_LIBRARIES}
    ${GFLAGS_STATIC_LIBRARIES}
    ${GOOGLETEST_STATIC_LIBRARIES}
J
Jinhui Yuan 已提交
53
    ${GOOGLEMOCK_STATIC_LIBRARIES}
W
willzhang4a58 已提交
54 55
    ${PROTOBUF_STATIC_LIBRARIES}
    ${GRPC_STATIC_LIBRARIES}
W
willzhang4a58 已提交
56
    ${ZLIB_STATIC_LIBRARIES}
J
jiyuan 已提交
57
    ${farmhash_STATIC_LIBRARIES}
W
willzhang4a58 已提交
58
    ${CUDNN_LIBRARIES}
W
willzhang4a58 已提交
59
    ${CUDA_LIBRARIES}
W
willzhang4a58 已提交
60
    ${BLAS_LIBRARIES}
W
willzhang4a58 已提交
61
    ${CMAKE_DL_LIBS}
W
willzhang4a58 已提交
62 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
J
Jinhui Yuan 已提交
86
  cub_copy_headers_to_destination
J
Jinhui Yuan 已提交
87
  eigen
W
willzhang4a58 已提交
88 89 90 91 92 93 94
)

include_directories(
    ${ZLIB_INCLUDE_DIR}
    ${GFLAGS_INCLUDE_DIR}
    ${GLOG_INCLUDE_DIR}
    ${GOOGLETEST_INCLUDE_DIR}
J
Jinhui Yuan 已提交
95
    ${GOOGLEMOCK_INCLUDE_DIR}
W
willzhang4a58 已提交
96 97
    ${PROTOBUF_INCLUDE_DIR}
    ${GRPC_INCLUDE_DIR}
W
willzhang4a58 已提交
98
    ${CUDNN_INCLUDE_DIRS}
C
chengtbf 已提交
99
    ${CUB_INCLUDE_DIR}
J
Jinhui Yuan 已提交
100
    ${EIGEN_INCLUDE_DIR}
W
willzhang4a58 已提交
101
)