google / google/googletest

FetchContent + VisualStudio miss google test header files in the generated project files

Open
#4,816 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
39.5k
Forks
10.9k
Avg merge
6d 13h
Merged PRs (30d)
1

Description

### Describe the issue

I use googletest with FetchContent and my main development environment is VisualStudio IDE - in the generated solution I can see gtest (and gtest_main) generated projects and I can see googletest source files (*.cc in Source Files) in these projects. Should I also see the header files like gtest.h in these projects (in Header Files)?

Should there be an entry in the googletest CMakeLists.txt for target_sources (of these header files) - I think that would instruct cmake to generate the Header Files entry in the generated project files.

### Steps to reproduce the problem

in the consuming CMakeLists.txt
...
include(FetchContent)

set(BUILD_GMOCK Off) # I am not sure if this meant to be used outside of googletest

FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG v1.17.0
)

FetchContent_MakeAvailable(googletest)
...

...
target_link_libraries(${PROJECT_NAME} PRIVATE
xyz
GTest::gtest_main
)
...

### What version of GoogleTest are you using?

1.17 (latest)

### What operating system and version are you using?

Windows 11 (latest)

### What compiler and version are you using?

VisualStudio (latest)

### What build system are you using?

What ever is bundled with the VisualStudio

### Additional context

_No response_

Contributor guide

Open the contributing guide

Research direction

Start with the googletest CMakeLists.txt and reproduce the FetchContent setup from the issue using Visual Studio's generated solution. Check how the gtest and gtest_main targets list source and header files; done means the expected headers appear in the generated project files without breaking the targets.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake, cpp
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.