Re: [CMake] Issue with qt5_add_resources with unit tests

2019-01-18 Thread Scott Bloom
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" 
Date: 1/18/19 19:11 (GMT-08:00)
To: Scott Bloom 
Cc: cmake Mailing List 
Subject: Re: [CMake] Issue with qt5_add_resources with unit tests

On 2019-01-19 00:09- 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 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.
>
> Not sure what is going on, but wondering if there was any advice out there 
> 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-when-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
__
-- 

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


Re: [CMake] Issue with qt5_add_resources with unit tests

2019-01-18 Thread Alan W. Irwin

On 2019-01-19 00:09- 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 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.

Not sure what is going on, but wondering if there was any advice out there 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

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
__
--

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


[CMake] Issue with qt5_add_resources with unit tests

2019-01-18 Thread Scott Bloom
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 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.

Not sure what is going on, but wondering if there was any advice out there for 
this problem

Scott



-- 

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