About new CMake FindwxWidgets module

138 views
Skip to first unread message

PB

unread,
Jul 5, 2022, 4:18:07 PM7/5/22
to wx-dev
Hi,

I do understand that FindwxWidgets.cmake is maintaned by Kitware, but as its recent changes were made by Maarten, I think this issue will be more visible posted here.


However, after doing that, when trying to configure a project using CMake with MinGW Makefiles generator, it cannot find wxWidgets libraries I built with gcc makefile bundled with wxWidgets, in %WXWIN%/lib/gcc_lib nor %WXWIN%/lib/gcc_dll.

I get this error

CMake Error at C:/Program Files/CMake/share/cmake-3.23/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
Could NOT find wxWidgets (missing: wxWidgets_LIBRARIES
wxWidgets_INCLUDE_DIRS) (Required is at least version "3.1")
Call Stack (most recent call first):
C:/Program Files/CMake/share/cmake-3.23/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
C:/Program Files/CMake/share/cmake-3.23/Modules/FindwxWidgets.cmake:984 (find_package_handle_standard_args)
CMakeLists.txt:27 (find_package)

and I did not find anything useful in CMakeOutput.log.

The odd thing is it cannot find wxWidgets regardless of WXWIN pointing to 3.2.0 or 3.1.7 wxWidgets installation, where 3.1.7 can be found with the original module.

Both old and new modules work with wxWidgets 3.1.7 and 3.2.0 built with msvc makefile bundled with wxWidgets when using CMake's Visual Studio 17 2022 generator (libraries in %WXWIN%/lib/vc_x64_lib and %WXWIN%/lib/vc_x64_dll).

Am I doing something wrong?

Thanks,
PB

Maarten Bent

unread,
Jul 5, 2022, 4:23:33 PM7/5/22
to wx-...@googlegroups.com
Could it be a caused by this previous change to the module?
It seems someone switched the search mode to using wx-config...
https://gitlab.kitware.com/cmake/cmake/-/commit/6fac8af9ca315f4dc71677b5d88d62c056e8cb9d

Maarten
--
You received this message because you are subscribed to the Google Groups "wx-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wx-dev+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/wx-dev/54702858-79ef-423d-9d5c-c12723c3730dn%40googlegroups.com.

PB

unread,
Jul 5, 2022, 4:41:55 PM7/5/22
to wx-dev
Maarten,

thanks for the quick reply. You were right, it is that change - it starts working when I revert it.

I actually noticed the check when looking at the module, found it odd but thought it was already there before, when it still worked.

I consider switching to unix find mode under MINGW incorrect, there is no wx-config bundled either with wxWidgets nor MinGW and it breaks builds that are setup correctly and worked before.

I believe the change needs to be reverted or explained why it is supposed to be correct. IMO, "It did not work for me without it" is not a valid reason for such (or any) change.

Do you (all) have an opinion on this?

Best,
PB


Maarten Bent

unread,
Jul 5, 2022, 5:53:17 PM7/5/22
to wx-...@googlegroups.com
I think MinGW should use win32 search mode, so it will be able to find installations created with the makefiles. This will now be broken when updating from CMake 3.23 to 3.24(RC).
But it would also be nice if it could find installations that have been built with configure, and have a wx-config available.
So I tried to enable both using the attached diff to FindwxWidgets.

Maarten
--
You received this message because you are subscribed to the Google Groups "wx-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wx-dev+un...@googlegroups.com.
FindwxWidgets.diff

PB

unread,
Jul 5, 2022, 6:15:24 PM7/5/22
to wx-dev
Maarten,

once again, thanks for the quick reply and actual code.

Unfortunately, I have to admit I failed to patch my CMake module so I could not try it.

But just looking at the diff: I am not sure if switching the find mode to unix when wxWidgets are not found with win32 will preserve the working module behaviour.

With the working module, when wxWidgets are not found, I can in CMakeGUI select a folder (wxWidgets_ROOT_DIR and wxWidgets_LIB_DIR) where to find them. Will this still work?  With the most-recent module this is not possible, those variables are not exposed in unix find mode.

I also do not understand the added if(TRUE) part but I guess it is not important here.

Best,
PB

Maarten Bent

unread,
Jul 5, 2022, 6:46:56 PM7/5/22
to wx-...@googlegroups.com
It will still use wxWidgets_ROOT_DIR and wxWidgets_LIB_DIR, because every time you click configure in cmake-gui, it tries the win32 search mode (the original behavior) first.
Only if it fails to find wxWidgets, it tries to find wxWidgets using wx-config.

I added if(TRUE) to prevent some automatic indenting and white space changes in the diff. I removed it in the final version for which I am preparing a merge request to CMake.

I attached the full file if that makes it easier for you.

Maarten

--
You received this message because you are subscribed to the Google Groups "wx-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wx-dev+un...@googlegroups.com.
FindwxWidgets.cmake

PB

unread,
Jul 6, 2022, 3:07:13 AM7/6/22
to wx-dev
Thanks again, I tested the module you attached and can confirm it works as expected now.

Maarten Bent

unread,
Jul 7, 2022, 2:34:59 PM7/7/22
to wx-...@googlegroups.com
All FindwxWidgets changes are now available in CMake 3.24.0-rc3.

On 6 Jul 2022 09:07, PB wrote:
Thanks again, I tested the module you attached and can confirm it works as expected now.
--
You received this message because you are subscribed to the Google Groups "wx-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wx-dev+un...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages