<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Exchange Server">
<!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
</head>
<body>
<div>
<div>That was it. I wound up finding a slightly different solution. I create a static library of the resources, and then have the unit tests link in that lib. </div>
<div><br>
</div>
<div>Which gets the same dependency tree the custom target. </div>
<div><br>
</div>
<div>My question, that I'm still confused about is why this is necessary. </div>
<div><br>
</div>
<div>I have two projects, that depens on the output of a single input.... </div>
<div><br>
</div>
<div>But this works.... </div>
<div><br>
</div>
<div id="x_composer_signature">~~Scott</div>
<div><br>
</div>
<div><br>
</div>
<div>-------- Original message --------</div>
<div>From: "Alan W. Irwin" <Alan.W.Irwin1234@gmail.com> </div>
<div>Date: 1/18/19 19:11 (GMT-08:00) </div>
<div>To: Scott Bloom <scott@towel42.com> </div>
<div>Cc: cmake Mailing List <cmake@cmake.org> </div>
<div>Subject: Re: [CMake] Issue with qt5_add_resources with unit tests </div>
<div><br>
</div>
</div>
<font size="2"><span style="font-size:11pt;">
<div class="PlainText">On 2019-01-19 00:09-0000 Scott Bloom wrote:<br>
<br>
> I use qt + google test to run tests in my build environment.<br>
><br>
> The problem I have, is in some (most) of my unit test directories, there will be multiple test executables created, all dependent on the same output file from the add_resources step.<br>
><br>
> Typically its something like<br>
><br>
> qt_add_resource( resourceVar resource.qrc )<br>
><br>
> add_executable( test1 test1main.cpp ${resourceVar} )<br>
> add_executable( test2 test2main.cpp ${resourceVar} )<br>
><br>
> On windows (running the build from cmake through visual studio with parallel building turned on) this sometimes (1 out of 20 or 30 builds or so) causes a race condition, where the dependency on the qrc_resource.cpp is attempted to be generated by both executable
dependencies at once.<br>
><br>
> Not sure what is going on, but wondering if there was any advice out there for this problem<br>
<br>
Hi Scott:<br>
<br>
I could find no google hits for qt_add_resource (except for your<br>
question). But that search did ask is "qt5_add_resources" what<br>
you meant?<br>
If so there is a rather old but still useful<br>
discussion at<br>
<<a href="https://stackoverflow.com/questions/23041356/corrupted-resource-cpp-file-when-using-qt5-add-resources-and-multithread-compil">https://stackoverflow.com/questions/23041356/corrupted-resource-cpp-file-when-using-qt5-add-resources-and-multithread-compil</a>><br>
for what appears to be exactly the problem you describe. See<br>
especially the CMake code associated with this comment:<br>
<br>
"The workaround is to add a custom target and add explicit depends on that".<br>
<br>
Actually, regardless of causes and whether you were refererring to<br>
qt5_add_resources or not I think that workaround will work to solve<br>
your issue since in a parallel build environment a custom target and<br>
relevant dependencies on that target always assures just one build<br>
(rather than multiple builds which race with each other) of whatever<br>
it refers to.<br>
<br>
Alan<br>
__________________________<br>
Alan W. Irwin<br>
<br>
Programming affiliations with the FreeEOS equation-of-state<br>
implementation for stellar interiors (freeeos.sf.net); the Time<br>
Ephemerides project (timeephem.sf.net); PLplot scientific plotting<br>
software package (plplot.sf.net); the libLASi project<br>
(unifont.org/lasi); the Loads of Linux Links project (loll.sf.net);<br>
and the Linux Brochure Project (lbproject.sf.net).<br>
__________________________<br>
<br>
Linux-powered Science<br>
__________________________<br>
</div>
</span></font>
</body>
</html>