#Integrating `googletest` in my workflow and projects using CMAKE

5 messages · Page 1 of 1 (latest)

night token
#

I hvae done git add submodule <googletest.git> ext/googletest and I have the below project structure. Under dev/common I have 2 sub-projects. memory_pool and memory_pool_tests.

.
├── README.md
├── dev
│   ├── common
│   │   ├── memory_pool
│   │   │   ├── CMakeLists.txt
│   │   │   ├── include
│   │   │   │   ├── bucket.h
│   │   │   │   ├── bucket_descriptors.h
│   │   │   │   └── memory_pool.h
│   │   │   └── src
│   │   │       └── main.cpp
│   │   ├── memory_pool_tests
│   │   │   ├── CMakeLists.txt
│   │   │   └── src
│   │   │       └── memory_pool_tests.cpp
│   │   └── thread_utils
│   │       ├── include
│   │       └── src
│   │           └── thread_utils.cpp
│   └── ext
│       └── googletest

./dev/common/memory_pool_tests/CMakeLists.txt has the following contents:

cmake_minimum_required(VERSION 3.25)
project(memory_pool_tests VERSION 1.0.0)

set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED True)

set(CMAKE_BUILD_TYPE Debug)

set(source_files
    src/memory_pool_tests.cpp
)

add_executable(memory_pool_tests ${source_files})

# Include the memory_pool headers
target_include_directories(memory_pool_tests  
PUBLIC ../memory_pool/include/
PUBLIC ../../ext/googletest/googletest/include/gtest/
)

enable_testing()

target_link_directories(${PROJECT_NAME}  
INTERFACE ../memory_pool/build/
PUBLIC ../../ext/googletest/build/
)

target_link_libraries(memory_pool_tests 
INTERFACE memory_pool 
PUBLIC gtest
PUBLIC gtest_main
)

include(GoogleTest)
gtest_discover_tests(memory_pool_tests)

I can't see the header files gtest.h in my memory_pool_tests project, and I am unable to include them. Do you guys have any hints, on what I am doing incorrectly?

grand relicBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

pliant birch
night token
#

FetchContent() wasn't working for me, some permissioning issue, but I am set up now.

#

!solved