1

I have a project where I have googletest in a sub-directory called Tests/GTest and I want to put google benchmark in a parallel sub-directory called Tests/GBenchmark (and probably google mock in Tests/GMock). That seems to be the corporate coding convention here. However, I don't know how to put a directive in CMakeLists.txt that explains to google benchmark where it will find googletest.

I have tried adding various versions of "../GTest" in the HandleGTest Hints section, but that hasn't helped. I'm a little closer by adding symbolic links, but that seems like a hack to me.

intel_chris
  • 708
  • 1
  • 6
  • 17
  • 1
    benchmark only needs googletest if you're planning on running the benchmark unit tests. If you don't need to do this (you likely don't if you're not developing benchmark), you should be able to set the BENCHMARK_ENABLE_TESTING flag to OFF. – dma Apr 03 '19 at 15:09
  • Making links from the directories to each other introduces circularities and causes CMake to hang when trying to delete a broken configuration. I may resort to dma's suggestion of disabling testing in the BENCHMARKs directory, but it isn't my first choice. It seems that there should be a way of specifying where a directory is to a CMake configuration when it isn't in the "normal" place. You can certainly do that with other make systems. – intel_chris Apr 04 '19 at 20:22
  • Turning the flags related to testing doesn't resolve the problem. The sample benchmarks still fail to compile. ` Building CXX object Tests/GBenchmark/test/CMakeFiles/benchmark_gtest.dir/benchmark_gtest.cc.o /Users/cfclark/nuodb/cfclark/DB-25833-from-master/Tests/GBenchmark/test/benchmark_gtest.cc:4:10: fatal error: 'gmock/gmock.h' file not found #include "gmock/gmock.h" ^~~~~~~~~~~~~~~ 1 error generated. ` – intel_chris Apr 04 '19 at 21:05
  • And as mentioned before I put google mock in Tests/GMock. – intel_chris Apr 04 '19 at 21:11
  • Here is an error complaining about gtest/gtest.h [ 18%] Building CXX object Tests/GBenchmark/test/CMakeFiles/string_util_gtest.dir/string_util_gtest.cc.o /Users/cfclark/nuodb/cfclark/DB-25833-from-master/Tests/GBenchmark/test/string_util_gtest.cc:6:10: fatal error: 'gtest/gtest.h' file not found #include "gtest/gtest.h" ^~~~~~~~~~~~~~~ 1 error generated. – intel_chris Apr 04 '19 at 21:13

0 Answers0