Rewrite gtest_main.cc, gmock_main.cc, gtest-all.cc, and gmock-all.cc to use `.h` or `.hpp` files rather than `.cc` files.
- Dominant language
- C++
- Stars
- 39.5k
- Forks
- 10.9k
- Avg merge
- 6d 13h
- Merged PRs (30d)
- 1
Description
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 **I**nclude 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 https://github.com/google/googletest/discussions/4580_
Contributor guide
Research direction
Start by inspecting gtest_main.cc, gmock_main.cc, gtest-all.cc, and gmock-all.cc, then compare their include handling with the repository's CMakeLists.txt and the failing Premake5-generated makefile. Done means the named files use the requested .h or .hpp includes and the project builds without requiring the source-directory include workaround.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- build-system, testing-qa
- Issue type
- Refactor
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100