I am trying to run wxWidget example using cmake but unable to include
the headers of wxWidgets in my C++ project(CMakeLists.txt). If i run the
program using the command:
g++ main.cpp `wx-config --cppflags --libs` -o wxTest
the program works and display the window. But how can i do that using
CMakeLists.txt file. For example, usually i create a separate folder
called external-libs and then inside it create a folder with the name whateverlibraryname
and then inside it create a header and src and lib folder where i place
the header files, any source files and .so files respectively. But in
the case of wxWidgets i have several static library files and also
inside the header there are many separate folders and i don't know how
to include them all. They produce the error:
fatal error: wx/wx.h: No such file or directory
#include <wx/wx.h>
I am using Ubuntu 18.04 and my project directory structure is as follows:
├──
build└──
source ├──
CMakeLists.txt ├──
external-libraries │ └── wxWidgets
│ ├──
headers │ │ ├── msvc
│ │ │ └── wx
│ │ └── wx
│ │ ├── android
│ │ ├── aui
│ │ ├── dfb
│ │ ├── generic
│ │ ├── gtk
│ │ ├── gtk1
│ │ ├── html
│ │ ├── meta
│ │ ├── motif
│ │ ├── msw
│ │ ├── osx
│ │ ├── persist
│ │ ├── private
│ │ ├── propgrid
│ │ ├── protocol
│ │ ├── qt
│ │ ├── ribbon
│ │ ├── richtext
│ │ ├── stc
│ │ ├── univ
│ │ ├── unix
│ │ ├── x11
│ │ ├── xml
│ │ └── xrc
│ ├──
lib │ ├── libwx_baseu-3.1.a
│ │ ├── libwx_baseu_net-3.1.a
│ │ ├── libwx_baseu_xml-3.1.a
│ │ ├── libwx_gtk3u_adv-3.1.a
│ │ ├── libwx_gtk3u_aui-3.1.a
│ │ ├── libwx_gtk3u_core-3.1.a
│ │ ├── libwx_gtk3u_gl-3.1.a
│ │ ├── libwx_gtk3u_html-3.1.a
│ │ ├── libwx_gtk3u_propgrid-3.1.a
│ │ ├── libwx_gtk3u_qa-3.1.a
│ │ ├── libwx_gtk3u_ribbon-3.1.a
│ │ ├── libwx_gtk3u_richtext-3.1.a
│ │ ├── libwx_gtk3u_stc-3.1.a
│ │ ├── libwx_gtk3u_xrc-3.1.a
│ │ ├── libwxjpeg-3.1.a
│ │ ├── libwxregexu-3.1.a
│ │ ├── libwxscintilla-3.1.a
│ │ └── libwxtiff-3.1.a
│ └──
src ├── main.cpp
Main.cpp has #include<wx/wx.h> at
the top. I am using VSCode and when i ran the program using g++(command
described above) it works but doesn't workwhen i run the same program
using CMake. That is how to include the header folder and use the lib
folder that contains all the wxWidgets headers and library files. What
should be the contents of the CMakeLists.txt files and what are the
other necessary things that i have to do to make this work.