[Windows篇] 在windows 10上源碼編譯gtest 並編寫CMakeLists.txt

本文首發於我的博客kezunlin.me/post/aca50f…,歡迎閱讀!linux

compile gtest on windows 10 git

Guide

download

wget https://github.com/google/googletest/archive/release-1.8.0.zip 複製代碼

compile

mkdir build 
    cd build
    sudo cmake-gui ..複製代碼

with optionsgithub

BUILD_SHARED_LIBS ON
    CMAKE_CONFIGURATION_TYPES Release複製代碼

compile and install gtest to C:Program Filesgtest.ubuntu

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

相關文章
相關標籤/搜索