Intellisense can't find include directory

I have set up gtest to be downloaded/built using an ExternalProject. The project builds/runs without error; however, in editor, the intellisense cannot seem to resolve the gtest include "gtest/gtest.h". It complains about not being able to find the directory "gtest". This results in lots of other things in the editor being indicated as an error.

I'm assuming I configured cmake correctly because the project builds and runs (including running in the test runner). Am I doing something wrong here? Any help on the matter would be greatly appreciated.

Thanks in advance


Here's what I have configured:

I am using Cygwin (64-bit) as my toolchain.
I am running CLion in a Windows 10 (64-bit) environment

gtest.cmake

include(ExternalProject)

ExternalProject_Add(
    googletest
    GIT_REPOSITORY https://github.com/google/googletest.git
    INSTALL_COMMAND ""
    UPDATE_COMMAND ""
    PATCH_COMMAND ""
    PREFIX ${CMAKE_BINARY_DIR}/gtest
    SOURCE_DIR ${CMAKE_BINARY_DIR}/gtest/src/googletest/googletest/googletest
)

ExternalProject_Get_Property(googletest source_dir binary_dir)

set(GTEST_INCLUDE_DIR ${source_dir}/include)
set(GTEST_LIB ${binary_dir}/libgtest.a)
set(GTEST_MAIN_LIB ${binary_dir}/libgtest_main.a)

include_directories(${GTEST_INCLUDE_DIR})


CMakeLists.txt (for the test project that uses gtest)

project (MyTestProject)

set(SOURCE_FILES main.cpp SomeTest.cpp)

include(../cmake/googletest.cmake)

add_executable(${PROJECT_NAME} ${SOURCE_FILES})

include_directories(${GTEST_INCLUDE_DIR})

add_dependencies(${PROJECT_NAME} googletest)

target_link_libraries(${PROJECT_NAME} ${GTEST_LIB})

enable_testing()
add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME})

add_custom_command(
        TARGET ${PROJECT_NAME}
        POST_BUILD
        COMMAND "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.exe"
)


Sample output from the editor

CLion GTest Header Problem.png


Message was edited by: Trevon Sutton

2 comments
Comment actions Permalink

After restarting the IDE a couple of times, the errors went away.

Thanks for you help anyway.

0
Comment actions Permalink

I have simmilar problem.

But I can fix it partialy by Run Configuration.

If I have normal configuration, with executeble my main goal (CheckTwoEnormousFiles) - Test not working and my main target (CheckTwoEnormousFiles) NOT builded (because code have errors).

But if I use Google Test Configuration with executable test target (CheckTwoEnormousFiles_test), than Tests are working but my main target (CheckTwoEnormousFiles) STILL NOT builded.

What I'm doing wrong?

0

Please sign in to leave a comment.