kezunlin · 2019年11月27日

[Windows篇] 在windows 10上源码编译gtest 并编写CMakeLists.txt

本文首发于个人博客https://kezunlin.me/post/aca50ff8/,欢迎阅读!

compile gtest on windows 10
<!--more-->

Guide

download

wget https://github.com/google/googletest/archive/release-1.8.0.zip 

compile

mkdir build 
cd build
sudo cmake-gui ..

with options

BUILD_SHARED_LIBS ON
CMAKE_CONFIGURATION_TYPES Release

compile and install gtest to C:\Program Files\gtest.

CMakeLists.txt

if(MSVC) 
    SET(GTEST_ROOT "C:/Program Files/gtest")
else()
    # BOOST_THREAD_LIBRARY  /usr/lib/x86_64-linux-gnu/libpthread.so
    MESSAGE( [Main] " BOOST_THREAD_LIBRARY = ${BOOST_THREAD_LIBRARY}")
endif(MSVC)

find_package(GTest REQUIRED) # GTest 1.8.0

find_package(GTest REQUIRED) # GTest 1.8.0
include_directories(${GTEST_INCLUDE_DIRS})
target_link_libraries(demo ${GTEST_LIBRARIES} ${BOOST_THREAD_LIBRARY})

Reference

History

  • 20180301: created.

Copyright

推荐阅读
关注数
2
文章数
52
[链接] C++,Python. Computer Vision and Deep Learning.
目录
极术微信服务号
关注极术微信号
实时接收点赞提醒和评论通知
安谋科技学堂公众号
关注安谋科技学堂
实时获取安谋科技及 Arm 教学资源
安谋科技招聘公众号
关注安谋科技招聘
实时获取安谋科技中国职位信息