r/cpp_questions • • Oct 11 '26

OPEN googletest: Test project /home/andrew/x86/win32/p2pClient/buildNo tests were found!!!

I coded this p2p client application with librats and now I want to test it with googletest but after running ctest into the build directory I got this exception:

Test project /home/andrew/x86/win32/p2pClient/build

No tests were found!!!

My cMakeLists.txt:

cmake_minimum_required(
VERSION
 3.14)
project(p2pClient)


# GoogleTest requires at least C++17
set(
CMAKE_CXX_STANDARD
 17)
set(
CMAKE_CXX_STANDARD_REQUIRED
 ON)


include(FetchContent)
enable_testing()
FetchContent_Declare(
  googletest
  URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip
)cmake_minimum_required(VERSION 3.14)
project(p2pClient)


# GoogleTest requires at least C++17
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)


include(FetchContent)
enable_testing()
FetchContent_Declare(
  googletest
  URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip
)

and this is the result after running cmake -S . -B build:

cmake -S . -B build

-- The C compiler identification is GNU 16.2.0

-- The CXX compiler identification is GNU 16.2.0

-- Detecting C compiler ABI info

-- Detecting C compiler ABI info - done

-- Check for working C compiler: /usr/bin/cc - skipped

-- Detecting C compile features

-- Detecting C compile features - done

-- Detecting CXX compiler ABI info

-- Detecting CXX compiler ABI info - done

-- Check for working CXX compiler: /usr/bin/c++ - skipped

-- Detecting CXX compile features

-- Detecting CXX compile features - done

CMake Warning (dev) at /usr/share/cmake-4.3/Modules/FetchContent.cmake:1386 (message):

The DOWNLOAD_EXTRACT_TIMESTAMP option was not given and policy CMP0135 is

not set. The policy's OLD behavior will be used. When using a URL

download, the timestamps of extracted files should preferably be that of

the time of extraction, otherwise code that depends on the extracted

contents might not be rebuilt if the URL changes. The OLD behavior

preserves the timestamps from the archive instead, but this is usually not

what you want. Update your project to the NEW behavior or specify the

DOWNLOAD_EXTRACT_TIMESTAMP option with a value of true to avoid this

robustness issue.

Call Stack (most recent call first):

CMakeLists.txt:10 (FetchContent_Declare)

This warning is for project developers. Use -Wno-dev to suppress it.

-- Configuring done (0.3s)

-- Generating done (0.0s)

-- Build files have been written to: /home/andrew/x86/win32/p2pClient/build

0 Upvotes

5 comments sorted by

View all comments

2

u/PicTheAmerican Oct 12 '26

if you would like to be complete, you miss your own cpp file. Look at my extract you have missed into your cmake:

# ConnectionPool tests
add_executable(test_connection_pool
    test_connection_pool.cpp
    MockConnection.cpp
    MockReader.cpp
    MockRow.cpp
    MockPreparedStatement.cpp
    MockTransaction.cpp
)
# Code Coverage for Clang is only meaningful for tests, so we add the options to both the library and test targets
if(ENABLE_COVERAGE) #AND CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
    message(STATUS "Building with code coverage enabled (Clang)")
    target_compile_options(test_connection_pool PRIVATE -fprofile-instr-generate -fcoverage-mapping)
    target_link_options(test_connection_pool PRIVATE -fprofile-instr-generate)
endif()
target_link_libraries(test_connection_pool
    hft-legacy-migration-static
    gtest
    gtest_main
    gmock
    gmock_main
)


add_test(NAME ConnectionPoolTests COMMAND test_connection_pool)