Page 1 of 1

wxWidgets + Windows + CMake

Posted: Sat Nov 02, 2019 5:08 pm
by heinermueller
Hi all,

what is the correct way to set up CMake with wxWidgets? Under Linux, all you have to do is

Code: Select all

find_package(wxWidgets COMPONENTS core base qa adv net html gl propgrid richtext REQUIRED)
and then include/link using the populated wxWidgets_USE_FILE/wxWidgets_LIBRARIES variables. Magic.
Under Windows, you have to point to the installation directory, e.g.

Code: Select all

set(wxWidgets_ROOT_DIR "C:/wxWidgets-3.1.3")
set(wxWidgets_LIB_DIR "C:/wxWidgets-3.1.3/lib/vc14x_x64_dll")
But then the behavior is still strange. When i use CMake GUI (3.16, latest), behavior is like this

1. delete cache (just to be consistent)
2. press 'configure' button
--> fail:
CMake Error at C:/Program Files/CMake/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:146 (message):
Could NOT find wxWidgets (missing: wxWidgets_LIBRARIES
wxWidgets_INCLUDE_DIRS core base qa adv net html gl propgrid richtext)
3. press 'configure' button again
--> success
Found wxWidgets: debug;C:/wxWidgets-3.1.3/lib/vc14x_x64_dll/wxmsw31ud_core.lib;optimized;C:/wxWidgets-3.1.3/lib/vc14x_x64_dll/wxmsw31u_core.lib;[...]found components: core base qa adv net html gl propgrid richtext png tiff jpeg zlib regex expat

I had the same behavior with a previous version of CMake-GUI (3.12). What is the correct way to set up wx under windows?

Best

Re: wxWidgets + Windows + CMake

Posted: Mon Nov 04, 2019 3:19 pm
by ONEEYEMAN
Hi,
Why do you need to use CMake?
Just compile you code with:

Code: Select all

g++ `wx-config --cxxflags --libs` *.cpp -o <my_binary>
and enjoy.

Thank you.

P.S.: Unless you have a huge distributed software to compile. But in that case you should have some kind of IDE (Anjuta, C::B, C::L) to help you with that.

Re: wxWidgets + Windows + CMake

Posted: Thu Nov 07, 2019 12:51 pm
by heinermueller
Hi ONEEYEMAN,

thanks for the hint. Actually we do have a quite large software (packet, with multiple exe and libraries) to compile. CMake looks like a great solution, especially when developers refuse to work with e.g. xcode =)

The idea of having a single project-file, easily switching compilers, IDEs and platforms is really great. With CMake (and companions) we can set up a development system in Linux in literally 5-10 minutes. It is definitely worth the try. I had a look at the CMake FindwxWidgets.cmake module and found the maintainer email. I will point them to this thread, maybe they have some solution or hint, that would be great.
Best regards

Re: wxWidgets + Windows + CMake

Posted: Thu Nov 07, 2019 3:27 pm
by ONEEYEMAN
Hi,
So, on Windows I am using MSVC. And since 3.1.3 has a solution file that you can use to work from it will be much easier. And to build wx itself - there is already wx solution.
On *nix/Solaris I use a terminal to build wx and then I installed Anjuta, which has a template to start with the wx development - all you do is start it and create a new wx-based project.
Or you can install C::B which is completely wx based, which is actually perfect solution.

And I also use Terminal to build wx on OSX and then Xcode to build the application.
I don't know why anybody will refuser to do that - it will generate ready to use bundle.

But if they don't - C::B is your friend again. Remember - its a wx solution. And it has an integrated wx RAD tool to simplify creating the GUI.

Thank you.

Re: wxWidgets + Windows + CMake

Posted: Fri Nov 15, 2019 3:18 pm
by Frank_WX
Had the same issue about a year ago. If you use a 64-bit command prompt (should be available from your menu) which is provided with VC and/or VS, cmake-gui will find the compilers correctly.

Re: wxWidgets + Windows + CMake

Posted: Thu Dec 12, 2019 6:33 pm
by Widgets
I've run into the same issue as the OP
Using the provided sln file for 3.1.2, I have been able to build the libraries I want, but I also wanted to compile all of the samples. These are not part of the 3.1.2 sln.
Rather than trying to build a new project for all of the samples within the given sln file, I figured it ought to be quicker to use CMake to generate a new sln file which included the samples.
Hence I tried using CMake on the latest code from Github but the directory src/png is completely empty, as is jpeg, expat, tiff & zlib

Copying the full contents of each directory from the 3.1.2 release, allowed the CMake configure steps to complete; the compile under MSVC 2019 failed only on a couple of projects & I haven't taken the time figure out why or how to fix it because I don't need them right now.

Should I raise this as an issue on wxWidgets Trac regarding these missing files?

Re: wxWidgets + Windows + CMake

Posted: Thu Dec 12, 2019 6:45 pm
by ONEEYEMAN
Hi,
First of all you don't need to use anything to build the samples. Every sample directory contains the project file which you can open and build from.
They are located inside wxWidgets\samples\{minimal} as minimal.vc{X}.

Second - you didn't clone the sources correctly. You should be using:

Code: Select all

