Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom flags for Dear ImGui integration #76

Closed
Xeverous opened this issue Nov 11, 2020 · 4 comments
Closed

Custom flags for Dear ImGui integration #76

Xeverous opened this issue Nov 11, 2020 · 4 comments

Comments

@Xeverous
Copy link

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 on MagnumIntegration::ImGui because it is an ALIAS target.

I'm also open to other solutions - preferably through CMake but without touching stuff like CMAKE_CXX_FLAGS.

@pezcode
Copy link
Contributor

pezcode commented Nov 11, 2020

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

@Xeverous
Copy link
Author

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

@Xeverous
Copy link
Author

I don't get the warning when using printf even without __USE_MINGW_ANSI_STDIO, it only happens for ImGui's functions.

@Xeverous
Copy link
Author

I think it's Dear ImGui's fault in this case: ocornut/imgui#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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

No branches or pull requests

3 participants