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

Added cmake tooling #57

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Added cmake tooling #57

wants to merge 1 commit into from

Conversation

pthom
Copy link

@pthom pthom commented Apr 18, 2024

If you are interested, this is a CMake file that I added. This CMake file was tested under linux, macOS and windows.
I also added a backend "glfw_gl3" for samples.

Feel free to close this PR if you prefer to continue with sharpmake only.

Note: this PR will not compile unless the simple fixes PR was applied before (in order to fix some compilation issues on diverse platforms)

@pthom pthom force-pushed the cmake_tooling branch 2 times, most recently from b7d9144 to 4807a24 Compare April 19, 2024 07:46
Code/ServerApp/Source/NetImguiServer_App.h Outdated Show resolved Hide resolved
CMakeLists.txt Show resolved Hide resolved
Code/Sample/Common/main_glfw_gl3.cpp Show resolved Hide resolved
@pthom
Copy link
Author

pthom commented Apr 21, 2024

@sammyfreg wrote:

I'm thinking about wanting this CMake file included or not. On one hand, it's good work and definitely nice to have, but on the other hand it might soon get out of date without me dedicating extra time to maintain it too. It is not too complex (the Sharpmake version is a bit more complicated, but could also be used to output a makefile I believe).

My advice is that you should not merge this PR, and leave it opened so that people who are looking for it might find it and know that they need to adapt it because it might be outdated.

@pthom
Copy link
Author

pthom commented Apr 21, 2024

@sammyfreg wrote:

The other thing is that we really only need the NetImguiServer application to have multi-platform compiling support. The samples are just a simple demonstration that can easily be compiled without a build system configured, and the NetImgui client code is usually included in an existing project, and is the one that was meant to be truly multi-platform.

By default, here are the options in the cmake file:

option(NETIMGUI_BUILD_CLIENT "Build client" ON)
option(NETIMGUI_BUILD_IMGUI "Build imgui from sources in netImgui" ${PROJECT_IS_TOP_LEVEL})
option(NETIMGUI_BUILD_SAMPLES "Build samples" ${PROJECT_IS_TOP_LEVEL})
option(NETIMGUI_BUILD_SERVER_LIB "Build server lib" ${PROJECT_IS_TOP_LEVEL})
option(NETIMGUI_BUILD_SERVER_APP_SOKOL "Build server app" ${PROJECT_IS_TOP_LEVEL})

i.e.

  • the client lib is built by default
  • ImGui is built only if compiling netImgui as the main project
  • Sample are built only if compiling netImgui as the main project
  • The server is built only if compiling netImgui as the main project. In the current state, the server can only be built with Sokol, but users may adapt it quite easily: I left hints in the cmake file for that.

@pthom pthom force-pushed the cmake_tooling branch 3 times, most recently from e7718cf to 0d0cae9 Compare April 21, 2024 06:59
This CMake file was tested under linux, macOS and windows.
Also added backend glfw_gl3 for samples.
@pthom
Copy link
Author

pthom commented Apr 21, 2024

I think I had been too fast in the last push, I added an ifdef inside Code/Sample/Common/main.cpp which probably led the CI to fail. I removed it and I hope that the CI will pass.

Anyhow, it is not very important that it passes since this PR is meant to remain opened and not merged.

@starlight-traveler
Copy link

starlight-traveler commented Jul 6, 2024

Real easy to add GlfwGL3 support, tests on MacOS with glfw installed via brew (not tested on non-Darwin Unix, will update once I get around to that). Maybe will get around to glfw compilation on Windows. DPI is a bit wonky, but that can be fixed in menu.

Will leave this here for posterity/those who dislike Cmake files. Simply replace the function not implemented.

function(_add_net_imgui_server_app_glfw_gl3)
    set(server_app_glfwgl3_dir ${SERVER_DIR}/GlfwGL3)
    file(GLOB server_app_glfwgl3_files ${server_app_glfwgl3_dir}/*.cpp)
    add_executable(net_imgui_server_app_glfwgl3 ${server_app_glfwgl3_files})
    target_link_libraries(net_imgui_server_app_glfwgl3 net_imgui_server_lib)

    # Find the GLFW package
    find_package(glfw3 REQUIRED)

    if(APPLE)
        # Link GLFW and frameworks needed for macOS
        target_link_libraries(net_imgui_server_app_glfwgl3 glfw "${GLFW_LIBRARIES}")
    elseif(UNIX)
        # Link GLFW and libraries needed for Unix-like systems
        target_link_libraries(net_imgui_server_app_glfwgl3 glfw "${GLFW_LIBRARIES}")
        target_link_libraries(net_imgui_server_app_glfwgl3 X11 GL Xcursor Xi)
    endif()

endfunction()

@sammyfreg
Copy link
Owner

sammyfreg commented Jul 6, 2024

What do you mean with 'wonki DPI'? It might be that you need to implement DPI awareness on a non window platform.

Search for "@SAMPLE_EDIT (DPI Awareness)" in the Server source code (I mostly used the Dear ImGui's sample code for creating the Server Application and @SAMPLE_EDIT tags indicate where I made some small changes to the original sources) to see how it is handled. Basically, the platform code should be calling "NetImguiServer::UI::SetWindowDPI()" to let the Server Application what's the current Window DPI, to adjust the font size.

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

Successfully merging this pull request may close these issues.

3 participants