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 https://wiki.wxwidgets.org/Wx-Config , however one is a compiler-flag, and one is a linker-flag.  This forum-link https://intellij-support.jetbrains.com/hc/en-us/community/posts/360001405200-How-to-add-gcc-compiler-flags-arguments-and-set-environment-variables 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.

0

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")

 

0

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.

 

0

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 https://stackoverflow.com/questions/68019574/how-to-include-wxwidgets-headers-in-cmake-project explains that 

CMake has first-party support for wxWidgets

and the following code worked:

find_package(wxWidgets REQUIRED gl core base OPTIONAL_COMPONENTS net)
include(${wxWidgets_USE_FILE})
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`.

0

请先登录再写评论。