Let's say I have main.cpp, a.h and b.h in the same folder. main.cpp includes a.h, and a.h includes b.h.
Checking the generated depends.make file, main.cpp.o depends both on a.h and b.h, as expected.
If b.h is moved to a folder B, and used the -iquote B flag, main.cpp.o does not depend any more on b.h.
I can put back the dependency by adding include_directories(${CMAKE_SOURCE_DIR}/B) to the CMakeLists.txt file. This however has a side effect: when compiling main.cpp, cmake uses the flag -I/pathTo/B. I prefer using -iquote instead of -I.
Is there a way in this second case to let cmake to detect the dependencies automatically without introducing the -I compiler flag?
-MMDflags are added by CMake to the compiler call (see e.g.CMAKE_DEPFILE_FLAGS_CXX). I'm not sure if it would help the generally changeCMAKE_INCLUDE_FLAG_CXX(which does define the-Iflag). Or long story short: CMake does not support-iquoteout-of-the-box.