[prev in list] [next in list] [prev in thread] [next in thread] 

List:       cmake
Subject:    [CMake] Prefix header for Makefiles
From:       Andrew Shaitorov <andrew.shaitorov () gmail ! com>
Date:       2015-08-26 9:48:58
Message-ID: CAO0JdscD+O+rWv4pAdf177uaGhdy+JJbhaSyWxOOTSY+qGXD8A () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Hi All!

I have a very annoying problem with CMake Makefiles generator.

I'm using prefix header (see attached archive for minimized test).

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):

set_source_files_properties(Main.cpp PROPERTIES
COMPILE_FLAGS "-include Prefix.h"
OBJECT_DEPENDS ${CMAKE_CURRENT_LIST_DIR}/Prefix.h)

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.

I seems like the following script have the same problem when using
FORCE_INCLUDE option:

https://github.com/larsch/cmake-precompiled-header/blob/master/PrecompiledHeader.cmake

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.

Any advise?

Best,
Andrew.

[Attachment #5 (text/html)]

<div dir="ltr">Hi All!<div><br></div><div>I have a very annoying problem with CMake \
Makefiles generator.</div><div><br></div><div>I&#39;m using prefix header (see \
attached archive for minimized test).</div><div><br></div><div>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><br></div><div><div><span class="" \
style="white-space:pre">	</span>set_source_files_properties(Main.cpp \
PROPERTIES</div><div><span class="" style="white-space:pre">		</span>COMPILE_FLAGS \
&quot;-include Prefix.h&quot;</div><div><span class="" \
style="white-space:pre">		</span>OBJECT_DEPENDS \
${CMAKE_CURRENT_LIST_DIR}/Prefix.h)</div></div><div><br></div><div>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><br></div><div>I seems like the \
following script have the same problem when using FORCE_INCLUDE \
option:</div><div><br></div><div><a \
href="https://github.com/larsch/cmake-precompiled-header/blob/master/PrecompiledHeader \
.cmake">https://github.com/larsch/cmake-precompiled-header/blob/master/PrecompiledHeader.cmake</a><br></div><div><br></div><div>I \
looked in CMake source code and didn&#39;t find a way to add Prefix.h in a list for \
dependency scanning. Also I don&#39;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><br></div><div>Any \
advise?</div><div><br></div><div>Best,</div><div>Andrew.<br \
clear="all"><div><br></div><div class="gmail_signature"><div></div></div> \
</div></div>

--001a1135ffb0a5f3ac051e33c364--


["CMakePrefixHeaderTest.zip" (application/zip)]

-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: \
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information \
on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at \
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic