On 05/21/2018 04:41 PM, Richard Kimberly Heck wrote: >> >> > > > I seem to have windres, actually, though under a slightly different >> >> > > >> >> > > > name. It's part of the mingw32-binutils package, but is >> installed as >> >> > > >> >> > > > /usr/bin/i686-w64-mingw32-windres. There is code in >> CMakeLists.txt to >> >> > > >> >> > > > set this, and it seems to work: >> >> > > >> >> > > > >> >> > > >> >> > > > build/CMakeFiles/3.11.0/CMakeRCCompiler.cmake:set(CMAKE_RC_COMPILER >> >> > > >> >> > > > "/usr/bin/i686-w64-mingw32-windres") >> >> > > >> >> > > > >> >> > > >> >> > > > But it doesn't seem to get used anywhere. >> >> > > >> >> > > > >> >> > > >> >> > > > I guess all we need to do now is figure out where and how to >> invoke this >> >> > > >> >> > > > to build a resource file from /development/cmake/lyx.rc. The >> link that >> >> > > >> >> > > > Jürgen found suggests we need somthing like: >> >> > > >> >> > > > >> >> > > >> >> > > > ${CMAKE_RC_COMPILER} -O coff -i development/cmake/lyx.rc -o >> lyx.coff >> >> > > >> >> > > > >> >> > > >> >> > > > and then to link the lyx.coff file into the executable. >> >> > > >> >> > > > >> >> > > >> >> > > > Riki >> >> > > >> >> > > > >> >> > > >> >> > > >> >> > > >> >> > > I found it too, but unfortunately it is not working. >> >> > > >> >> > > 1.) The RC-compiler grumbles about not able to find "config.h". >> >> > > >> >> > > 2.) Copying this file to '.' does not help either. This time because >> >> > > of undefined resource. >> >> > > >> >> > > 3.) /usr/bin/i686-w64-mingw32-windres --help does not give me a clue >> >> > > about the correct >> >> > > >> >> > > settings to be used. >> >> > > >> >> > > >> >> > > >> >> > > I gave up. >> >> > > >> >> > >> >> > I had to change the lyx.rc file to use "/" instead of "\". >> Otherwise, of >> >> > course, it fails to find the icon file. But then I do get lyx.coff >> >> > (which I'm attaching in case you need to use it for testing). Now >> how to >> >> > link it into the main executable? (Well, and longer term, how to build >> >> > it automatically, though we could just put lyx.coff into >> >> > development/cmake/, too.) >> >> > >> >> > Riki >> >> > >> >> >> >> I still get >> >> i686-w64-mingw32-windres: no resources >> >> src/CMakeFiles/LyX.dir/build.make:1531: recipe for target >> 'src/CMakeFiles/LyX.dir/__/development/cmake/lyx.rc.res' failed >> >> >> >> What is this file 'lyx.coff' you write about, and how is it created? >> > > GNU ld can't handle the res format, but it can handle coff apparently, > so you have to pass "-O coff" to windres to get it to build this. (The > `file' command says: Intel 80386 COFF object file.) Assuming it was > built right, I think we can just put it into our sources. It shouldn't > change unless either lyx.rc does or the icon itself does. > > The attached defines FILE_RC as needed. I think all that's left is to > arrange for this to be linked into the binary. See e.g. > > https://stackoverflow.com/questions/708238/how-do-i-add-an-icon-to-a-mingw-gcc-compiled-executable
The attached patch seems like it should link the coff file, and I see: src/CMakeFiles/LyX2.3.dir/linklibs.rsp:../bin/libmathed.a ../bin/libinsets.a ../bin/libfrontends.a ../bin/libfrontend_qt.a ../bin/libgraphics.a ../bin/libsupport.a **/home/rikiheck/cvs/lyx/lyx-windows/development/cmake/lyx.coff** ../bin/libmytheslibstatic.a /usr/i686-w64-mingw32/sys-root/mingw/bin/iconv.dll /usr/i686-w64-mingw32/sys-root/mingw/lib/libqt5main.a ../bin/libhunspell.a -lole32 ../bin/libfrontends.a /usr/i686-w64-mingw32/sys-root/mingw/lib/libQt5Concurrent.dll.a /usr/i686-w64-mingw32/sys-root/mingw/lib/libQt5Svg.dll.a /usr/i686-w64-mingw32/sys-root/mingw/lib/libQt5Widgets.dll.a /usr/i686-w64-mingw32/sys-root/mingw/lib/libQt5WinExtras.dll.a -lgdi32 /usr/i686-w64-mingw32/sys-root/mingw/lib/libQt5Gui.dll.a /usr/i686-w64-mingw32/sys-root/mingw/lib/libQt5Core.dll.a -lz -lshlwapi -lpsapi -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 so it looks like it should be in there. But it doesn't give me the icon when I install it. I suspect that the lyx.coff file I generated isn't right, but I'm not sure what to try now. Riki
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4062420053..210ff7b214 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -96,11 +96,12 @@ endif() if(WIN32) if (MINGW) - set(FILE_RC ${TOP_CMAKE_PATH}/lyx.coff) + set(FILE_RC_COMPILED ${TOP_CMAKE_PATH}/lyx.coff) + message(STATUS "Using icon defined in resource file: ${FILE_RC_COMPILED}") else() set(FILE_RC ${TOP_CMAKE_PATH}/lyx.rc) + message(STATUS "Using icon defined in resource file: ${FILE_RC}") endif() - message(STATUS "Using icon defined in resource file: ${FILE_RC}") endif() lyx_find_info_files(LyXInfoFiles ${TOP_SRC_DIR}/*) @@ -136,7 +137,7 @@ target_link_libraries(${_lyx} frontend_qt graphics support - ${FILE_RC} + ${FILE_RC_COMPILED} ${MYTHESLIB_LIBRARY} ${ICONV_LIBRARY} ${LYX_QTMAIN_LIBRARY}