wxWidgets + Windows + CMake

Do you have a question about makefiles, a compiler or IDE you are using and need to know how to set it up for wxWidgets or why it doesn't compile but other IDE's do ? Post your questions here.
Post Reply
heinermueller
Experienced Solver
Experienced Solver
Posts: 66
Joined: Sat Oct 26, 2013 11:54 am

wxWidgets + Windows + CMake

Post by heinermueller » Sat Nov 02, 2019 5:08 pm

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

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 3508
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: wxWidgets + Windows + CMake

Post by ONEEYEMAN » Mon Nov 04, 2019 3:19 pm

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.

heinermueller
Experienced Solver
Experienced Solver
Posts: 66
Joined: Sat Oct 26, 2013 11:54 am

Re: wxWidgets + Windows + CMake

Post by heinermueller » Thu Nov 07, 2019 12:51 pm

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

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 3508
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: wxWidgets + Windows + CMake

Post by ONEEYEMAN » Thu Nov 07, 2019 3:27 pm

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.

Post Reply