kigster / cmake-project-template

This project is aimed at jump-starting a C/C++ project that can build libraries, binaries and have a working unit test suite. It uses CMake build system and is deliberately completely minimal.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Manuel build: Missing CMakeLists.txt in /test/lib/googletest and fails to link gtest

Lauenburg opened this issue · comments

Using a fresh clone (e3ad4b6) the manual build fails on my system (MacOS 10.15).

In /Users/lauenburg/Projects/cmake-project-template/test/lib/googletest running:

rm -rf build && mkdir build
git submodule init && git submodule update
cd build
cmake ..

Leads to the following error, telling me that cmake-project-template/test/lib/googletest needs to contain a CMakeLists.txt file:

-- Detecting CXX compile features - done
CMake Error at test/CMakeLists.txt:4 (add_subdirectory):
  The source directory

    /Users/lauenburg/Projects/cmake-project-template/test/lib/googletest

  does not contain a CMakeLists.txt file.


-- Configuring incomplete, errors occurred!

When adding an empty CMakeLists.txt file to cmake-project-template/test/lib/googletest cmake complets succesfully.

But if I then run make && make install make fails as it can not find google test:

/Users/lauenburg/Projects/cmake-project-template/test/main.cpp:1:10: fatal error: 'gtest/gtest.h' file not found
#include "gtest/gtest.h"
         ^~~~~~~~~~~~~~~
1 error generated.
make[2]: *** [test/CMakeFiles/divider_tests.dir/main.cpp.o] Error 1
make[1]: *** [test/CMakeFiles/divider_tests.dir/all] Error 2
make: *** [all] Error 2

I installed and tested google-test on my machine and it works perfectly. Is there something that I am missing?

I tried it again today and found out that the manual steps work if you clone the repo and do not download it.
Sorry for any inconvenience!