This is a dual counterpart to #26043: this time I found a problem in my project after switching it to CMake due to the fact that wxUSE_GUI is not defined as 1 any longer, when I assumed it would be.
This is especially problematic for .rc files, as they don't include any wx headers typically and I have
#if wxUSE_GUI #define wxUSE_RC_MANIFEST 1 #define wxUSE_DPI_AWARE_MANIFEST 2 #include "wx/msw/wx.rc" #endif
in them because I share the same file between GUI and non-GUI versions of the application.
Workaround is simple enough, of course, once you know about the problem, but shouldn't wx::core provide wxUSE_GUI=1 in its INTERFACE compile definitions? I.e. maybe apply something like this:
diff --git a/build/cmake/functions.cmake b/build/cmake/functions.cmake index 83b4c2ca6e..55bfd7ac14 100644 --- a/build/cmake/functions.cmake +++ b/build/cmake/functions.cmake @@ -362,13 +362,13 @@ function(wx_set_target_properties target_name) # Set common compile definitions target_compile_definitions(${target_name} PRIVATE WXBUILDING) if(wxTARGET_IS_MONO AND wxUSE_GUI) - target_compile_definitions(${target_name} PRIVATE wxUSE_GUI=1 wxUSE_BASE=1) + target_compile_definitions(${target_name} PUBLIC wxUSE_GUI=1 PRIVATE wxUSE_BASE=1) elseif(wxTARGET_IS_PLUGIN) target_compile_definitions(${target_name} PRIVATE wxUSE_GUI=0 wxUSE_BASE=0) elseif(wxTARGET_IS_BASE OR NOT wxUSE_GUI) target_compile_definitions(${target_name} PRIVATE wxUSE_GUI=0 wxUSE_BASE=1) else() - target_compile_definitions(${target_name} PRIVATE wxUSE_GUI=1 wxUSE_BASE=0) + target_compile_definitions(${target_name} PUBLIC wxUSE_GUI=1 PRIVATE wxUSE_BASE=0) endif() if(MSVC)
or would this cause some problems?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
I think this is fine.
How did this work before CMake, because wx-config also doesn't expose this afaic?
As discussed in #26043 we can't seem to do the same as wx-config, add -DwxUSE_GUI=0 for wx::base, because wx::core and other libraries will inherit it and it will override their -DwxUSE_GUI=1.
Instead we could add a different (interface) library for that:
add_library(wxbase_only INTERFACE) target_link_libraries(wxbase_only INTERFACE wxbase) target_compile_definitions(wxbase_only INTERFACE wxUSE_GUI=0) wx_install(TARGETS wxbase_only EXPORT wxWidgetsTargets)
And then, for example, this could be changed from:
https://github.com/wxWidgets/wxWidgets/blob/7c3e00ccbd7bd1d24adbc6717902ad8819c85b79/build/cmake/functions.cmake#L974-L980
to
if(APP_CONSOLE) wx_exe_link_libraries(${target_name} wxbase_only) else() wx_exe_link_libraries(${target_name} wxcore) endif()
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()