#19278: Cannot find wxWidgets for MinGW using find_package

179 views
Skip to first unread message

wxTrac

unread,
Oct 6, 2021, 4:47:30 AM10/6/21
to wx-...@googlegroups.com
#19278: Cannot find wxWidgets for MinGW using find_package
-------------------------+--------------------
Reporter: jjELT | Owner:
Type: defect | Status: new
Priority: normal | Milestone:
Component: 3rdparty | Version: 3.1.5
Keywords: CMake,MinGW | Blocked By:
Blocking: | Patch: 0
-------------------------+--------------------
I am building wxWidgets 3.1.5 using CMake, with the appropriate arguments
for the toolchains MSVC and MinGW on Windows, as well as the GNU compilers
on Linux.

When using wxWidgets in a CMake project, by calling
`find_package(wxWidgets)`, I have (CMake has) no problems finding
wxWidgets for MSVC on Windows and GCC on Linux. Using MinGW on Windows I
always get the error:

{{{
-- Could NOT find wxWidgets (missing: wxWidgets_LIBRARIES
wxWidgets_INCLUDE_DIRS)
wxWidgets NOT found!
}}}

I already created a report in the CMake community, where you can find all
details, as well as a sample project to reproduce the error, but I have
not yet received any feedback:

https://discourse.cmake.org/t/cannot-find-wxwidgets-for-mingw-using-find-
package/3860

I hope there is all the information to reproduce the error and ideally
also to point out what arguments/aspects I am missing.

--
Ticket URL: <https://trac.wxwidgets.org/ticket/19278>

wxTrac

unread,
Oct 6, 2021, 4:53:46 PM10/6/21
to wx-...@googlegroups.com
#19278: Cannot find wxWidgets for MinGW using find_package
-----------------------+-------------------------
Reporter: jjELT | Owner:
Type: defect | Status: new
Priority: normal | Milestone:
Component: 3rdparty | Version: 3.1.5
Resolution: | Keywords: CMake,MinGW
Blocked By: | Blocking:
Patch: 0 |
-----------------------+-------------------------

Comment (by MaartenB):

You install it to
`<EXTERNAL_PROJECTS>/Install/wxwidgets/v3.1.5/gnu/amd64/Release`

but when building the sample you use

`-DwxWidgets_ROOT_DIR=<EXTERNAL_PROJECTS>/Install/wxwidgets/v3.1.5/gnu/amd64/static/`.

These should be the same directory. `wxWidgets_ROOT_DIR` should point to
the directory containing the `include`, `lib` and `bin` folder.

--
Ticket URL: <https://trac.wxwidgets.org/ticket/19278#comment:1>

wxTrac

unread,
Oct 7, 2021, 4:27:50 AM10/7/21
to wx-...@googlegroups.com
#19278: Cannot find wxWidgets for MinGW using find_package
-----------------------+-------------------------
Reporter: jjELT | Owner:
Type: defect | Status: new
Priority: normal | Milestone:
Component: 3rdparty | Version: 3.1.5
Resolution: | Keywords: CMake,MinGW
Blocked By: | Blocking:
Patch: 0 |
-----------------------+-------------------------
Changes (by jjELT):

* cc: j.jochum@… (added)


Comment:

I just realised I miscorrected myself in the second post from yesterday on
discourse.cmake.org. I deleted that second post.

I am in fact installing wxWidgets into the folder
`<EXTERNAL_PROJECTS>/Install/wxwidgets/v3.1.5/gnu/amd64/static/`, by
defining the `CMAKE_INSTALL_PREFIX` when configuring the CMake project.

{{{
...
-DCMAKE_INSTALL_PREFIX=<EXTERNAL_PROJECTS>/Install/wxwidgets/v3.1.5/gnu/amd64/static
}}}

Later on, the line when I am actually triggering the `install` phase, was
correct after all, as the mentioned path is not the "target" install-path,
but rather where the compiled code is laying, which should be installed:

{{{
C:/Program Files/CMake/bin/cmake.exe --install
<EXTERNAL_PROJECTS>/Build/wxwidgets/v3.1.5/gnu/amd64/Release
}}}

