Skip to content
This repository has been archived by the owner on Feb 21, 2019. It is now read-only.

Qt resource compilation of bitshares.qrc fails because images are not copied to build folder #52

Closed
arhag opened this issue Sep 22, 2014 · 7 comments

Comments

@arhag
Copy link

arhag commented Sep 22, 2014

Moved from: bitshares/bitshares1-core#801

The following is a snippet of code from bitsharesx/programs/qt_wallet/CMakeLists.txt:

set(static_bitshares_resource_files bitshares.qrc
                                    images/splash_screen.jpg
                                    images/qtapp.ico
                                    images/tray_icon.png)
foreach(static_resource_file ${static_bitshares_resource_files})
  get_filename_component(static_resource_file_path "${static_resource_file}" DIRECTORY)
  set(PRE_BUILD_STEP_COMMANDS ${PRE_BUILD_STEP_COMMANDS}
      COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_CURRENT_BINARY_DIR}/${static_resource_file_path}"
      COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/${static_resource_file}" "${CMAKE_CURRENT_BINARY_DIR}/${static_resource_file_path}")
endforeach()
...
ADD_CUSTOM_COMMAND(TARGET ${APP_NAME} PRE_BUILD ${PRE_BUILD_STEP_COMMANDS} 
  COMMENT "Copying static resource files to build directory."
)

Based on my limited understanding, it is supposed to copy the image files over to the build folder prior to the dependencies of the BitSharesX target running. This is because one of its dependencies, the programs/qt_wallet/qrc_bitshares.cpp target, needs to have the images in the same folder as the bitshares.qrc file for Qt's resource compiler to work.

However, when I tried running the build in a separate build folder, it does not appear to copy those image files from the source directory to the build directory before the programs/qt_wallet/qrc_bitshares.cpp target runs. This results in the following error during the build process:

...
[ 94%] Built target buildweb
make[2]: *** No rule to make target `programs/qt_wallet/images/splash_screen.jpg', needed by `programs/qt_wallet/qrc_bitshares.cpp'.  Stop.
make[1]: *** [programs/qt_wallet/CMakeFiles/BitSharesX.dir/all] Error 2
make: *** [all] Error 2

instead of the expected:

...
[ 94%] Built target buildweb
[ 94%] Generating qrc_bitshares.cpp
Scanning dependencies of target BitSharesX
[ 94%] Building CXX object programs/qt_wallet/CMakeFiles/BitSharesX.dir/qrc_bitshares.cpp.o
...

Manually copying the images folder from source directory to the build directory before running make allowed me to successfully build the binary, but obviously the proper solution requires fixing the problem in the CMake script.

@vikramrajkumar
Copy link
Contributor

Is this fixed by 77d3e8f ?

@emfrias
Copy link
Contributor

emfrias commented Sep 22, 2014

The CMake rules work for windows, but apparently not for anywhere else. According to the CMake manual, PRE_BUILD steps are actually executed as "pre-link" steps on UNIX, and that probably doesn't happen until after the resource compiler is run. We'll probably need more complicated rules to do this right.

@arhag
Copy link
Author

arhag commented Sep 22, 2014

Is this fixed by 77d3e8f ?

Nope. I have those changes, and for some reason the resulting Makefile doesn't do what it is supposed to. By the way, why not just have CMake copy the images itself just like it is done with bitshares.qrc in:

file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/bitshares.qrc" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")

instead of depending on the Makefile to do it?

@emfrias
Copy link
Contributor

emfrias commented Sep 22, 2014

The files need to be copied whenever they change--if you modify the splash screen and then run make, it should build you a version of BitSharesX with the new splash screen. If you just have CMake do it, it will only copy the files over whenever you run CMake. Sometimes that will do the right thing, but often you won't see your changes and have no idea why.

emfrias added a commit that referenced this issue Sep 22, 2014
…y to make them work on unix as well as windows (only tested for windows out-of-tree builds, but cmake is cross-platform, right?)

#52
@nathanielhourt
Copy link
Contributor

This is only an issue for out-of-source builds. Just do an in-source build and you'll be fine.

@arhag
Copy link
Author

arhag commented Sep 22, 2014

@nathanhourt, well sure (or just copy the images folder manually like I did to build), but out-of-source builds should automatically work too.

@emfrias, I tried out the changes in your commit (6cb3742) on my Linux machine and it solved the problem. Thanks. Should I close this issue?

@nathanielhourt
Copy link
Contributor

Seems to be resolved.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants