MSW, CMake, VS and Samples

32 views
Skip to first unread message

Eric Jensen

unread,
Nov 11, 2022, 9:30:32 AM11/11/22
to wx-u...@googlegroups.com
Hi all,

I just noticed that in the latest wx version, all samples except the
"minimal" don't come with VS solution files any longer. I assume
everyone is supposed to build them themselves using cmake?

First i build the wx libs using the provided VS solution files from
<wxdir>/build/msw/

Then i used CMake to create new solution files so i could build the
samples.

Result:
1) As i had to create a new directory for the Cmake output, i now
have a different root path for wx include files and libs.
<wxdir>/include/ vs wxdir/cmake/lib/

2) when ever i build a sample, the executable is always generated in
<wxdir>/cmake/lib/vc_lib/
So the output files for all samples are in the same directory,
together with the wx libs

Are these two issues expected/intentional, or did i make something
wrong?

I realize you probably made the change to make your life easier. But
for the wx-users (at least the ones using VS), this is a step
backwards in convenience.

If you can provide VS solution files for the minimal sample, why not
for the other samples? Or do you have to maintain them by hand now,
and therefore do it only for the "minimal" sample?

Eric

PB

unread,
Nov 11, 2022, 4:35:07 PM11/11/22
to wx-users
Hi Eric,

my 2 cents as another user.

I just noticed that in the latest wx version, all samples except the
"minimal" don't come with VS solution files any longer. I assume
everyone is supposed to build them themselves using cmake?
That is because the solutions were generated by bakefile, which unfortunately does not (and AFAIK never will) support the 2010+ msbuild MSVS solution/project format. You can still build (most?) samples with provided GCC and MSVC makefiles, but I understand it may seem less convenient.

First i build the wx libs using the provided VS solution files from
<wxdir>/build/msw/

Then i used CMake to create new solution files so i could build the
samples.

Result:
1) As i had to create a new directory for the Cmake output, i now
have a different root path for wx include files and libs.
<wxdir>/include/ vs wxdir/cmake/lib/

2) when ever i build a sample, the executable is always generated in
<wxdir>/cmake/lib/vc_lib/
So the output files for all samples are in the same directory,
together with the wx libs

Are these two issues expected/intentional, or did i make something
wrong?

Yes, that is how it works.

Regarding (1). It means that with CMake-built wxWidgets we cannot use WXDIR convention, depending on both includes and libraries being under the same folder. But this can be solved by installing wxWidgets (CMake variable wxBUILD_INSTALL is on by default).

Just make sure to set the proper folder in CMAKE_INSTALL_PREFIX  as the one selected by default (by CMake convention it's program files) is not usually writable. Then in the generated MSVS solution build the install target, which results in copying the files to the install folder. WXDIR then should be the folder where wxWidgets were installed, not where they were built.

However, unlike with makefile built wxWidgets, installed wxWidgets probably cannot have multiple builds (aside from Debug and Release built with multi-target generators such as Visual Studio XY) in the same folder (e.g., MSVC / GCC, 32 / 64 bit, static / DLL, different wxCFG etc.).

Regarding (2). I myself find this very convenient, the only downside being that (a) one cannot have both Debug and Release samples built and (b) some samples use the same name for their data files which makes few samples not work properly.
 
I realize you probably made the change to make your life easier. But
for the wx-users (at least the ones using VS), this is a step
backwards in convenience.

If you can provide VS solution files for the minimal sample, why not
for the other samples? Or do you have to maintain them by hand now,
and therefore do it only for the "minimal" sample?

AFAIK, the minimal sample is basically created and maintained by hand (just like the library solutions). This is a major unpleasantness and unfeasible to do for more than one. I believe vadz mentioned looking for a solution to this, since bakefile is retired.

IMO, the already very scarce developer resources are better spent on the code, instead of on maintaining another build system. CMake may not be perfect, but it is good enough. In some aspects, it is better, e.g., I can fully customize the build without modifying setup.h.

I recommend using CMake-GUI (and checking Grouped as well as Advanced), in particular if you are new to CMake.

Regards,
PB

Vadim Zeitlin

unread,
Nov 12, 2022, 8:26:05 AM11/12/22
to wx-u...@googlegroups.com, Eric Jensen
On Fri, 11 Nov 2022 15:30:27 +0100 Eric Jensen wrote:

EJ> I just noticed that in the latest wx version, all samples except the
EJ> "minimal" don't come with VS solution files any longer.

I'm aware of this and would like to find some solution to provide MSBuild
(.vcxproj) projects for them. Unfortunately so far I haven't been able to
find any really satisfactory solution. See the thread starting at

https://groups.google.com/g/wx-dev/c/XSFIlZ85fG8/m/LfOJ249GAgAJ

for the discussion so far.

EJ> I assume everyone is supposed to build them themselves using cmake?

This is one possibility. I don't like it very much, but the whole world is
standardizing on CMake, so maybe we just need to accept it and live with
it.

Another possibility is to use some meta-build system to generate them.
Unfortunately I don't think there is anything that would work for us out of
the box. In principle, all of bakefile 1.x (which is, however, unmaintained
and still not even ported to Python 3), premake, meson, or xmake (see
https://groups.google.com/g/wx-dev/c/XSFIlZ85fG8/m/rYCWRAEGAgAJ) should be
able to generate the relatively simple projects for the samples, but there
are various problems with all of them. The real solution is probably to
spend a week-end (or a week...) making one of them work for us.

Finally, there is also a possibility to write some bespoke script to just
generate the projects we want for the samples. This could turn out to be
simpler than working with an existing use system because we only need to
target this one specific scenario. But, again, somebody needs to actually
do it and I just couldn't find any time for this so far.

EJ> If you can provide VS solution files for the minimal sample, why not
EJ> for the other samples? Or do you have to maintain them by hand now,
EJ> and therefore do it only for the "minimal" sample?

Yes. Maintaining all the projects by hand is really not an option.

Regards,
VZ

--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/
Reply all
Reply to author
Forward
0 new messages