[CMake] Fix regression on non-systemlib build mode for protobuf/grpc
authorMyungJoo Ham <myungjoo.ham@samsung.com>
Wed, 17 Jul 2019 05:49:11 +0000 (14:49 +0900)
committerMyungJoo Ham <myungjoo.ham@samsung.com>
Wed, 17 Jul 2019 05:49:11 +0000 (14:49 +0900)
Fix regression on non-systemlib builds.

Change-Id: Ie7912aba09d30bbf14557019d5d56b932fa1161f
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_framework.cmake

index 3c60f95646af4c8e0aadf94957fb1f3d701af10b..450f3cfbcba40ddb06f395e34e2de186eff0b34d 100644 (file)
@@ -303,6 +303,7 @@ if (systemlib_PROTOBUF)
 else (systemlib_PROTOBUF)
   set(tensorflow_EXTERNAL_LIBRARIES ${tensorflow_EXTERNAL_LIBRARIES}
     ${protobuf_STATIC_LIBRARIES})
+  set(APPEND tensorflow_EXTERNAL_DEPENDENCIES protobuf)
 endif (systemlib_PROTOBUF)
 
 if (systemlib_ABSEIL_CPP)
@@ -378,6 +379,7 @@ if(tensorflow_ENABLE_GRPC_SUPPORT)
   else (systemlib_GRPC)
     set(tensorflow_EXTERNAL_LIBRARIES ${tensorflow_EXTERNAL_LIBRARIES}
       ${grpc_STATIC_LIBRARIES})
+    set(APPEND tensorflow_EXTERNAL_DEPENDENCIES grpc)
   endif (systemlib_GRPC)
 
   if(tensorflow_ENABLE_SSL_SUPPORT)
index 9c6c422349b2690ee24ad001a4753aef0e0dd558..004115805cf915fbb1c0592be232f27ac227f12e 100644 (file)
@@ -35,6 +35,7 @@ if (systemlib_GRPC)
   # If we hit this line, grpc is already built and installed to the system.
   add_custom_target(grpc_)
   add_custom_target(grpc_copy_headers_to_destination)
+  set(GRPC_DEPENDENCY grpc_)
 
   # Locate grpc's executables for tf_core_framework.cmake.
   set(GRPC_BUILD /usr/bin)
@@ -54,7 +55,7 @@ else (systemlib_GRPC)
   if(WIN32)
     # We use unsecure gRPC because boringssl does not build on windows
     set(grpc_TARGET grpc++_unsecure)
-    set(grpc_DEPENDS protobuf zlib)
+    set(grpc_DEPENDS protobuf_ zlib)
     set(grpc_SSL_PROVIDER NONE)
     if(${CMAKE_GENERATOR} MATCHES "Visual Studio.*")
       set(grpc_STATIC_LIBRARIES
@@ -70,10 +71,10 @@ else (systemlib_GRPC)
   else()
     set(grpc_TARGET grpc++)
     if(tensorflow_ENABLE_SSL_SUPPORT)
-      set(grpc_DEPENDS boringssl protobuf zlib)
+      set(grpc_DEPENDS boringssl protobuf_ zlib)
       set(grpc_SSL_PROVIDER module)
     else()
-      set(grpc_DEPENDS protobuf zlib)
+      set(grpc_DEPENDS protobuf_ zlib)
       set(grpc_SSL_PROVIDER NONE)
     endif()
     set(grpc_STATIC_LIBRARIES
@@ -87,7 +88,7 @@ else (systemlib_GRPC)
 
   add_definitions(-DGRPC_ARES=0)
 
-  ExternalProject_Add(grpc_
+  ExternalProject_Add(grpc
       PREFIX grpc
       DEPENDS ${grpc_DEPENDS}
       GIT_REPOSITORY ${GRPC_URL}
@@ -114,4 +115,6 @@ else (systemlib_GRPC)
       DEPENDEES patch
       DEPENDERS build
   )
+  add_custom_target(grpc_)
+  set(GRPC_DEPENDENCY grpc_ grpc)
 endif (systemlib_GRPC)
index dd735492756d517804905365ffd565b13134c07e..fb808386627e4adb46318b19f8994e4af3ca67af 100644 (file)
@@ -29,6 +29,7 @@ if (systemlib_PROTOBUF)
   # If we hit this line, protobuf is already built and installed to the system.
   add_custom_target(protobuf_)
   add_custom_target(protobuf_copy_headers_to_destination)
+  set(PROTOBUF_DEPENDENCY protobuf_)
 
 else (systemlib_PROTOBUF)
   include (ExternalProject)
@@ -82,7 +83,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}
@@ -109,4 +110,6 @@ else (systemlib_PROTOBUF)
           -Dprotobuf_MSVC_STATIC_RUNTIME:BOOL=OFF
           -DZLIB_ROOT:STRING=${ZLIB_INSTALL}
   )
+  add_custom_target(protobuf_)
+  set(PROTOBUF_DEPENDENCY protobuf_ protobuf)
 endif (systemlib_PROTOBUF)
index ecde38ba088bb1111887eb694f4deab24fcf1be5..f5833510e6bd1b126cdcb3213b0ad7c52cd6079f 100644 (file)
@@ -76,7 +76,7 @@ if((NOT WIN32) AND (tensorflow_ENABLE_GRPC_SUPPORT))
                "${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_DEPENDENCY} ${GRPC_DEPENDENCY}
         COMMENT "Running C++ protocol buffer grpc compiler on ${FIL}"
         VERBATIM )
     endforeach()