qt .qrc file modifications require two builds

classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|

qt .qrc file modifications require two builds

Glenn Hughes
If I modify my .qrc file, the first build regenerates the cxx output
file, but the cxx file itself is not compiled and linked in until I
build again.
Is there a way to add an additional dependency to allow the system to
realize that the cxx file needs a rebuild on the first pass?

The CMake script in question looks more or less like:

FILE (GLOB my_RESOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "res/*.qrc"  )
QT4_ADD_RESOURCES( my_RESOURCES_SOURCES ${my_RESOURCES} )

...

ADD_EXECUTABLE( myApp MACOSX_BUNDLE ${mySrcs}  ${my_RESOURCES_SOURCES} )

Is there something else I should be doing? Building under Xcode.

Thanks!
G
_______________________________________________
Powered by www.kitware.com

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

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

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: qt .qrc file modifications require two builds

John Drescher-2
> The CMake script in question looks more or less like:
>
> FILE (GLOB my_RESOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "res/*.qrc"  )
> QT4_ADD_RESOURCES( my_RESOURCES_SOURCES ${my_RESOURCES} )
>
> ...

It's always best to not do any file globbing and add each file by
hand. I believe this is causing the problem.

John
_______________________________________________
Powered by www.kitware.com

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

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

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: qt .qrc file modifications require two builds

Glenn Hughes
Really? How could it? Suppose I only have 1 qrc file, named foo.qrc:
wouldn't these two lines be equivalent?

FILE (GLOB my_RESOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "res/*.qrc"  )
SET( my_RESOURCES "res/foo.qrc")

???
TIA
G

On Tue, Dec 15, 2009 at 7:15 PM, John Drescher <[hidden email]> wrote:

>> The CMake script in question looks more or less like:
>>
>> FILE (GLOB my_RESOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "res/*.qrc"  )
>> QT4_ADD_RESOURCES( my_RESOURCES_SOURCES ${my_RESOURCES} )
>>
>> ...
>
> It's always best to not do any file globbing and add each file by
> hand. I believe this is causing the problem.
>
> John
>
_______________________________________________
Powered by www.kitware.com

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

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

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: qt .qrc file modifications require two builds

Michael Jackson


On Dec 15, 2009, at 7:24 PM, Glenn Hughes wrote:

