Closed Xeverous closed 3 years ago
Try adding the compile flag to MagnumImGuiIntegration
, but you'll need CMake 3.13 to modify targets created in a different directory.
Something like the following could work with older CMake versions:
set_source_files_properties("${IMGUI_DIR}/imgui.cpp"
TARGET_DIRECTORY MagnumImGuiIntegration
PROPERTIES COMPILE_DEFINITIONS $<$<CXX_COMPILER_ID:GNU>:__USE_MINGW_ANSI_STDIO=1>
)
I'm using CMake 3.18 (and willing to upgrade whenever needed). This works: target_compile_options(MagnumImGuiIntegration PUBLIC $<$<CXX_COMPILER_ID:GNU>:-D__USE_MINGW_ANSI_STDIO=1>)
but I still get the warning. The problem lies in Dear ImGui's #define IM_FMTARGS(FMT) __attribute__((format(printf, FMT, FMT+1)))
which might not be correct for MinGW (which has ms_printf
and gnu_printf
formats).
I don't get the warning when using printf
even without __USE_MINGW_ANSI_STDIO
, it only happens for ImGui's functions.
I think it's Dear ImGui's fault in this case: https://github.com/ocornut/imgui/issues/3592. I don't get these warnings for standard printf
and ImGui uses them in their implementation - ImGui's text functions are just incorrectly labeled for MinGW.
I have this problem: https://stackoverflow.com/a/57608651/4818802
I want to add
target_compile_options(??? PUBLIC $<$<CXX_COMPILER_ID:GNU>:-D__USE_MINGW_ANSI_STDIO=1>)
so that ImGui is built with this flag and the flag is forwarded to my project. What would be a correct target? I can not specify this property onMagnumIntegration::ImGui
because it is anALIAS
target.I'm also open to other solutions - preferably through CMake but without touching stuff like
CMAKE_CXX_FLAGS
.