How to add compile-flags to config (solving another problem of WxWidgets missing setup.h"


I'm trying to add in `WxWidgets` to my code, and it's working on the command-line (so my installation of `WxWidgets` is verified).

/usr/bin/c++ main.cpp  `wx-config --cxxflags` `wx-config --libs` 

Those are compile-flags (sort of), based on , however one is a compiler-flag, and one is a linker-flag.  This forum-link addresses that, but only compiler-flags. Based on that, I haven't manager to get either flag actually added to the process. Thanks for any help.

Comment actions Permalink

Thanks for the information. Could you expand a bit on the syntax to pass in multiple-value parameters? I have tried several things, and not been able to get it to work. Example:

set(CMAKE_CXX_FLAGS `wx-config --cxxflags`)
Compiler exited with error code 1: /usr/bin/c++ -xc++ wx-config;--cxxflags : No such file or directory

I tried variations on that, but haven't yet hit the magic formula. :)

set(CMAKE_CXX_FLAGS "wx-config --cxxflags")
set(CMAKE_CXX_FLAGS --cxxflags)
set(CMAKE_CXX_FLAGS "--cxxflags")
set(WX-CONFIG --cxxflags)
set(WX-CONFIG "--cxxflags")


Comment actions Permalink

Upon further reading, they're not actually multiple-value parameters, but a backtick-delimited command, to the `wx-config` executable part of `WxWidgets`. The actual result of those is this:

`wx-config --cxxflags`
-I/usr/lib/x86_64-linux-gnu/wx/include/gtk3-unicode-3.2-unofficial -I/usr/include/wx-3.2-unofficial -D_FILE_OFFSET_BITS=64 -DWXUSINGDLL -D__WXGTK__ -pthread

`wx-config --libs` 
-L/usr/lib/x86_64-linux-gnu -pthread   -lwx_gtk3u_unofficial_xrc-3.2 -lwx_gtk3u_unofficial_html-3.2 -lwx_gtk3u_unofficial_qa-3.2 -lwx_gtk3u_unofficial_core-3.2 -lwx_baseu_unofficial_xml-3.2 -lwx_baseu_unofficial_net-3.2 -lwx_baseu_unofficial-3.2 

So the question could also be, how to incorporate an `-I/usr/lib...` set of directives, into the CMAKE file.


Comment actions Permalink

Happy to say I found an answer - it isn't required to pass in the full set of auto-generated flags, it turns out that explains that 

CMake has first-party support for wxWidgets

and the following code worked:

find_package(wxWidgets REQUIRED gl core base OPTIONAL_COMPONENTS net)
add_executable(hello main.cpp)
target_link_libraries(hello PRIVATE ${wxWidgets_LIBRARIES})

where `hello` is my own package, everything else is a directive to `WxWidgets`.


Please sign in to leave a comment.