> Really? How could it? Suppose I only have 1 qrc file, named foo.qrc:
> wouldn't these two lines be equivalent?
>
> FILE (GLOB my_RESOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "res/
> *.qrc"  )
> SET( my_RESOURCES "res/foo.qrc")
>
> ???
> TIA
> G
>
> On Tue, Dec 15, 2009 at 7:15 PM, John Drescher  
> <[hidden email]> wrote:
>>> The CMake script in question looks more or less like:
>>>
>>> FILE (GLOB my_RESOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "res/
>>> *.qrc"  )
>>> QT4_ADD_RESOURCES( my_RESOURCES_SOURCES ${my_RESOURCES} )
>>>
>>> ...
>>
>> It's always best to not do any file globbing and add each file by
>> hand. I believe this is causing the problem.
>>
>> John
>>

I wont debate the merits of FILE(GLOB.. ) but looking back through the  
mail list archives FILE (GLOB ..) leads to more problems for more  
people than it probably solves. I would stay away from it unless you  
have some pretty special circumstances.

_________________________________________________________
Mike Jackson                  [hidden email]
BlueQuartz Software                    www.bluequartz.net
Principal Software Engineer                  Dayton, Ohio
_______________________________________________
Powered by www.kitware.com

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

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

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: qt .qrc file modifications require two builds

Glenn Hughes
Removed the globbing, same exact behavior.
Any other ideas?

Does this normally work for people? Any examples?

G
_______________________________________________
Powered by www.kitware.com

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

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

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: qt .qrc file modifications require two builds

Clinton Stimpson

Do you have a minimal example to demonstrate it?
I wonder if its related to how dependencies for qrc files are handled.

Clint

On Wednesday 16 December 2009 01:27:55 pm Glenn Hughes wrote:

> Removed the globbing, same exact behavior.
> Any other ideas?
>
> Does this normally work for people? Any examples?
>
> G
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake

_______________________________________________
Powered by www.kitware.com

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

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

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: qt .qrc file modifications require two builds

John Drescher-2
In reply to this post by Glenn Hughes
On Wed, Dec 16, 2009 at 3:27 PM, Glenn Hughes <[hidden email]> wrote:
> Removed the globbing, same exact behavior.
> Any other ideas?
>
> Does this normally work for people? Any examples?
>

Works fine for me. Although I rarely update the .qrc files.

John
_______________________________________________
Powered by www.kitware.com

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

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

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: qt .qrc file modifications require two builds

Glenn Hughes
Here's a very short example that demonstrates the problem.
This is a CMake file for the "states" qt 4.6 example
(Developer/Examples/Qt/animation/states)

#---
PROJECT(states) # the name of your project

CMAKE_MINIMUM_REQUIRED(VERSION 2.4.0)

FIND_PACKAGE(Qt4 REQUIRED) # find and setup Qt4 for this project

INCLUDE(${QT_USE_FILE})

SET ( states_SRCS main.cpp )
SET ( states_HEADERS main.h )
SET ( states_RESOURCES states.qrc )

QT4_WRAP_CPP( states_MOC_files ${states_HEADERS})
QT4_ADD_RESOURCES( states_RESOURCES_SOURCES ${states_RESOURCES} )

INCLUDE_DIRECTORIES( ${CMAKE_BINARY_DIR} )

ADD_EXECUTABLE( states MACOSX_BUNDLE ${states_SRCS}
${states_MOC_files} ${states_RESOURCES_SOURCES} )
TARGET_LINK_LIBRARIES(states ${QT_LIBRARIES})

#---
Put this in the states directory, run CMake ./ -G Xcode
Open the Xcode project and build. Builds fine.
Next, open states.qrc, make any sort of modification, even just typing
a space. Save the file.
Build. You will notice the "run custom script" phase executes, but
that's all. (qrc_states.cxx is generated)
Press Build again. You will notice that qrc_states.cxx compiles and
the project is relinked. That should have been done the first time.

G
_______________________________________________
Powered by www.kitware.com

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

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

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: qt .qrc file modifications require two builds

Clinton Stimpson
It looks like a bug in the Xcode generator.
Here's an even simpler example:

project(test_xcode)

add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/test.h
     COMMAND cp ${CMAKE_SOURCE_DIR}/test.h.in ${CMAKE_BINARY_DIR}/test.h
     DEPENDS ${CMAKE_SOURCE_DIR}/test.h.in
     )

include_directories(${CMAKE_BINARY_DIR})

add_executable(test_xcode
     ${CMAKE_BINARY_DIR}/test.h
     ${CMAKE_SOURCE_DIR}/test.h.in
     main.cpp)

I have to hit build twice if test.h.in is modified.

Clint


On Dec 16, 2009, at 2:00 PM, Glenn Hughes wrote:

> Here's a very short example that demonstrates the problem.
> This is a CMake file for the "states" qt 4.6 example
> (Developer/Examples/Qt/animation/states)
>
> #---
> PROJECT(states) # the name of your project
>
> CMAKE_MINIMUM_REQUIRED(VERSION 2.4.0)
>
> FIND_PACKAGE(Qt4 REQUIRED) # find and setup Qt4 for this project
>
> INCLUDE(${QT_USE_FILE})
>
> SET ( states_SRCS main.cpp )
> SET ( states_HEADERS main.h )
> SET ( states_RESOURCES states.qrc )
>
> QT4_WRAP_CPP( states_MOC_files ${states_HEADERS})
> QT4_ADD_RESOURCES( states_RESOURCES_SOURCES ${states_RESOURCES} )
>
> INCLUDE_DIRECTORIES( ${CMAKE_BINARY_DIR} )
>
> ADD_EXECUTABLE( states MACOSX_BUNDLE ${states_SRCS}
> ${states_MOC_files} ${states_RESOURCES_SOURCES} )
> TARGET_LINK_LIBRARIES(states ${QT_LIBRARIES})
>
> #---
> Put this in the states directory, run CMake ./ -G Xcode
> Open the Xcode project and build. Builds fine.
> Next, open states.qrc, make any sort of modification, even just typing
> a space. Save the file.
> Build. You will notice the "run custom script" phase executes, but
> that's all. (qrc_states.cxx is generated)
> Press Build again. You will notice that qrc_states.cxx compiles and
> the project is relinked. That should have been done the first time.
>
> G
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/ 
> opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at: http://
> www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake

_______________________________________________
Powered by www.kitware.com

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

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

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: qt .qrc file modifications require two builds

Brad King
Clinton Stimpson wrote:

> It looks like a bug in the Xcode generator.
> Here's an even simpler example:
>
> project(test_xcode)
>
> add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/test.h
>     COMMAND cp ${CMAKE_SOURCE_DIR}/test.h.in ${CMAKE_BINARY_DIR}/test.h
>     DEPENDS ${CMAKE_SOURCE_DIR}/test.h.in
>     )
>
> include_directories(${CMAKE_BINARY_DIR})
>
> add_executable(test_xcode
>     ${CMAKE_BINARY_DIR}/test.h
>     ${CMAKE_SOURCE_DIR}/test.h.in
>     main.cpp)
>
> I have to hit build twice if test.h.in is modified.

