At commit 880896c the recommended method of including googletest in your project results in cmake errors (see below). I have reproduced this error on FreeBSD 11.2 (cmake 3.12.
Changing cmake to require commit b88511e rather than master seems resolve the issue.
ExternalProject_Add(googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG b88511ef640c046ec9c7553b383a2aba64c80967
SOURCE_DIR "${CMAKE_BINARY_DIR}/googletest-src"
BINARY_DIR "${CMAKE_BINARY_DIR}/googletest-build"
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
TEST_COMMAND ""
)
CMake Error in build/googletest-src/googlemock/CMakeLists.txt:
Target "gmock_main" INTERFACE_INCLUDE_DIRECTORIES property contains path:
"[...]/build/googletest-src/googletest/include"
which is prefixed in the build directory.
CMake Error in build/googletest-src/googlemock/CMakeLists.txt:
Target "gmock_main" INTERFACE_INCLUDE_DIRECTORIES property contains path:
"[...]/build/googletest-src/googletest/include"
which is prefixed in the build directory.Target "gmock_main"
INTERFACE_INCLUDE_DIRECTORIES property contains path:
"[...]/build/googletest-src/googletest/include"
which is prefixed in the source directory.
CMake Error in build/googletest-src/googlemock/CMakeLists.txt:
Target "gmock_main" INTERFACE_INCLUDE_DIRECTORIES property contains path:
"[...]/build/googletest-src/googlemock/include"
which is prefixed in the build directory.
CMake Error in build/googletest-src/googlemock/CMakeLists.txt:
Target "gmock_main" INTERFACE_INCLUDE_DIRECTORIES property contains path:
"[...]/build/googletest-src/googlemock/include"
which is prefixed in the build directory.Target "gmock_main"
INTERFACE_INCLUDE_DIRECTORIES property contains path:
"[...]/build/googletest-src/googlemock/include"
which is prefixed in the source directory.
@wfvining @gennadiycivil I can take a look at this, but it will probably be a few hours.
@dakotahawkins please do, if possible please work with @wfvining to duplicate the original issue and fix it
Thank you again
@wfvining I must be missing something, but I can't get this to happen in a small example project (following the recommended instructions except copying googletest from a local directory).
I've tried relative/absolute CMAKE_INSTALL_PREFIX, switching googletest to the old commit/building/switching to master/building again. Nothing so far.
Could you fork and modify my example repo to reproduce the problem so I can take a look? Just change whatever CMake files you want and try to make build.sh reproduce the issue if you can.
Thanks for any help you can provide!
@gennadiycivil FYI
@wfvining Scratch the above... could you try
ExternalProject_Add(googletest
GIT_REPOSITORY https://github.com/dakotahawkins/googletest.git
GIT_TAG fix-1764_CMake-errors-in-googlemock
...
and see if it resolves the problem?
I will give that a try as soon as I get a chance and let you know.
This appears to stem from the documentation not keeping up with the code. I have submitted a patch to the documentation with the appropriate change.
@wfvining Any chance my branch fixed the error anyway?
No, it didn't.
OK, I can reproduce it at least by adding that extra target_include_directories call.
I'm not sure there's any way around it (except for not doing it), but it's also not obvious to me what made it start happening.
Changing it to
target_include_directories(gmock_main SYSTEM BEFORE INTERFACE
"$<BUILD_INTERFACE:${gtest_SOURCE_DIR}/include>"
"$<BUILD_INTERFACE:${gmock_SOURCE_DIR}/include>")
fixes the problem, but as you pointed out is redundant now.
Most helpful comment
OK, I can reproduce it at least by adding that extra
target_include_directoriescall.I'm not sure there's any way around it (except for not doing it), but it's also not obvious to me what made it start happening.
Changing it to
fixes the problem, but as you pointed out is redundant now.