From 28493424354c9b2b659020a6a6ed11d307ddfe91 Mon Sep 17 00:00:00 2001 From: Jinzhe Zeng Date: Mon, 10 Oct 2022 17:10:14 -0400 Subject: [PATCH 1/2] replace `:` by `;` from `LD_LIBRARY_PATH` in cmake Fixes #1957. Signed-off-by: Jinzhe Zeng --- source/cmake/Findtensorflow.cmake | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/cmake/Findtensorflow.cmake b/source/cmake/Findtensorflow.cmake index 07c3cbd16e..1d7076807f 100644 --- a/source/cmake/Findtensorflow.cmake +++ b/source/cmake/Findtensorflow.cmake @@ -153,12 +153,14 @@ if (NOT TensorFlow_INCLUDE_DIRS_GOOGLE) message(STATUS "Protobuf headers are not found in the directory of TensorFlow, assuming external protobuf was used to build TensorFlow") # try to find from ldd list of TF library # a warning is threw here, just ignore it + # https://stackoverflow.com/a/49738486/9567349 + string(REPLACE ":" ";" _LD_LIBRARY_DIRS $ENV{LD_LIBRARY_PATH}) file(GET_RUNTIME_DEPENDENCIES RESOLVED_DEPENDENCIES_VAR TensorFlow_LINKED_LIBRARIES UNRESOLVED_DEPENDENCIES_VAR TensorFlow_LINKED_LIBRARIES_UNRESOLVED LIBRARIES ${TensorFlowFramework_LIBRARY} POST_INCLUDE_REGEXES "^.+protobuf\..+$" - DIRECTORIES $ENV{LD_LIBRARY_PATH} + DIRECTORIES ${_LD_LIBRARY_DIRS} ) # search protobuf from linked libraries foreach(_lib ${TensorFlow_LINKED_LIBRARIES}) From eb37f9588fd2ba563e8c5272d7b7b37bdb936085 Mon Sep 17 00:00:00 2001 From: Jinzhe Zeng Date: Mon, 10 Oct 2022 17:25:33 -0400 Subject: [PATCH 2/2] consider the situation when LD_LIBRARY_PATH is empty --- source/cmake/Findtensorflow.cmake | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/cmake/Findtensorflow.cmake b/source/cmake/Findtensorflow.cmake index 1d7076807f..32e120a191 100644 --- a/source/cmake/Findtensorflow.cmake +++ b/source/cmake/Findtensorflow.cmake @@ -154,7 +154,9 @@ if (NOT TensorFlow_INCLUDE_DIRS_GOOGLE) # try to find from ldd list of TF library # a warning is threw here, just ignore it # https://stackoverflow.com/a/49738486/9567349 - string(REPLACE ":" ";" _LD_LIBRARY_DIRS $ENV{LD_LIBRARY_PATH}) + if ($ENV{LD_LIBRARY_PATH}) + string(REPLACE ":" ";" _LD_LIBRARY_DIRS $ENV{LD_LIBRARY_PATH}) + endif() file(GET_RUNTIME_DEPENDENCIES RESOLVED_DEPENDENCIES_VAR TensorFlow_LINKED_LIBRARIES UNRESOLVED_DEPENDENCIES_VAR TensorFlow_LINKED_LIBRARIES_UNRESOLVED