Sorry for the confusion.

As mentioned in the post on discourse.cmake.org I am building wxWidgets
both with MinGW as well as MSVC, so I have these two respective install
folders

{{{
<EXTERNAL_PROJECTS>\Install\wxwidgets\v3.1.5\gnu\amd64\static
<EXTERNAL_PROJECTS>\Install\wxwidgets\v3.1.5\msvc\amd64\static
}}}

both having the three subfolders `bin`, `include` and `lib` you mentioned.
The subfolders and files inside these folders differ though. The content
in the `.../gnu/..` folder appears to be tagged with a `*-3.1` (at least
some files and folders).

For instance I see the following files and folders:

{{{
..\gnu\amd64\static\bin\wxrc-3.1.exe

..\msvc\amd64\static\bin\wxrc.exe
}}}

{{{
..\gnu\amd64\static\include\wx-3.1\wx\..

..\msvc\amd64\static\include\msvc\wx\..
..\msvc\amd64\static\include\wx\..
}}}

{{{
..\gnu\amd64\static\lib\wx\..
..\gnu\amd64\static\lib\libwx_baseu_net-3.1.a
..\gnu\amd64\static\lib\libwx_baseu_xml-3.1.a
..

..\msvc\amd64\static\lib\vc_x64_lib\mswu\..
..\msvc\amd64\static\lib\vc_x64_lib\mswud\..
..\msvc\amd64\static\lib\wxbase31u.lib
..\msvc\amd64\static\lib\wxbase31u_net.lib
..
}}}

--
Ticket URL: <https://trac.wxwidgets.org/ticket/19278#comment:2>

wxTrac

unread,
Oct 7, 2021, 5:07:14 AM10/7/21
to wx-...@googlegroups.com
#19278: Cannot find wxWidgets for MinGW using find_package
-----------------------+-------------------------
Reporter: jjELT | Owner:
Type: defect | Status: new
Priority: normal | Milestone:
Component: 3rdparty | Version: 3.1.5
Resolution: | Keywords: CMake,MinGW
Blocked By: | Blocking:
Patch: 0 |
-----------------------+-------------------------

Comment (by MaartenB):

Since 3.1.5 there have been some improvements related to the library names
when building with CMake. They should now have the same names as if they
were built using the makefiles.
Maybe you can try to build the latest version from the git repository to
see if it has been fixed?

You could also enable the debug output in `FindWxWidgets.cmake` (somewhere
in `share/cmake-3.21/Modules/FindwxWidgets.cmake`) to see what the script
is looking for, and how it differs from your files. Just uncomment the
`DBG_MSG` and/or `DBG_MSG_V` macros.
(Note this is not a script from wxWidgets, but it is part of CMake).

--
Ticket URL: <https://trac.wxwidgets.org/ticket/19278#comment:3>

wxTrac

unread,
Oct 12, 2021, 4:46:23 PM10/12/21
to wx-...@googlegroups.com
#19278: Cannot find wxWidgets for MinGW using find_package
-----------------------+-------------------------
Reporter: jjELT | Owner:
Type: defect | Status: new
Priority: normal | Milestone:
Component: 3rdparty | Version: 3.1.5
Resolution: | Keywords: CMake,MinGW
Blocked By: | Blocking:
Patch: 0 |
-----------------------+-------------------------
Changes (by jjELT):

* cc: j.jochum@… (removed)


Comment:

The latest `master` (700dd3e9) does not build, as the file
`wxWidgets/3rdparty/pcre/src/pcre2_auto_possess.c` appears to be missing.
I went through the commit history and checked out arbitrary commits
between tag `v3.1.5` and the latest master. The commit with SHA-1 ID
`02c90d126` was the first I found, which built without errors. I used the
exact same commands as before, just replacing the folder name `v3.1.5`
with `latest`.

As you said, the folder structure was updated somewhere along the way for
a CMake build with MinGW.

I debugged finding wxWidgets by setting

{{{
set(CMAKE_FIND_DEBUG_MODE ON)
}}}

in the CMakeLists.txt file of the `cmake-find-wxwidgets` sample project.

