First, the compilation environment is:
- windows 64
 - Visual Studio Community 2022 Release - AMD64
 - CMake
 - vcpkg
 
Well, let's take a look at the project directory structure first.
.
│  .gitignore
│  CMakeLists.txt
│  LICENSE
│  README.md
│
├─.vscode
│      launch.json
│      settings.json
│
├─include
│      BDictionary.h
│      bencoding.h
│      BInteger.h
│      BItem.h
│      BItemVisitor.h
│      BList.h
│      BString.h
│      CMakeLists.txt
│      Decoder.h
│      Encoder.h
│      PrettyPrinter.h
│      Utils.h
│
├─src
│      BDictionary.cpp
│      BInteger.cpp
│      BItem.cpp
│      BItemVisitor.cpp
│      BList.cpp
│      BString.cpp
│      CMakeLists.txt
│      Decoder.cpp
│      Encoder.cpp
│      PrettyPrinter.cpp
│      Utils.cpp
│
└─tests
        BDictionaryTests.cpp
        BIntegerTests.cpp
        BListTests.cpp
        BStringTests.cpp
        CMakeLists.txt
        DecoderTests.cpp
        EncoderTests.cpp
        main.cpp
        PrettyPrinterTests.cpp
        TestUtils.cpp
        TestUtils.h
        UtilsTests.cpp
This project is a parsing library about Bencode on Github, the address is here: https://github.com/s3rvac/cpp-bencoding.git
As you can see, this project is controlled by CMake, and there are four CMakeLists under the directory. Among them, the contents of ./src/CMakeLists.txt and ./include/CMakeLists.txt are not important.
Let's mainly look at the contents of ./CMakeLists.txt and ./tests/CMakeLists.txt.
# ./CMakeLists.txt
cmake_minimum_required(VERSION 3.10)
SET(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake")
project(cpp-bencoding CXX)
include_directories(include)
add_subdirectory(include)
add_subdirectory(src)
add_subdirectory(tests)
enable_testing()
# ./tests/CMakeLists.txt
find_package(GTest CONFIG REQUIRED)
set(TESTER_SOURCES
    BDictionaryTests.cpp
    BIntegerTests.cpp
    BListTests.cpp
    BStringTests.cpp
    DecoderTests.cpp
    EncoderTests.cpp
    PrettyPrinterTests.cpp
    TestUtils.cpp
    UtilsTests.cpp
    main.cpp
        )
add_executable(tester ${TESTER_SOURCES})
target_link_libraries(tester PRIVATE bencoding GTest::gmock GTest::gtest GTest::gmock_main GTest::gtest_main)
include(CTest)
include(GoogleTest)
gtest_discover_tests(tester)
Well, the background is basically explained clearly. As it is now, the compilation passes and the test program runs successfully. The problem is that my CTest doesn't discover the tests, it tells me that no tests were found, Is gtest_discover_tests() causing the problem? Also, can I run a single test function by mouse click in visual studio code like in visual studio?