This is a known limitation, and it is very hard to fix because
Xcode does not provide real custom command support.  It only
provides "shell script" build phases which we use to drive a
Makefile system that has the real custom commands.  Currently
the projects that CMake generates do not convince Xcode to
run the shell script build phase at the right time in all cases.

See CMake's BuildDepends test:

  http://www.cmake.org/cgi-bin/viewcvs.cgi/Tests/BuildDepends/CMakeLists.txt?revision=1.14&root=CMake&view=markup

Note the "HELP_XCODE" blocks.

-Brad
_______________________________________________
Powered by www.kitware.com

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

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

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: qt .qrc file modifications require two builds

Clinton Stimpson
On Wednesday 16 December 2009 04:05:22 pm Brad King wrote:

> Clinton Stimpson wrote:
> > It looks like a bug in the Xcode generator.
> > Here's an even simpler example:
> >
> > project(test_xcode)
> >
> > add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/test.h
> >     COMMAND cp ${CMAKE_SOURCE_DIR}/test.h.in ${CMAKE_BINARY_DIR}/test.h
> >     DEPENDS ${CMAKE_SOURCE_DIR}/test.h.in
> >     )
> >
> > include_directories(${CMAKE_BINARY_DIR})
> >
> > add_executable(test_xcode
> >     ${CMAKE_BINARY_DIR}/test.h
> >     ${CMAKE_SOURCE_DIR}/test.h.in
> >     main.cpp)
> >
> > I have to hit build twice if test.h.in is modified.
>
> This is a known limitation, and it is very hard to fix because
> Xcode does not provide real custom command support.  It only
> provides "shell script" build phases which we use to drive a
> Makefile system that has the real custom commands.  Currently
> the projects that CMake generates do not convince Xcode to
> run the shell script build phase at the right time in all cases.
>
> See CMake's BuildDepends test:
>
>  
> http://www.cmake.org/cgi-bin/viewcvs.cgi/Tests/BuildDepends/CMakeLists.txt?
>revision=1.14&root=CMake&view=markup
>
> Note the "HELP_XCODE" blocks.
>
> -Brad

What about adding a custom build phase and insert it before the "Compile
Sources" build phase?

<http://developer.apple.com/mac/library/documentation/DeveloperTools/Conceptual/XcodeBuildSystem/200-
Build_Phases/bs_build_phases.html>

Clint

_______________________________________________
Powered by www.kitware.com

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

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

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: qt .qrc file modifications require two builds

David Cole
On Wed, Dec 16, 2009 at 6:16 PM, Clinton Stimpson <[hidden email]> wrote:
On Wednesday 16 December 2009 04:05:22 pm Brad King wrote:
> Clinton Stimpson wrote:
> > It looks like a bug in the Xcode generator.
> > Here's an even simpler example:
> >
> > project(test_xcode)
> >
> > add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/test.h
> >     COMMAND cp ${CMAKE_SOURCE_DIR}/test.h.in ${CMAKE_BINARY_DIR}/test.h
> >     DEPENDS ${CMAKE_SOURCE_DIR}/test.h.in
> >     )
> >
> > include_directories(${CMAKE_BINARY_DIR})
> >
> > add_executable(test_xcode
> >     ${CMAKE_BINARY_DIR}/test.h
> >     ${CMAKE_SOURCE_DIR}/test.h.in
> >     main.cpp)
> >
> > I have to hit build twice if test.h.in is modified.
>
> This is a known limitation, and it is very hard to fix because
> Xcode does not provide real custom command support.  It only
> provides "shell script" build phases which we use to drive a
> Makefile system that has the real custom commands.  Currently
> the projects that CMake generates do not convince Xcode to
> run the shell script build phase at the right time in all cases.
>
> See CMake's BuildDepends test:
>
>
> http://www.cmake.org/cgi-bin/viewcvs.cgi/Tests/BuildDepends/CMakeLists.txt?
>revision=1.14&root=CMake&view=markup
>
> Note the "HELP_XCODE" blocks.
>
> -Brad

What about adding a custom build phase and insert it before the "Compile
Sources" build phase?

