<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hej Andrew,<div class=""><br class=""></div><div class="">CMake does never scan source files (as far as I know), as it is not a compiler. From your question it almost seem you are making this assumption, so I just wanted to make sure to mention at least this.</div><div class=""><br class=""></div><div class="">Then, for your particular issue: two things that come to my mind:</div><div class="">* I’d imagine you have somewhere a add_executable(main Main.cpp Prefix.h DependHeader.h) - as far as I can tell, the only thing that really matters, is that the main executable gets recompiled whenever you make a change in any of the headers. To put it differently, I *don’t* think you (should) need the OBJECT_DEPENDS.</div><div class="">* If you’re worried about scaling, maybe you could have a look at the file(GLOB ) command. However, be sure to also carefully read the potential problems with that approach. In my current (big) project, we explicitly list each source file for most parts of the source tree. In practice you’re surely *not* going to add all 50 new files at once. It is a very simple thing to add the newly created file to some variable in the correct CMakeLists.txt file. You just have to remember to do it, it’s really not a big deal.</div><div class=""><br class=""></div><div class="">By the way, we’re actually using the PrecompiledHeader script - it works flawlessly.</div><div class=""><br class=""></div><div class="">Sincerely, Jakob </div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On 26 Aug 2015, at 11:48, Andrew Shaitorov <<a href="mailto:andrew.shaitorov@gmail.com" class="">andrew.shaitorov@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Hi All!<div class=""><br class=""></div><div class="">I have a very annoying problem with CMake Makefiles generator.</div><div class=""><br class=""></div><div class="">I'm using prefix header (see attached archive for minimized test).</div><div class=""><br class=""></div><div class="">There is one source file named Main.cpp and two header files: Prefix.h and DependHeader.h. Prefix.h includes DependHeader.h and Main.cpp includes Prefix.h by using prefix header compiler flag (-include for GCC/Clang and /FI for MSVC):</div><div class=""><br class=""></div><div class=""><div class=""><span class="" style="white-space:pre"> </span>set_source_files_properties(Main.cpp PROPERTIES</div><div class=""><span class="" style="white-space:pre">         </span>COMPILE_FLAGS "-include Prefix.h"</div><div class=""><span class="" style="white-space:pre">             </span>OBJECT_DEPENDS ${CMAKE_CURRENT_LIST_DIR}/Prefix.h)</div></div><div class=""><br class=""></div><div class="">When I change Prefix.h, then make recompiles Main.cpp as needed. But when I make a change in DependHeader.h, then no recompilation happens. Its clear for me that I have to specify all depend files in OBJECT_DEPENDS option, but in real project there may be a lot of depend files with nested includes. And the most annoying thing is that the project compiles without any errors and may just crash because of struct layout or other critical changes in depend headers.</div><div class=""><br class=""></div><div class="">I seems like the following script have the same problem when using FORCE_INCLUDE option:</div><div class=""><br class=""></div><div class=""><a href="https://github.com/larsch/cmake-precompiled-header/blob/master/PrecompiledHeader.cmake" class="">https://github.com/larsch/cmake-precompiled-header/blob/master/PrecompiledHeader.cmake</a><br class=""></div><div class=""><br class=""></div><div class="">I looked in CMake source code and didn't find a way to add Prefix.h in a list for dependency scanning. Also I don't know how to run depend scanner on Prefix.h in CMake script to generate a list of all depend files for OBJECT_DEPENDS option.</div><div class=""><br class=""></div><div class="">Any advise?</div><div class=""><br class=""></div><div class="">Best,</div><div class="">Andrew.<br clear="all" class=""><div class=""><br class=""></div><div class="gmail_signature"><div class=""></div></div>
</div></div>
<span id="cid:50E63A0C-707D-4C5D-9587-756ABEA9C6BC"><CMakePrefixHeaderTest.zip></span>-- <br class=""><br class="">Powered by <a href="http://www.kitware.com" class="">www.kitware.com</a><br class=""><br class="">Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" class="">http://www.cmake.org/Wiki/CMake_FAQ</a><br class=""><br class="">Kitware offers various services to support the CMake community. For more information on each offering, please visit:<br class=""><br class="">CMake Support: <a href="http://cmake.org/cmake/help/support.html" class="">http://cmake.org/cmake/help/support.html</a><br class="">CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" class="">http://cmake.org/cmake/help/consulting.html</a><br class="">CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" class="">http://cmake.org/cmake/help/training.html</a><br class=""><br class="">Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" class="">http://www.kitware.com/opensource/opensource.html</a><br class=""><br class="">Follow this link to subscribe/unsubscribe:<br class=""><a href="http://public.kitware.com/mailman/listinfo/cmake" class="">http://public.kitware.com/mailman/listinfo/cmake</a></div></blockquote></div><br class=""></div></body></html>