In the end I found out I needed to set these variables:

{{{
set(wxWidgets_ROOT_DIR
<EXTERNAL_PROJECTS>/Install/wxwidgets/latest/gnu/amd64/static")
set(wxWidgets_LIB_DIR
"<EXTERNAL_PROJECTS>/Install/wxwidgets/latest/gnu/amd64/static/lib/gcc_x64_lib")
set(CMAKE_PREFIX_PATH ${wxWidgets_ROOT_DIR})
}}}

Not setting `wxWidgets_LIB_DIR` makes the
[https://cmake.org/cmake/help/latest/module/FindwxWidgets.html
FindwxWidgets script] look in the folders `gcc_lib` and `gcc_xp_dll`
instead of `gcc_x64_lib`, so there is still some more work to be done,
then for MSVC and GCC (Linux), but at least I appear to have found a
solution.

I now have to create an intermediate fix for my project, using v3.1.5 for
MSVC and GCC and using the above mentioned particular commit when
compiling with MinGW. Or I'll wait for v3.1.6 to come out...

Anyways, thanks for the support!

--
Ticket URL: <https://trac.wxwidgets.org/ticket/19278#comment:4>

wxTrac

unread,
Oct 12, 2021, 5:19:47 PM10/12/21
to wx-...@googlegroups.com
#19278: Cannot find wxWidgets for MinGW using find_package
-----------------------+-------------------------
Reporter: jjELT | Owner:
Type: defect | Status: new
Priority: normal | Milestone:
Component: 3rdparty | Version: 3.1.5
Resolution: | Keywords: CMake,MinGW
Blocked By: | Blocking:
Patch: 0 |
-----------------------+-------------------------

Comment (by vadz):

I can't comment on the CMake stuff, but you need to initialize
`3rdparty/pcre` submodule to build the latest master.

--
Ticket URL: <https://trac.wxwidgets.org/ticket/19278#comment:5>

wxTrac

unread,
Oct 12, 2021, 5:20:09 PM10/12/21
to wx-...@googlegroups.com
#19278: Cannot find wxWidgets for MinGW using find_package
-----------------------+-------------------------
Reporter: jjELT | Owner:
Type: defect | Status: new
Priority: normal | Milestone:
Component: 3rdparty | Version: 3.1.5
Resolution: | Keywords: CMake,MinGW
Blocked By: | Blocking:
Patch: 0 |
-----------------------+-------------------------

Comment (by oneeyeman):

Hi,
PLease use the instructions found at https://wxwidgets.org/develop/code-
repository/, namely use either


{{{
git submodule update --init
}}}

if you want to update the existing cloned repository to the latest code,
or


{{{
git clone --recurse-submodules https://github.com/wxWidgets/wxWidgets.git
}}}

if you want to make a new cloned repo.

Also, please update whatever script(s) you are using that retrieves
wxWidgets from its repository to use the proper syntax.

Also, please use provided "CMake' project sample in order to build either
the library or the user code itself.

Thank you.

--
Ticket URL: <https://trac.wxwidgets.org/ticket/19278#comment:6>

wxTrac

unread,
Oct 13, 2021, 2:42:13 AM10/13/21
to wx-...@googlegroups.com
#19278: Cannot find wxWidgets for MinGW using find_package
-----------------------+-------------------------
Reporter: jjELT | Owner:
Type: defect | Status: new
Priority: normal | Milestone:
Component: 3rdparty | Version: 3.1.5
Resolution: | Keywords: CMake,MinGW
Blocked By: | Blocking:
Patch: 0 |
-----------------------+-------------------------
Changes (by jjELT):

* cc: j.jochum@… (added)


Comment:

Right, I forgot to run these commands again. I had already done this once
earlier, else I wouldn't have all the submodules in the `src` folder, but
forgot to run them again after having checked out the latest `master`.

I suppose for MinGW I can now use the latest commit in the `master`
branch. Thanks!

--
Ticket URL: <https://trac.wxwidgets.org/ticket/19278#comment:7>
Reply all
Reply to author
Forward
0 new messages