Glow: googletest error

Created on 19 Sep 2018  路  14Comments  路  Source: pytorch/glow

when I build glow with
cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -DGLOW_WITH_CPU=1 -DGLOW_WITH_OPENCL=0
I get the following err msg:

CMake Error at tests/googletest/googletest/cmake/internal_utils.cmake:153 (add_library):
  add_library cannot create target "gtest" because an imported target with
  the same name already exists.
Call Stack (most recent call first):
  tests/googletest/googletest/cmake/internal_utils.cmake:176 (cxx_library_with_type)
  tests/googletest/googletest/CMakeLists.txt:99 (cxx_library)


CMake Error at tests/googletest/googletest/cmake/internal_utils.cmake:153 (add_library):
  add_library cannot create target "gtest_main" because an imported target
  with the same name already exists.
Call Stack (most recent call first):
  tests/googletest/googletest/cmake/internal_utils.cmake:176 (cxx_library_with_type)
  tests/googletest/googletest/CMakeLists.txt:100 (cxx_library)


CMake Error at tests/googletest/googletest/CMakeLists.txt:101 (target_link_libraries):
  Cannot specify link libraries for target "gtest_main" which is not built by
  this project.


-- Configuring incomplete, errors occurred!

llvm 5.0.0 cannot work?

All 14 comments

@compnerd Do you know what's going on?

@lijiansong Is this an LLVM-related problem? Could you try with LLVM6.0 ?

No, it's NOT llvm related problem, it's a google-test related problem.

What version of cmake?

@nadavrot
cmake version 3.10.1

CMake suite maintained and supported by Kitware (kitware.com/cmake).

My llvm is build by make, not ninja

@lijiansong can you dump the whole output of the command:
cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -DGLOW_WITH_CPU=1 -DGLOW_WITH_OPENCL=0

@rdzhabarov

Re-run cmake no build system arguments
-- Found LLVM 6.0.0
-- Using LLVMConfig.cmake in: /Users/lijiansong/work-space/compile/llvm/llvm-6.0.0.src/build/lib/cmake/llvm
--
-- ******** Summary ********
--   CMake version         : 3.10.1
--   CMake command         : /Users/lijiansong/work-space/compile/llvm/cmake-3.10.1-Darwin-x86_64/CMake.app/Contents/bin/cmake
--   System                : Darwin
--   C++ compiler          : /Library/Developer/CommandLineTools/usr/bin/c++
--   C++ compiler version  : 9.0.0.9000039
--   CXX flags             :  -Wall -Wnon-virtual-dtor -fno-exceptions -fno-rtti
--   Build type            : Debug
--   Compile definitions   : GLOW_WITH_CPU=1;GOOGLE_PROTOBUF_NO_RTTI;ONNX_NAMESPACE=onnx
--   CMAKE_PREFIX_PATH     :
--   CMAKE_INSTALL_PREFIX  : /usr/local
--   CMAKE_MODULE_PATH     : /Users/lijiansong/glow/cmake/modules
--
--   ONNX version          : 1.3.0
--   ONNX NAMESPACE        : onnx
--   ONNX_BUILD_TESTS      : OFF
--   ONNX_BUILD_BENCHMARKS : OFF
--   ONNX_USE_LITE_PROTO   : OFF
--   ONNXIFI_DUMMY_BACKEND : OFF
--
--   Protobuf compiler     : /usr/local/bin/protoc
--   Protobuf includes     : /usr/local/include
--   Protobuf libraries    : /usr/local/lib/libprotobuf.dylib
--   BUILD_ONNX_PYTHON     : OFF
CMake Error at tests/googletest/googletest/cmake/internal_utils.cmake:162 (add_library):
  add_library cannot create target "gtest" because an imported target with
  the same name already exists.
Call Stack (most recent call first):
  tests/googletest/googletest/cmake/internal_utils.cmake:198 (cxx_library_with_type)
  tests/googletest/googletest/CMakeLists.txt:133 (cxx_library)


CMake Error at tests/googletest/googletest/cmake/internal_utils.cmake:162 (add_library):
  add_library cannot create target "gtest_main" because an imported target
  with the same name already exists.
Call Stack (most recent call first):
  tests/googletest/googletest/cmake/internal_utils.cmake:198 (cxx_library_with_type)
  tests/googletest/googletest/CMakeLists.txt:134 (cxx_library)


CMake Error at tests/googletest/googletest/CMakeLists.txt:139 (target_include_directories):
  Cannot specify include directories for imported target "gtest".


CMake Error at tests/googletest/googletest/CMakeLists.txt:142 (target_include_directories):
  Cannot specify include directories for imported target "gtest_main".


CMake Error at tests/googletest/googletest/CMakeLists.txt:146 (target_link_libraries):
  Cannot specify link libraries for target "gtest_main" which is not built by
  this project.


-- Configuring incomplete, errors occurred!
See also "/Users/lijiansong/glow/build/CMakeFiles/CMakeOutput.log".

can you try to build glow without tests? (e.g., supplying -DGLOW_BUILD_TESTS=OFF)

Not a solution, but the error you are seeing is pretty weird and not reproducible. (btw, my cmake version is cmake version 3.12.2)

@rdzhabarov
Maybe environment problem, when I try it on another server, it works well.
Do you have a docker build for Glow?

Do you have a docker build for Glow?

Not that I'm aware of. Going to close/resolve this issue.

I ran in to this issue on windows when building with llvm 7.0 (build from source). Turning off LLVM_INCLUDES_TESTS when building llvm did the trick.

I want to comment for posterity. To fix this problem, configure LLVM with cmake <other flags> -DLLVM_INCLUDE_TESTS=OFF.

I want to comment for posterity. To fix this problem, configure LLVM with cmake <other flags> -DLLVM_INCLUDE_TESTS=OFF.

Thanks, that extra S proposed by @ayermolo was throwing me off.

My bad. Should have just copied and pasted. :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jackm321 picture jackm321  路  3Comments

rdzhabarov picture rdzhabarov  路  4Comments

georgeokelly picture georgeokelly  路  4Comments

gcatron picture gcatron  路  4Comments

s-peryt picture s-peryt  路  3Comments