wxButton flickering on the screen, CMake resource file with MINGw Topic is solved
Re: wxButton flickering on the screen, CMake resource file with MINGw
I've tried to build a project with you .bat file provided, however still got the same issue: wx/msw/wx.rc no such file or directory
Re: wxButton flickering on the screen, CMake resource file with MINGw
But you wrote before that my project worked for you?
Is the file actually there (i.e., in WXDIR/include/wx/msw).
Do you still do the odd things for resources as you posted or do you just what I did (assuming my unmodified CMakefile worked for you), i.e., nothing except adding your .rc file to the sources list for the executable.
EDIT
I missed your post on the previous page. You seem to be using MSYS2 shell/CMake, I have no experience with it, always using Windows command line (albeit compiler toolchain from MSYS2 package) and "normal" CMake myself. I would assume that with MSYS2 should you not be using "MSYS makefiles" instead of "MinGW makefiles" generator but I guess that is not true (or matters).
Is the file actually there (i.e., in WXDIR/include/wx/msw).
Do you still do the odd things for resources as you posted or do you just what I did (assuming my unmodified CMakefile worked for you), i.e., nothing except adding your .rc file to the sources list for the executable.
EDIT
I missed your post on the previous page. You seem to be using MSYS2 shell/CMake, I have no experience with it, always using Windows command line (albeit compiler toolchain from MSYS2 package) and "normal" CMake myself. I would assume that with MSYS2 should you not be using "MSYS makefiles" instead of "MinGW makefiles" generator but I guess that is not true (or matters).
Re: wxButton flickering on the screen, CMake resource file with MINGw
Everything that passed to target executable is just .cpp and .c files. Yes, I mean your project worked on my computer just unpacked him and it's fine. However, if I'm trying to build my project with .bat file you've provided, it's fails with the same error. And, unfortunately, I guess, shell is doesn't matter when passing the same command to executable. I'm running out of ideas. All files are there for sure, double-checked. If I'm moving wx folder to my cmakelists location I got another error: rcdefs.h no such file or directory.
Re: wxButton flickering on the screen, CMake resource file with MINGw
The bat file should be irrelevant, it is CMakefile that matters. As I wrote, the only difference I can think of is between MSYS2 shell/compilers you (probably) use and Windows command line used in my project.
You still also did not answer my important questions about your CMakefile, i.e. did you try without all that resource-related stuff you posted before or not? Sorry, but I hate to ask the same question again and again, and I already did several times in this thread...
Re: wxButton flickering on the screen, CMake resource file with MINGw
I'm sorry for misunderstanding. Yes, I have a cmakefile where I pass sources only for example, or did like your file. But still I have that issue, maybe cause of directories. My cmakelists in one directory, when wxwidgets is in another completely, however it should be totally fine.
I tried different combinations. Maybe print some messages for a little debugging, but not so sure where to look
I tried different combinations. Maybe print some messages for a little debugging, but not so sure where to look
Re: wxButton flickering on the screen, CMake resource file with MINGw
So I have wxWidgets located in following directory:
Project/target/lib/wxWidgets
also in target I have main code for my app, like MainFrame.cpp, ChildView.cpp, Project.cpp and etc.
Cmakelists is in
Project/cmake_configs
I am passing this source files by this .cmake file that I including in my main CMakeLists.txt with include(target_src.cmake)
Maybe this is interferring some how with wxWidgets including, but I am not so sure
Don't mind add_custom_target, it's has no impact on my result
Project/target/lib/wxWidgets
also in target I have main code for my app, like MainFrame.cpp, ChildView.cpp, Project.cpp and etc.
Cmakelists is in
Project/cmake_configs
I am passing this source files by this .cmake file that I including in my main CMakeLists.txt with include(target_src.cmake)
Code: Select all
set(TARGET_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../target")
file(GLOB TRGT_CPP_FILES
${TARGET_PATH}/*.cpp
${TARGET_PATH}/Render/*.cpp
${TARGET_PATH}/win_thread/*.c)
file(GLOB TRGT_H_FILES
${TARGET_PATH}/*.h
${TARGET_PATH}/win_thread/*.h)
include_directories(
${TARGET_PATH}/Render
${TARGET_PATH}/win_thread
${TARGET_PATH}
)
add_custom_target(COPY_RESOURCES ALL
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_SOURCE_DIR}/../glew
${CMAKE_SOURCE_DIR}/../build)
Don't mind add_custom_target, it's has no impact on my result
Re: wxButton flickering on the screen, CMake resource file with MINGw
I have an output in console after compiling project.rc.obj saying like Too long command line.
What to do with that? Seeing it first time in my life
Also I'm interested, how does your app launches a GUI and console at the same time, I thought that impossible.
What to do with that? Seeing it first time in my life
Also I'm interested, how does your app launches a GUI and console at the same time, I thought that impossible.
Re: wxButton flickering on the screen, CMake resource file with MINGw
I think we are going nowhere and I am afraid I am unable to help you: I guess I lack both knowledge and ability to explain myself properly.
The above adds the application .rc file (which includes wx/wx.rc) to the list of the source files later passed to add_executable().
The above ensures that application manifest claiming support for Per Monitor V2 DPI-awareness is used.
I asked about Windows resource related code (without all that complicated stuff, as I wrote, the two lines used in my CMake should be enough, see below), yet there was none there?
Code: Select all
set(SRC_FILES minimal.cpp minimal.rc)
Code: Select all
target_compile_definitions(${PROJECT_NAME} PRIVATE wxUSE_DPI_AWARE_MANIFEST=2)
AFAIK, Windows command line length limit is about 8k characters: Are you really hitting it? You never posted your build commands (e.g., to see what paths are passed to the GCC resource compiler - windres). Anyway, I thought CMake should be able to work around the limit using response files? If it cannot automatically, did you try setting those (undocumented?) CMAKE_*_USE_RESPONSE_FILE_* variables you can find on the web (e.g., here). That assumes your paths are correct and really cannot be shorter (e.g., the folder depth decreased, not using absolute paths for compiler tools...). But once again, I have little CMake knowledge.
This is default for MinGW, unless you pass "-mwindows" to the linker.
Re: wxButton flickering on the screen, CMake resource file with MINGw
So this is the output I have when configuring CMakeLists.TXT
This is my .rc file content:
I am including this file like
And then add it to my target_executable
This is my error output when trying to build project (its build everything except project.rc.obj)
Setting up this variables doesn't help, cause I have no specified toolchain file for CMake
Also, one more thing.
When I have this code in my CMakeLists.txt or another .cmake file
I'm getting slightly different output
If I'm inserting this code to setup a specified windres compiler for resource file in a project you sent me, I have the same issue like wx.rc couldn't be found. So your project works fine without that if(MINGW) stuff relate, so I'm thinking that's not a key to the solution.
That's the output of building your project with my tools and CMake
Thank you for your patience and fast response, I do really appreciate that.
Code: Select all
[proc] Executing command: C:/software/mingw64/bin/cmake.exe --no-warn-unused-cli -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_CXX_COMPILER:FILEPATH=C:/software/mingw64/bin/g++.exe -DCMAKE_C_COMPILER:FILEPATH=C:/software/mingw64/bin/gcc.exe -SD:/Users/user/Desktop/cmake_test/project_name/shell/CMake/cmake_configs -Bd:/Users/user/Desktop/cmake_test/project_name/shell/CMake/build -G "MinGW Makefiles"
[cmake] Not searching for unused variables given on the command line.
[cmake] -- The C compiler identification is GNU 13.2.0
[cmake] -- The CXX compiler identification is GNU 13.2.0
[cmake] -- Detecting C compiler ABI info
[cmake] -- Detecting C compiler ABI info - done
[cmake] -- Check for working C compiler: C:/software/mingw64/bin/gcc.exe - skipped
[cmake] -- Detecting C compile features
[cmake] -- Detecting C compile features - done
[cmake] -- Detecting CXX compiler ABI info
[cmake] -- Detecting CXX compiler ABI info - done
[cmake] -- Check for working CXX compiler: C:/software/mingw64/bin/g++.exe - skipped
[cmake] -- Detecting CXX compile features
[cmake] -- Detecting CXX compile features - done
[cmake] -- Found OpenGL: opengl32
[cmake] -- Found wxWidgets: D:/Users/user/Desktop/cmake_test/project_name/shell/CMake/target/lib/wxWidgets/lib/gcc_x64_lib/libwxmsw32ud_aui.a;D:/Users/user/Desktop/cmake_test/project_name/shell/CMake/target/lib/wxWidgets/lib/gcc_x64_lib/libwxmsw32ud_core.a;D:/Users/user/Desktop/cmake_test/project_name/shell/CMake/target/lib/wxWidgets/lib/gcc_x64_lib/libwxbase32ud.a;D:/Users/user/Desktop/cmake_test/project_name/shell/CMake/target/lib/wxWidgets/lib/gcc_x64_lib/libwxpngd.a;D:/Users/user/Desktop/cmake_test/project_name/shell/CMake/target/lib/wxWidgets/lib/gcc_x64_lib/libwxtiffd.a;D:/Users/user/Desktop/cmake_test/project_name/shell/CMake/target/lib/wxWidgets/lib/gcc_x64_lib/libwxjpegd.a;D:/Users/user/Desktop/cmake_test/project_name/shell/CMake/target/lib/wxWidgets/lib/gcc_x64_lib/libwxzlibd.a;D:/Users/user/Desktop/cmake_test/project_name/shell/CMake/target/lib/wxWidgets/lib/gcc_x64_lib/libwxregexud.a;D:/Users/user/Desktop/cmake_test/project_name/shell/CMake/target/lib/wxWidgets/lib/gcc_x64_lib/libwxexpatd.a;winmm;comctl32;uuid;oleacc;uxtheme;rpcrt4;shlwapi;version;wsock32 (found version "3.2.3") found components: aui core base png tiff jpeg zlib regex expat
[cmake] -- Configuring done (1.8s)
[cmake] -- Generating done (0.2s)
[cmake] -- Build files have been written to: D:/Users/user/Desktop/cmake_test/project_name/shell/CMake/build
Code: Select all
#include "wx/msw/wx.rc"
#include "windows.h"
#define wxUSE_RC_MANIFEST 1
#define wxUSE_DPI_AWARE_MANIFEST 2
Code: Select all
set(RC_FILE project.rc)
Code: Select all
add_executable(${PROJECT_NAME} ${TRGT_CPP_FILES} ${FPO_C_FILES} ${SLPO_C_FILES} ${RC_FILE})
Code: Select all
[build] Starting build
[proc] Executing command: C:/software/mingw64/bin/cmake.exe --build d:/Users/user/Desktop/cmake_test/project_name/shell/CMake/build --config Debug --target all -j 16 --
[build] [ 0%] Built target COPY_RESOURCES
[build] [ 0%] Building RC object CMakeFiles/Vima_WX.dir/project.rc.obj
[build] Too long command line.
[build] C:\software\mingw64\bin\windres.exe: preprocessing failed.
[build] mingw32-make[2]: *** [CMakeFiles\Vima_WX.dir\build.make:6209: CMakeFiles/Vima_WX.dir/project.rc.obj] Error 1
[build] mingw32-make[1]: *** [CMakeFiles\Makefile2:110: CMakeFiles/Vima_WX.dir/all] Error 2
[build] mingw32-make: *** [Makefile:90: all] Error 2
[proc] The command: C:/software/mingw64/bin/cmake.exe --build d:/Users/user/Desktop/cmake_test/project_name/shell/CMake/build --config Debug --target all -j 16 -- exited with code: 2
[driver] Build completed: 00:00:01.713
[build] Build finished with exit code 2
Code: Select all
set(CMAKE_C_USE_RESPONSE_FILE_FOR_INCLUDES 1)
set(CMAKE_CXX_USE_RESPONSE_FILE_FOR_INCLUDES 1)
set(CMAKE_C_USE_RESPONSE_FILE_FOR_LIBRARIES 1)
set(CMAKE_CXX_USE_RESPONSE_FILE_FOR_LIBRARIES 1)
set(CMAKE_C_USE_RESPONSE_FILE_FOR_OBJECTS 1)
set(CMAKE_CXX_USE_RESPONSE_FILE_FOR_OBJECTS 1)
When I have this code in my CMakeLists.txt or another .cmake file
Code: Select all
if (MINGW)
set(CMAKE_RC_COMPILER_INIT windres)
ENABLE_LANGUAGE(RC)
SET(CMAKE_RC_COMPILE_OBJECT
"<CMAKE_RC_COMPILER> <DEFINES> -i <SOURCE> -o <OBJECT>")
endif(MINGW)
Code: Select all
[build] Starting build
[proc] Executing command: C:/software/mingw64/bin/cmake.exe --build d:/Users/user/Desktop/cmake_test/project_name/shell/CMake/build --config Debug --target all -j 16 --
[build] [ 0%] Built target COPY_RESOURCES
[build] [ 0%] Building RC object CMakeFiles/Vima_WX.dir/project.rc.obj
[build] D:\Users\user\Desktop\cmake_test\project_name\shell\CMake\cmake_configs\project.rc:1:10: fatal error: wx/msw/wx.rc: No such file or directory
[build] 1 | #include "wx/msw/wx.rc"
[build] | ^~~~~~~~~~~~~~
[build] compilation terminated.
[build] C:\software\mingw64\bin\windres.exe: preprocessing failed.
[build] mingw32-make[2]: *** [CMakeFiles\Vima_WX.dir\build.make:6209: CMakeFiles/Vima_WX.dir/project.rc.obj] Error 1
[build] mingw32-make[1]: *** [CMakeFiles\Makefile2:110: CMakeFiles/Vima_WX.dir/all] Error 2
[build] mingw32-make: *** [Makefile:90: all] Error 2
[proc] The command: C:/software/mingw64/bin/cmake.exe --build d:/Users/user/Desktop/cmake_test/project_name/shell/CMake/build --config Debug --target all -j 16 -- exited with code: 2
[driver] Build completed: 00:00:01.464
[build] Build finished with exit code 2
That's the output of building your project with my tools and CMake
Code: Select all
[main] Building folder: testresource-cmake
[main] The folder containing the CMake cache is missing. The cache will be regenerated.
[main] Configuring project: testresource-cmake
[proc] Executing command: C:\software\mingw64\bin\cmake.EXE --no-warn-unused-cli -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_CXX_COMPILER:FILEPATH=C:/software/mingw64/bin/g++.exe -DCMAKE_C_COMPILER:FILEPATH=C:/software/mingw64/bin/gcc.exe -SD:/Users/user/Desktop/testresource-cmake -Bd:/Users/user/Desktop/testresource-cmake/build -G Ninja
[cmake] Not searching for unused variables given on the command line.
[cmake] -- The C compiler identification is GNU 13.2.0
[cmake] -- The CXX compiler identification is GNU 13.2.0
[cmake] -- Detecting C compiler ABI info
[cmake] -- Detecting C compiler ABI info - done
[cmake] -- Check for working C compiler: C:/software/mingw64/bin/gcc.exe - skipped
[cmake] -- Detecting C compile features
[cmake] -- Detecting C compile features - done
[cmake] -- Detecting CXX compiler ABI info
[cmake] -- Detecting CXX compiler ABI info - done
[cmake] -- Check for working CXX compiler: C:/software/mingw64/bin/g++.exe - skipped
[cmake] -- Detecting CXX compile features
[cmake] -- Detecting CXX compile features - done
[cmake] -- Found wxWidgets: D:/Users/user/Desktop/testresource-cmake/wxWidgets/lib/gcc_x64_lib/libwxmsw32ud_core.a;D:/Users/user/Desktop/testresource-cmake/wxWidgets/lib/gcc_x64_lib/libwxbase32ud.a;D:/Users/user/Desktop/testresource-cmake/wxWidgets/lib/gcc_x64_lib/libwxpngd.a;D:/Users/user/Desktop/testresource-cmake/wxWidgets/lib/gcc_x64_lib/libwxtiffd.a;D:/Users/user/Desktop/testresource-cmake/wxWidgets/lib/gcc_x64_lib/libwxjpegd.a;D:/Users/user/Desktop/testresource-cmake/wxWidgets/lib/gcc_x64_lib/libwxzlibd.a;D:/Users/user/Desktop/testresource-cmake/wxWidgets/lib/gcc_x64_lib/libwxregexud.a;D:/Users/user/Desktop/testresource-cmake/wxWidgets/lib/gcc_x64_lib/libwxexpatd.a;winmm;comctl32;uuid;oleacc;uxtheme;rpcrt4;shlwapi;version;wsock32 (found version "3.2.3") found components: core base png tiff jpeg zlib regex expat
[cmake] -- Configuring done (1.5s)
[cmake] -- Generating done (0.0s)
[cmake] -- Build files have been written to: D:/Users/user/Desktop/testresource-cmake/build
[build] Starting build
[proc] Executing command: C:\software\mingw64\bin\cmake.EXE --build d:/Users/user/Desktop/testresource-cmake/build --config Debug --target all --
[build] [2/3 33% :: 0.140] Building RC object CMakeFiles/minimal.dir/minimal.rc.obj
[build] [2/3 66% :: 3.226] Building CXX object CMakeFiles/minimal.dir/minimal.cpp.obj
[build] [3/3 100% :: 16.256] Linking CXX executable minimal.exe
[driver] Build completed: 00:00:16.310
[build] Build finished with exit code 0
Last edited by cortes707 on Tue Nov 21, 2023 3:35 pm, edited 1 time in total.
Re: wxButton flickering on the screen, CMake resource file with MINGw
IMO, your library path is extremely and unnecessarily long. I do understand that being unable to use exactly the folder structure one wants is annoying, but unfortunately, it is what it is.cortes707 wrote: ↑Tue Nov 21, 2023 5:34 am So this is the output I have when configuring CMakeLists.TXTCode: Select all
[cmake] -- Found wxWidgets: D:/Users/emelyanovki/Desktop/cmake_test/uts_800_dev_fpo/shell/CMake/target/lib/wxWidgets/lib/gcc_x64_lib
Firstly, this is incorrect as those wxUSE_* must be defined before wx.rc is included. Secondly, I may remember it wrong, but I think at least one .rc compiler (between MSVC's , GCC's, and clang's) did not like defines like that in the .rc file. Anyway, wxUSE_RC_MANIFEST is on by default with MinGW and I would recommend setting wxUSE_DPI_AWARE_MANIFEST the same way I did in my example project, i.e., as a cmake target definition.cortes707 wrote: ↑Tue Nov 21, 2023 5:34 am This is my .rc file content:Code: Select all
#include "wx/msw/wx.rc" #include "windows.h" #define wxUSE_RC_MANIFEST 1 #define wxUSE_DPI_AWARE_MANIFEST 2
Unfortunately, we do not get to see the actual build commands used.
Regarding the windres preprocessing failure, this may be caused by what I wrote above about preprocessor directives in .rc file (but probably by not finding wx.rc), I would still remove them both to see if it helps.
For the third (?) time: Why do you do all that? Just adding .rc file should be enough. I think when you mess with .rc compiler settings like this, the wxWidgets include paths are not passed to it.cortes707 wrote: ↑Tue Nov 21, 2023 5:34 am When I have this code in my CMakeLists.txt or another .cmake fileCode: Select all
if (MINGW) set(CMAKE_RC_COMPILER_INIT windres) ...
Re: wxButton flickering on the screen, CMake resource file with MINGw
Yeah, I removed defines in .rc file and put it like you did. However, still it's doesn't matter cause compiler fails on reading .rc file already on the first line.
Next, what's the way I could show you exact build command?
As I mentioned before, if I'm not using construction with defining RC_compiler I have a error saying too long command line, and still error2 preprocessing failed.
Next, what's the way I could show you exact build command?
As I mentioned before, if I'm not using construction with defining RC_compiler I have a error saying too long command line, and still error2 preprocessing failed.
Re: wxButton flickering on the screen, CMake resource file with MINGw
Well, perhaps you do not get the long command line error doing the odd stuff because you are not passing the include paths to windres and thus wx.rc is not found.
Cursory Google search revealed that CMake has "--verbose" parameter.
Anyway, I am out of ideas. Perhaps start a topic with a relevant title, summarizing the issue and hope someone else may be able to help.
Re: wxButton flickering on the screen, CMake resource file with MINGw
I got the issue. So I have a file with include_directories(...) called like on really a lot of directories. When I'm including this file and them I got that issue too long command line. Without this including .rc object compiles okay, however, this directories are necessary for my project. I guess that's not a problem of wxWidgets and other stuff anymore, more likely CMake related
Re: wxButton flickering on the screen, CMake resource file with MINGw
Hi,
How big is the full path and the file name? Can you reduce it?
If it's some kind of external library - see if can reinstall it to a different place.
Thank you.
How big is the full path and the file name? Can you reduce it?
If it's some kind of external library - see if can reinstall it to a different place.
Thank you.
Re: wxButton flickering on the screen, CMake resource file with MINGw
I have little doubt that is a CMake issue. When running cmake from the .bat file in my example project posted ITT, with added --verbose parameter, it is apparent it automatically uses response files for c++.exe but not windres.exe:
vsC:\msys64\ucrt64\bin\c++.exe -DUNICODE -D_UNICODE -DwxUSE_DPI_AWARE_MANIFEST=2 @CMakeFiles/minimal.dir/includes_CXX.rsp -g -MD -MT CMakeFiles/minimal.dir/minimal.cpp.obj -MF CMakeFiles\minimal.dir\minimal.cpp.obj.d -o CMakeFiles\minimal.dir\minimal.cpp.obj -c D:\Dev\Desktop\wxPokusy\_forum\testresource-cmake\minimal.cpp
Based on Google search, it seems to be known but unresolved CMake issue. I assume you have known that all the time, hence your "odd" resource CMake code which I did not understand the purpose of, until now.C:\msys64\ucrt64\bin\windres.exe -O coff -DUNICODE -D_UNICODE -DwxUSE_DPI_AWARE_MANIFEST=2 -I D:\Dev\Desktop\Lib\wxWidgets-3.2.4\lib\gcc_lib\mswu -I D:\Dev\Desktop\Lib\wxWidgets-3.2.4\include D:\Dev\Desktop\wxPokusy\_forum\testresource-cmake\minimal.rc CMakeFiles\minimal.dir\minimal.rc.obj
EDIT
There may be a reason why CMake does not support response files for windres. I created extremely long includes and passed CMake "-DCMAKE_RC_USE_RESPONSE_FILE_FOR_INCLUDES=ON". CMake did use a response file for windres, yet windres still failed:
The .rsp file for resource compiler is almost identical to that of c++ compiler (the former has a space after -I and does not use "system" for wxWidgets path).C:\msys64\ucrt64\bin\windres.exe -O coff -DUNICODE -D_UNICODE -DwxUSE_DPI_AWARE_MANIFEST=2 @CMakeFiles/minimal.dir/includes_RC.rsp D:\Dev\Desktop\wxPokusy\_forum\testresource-cmake\minimal.rc CMakeFiles\minimal.dir\minimal.rc.obj
The command line is too long.
C:\msys64\ucrt64\bin\windres.exe: preprocessing failed.
When I made the includes in includes_RC.rsp shorter enough, windres compiled the resource using the response file just fine. So I think, in the end, it is windres issue and should be reported there (assuming there is not an existing ticket already there).
EDIT 2
I was able to find a workaround that worked for me, but I am using self-built wxWidgets, not MSYS2 package (which I think you do).
I just used your attempt at the workaround but added a define ensuring the expected manifest is used and set wxWidgets include path (and removed the two lines I thought unnecessary now), see also the attached full project:
Code: Select all
if(MINGW)
SET(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> -O coff -DwxUSE_DPI_AWARE_MANIFEST=2 -I \"${wxWidgets_ROOT_DIR}/include\" -i <SOURCE> -o <OBJECT>")
endif(MINGW)
The solution may not be ideal and future-proof, but it worked for me and I could not figure a better one (aside from actually making the paths shorter, i.e., the project folder structure not so deep).
- Attachments
-
- testresource-cmake2.zip
- (109.67 KiB) Downloaded 20 times