-
-
Save brockoffdev/76c56b481d6527f755be77546560e107 to your computer and use it in GitHub Desktop.
Install Google Test and Google Mock on Ubuntu
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cmake_minimum_required(VERSION 3.5) | |
project(example LANGUAGES CXX) | |
set(CMAKE_CXX_STANDARD 11) | |
set(CMAKE_CXX_STANDARD_REQUIRED ON) | |
find_package(GTest REQUIRED) | |
include_directories(${GTEST_INCLUDE_DIRS}) | |
add_executable(example main.cpp) | |
target_link_libraries(example ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cd ~ | |
git clone https://github.com/google/googletest.git | |
cd googletest | |
mkdir build && cd build | |
cmake .. -DBUILD_SHARED_LIBS=ON -DINSTALL_GTEST=ON -DCMAKE_INSTALL_PREFIX:PATH=/usr | |
make -j8 | |
sudo make install | |
sudo ldconfig |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <gtest/gtest.h> | |
TEST(test_case, example_test) | |
{ | |
EXPECT_EQ(2, 2); | |
} | |
int main(int argc, char **argv) | |
{ | |
testing::InitGoogleTest(&argc, argv); | |
return RUN_ALL_TESTS(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment