PatWie / tensorflow-cmake

TensorFlow examples in C, C++, Go and Python without bazel but with cmake and FindTensorFlow.cmake
Apache License 2.0
439 stars 91 forks source link

Turn CMakeList to MakeFile #30

Closed goncamateus closed 5 years ago

goncamateus commented 5 years ago

Hello again @PatWie ! Sorry to bother, but is there any version that you made on MakeFile instead of CMakeList? My program is built on MakeFile's way and I'll integrate the TF C++ lib into it. Just to check with you. Thanks!

PatWie commented 5 years ago

Just cmake here as it is the most generic build-system and building TensorFlow ops, ... need some information (header-files, lib-files, ABI-version, defines) depending on the TF-version itself.

But cmake will create several Makefiles. See

https://github.com/PatWie/tensorflow-cmake/blob/675970503a1cffbc033d900c4d528d2d6ae73ed6/cmake/modules/FindTensorFlow.cmake#L271 for linking. Compiling just needs the header-files. The full linking on my machine is done by

/usr/bin/c++ -fPIC   -march=native -fopenmp  -D_GLIBCXX_USE_CXX11_ABI=1  \
      -shared -Wl,-soname,matrix_add_op.so -o matrix_add_op.so CMakeFiles/matrix_add_op.dir/kernels/matrix_add_op.cc.o \
      CMakeFiles/matrix_add_op.dir/kernels/matrix_add_kernel.cc.o CMakeFiles/matrix_add_op.dir/ops/matrix_add.cc.o \
      -Wl,-rpath,$HOME/git/github.com/patwie/tensorflow-cmake/custom_op/user_ops:$HOME/.local/lib/python3.6/site-packages/tensorflow matrix_add_op_cu.so \
      $HOME/.local/lib/python3.6/site-packages/tensorflow/libtensorflow_framework.so \
      /opt/cuda/toolkit_10.0/cuda/lib64/libcudart_static.a -lpthread -ldl -lrt