WIP: Fix cmake errors at ld step.
authorMyungJoo Ham <myungjoo.ham@samsung.com>
Wed, 10 Jul 2019 11:37:36 +0000 (20:37 +0900)
committerMyungJoo Ham <myungjoo.ham@samsung.com>
Wed, 10 Jul 2019 12:05:33 +0000 (21:05 +0900)
Change-Id: Ic1fa92de1cd31d0a06e707042988c277dd69e2df
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
tensorflow/contrib/cmake/CMakeLists.txt
tensorflow/contrib/cmake/external/grpc.cmake
tensorflow/contrib/cmake/external/protobuf.cmake
tensorflow/contrib/cmake/tf_core_distributed_runtime.cmake
tensorflow/contrib/cmake/tf_core_framework.cmake
tensorflow/contrib/cmake/tf_python.cmake
tensorflow/contrib/cmake/tf_shared_lib.cmake
tensorflow/contrib/cmake/tf_tools.cmake

index a6d6e31..3c60f95 100644 (file)
@@ -297,13 +297,13 @@ else (systemlib_ZLIB)
     ${zlib_STATIC_LIBRARIES})
 endif (systemlib_ZLIB)
 
-if (protobuf_PROTOBUF)
+if (systemlib_PROTOBUF)
   set(tensorflow_EXTERNAL_LIBRARIES ${tensorflow_EXTERNAL_LIBRARIES}
     ${PROTOBUF_LIBRARIES})
-else (protobuf_PROTOBUF)
+else (systemlib_PROTOBUF)
   set(tensorflow_EXTERNAL_LIBRARIES ${tensorflow_EXTERNAL_LIBRARIES}
     ${protobuf_STATIC_LIBRARIES})
-endif (protobuf_PROTOBUF)
+endif (systemlib_PROTOBUF)
 
 if (systemlib_ABSEIL_CPP)
   set(tensorflow_EXTERNAL_LIBRARIES ${tensorflow_EXTERNAL_LIBRARIES}
@@ -313,14 +313,6 @@ else (systemlib_ABSEIL_CPP)
     ${abseil_cpp_STATIC_LIBRARIES})
 endif (systemlib_ABSEIL_CPP)
 
