-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
68 lines (53 loc) · 2.21 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
cmake_minimum_required(VERSION 3.10)
project (zmq_dataset)
# set(CMAKE_CXX_STANDARD 11)
# set(CMAKE_CXX_STANDARD_REQUIRED True)
# add_definitions(-D_GLIBCXX_USE_CXX11_ABI=0 -DNDEBUG)
set(CMAKE_SHARED_LIBRARY_SUFFIX ".so")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/zmq_ops)
if(NOT DEFINED ENV{CONDA_ENV_PATH})
message(FATAL_ERROR "ENV CONDA_ENV_PATH not set")
else()
message(STATUS "env CONDA_ENV_PATH: $ENV{CONDA_ENV_PATH}")
endif()
set(python_bin_path $ENV{CONDA_ENV_PATH}/bin/python)
execute_process(COMMAND ${python_bin_path} -c "import tensorflow as tf; print(tf.sysconfig.get_include())"
RESULT_VARIABLE result
OUTPUT_VARIABLE tf_inc
)
if(NOT ${result} EQUAL 0)
message(FATAL_ERROR "failed to get tensorflow include ${result}")
else()
string(STRIP ${tf_inc} tf_inc)
message(STATUS "tensorflow include path: ${tf_inc}")
endif()
execute_process(COMMAND ${python_bin_path} -c "import tensorflow as tf; print(' '.join(tf.sysconfig.get_link_flags()), end='')"
RESULT_VARIABLE result
OUTPUT_VARIABLE tf_lib
)
if(NOT ${result} EQUAL 0)
message(FATAL_ERROR "failed to get tensorflow library ${result}")
else()
string(STRIP ${tf_lib} tf_lib)
message(STATUS "tensorflow library path: ${tf_lib}")
endif()
execute_process(COMMAND ${python_bin_path} -c "import tensorflow as tf; print(' '.join(tf.sysconfig.get_compile_flags()), end='')"
RESULT_VARIABLE result
OUTPUT_VARIABLE tf_flag
)
if(NOT ${result} EQUAL 0)
message(FATAL_ERROR "failed to get tensorflow compile flags ${result}")
else()
string(STRIP ${tf_flag} tf_flag)
message(STATUS "tensorflow compile flags: ${tf_flag}")
endif()
# C++11 required for tensorflow
set(CMAKE_CXX_FLAGS "-std=c++11 ${tf_flag} ${CMAKE_CXX_FLAGS}")
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-as-needed ${tf_lib} ${CMAKE_SHARED_LINKER_FLAGS}")
set(conda_inc $ENV{CONDA_ENV_PATH}/include)
message(STATUS "conda include path: ${conda_inc}")
set(conda_lib $ENV{CONDA_ENV_PATH}/lib)
message(STATUS "conda library path: ${conda_lib}")
set(protoc_bin_path $ENV{CONDA_ENV_PATH}/bin/protoc)
add_subdirectory(proto)
add_subdirectory(src)