No subject


Wed May 9 12:08:04 EDT 2012


-DCODEGEN so it won't include the generated file, which of course wouldn't
even exist on the first pass.  But since CMake doesn't preprocess headers,
it creates a circular dependency situation, where the code generator
"depends" on files which it generates.  This causes unnecessary rebuilds,
since the code generator gets rebuilt after every time it regenerates files.

I thought I could create a dummy "GeneratedFile.h" in the directory
containing the codegen files, and put this into the CMakeLists.txt in that
directory:
include_directories(
  BEFORE
  ${PROJECT_SOURCE_DIR}/src/codegen
)

That seemed to work the first time -- if I looked at the codegen's
depend.make file I saw lines like "SomeUtilityFile.cpp.o:
..../codegen/GeneratedFile.h" -- the dummy version of the file.

The problem is that CMake seems to have a global dependency cache, so once
SomeUtilityFile.cpp gets built for the program, the dependency globally
changes to the real GeneratedFile.h.

Any ideas to make this work, or other ways I can work around the problem?

Thank you
-dan

--14dae93406f3353cfc04cb306955
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Hi,<br><br>I&#39;m having issues with the way CMake scans for dependencies.=
=A0 It&#39;s causing unpredictable rebuilds of my project which means I nee=
d to run &#39;make&#39; multiple times (until nothing rebuilds) before I ca=
n &#39;sudo make install&#39;.<br>

<br>The project incorporates a code generator.=A0 It parses all C++ header =
files and produces .h and .cpp files, which are then built into the main pr=
ogram.=A0 The codegen and program both depend on a set of common utility fi=
les, which contain lines like this:<br>

<br>#ifndef CODEGEN<br>=A0 #include &quot;GeneratedFile.h&quot;<br>#endif<b=
r><br>From a compile standpoint, there is no problem -- the codegen is buil=
t with -DCODEGEN so it won&#39;t include the generated file, which of cours=
e wouldn&#39;t even exist on the first pass.=A0 But since CMake doesn&#39;t=
 preprocess headers, it creates a circular dependency situation, where the =
code generator &quot;depends&quot; on files which it generates.=A0 This cau=
ses unnecessary rebuilds, since the code generator gets rebuilt after every=
 time it regenerates files.<br>

<br>I thought I could create a dummy &quot;GeneratedFile.h&quot; in the dir=
ectory containing the codegen files, and put this into the CMakeLists.txt i=
n that directory:<br>include_directories(<br>=A0 BEFORE<br>=A0 ${PROJECT_SO=
URCE_DIR}/src/codegen<br>

)<br><br>That seemed to work the first time -- if I looked at the codegen&#=
39;s depend.make file I saw lines like &quot;SomeUtilityFile.cpp.o: ..../co=
degen/GeneratedFile.h&quot; -- the dummy version of the file.<br><br>The pr=
oblem is that CMake seems to have a global dependency cache, so once SomeUt=
ilityFile.cpp gets built for the program, the dependency globally changes t=
o the real GeneratedFile.h.<br>

<br>Any ideas to make this work, or other ways I can work around the proble=
m?<br><br>Thank you<br>-dan<br>

--14dae93406f3353cfc04cb306955--


More information about the CMake mailing list