For case2, it happen the message
#include errors detected. Please update your includePath. Squiggles are disabled for this translation unit
// main.cpp
#include "shared/main.hpp"
Folder
test/src/main.cpp
test/include/shared/main.hpp
case1
# cmake
add_executable(test
${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp
${CMAKE_CURRENT_SOURCE_DIR}/include/shared/main.hpp)
target_include_directories(test PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
case2
add_executable(test
${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp)
target_include_directories(test PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)