-
-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
Add CMake project #1778
Add CMake project #1778
Conversation
Now implemented: - Build ImGui library (CMake's package); - Optionaly build implementation (ImGui_BUILD_IMPLEMENTATION option); - Optionaly build examples (ImGui_BUILD_EXAMPLES option); Added examples: - opengl2_example; - sdl_opengl2_example. CMake's ImGui package contains targets: - ImGui::Library; - ImGui::Demo; - ImGui::ImplOpenGL2; - ImGui::ImplGlfw; - ImGui::ImplSDL2. Users can easy link ImGui::Impl<Xxx> libraries and use example binding implementation in custom projects. Tested with MinGW-w64 and MSVC toolchains.
Hello @podsvirov, thanks a lot! This looks solid! My mental roadmap is that I would like 1.62~1.63 to include the refactored example structure (the same as in the viewport branch, but without the multi-viewport support) in master. At the same time we can provide both premake and cmake projects. So this can be part of that effort. I don't know when I will be able to test and look at this seriously, please bear with me there. Some quick feedback:
|
Answer:
|
For me the focus of those cmake/premake build files is to build the example apps. It's ok if they have an option to create a .lib but the Demo should be included in there. The Demo is part of imgui and we shouldn't encourage removing it. If users want to configure imgui they can use imconfig.h, they are many other useful options in there that requires compile-time modification and you can't possibly custom-wrap all those options in the cmake file. Let the user pass the ImGui is really not designed to be packaged into a library, nor "installed" in system paths - I think it is often a mistake to do so because it often creates a situation that prevents users from actually configuring the library. We want to encourage people to configure the library to e.g. add the necessary defines to use their maths types and cast them to ImVec2 implicitly, or to modify the ImDrawIdx type, or the ImDrawVert layout.
I think it would be perfectly fine compile the imgui_implXXX files into each example, to put an emphasis that they are example code that the user can freely rework and modify, rather than libraries. |
Yeah this is still a horror. We'd never ever ever be okay with editing third-party source just to set configs. A configure script or CMakeLists file is definitely what should be done to generate such a file (this is why there needs to be a top-level CMakeLists.txt file who's sole purpose is to include the necessary source files and generate the configuration source based on the options specified, this would allow
This should all be done via a generated configuration file, all of it. |
Well you can generate a imconfig file and use
What if the file didn't exist in the repository? Would you consider it third-party to create a file that doesn't exist? The provided file is 100% comments and guaranteed to always be 100% comments. It only exists so people don't need to manually create a file before compiling. |
If I delete the imconfig.h file from the repo, I slightly reduce friction for people who have an elaborate build system in place (who could perfectly use I am happy to hear of other alternatives but I haven't found one yet. Btw none of that really affects the PR much, I was merely elaborating on the fact that if people want to strip the demo code it should be done in a standard manner of using a configuration file, not by deciding that the cmake script would split imgui in 2 libraries. (I am myself really looking forward to switch to using project generators for the examples so this is super useful.) |
Keeping the existing imgui config file is fine in the project, but including a default CMakeLists.txt file (and/or make/configure script) to generate one while using the generated file and including the rest of the files as a bindable project in cmake would make add_subdirectory'ing super easy. |
Closing this PR as we moved to #1713 with a more complete/recent PR. |
Now implemented:
Added examples:
CMake's ImGui package contains targets:
Users can easy link ImGui::Impl libraries and use example binding
implementation in custom projects.
Tested with MinGW-w64 and MSVC toolchains.