<<a href="http://developer.apple.com/mac/library/documentation/DeveloperTools/Conceptual/XcodeBuildSystem/200- Build_Phases/bs_build_phases.html" target="_blank">http://developer.apple.com/mac/library/documentation/DeveloperTools/Conceptual/XcodeBuildSystem/200-
Build_Phases/bs_build_phases.html>


Generated Xcode projects do use "Run Script" build phases... Perhaps there's a way we could specify input and output files for those build phases. Those bits of the UI seem to be empty when I inspect an Xcode project built from your "test.h.in" example here.

This issue appears to be reporting the same thing...


(So there's already a bug tracker entry about it...)



_______________________________________________
Powered by www.kitware.com

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

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

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: qt .qrc file modifications require two builds

Clinton Stimpson

On Dec 16, 2009, at 5:36 PM, David Cole wrote:

On Wed, Dec 16, 2009 at 6:16 PM, Clinton Stimpson <[hidden email]> wrote:
On Wednesday 16 December 2009 04:05:22 pm Brad King wrote:
> Clinton Stimpson wrote:
> > It looks like a bug in the Xcode generator.
> > Here's an even simpler example:
> >
> > project(test_xcode)
> >
> > add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/test.h
> >     COMMAND cp ${CMAKE_SOURCE_DIR}/test.h.in ${CMAKE_BINARY_DIR}/test.h
> >     DEPENDS ${CMAKE_SOURCE_DIR}/test.h.in
> >     )
> >
> > include_directories(${CMAKE_BINARY_DIR})
> >
> > add_executable(test_xcode
> >     ${CMAKE_BINARY_DIR}/test.h
> >     ${CMAKE_SOURCE_DIR}/test.h.in
> >     main.cpp)
> >
> > I have to hit build twice if test.h.in is modified.
>
> This is a known limitation, and it is very hard to fix because
> Xcode does not provide real custom command support.  It only
> provides "shell script" build phases which we use to drive a
> Makefile system that has the real custom commands.  Currently
> the projects that CMake generates do not convince Xcode to
> run the shell script build phase at the right time in all cases.
>
> See CMake's BuildDepends test:
>
>
> http://www.cmake.org/cgi-bin/viewcvs.cgi/Tests/BuildDepends/CMakeLists.txt?
>revision=1.14&root=CMake&view=markup
>
> Note the "HELP_XCODE" blocks.
>
> -Brad

What about adding a custom build phase and insert it before the "Compile
Sources" build phase?

<http://developer.apple.com/mac/library/documentation/DeveloperTools/Conceptual/XcodeBuildSystem/200-
Build_Phases/bs_build_phases.html
>


Generated Xcode projects do use "Run Script" build phases... Perhaps there's a way we could specify input and output files for those build phases. Those bits of the UI seem to be empty when I inspect an Xcode project built from your "test.h.in" example here.


If I specify the input (path to test.h.in) & output (path to generated test.h) for the "CMake Rules" build phase, the problem goes away.
Maybe we can put all inputs and all outputs in there for generated files in that project?  The script (makefile) it calls already has the smarts for which ones really need updating.
Or is there a reason we can't just add a build phase for each add_custom_command() ?  Possibly too much clutter?

Clint


_______________________________________________
Powered by www.kitware.com

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

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

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: qt .qrc file modifications require two builds

Brad King
Clinton Stimpson wrote:
> If I specify the input (path to test.h.in) & output (path to generated
> test.h) for the "CMake Rules" build phase, the problem goes away.
> Maybe we can put all inputs and all outputs in there for generated files
> in that project?  The script (makefile) it calls already has the smarts
> for which ones really need updating.

I once investigated doing this but never finished.  I think it requires
a graph algorithm to split rules into maximal groups such that each
group has inputs and outputs that are disjoint.  Each group gets one
"Run Script" build phase.

> Or is there a reason we can't just add a build phase for each
> add_custom_command() ?  Possibly too much clutter?

One could try that.  I don't know how well build phases scale.
There is also the issue that build phases are not per-configuration,
so the scripts would have to test $(CONFIGURATION).  Currently this
is done by using $(CONFIGURATION) to select which Makefile rule to
drive.

Somewhere I have a patch series that I started last time I investigated
this problem.  If anyone wants to volunteer to work on it I can send my
current patches (they probably don't apply to CVS HEAD now though).
IIRC the patches factor out some of the VS IDE custom script code for
re-use with Xcode.

-Brad
_______________________________________________
Powered by www.kitware.com

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

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

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake