Setup Google test in CLion

后端 未结 3 1813
渐次进展
渐次进展 2021-01-30 20:51

I have been sitting online for hours already trying to setup Google test on Clion in Linux but have not been able to find anything.

Can someone guide me with setting thi

3条回答
  •  北荒
    北荒 (楼主)
    2021-01-30 21:19

    1.Git clone the google-test C++ test framework

    From https://github.com/google/googletest.git
    

    2.Include the google-test directories

    #Add the google test subdirectory
    add_subdirectory(PATH_TO_GOOGLETEST)
    
    #include googletest/include dir
    include_directories(PATH_TO_GOOGLETEST/googletest/include)
    
    #include the googlemock/include dir
    include_directories(PATH_TO_GOOGLETEST/googlemock/include)
    

    3. Link your executable with google-test (This is after creating your executable)

    #Define your executable
    add_executable(EXECUTABLE_NAME ${SOURCE_FILES})
    
    #Link with GoogleTest
    target_link_libraries(EXECUTABLE_NAME gtest gtest_main)
    
    #Link with GoogleMock
    target_link_libraries(EXECUTABLE_NAME gmock gmock_main)
    

提交回复
热议问题