Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite gtest_main.cc, gmock_main.cc, gtest-all.cc, and gmock-all.cc to use .h or .hpp files rather than .cc files. #4585

Open
AeroSW opened this issue Jul 31, 2024 · 0 comments

Comments

@AeroSW
Copy link

AeroSW commented Jul 31, 2024

Hello everyone,

I am attempting to build googletest and googlemock from its source directly using Premake5.

Background on builder choice:
My project is using Premake5 because it seemed easier to setup compared to CMAKE, and I feel this is true so far, since, CMAKE guides are relatively confusing to follow and Premake5 is just Lua.

Issue

I am currently running into an error where my generated makefile script is finding the following error:

extern/__include__/GoogleTest/googlemock/src/gmock-all.cc:42:10: fatal error: src/gmock-cardinalities.cc: No such file or directory
   42 | #include "src/gmock-cardinalities.cc"
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.

This error feels weird because it makes it seem like I should add -Igooglemock/src which is not really a standard practice for C++ where you typically want to Include Header files and not Source files.

I have GoogleTest project forked and linked as a submodule to my project, so I have everything that is on the master branch. Is this a mistake in the source code to include source code rather than the headers?

Additional Information

I am using VSCode with GCC 14 (C++23).

Edit 1 (From my own comment below)

https://cplusplus.com/forum/general/39618/

Generally, it seems to be looked down upon to include source files due to compilation and linking ending up including the file twice...

Edit 2 (From my second comment)

Looking at your CMakeLists.txt file, it does appear that you are including source files as if they were header files...

get_target_property(gtest_include_dirs gtest INCLUDE_DIRECTORIES)
set(gmock_build_include_dirs
  "${gmock_SOURCE_DIR}/include"
  "${gmock_SOURCE_DIR}"
  "${gtest_include_dirs}")
include_directories(${gmock_build_include_dirs})

Originally posted by @AeroSW in #4580

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant