[prev in list] [next in list] [prev in thread] [next in thread]
List: cmake
Subject: Re: [CMake] Issue with qt5_add_resources with unit tests
From: Scott Bloom <scott () towel42 ! com>
Date: 2019-01-19 3:29:41
Message-ID: CY4PR1001MB2182366E1B0C60B69B6C9F51A99D0 () CY4PR1001MB2182 ! namprd10 ! prod ! outlook ! com
[Download RAW message or body]
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.
Which gets the same dependency tree the custom target.
My question, that I'm still confused about is why this is necessary.
I have two projects, that depens on the output of a single input....
But this works....
~~Scott
-------- Original message --------
From: "Alan W. Irwin" <Alan.W.Irwin1234@gmail.com>
Date: 1/18/19 19:11 (GMT-08:00)
To: Scott Bloom <scott@towel42.com>
Cc: cmake Mailing List <cmake@cmake.org>
Subject: Re: [CMake] Issue with qt5_add_resources with unit tests
On 2019-01-19 00:09-0000 Scott Bloom wrote:
> I use qt + google test to run tests in my build environment.
>
> 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.
>
> Typically its something like
>
> qt_add_resource( resourceVar resource.qrc )
>
> add_executable( test1 test1main.cpp ${resourceVar} )
> add_executable( test2 test2main.cpp ${resourceVar} )
>
> On windows (running the build from cmake through visual studio with paral=
lel building turned on) this sometimes (1 out of 20 or 30 builds or so) cau=
ses a race condition, where the dependency on the qrc_resource.cpp is attem=
pted to be generated by both executable dependencies at once.
>
> Not sure what is going on, but wondering if there was any advice out ther=
e for this problem
Hi Scott:
I could find no google hits for qt_add_resource (except for your
question). But that search did ask is "qt5_add_resources" what
you meant?
If so there is a rather old but still useful
discussion at
<https://stackoverflow.com/questions/23041356/corrupted-resource-cpp-file-w=
hen-using-qt5-add-resources-and-multithread-compil>
for what appears to be exactly the problem you describe. See
especially the CMake code associated with this comment:
"The workaround is to add a custom target and add explicit depends on that"=
.
Actually, regardless of causes and whether you were refererring to
qt5_add_resources or not I think that workaround will work to solve
your issue since in a parallel build environment a custom target and
relevant dependencies on that target always assures just one build
(rather than multiple builds which race with each other) of whatever
it refers to.
Alan
__________________________
Alan W. Irwin
Programming affiliations with the FreeEOS equation-of-state
implementation for stellar interiors (freeeos.sf.net); the Time
Ephemerides project (timeephem.sf.net); PLplot scientific plotting
software package (plplot.sf.net); the libLASi project
(unifont.org/lasi); the Loads of Linux Links project (loll.sf.net);
and the Linux Brochure Project (lbproject.sf.net).
__________________________
Linux-powered Science
__________________________
[Attachment #3 (text/html)]
<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/questio \
ns/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>
--
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:
https://cmake.org/mailman/listinfo/cmake
--===============0364636226==--
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic