How to set up googleTest as a shared library on Linux

后端 未结 12 2598
北荒
北荒 2020-11-28 01:04

Debian does not provide any precompiled packages for gTest anymore. They suggest you integrate the framework into your project\'s makefile. But I want to keep my makefile cl

12条回答
  •  执念已碎
    2020-11-28 01:54

    The following method avoids manually messing with the /usr/lib directory while also requiring minimal change in your CMakeLists.txt file. It also lets your package manager cleanly uninstall libgtest-dev.

    The idea is that when you get the libgtest-dev package via

    sudo apt install libgtest-dev
    

    The source is stored in location /usr/src/googletest

    You can simply point your CMakeLists.txt to that directory so that it can find the necessary dependencies

    Simply replace FindGTest with add_subdirectory(/usr/src/googletest gtest)

    At the end, it should look like this

    add_subdirectory(/usr/src/googletest gtest)
    target_link_libraries(your_executable gtest)
    

提交回复
热议问题