-if (systemlib_GRPC)
-  set(tensorflow_EXTERNAL_LIBRARIES ${tensorflow_EXTERNAL_LIBRARIES}
-    ${GRPC_LIBRARIES} ${CARES_LIBRARIES})
-else (systemlib_GRPC)
-  set(tensorflow_EXTERNAL_LIBRARIES ${tensorflow_EXTERNAL_LIBRARIES}
-    ${grpc_STATIC_LIBRARIES})
-endif (systemlib_GRPC)
-
 message("Library Options = [${tensorflow_EXTERNAL_LIBRARIES}]")
 
 set(tensorflow_EXTERNAL_DEPENDENCIES
@@ -333,7 +325,7 @@ set(tensorflow_EXTERNAL_DEPENDENCIES
     farmhash_copy_headers_to_destination
     highwayhash_copy_headers_to_destination
     nsync_copy_headers_to_destination
-    protobuf
+    protobuf_
     eigen
     gemmlowp
     cub
@@ -378,8 +370,16 @@ if(tensorflow_ENABLE_GRPC_SUPPORT)
   include(grpc)
   include_directories(${GRPC_INCLUDE_DIRS})
   # Place boringssl after grpc as grpc depends on boringssl.
-  list(APPEND tensorflow_EXTERNAL_LIBRARIES ${grpc_STATIC_LIBRARIES})
-  list(APPEND tensorflow_EXTERNAL_DEPENDENCIES grpc)
+  list(APPEND tensorflow_EXTERNAL_DEPENDENCIES grpc_)
+
+  if (systemlib_GRPC)
+    set(tensorflow_EXTERNAL_LIBRARIES ${tensorflow_EXTERNAL_LIBRARIES}
+      ${GRPC_LIBRARIES} ${CARES_LIBRARIES})
+  else (systemlib_GRPC)
+    set(tensorflow_EXTERNAL_LIBRARIES ${tensorflow_EXTERNAL_LIBRARIES}
+      ${grpc_STATIC_LIBRARIES})
+  endif (systemlib_GRPC)
+
   if(tensorflow_ENABLE_SSL_SUPPORT)
     list(APPEND tensorflow_EXTERNAL_LIBRARIES ${boringssl_STATIC_LIBRARIES})
     list(APPEND tensorflow_EXTERNAL_DEPENDENCIES boringssl)
index b3987f1..aca09a4 100644 (file)
@@ -23,7 +23,7 @@ if (systemlib_GRPC)
 
   # To meet DEPENDS grpc from other projects.
   # If we hit this line, grpc is already built and installed to the system.
-  add_custom_target(grpc)
+  add_custom_target(grpc_)
   add_custom_target(grpc_copy_headers_to_destination)
 
   # Locate grpc's executables for tf_core_framework.cmake.
@@ -77,7 +77,7 @@ else (systemlib_GRPC)
 
   add_definitions(-DGRPC_ARES=0)
 
-  ExternalProject_Add(grpc
+  ExternalProject_Add(grpc_
       PREFIX grpc
       DEPENDS ${grpc_DEPENDS}
       GIT_REPOSITORY ${GRPC_URL}
index 95845ad..dd73549 100644 (file)
@@ -27,7 +27,7 @@ if (systemlib_PROTOBUF)
 
   # To meet DEPENDS protobuf from other projects.
   # If we hit this line, protobuf is already built and installed to the system.
-  add_custom_target(protobuf)
+  add_custom_target(protobuf_)
   add_custom_target(protobuf_copy_headers_to_destination)
 
 else (systemlib_PROTOBUF)
@@ -82,7 +82,7 @@ else (systemlib_PROTOBUF)
     set(PROTOBUF_PROTOC_EXECUTABLE ${CMAKE_CURRENT_BINARY_DIR}/protobuf/src/protobuf/protoc)
   endif()
 
-  ExternalProject_Add(protobuf
+  ExternalProject_Add(protobuf_
       PREFIX protobuf
       DEPENDS zlib
       GIT_REPOSITORY ${PROTOBUF_URL}
index 58c7a16..3bd2c21 100644 (file)
@@ -32,7 +32,7 @@ list(REMOVE_ITEM tf_core_distributed_runtime_srcs ${tf_core_distributed_runtime_
 add_library(tf_core_distributed_runtime OBJECT ${tf_core_distributed_runtime_srcs})
 
 add_dependencies(tf_core_distributed_runtime
-    tf_core_cpu grpc
+    tf_core_cpu grpc_
 )
 
 ########################################################
index 901f8e7..60a3039 100644 (file)
@@ -39,7 +39,7 @@ function(RELATIVE_PROTOBUF_GENERATE_CPP SRCS HDRS ROOT_DIR)
              "${CMAKE_CURRENT_BINARY_DIR}/${REL_DIR}/${FIL_WE}.pb.h"
       COMMAND  ${PROTOBUF_PROTOC_EXECUTABLE}
       ARGS --cpp_out  ${CMAKE_CURRENT_BINARY_DIR} -I ${ROOT_DIR} ${ABS_FIL} -I ${PROTOBUF_INCLUDE_DIRS}
-      DEPENDS ${ABS_FIL} protobuf
+      DEPENDS ${ABS_FIL} protobuf_
       COMMENT "Running C++ protocol buffer compiler on ${FIL}"
       VERBATIM )
   endforeach()
@@ -76,7 +76,7 @@ if(NOT WIN32)
                "${CMAKE_CURRENT_BINARY_DIR}/${REL_DIR}/${FIL_WE}.pb.h"
         COMMAND ${PROTOBUF_PROTOC_EXECUTABLE}
         ARGS --grpc_out ${CMAKE_CURRENT_BINARY_DIR} --cpp_out ${CMAKE_CURRENT_BINARY_DIR} --plugin protoc-gen-grpc=${GRPC_BUILD}/grpc_cpp_plugin -I ${ROOT_DIR} ${ABS_FIL} -I ${PROTOBUF_INCLUDE_DIRS}
-        DEPENDS ${ABS_FIL} protobuf grpc
+        DEPENDS ${ABS_FIL} protobuf_ grpc_
         COMMENT "Running C++ protocol buffer grpc compiler on ${FIL}"
         VERBATIM )
     endforeach()
index fa43094..3bd4317 100755 (executable)
@@ -81,7 +81,7 @@ function(RELATIVE_PROTOBUF_GENERATE_PYTHON ROOT_DIR SRCS)
       OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/tf_python/${REL_DIR}/${FIL_WE}_pb2.py"
       COMMAND ${PROTOBUF_PROTOC_EXECUTABLE}
       ARGS --python_out  ${CMAKE_CURRENT_BINARY_DIR}/tf_python/ -I ${ROOT_DIR} -I ${PROTOBUF_INCLUDE_DIRS} ${ABS_FIL}
-      DEPENDS ${PROTOBUF_PROTOC_EXECUTABLE} protobuf
+      DEPENDS ${PROTOBUF_PROTOC_EXECUTABLE} protobuf_
       COMMENT "Running Python protocol buffer compiler on ${FIL}"
       VERBATIM )
   endforeach()
@@ -110,7 +110,7 @@ function(RELATIVE_PROTOBUF_GENERATE_CPP SRCS HDRS ROOT_DIR)
              "${CMAKE_CURRENT_BINARY_DIR}/${REL_DIR}/${FIL_WE}.pb.h"
       COMMAND  ${PROTOBUF_PROTOC_EXECUTABLE}
       ARGS --cpp_out  ${CMAKE_CURRENT_BINARY_DIR} -I ${ROOT_DIR} ${ABS_FIL} -I ${PROTOBUF_INCLUDE_DIRS}
-      DEPENDS ${ABS_FIL} protobuf
+      DEPENDS ${ABS_FIL} protobuf_
       COMMENT "Running C++ protocol buffer compiler on ${FIL}"
       VERBATIM )
   endforeach()
index eff48a2..c520ce4 100644 (file)
@@ -198,10 +198,14 @@ install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/tensorflow/core/
 install(DIRECTORY ${tensorflow_source_dir}/tensorflow/stream_executor/
         DESTINATION include/tensorflow/stream_executor
         FILES_MATCHING PATTERN "*.h")
-# google protobuf headers
-install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/protobuf/src/protobuf/src/google/
-        DESTINATION include/google
-        FILES_MATCHING PATTERN "*.h")
+if (systemlib_PROTOBUF)
+  message ("Skip installing protobuf headers.")
+else (systemlib_PROTOBUF)
+  # google protobuf headers
+  install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/protobuf/src/protobuf/src/google/
+          DESTINATION include/google
+          FILES_MATCHING PATTERN "*.h")
+endif (systemlib_PROTOBUF)
 # Eigen directory
 install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/eigen/src/eigen/Eigen/
         DESTINATION include/Eigen)
index 03bde5b..f1de984 100644 (file)
@@ -34,7 +34,7 @@ target_link_libraries(${proto_text} PUBLIC
 
 add_dependencies(${proto_text} tf_core_lib)
 if(tensorflow_ENABLE_GRPC_SUPPORT)
-    add_dependencies(${proto_text} grpc)
+    add_dependencies(${proto_text} grpc_)
 endif(tensorflow_ENABLE_GRPC_SUPPORT)
 
 file(GLOB_RECURSE tf_tools_transform_graph_lib_srcs