git clone --recurse-submodules https://github.com/wxWidgets/wxWidgets.git
or, if you already cloned the sources

Code: Select all

git submodule update --init
Let us know if the samples will not build out the box with the provided projects.

Keep in mind - the complete solution for the samples is NOT provided, it is there only to build the library. Samples are buildable from the project ones as you don't need a solution to build them.

Thank you.

Re: wxWidgets + Windows + CMake

Posted: Thu Dec 12, 2019 7:30 pm
by Widgets
ONEEYEMAN wrote:
Thu Dec 12, 2019 6:45 pm
Hi,
First of all you don't need to use anything to build the samples. Every sample directory contains the project file which you can open and build from.
They are located inside wxWidgets\samples\{minimal} as minimal.vc{X}.

Second - you didn't clone the sources correctly. You should be using:

Code: Select all

git clone --recurse-submodules https://github.com/wxWidgets/wxWidgets.git
Thank you for the pointers. For the clone, being a Github newb, I simply followed the instructions on the Github site; I am just getting to know Git, so it is good to know how to fix it.
The main Github repo does not even show directories for the missing ones, but it does seem to show something that looks like links.
Still I would have expected these directories to be a part of the clone.
ONEEYEMAN wrote:
Thu Dec 12, 2019 6:45 pm
or, if you already cloned the sources

Code: Select all

git submodule update --init
I have other reasons for trying out CMake - other projects which probably would benefit from my knowing more about how to make CMake work and have it find all the bits it needs
ONEEYEMAN wrote:
Thu Dec 12, 2019 6:45 pm
Let us know if the samples will not build out the box with the provided projects.

Keep in mind - the complete solution for the samples is NOT provided, it is there only to build the library. Samples are buildable from the project ones as you don't need a solution to build them.

Thank you.
Some of this goes back to earlier experiences with wxWidgets when the solution files contained all project & solution files. Later on, using more recent versions of MSVC to try to read solution & workspace files produced by and for earlier versions seemed to involve manual editing of project & solution files and worse :-)
Yes the latest 3.1.2 samples directories (at least the ones I have checked) contain project files, though most are for earlier versions of MSVC.
Fortunately, in my current trials with MSVC 2019, I find this no longer a problem. It knows how to read and update earlier solution files.

Re: wxWidgets + Windows + CMake

Posted: Thu Dec 12, 2019 7:45 pm
by ONEEYEMAN
Hi,
Widgets wrote:
Thu Dec 12, 2019 7:30 pm
ONEEYEMAN wrote:
Thu Dec 12, 2019 6:45 pm
Hi,
First of all you don't need to use anything to build the samples. Every sample directory contains the project file which you can open and build from.
They are located inside wxWidgets\samples\{minimal} as minimal.vc{X}.

Second - you didn't clone the sources correctly. You should be using:

Code: Select all

git clone --recurse-submodules https://github.com/wxWidgets/wxWidgets.git
Thank you for the pointers. For the clone, being a Github newb, I simply followed the instructions on the Github site; I am just getting to know Git, so it is good to know how to fix it.
The main Github repo does not even show directories for the missing ones, but it does seem to show something that looks like links.
Still I would have expected these directories to be a part of the clone.
Those are external projects to wxWidgets and when the library transitioned to Git{Hub}, they become an external modules.
That way it is very easy to get the updates and talk to the automatic builds.
Widgets wrote:
Thu Dec 12, 2019 7:30 pm
ONEEYEMAN wrote:
Thu Dec 12, 2019 6:45 pm
or, if you already cloned the sources

Code: Select all

git submodule update --init
I have other reasons for trying out CMake - other projects which probably would benefit from my knowing more about how to make CMake work and have it find all the bits it needs
ONEEYEMAN wrote:
Thu Dec 12, 2019 6:45 pm
Let us know if the samples will not build out the box with the provided projects.

Keep in mind - the complete solution for the samples is NOT provided, it is there only to build the library. Samples are buildable from the project ones as you don't need a solution to build them.

Thank you.
Some of this goes back to earlier experiences with wxWidgets when the solution files contained all project & solution files. Later on, using more recent versions of MSVC to try to read solution & workspace files produced by and for earlier versions seemed to involve manual editing of project & solution files and worse :-)
Yes the latest 3.1.2 samples directories (at least the ones I have checked) contain project files, though most are for earlier versions of MSVC.
Fortunately, in my current trials with MSVC 2019, I find this no longer a problem. It knows how to read and update earlier solution files.
The reason for you using CMake is noted. ;-)
However, there is absolutely no reason to use CMake when building wxWidgets and/or samples. The library provides everything out the box.
Building user code is a different story especially if it contains some additional library.

Thank you.

Re: wxWidgets + Windows + CMake

Posted: Thu Dec 12, 2019 7:54 pm
by ONEEYEMAN
The clone commands are taken from http://wxwidgets.org/develop/code-repository/.

Also, I'm not aware of any manual editing for project/solution files with any of the provided wx versions for any MSVC version. Granted sometimes during conversion the dependencies were lost and you had to keep building until you get 0 errors. But I never heard about such problem.

Also right now with Git and Continuos Integration thru Travis CI/AppVeyor it is impossible to fail the build. Such failure will be immediately caught and fixed.

Thank you.