How does qmake handle this conflict of resource names? The QT4_MAKE_OUTPUT_FILE() part looks fine to me.
However, have you considered an alternative to string(RANDOM LENGTH 16 outfilename) which is to allow the caller to pass in the "-name ..." option. qt4_add_resources(app_source_res res_a.qrc OPTIONS -name res_a) qt4_add_resources(app_source_res res_b.qrc OPTIONS -name res_b) If the caller needs truly random names, the caller could still do a string(RANDOM ...). Clint On Tuesday, November 24, 2015 11:01:27 AM Joseph Shen wrote: > Dear CMake developers: > > Please view attached small patch that try to fix Qt4Macros generate > resources with same file name error. > > Right now, in the CMake main branch, using cmake with Qt4 library > add resources project can be done like this: > > qt4_add_resources(app_source_res res_a.qrc) > qt4_add_resources(app_source_res res_b.qrc) > > and above two line added two resource file, but if we try to add resource > file with same name, a very subtle error will happen: only one file will > be compile the as resources, and the other was totally ignored. > > In some big projects, using the same file name as resource file name > can be very common, especially when we using multi cmake files try > to make the whole project into small ones, in each cmake files someone > maybe just using the same resources file name like res.qrc which is > located in the sub module resources folder. > > qt4_add_resources(app_source_res res.qrc) > > so, if they try to do this, and in the last add ${app_source_res} to the > dependency list using: > > add_executable(project_name ${app_source_res} ...) > > but in reality they just add one resources file, but CMake do not report > any error or warning. > > From the source of Qt4Macros we can see: > > line 211: get_filename_component(outfilename ${it} NAME_WE) > line 244: ARGS ${rcc_options} -name ${outfilename} -o ${outfile} ${infile} > > > became we just using NAME_WE as the output file, if two files with same > file name, one will overwrite the other, and this is the reason why the > error > will happen. > > To fix this, I view the whole Qt4Macros source file, find a function > QT4_MAKE_OUTPUT_FILE already exist to do something just what we > need. so I work out a patch add two line code and remove two, and it works > good to me, and I think this might fix the problem. > > Please view this patch, thanks :) -- 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: http://public.kitware.com/mailman/listinfo/cmake-developers