Setting up GMock with CMAKE (and Doxygen and ...)

2,774 views
Skip to first unread message

Adam Getchell

unread,
Dec 10, 2013, 8:44:04 PM12/10/13
to googl...@googlegroups.com
I'd like to integrate GMock into my CMakeLists.txt for my project:


I've read over:






Just doing the basic setup of including:


################################################################################
################################################################################
add_subdirectory(gmock-1.7.0)
enable_testing(true)
include_directories(${gmock_SOURCE_DIR}/include ${gmock_SOURCE_DIR})

Results in the following compilation error for main.cpp:

┌─[getchell][Hapkido][±][master ][~/CDT-plusplus]

└─▪ make

[ 11%] Built target cdt

[ 22%] Building CXX object CMakeFiles/main.dir/main.cpp.o

In file included from /Users/getchell/CDT-plusplus/main.cpp:1:

In file included from /Users/getchell/CDT-plusplus/gmock-1.7.0/include/gmock/gmock.h:58:

In file included from /Users/getchell/CDT-plusplus/gmock-1.7.0/include/gmock/gmock-actions.h:46:

In file included from /Users/getchell/CDT-plusplus/gmock-1.7.0/include/gmock/internal/gmock-internal-utils.h:45:

In file included from /Users/getchell/CDT-plusplus/gmock-1.7.0/include/gmock/internal/gmock-generated-internal-utils.h:44:

/Users/getchell/CDT-plusplus/gmock-1.7.0/include/gmock/internal/gmock-port.h:45:10: fatal error: 

      'gtest/internal/gtest-linked_ptr.h' file not found

#include "gtest/internal/gtest-linked_ptr.h"

         ^

1 error generated.

make[2]: *** [CMakeFiles/main.dir/main.cpp.o] Error 1

make[1]: *** [CMakeFiles/main.dir/all] Error 2

make: *** [all] Error 2


Suggestions to fix this? Better yet, directions for building GMock in a build directory instead of adding it to my source files?

Thanks for any pointers,

Adam

Adam Getchell

unread,
Oct 7, 2014, 2:42:40 PM10/7/14
to googl...@googlegroups.com
After reading "Modern C++ Programming with Test-Driven Development", and most crucially, the errata, along with David Alfonso's GMock/CMAKE github project skeleton:


I've gotten this to work.

The only hangup now is getting Travis CI to build and link to GMock successfully:

Adam Getchell

unread,
Oct 9, 2014, 5:55:24 PM10/9/14
to googl...@googlegroups.com
Got Travis CI and GMock to work together, by setting GMOCK_HOME="$TRAVIS_BUILD_DIR/gmock-1.7.0"

https://github.com/acgetchell/CDT-plusplus
Reply all
Reply to author
Forward
0 new messages