Quickstart: Building with CMake fails on Ubuntu 20.04 #4469
-
Following the quickstart: https://google.github.io/googletest/quickstart-cmake.html with file content as shown below, Due to the
cmake_minimum_required(VERSION 3.14)
project(my_project)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
include(FetchContent)
FetchContent_Declare(
googletest
URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip
)
enable_testing()
add_executable(
hello_test
hello_test.cc
)
target_link_libraries(
hello_test
GTest::gtest_main
)
include(GoogleTest)
gtest_discover_tests(hello_test)
#include <gtest/gtest.h>
TEST(HelloTest, BasicAssertions) {
EXPECT_STRNE("hello", "world");
EXPECT_EQ(7*6, 42)
} |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I found that I missed a line in the |
Beta Was this translation helpful? Give feedback.
I found that I missed a line in the
CMakeLists.txt
file. The line should go immediately after theFetchContent
line, and should containFetchContent_MakeAvailable(googletest)