StudioCherno / Walnut

Walnut is a simple application framework for Vulkan and Dear ImGui apps
MIT License
1.99k stars 367 forks source link

Add basic Linux+CMake support! #31

Open valerioformato opened 1 year ago

valerioformato commented 1 year ago

This PR adds support for building Walnut under Linux using CMake. The build configuration follows very closely the premake one.

On the Walnut side the only thing missing was an entrypoint. The remaining 90% of the work was just writing the CMake build files, basically translating the premake build :)

Tested under Arch Linux, with Vulkan SDK version 1.3.224, CMake 3.24.2 Screenshot_20221029_171658

NOTE: this patch also requires a fix in the GLFW submodule, see corresponding PR in the GLFW repo

DaveAxiom commented 1 year ago

Looks good -- I didn't test it. I'd take it you are using CMake because you are using CLion. That goes against Cherno conventions though as this community is using the latest Premake.

SYBIOTE commented 1 year ago

hello can you please tell me how I can compile and run on a MacOS? I successfully used make to create the executable , but I these errors Glfw Error 65542: Cocoa: Vulkan instance missing VK_EXT_metal_surface extension Glfw Error 65542: Vulkan: Window surface creation extensions not found [vulkan] Error: VkResult = -7

valerioformato commented 1 year ago

Looks good -- I didn't test it. I'd take it you are using CMake because you are using CLion. That goes against Cherno conventions though as this community is using the latest Premake.

I know premake is the standard here. I was thinking that maybe the two don't have to be mutually exclusive. I've seen projects that support multiple build systems. Of course, this comes with the additional hurdle of keeping the two build systems aligned and I woud understand if this is considered too big to be handled right now.

valerioformato commented 1 year ago

hello can you please tell me how I can compile and run on a MacOS? I successfully used make to create the executable , but I these errors Glfw Error 65542: Cocoa: Vulkan instance missing VK_EXT_metal_surface extension Glfw Error 65542: Vulkan: Window surface creation extensions not found [vulkan] Error: VkResult = -7

Not sure what could be the problem but while working on this I found out that the GLFW fork used for Walnut is only tested on Windows so I had to patch it for Linux. My guess is that it should be appropriately patched for OSX as well so I suggest you start looking there. The GLFW repo comes with example/test executables that you could try to run after compiling it on your machine. If those work then I'd say that the problem is elsewhere :)

SYBIOTE commented 1 year ago

got that , I had no idea this could have been the problem , thanks ill look into it and try to get it to work

Radagan commented 1 year ago

@valerioformato Thank you for this PR! This is exactly what I was looking for: CMake and Linux support. I'm hoping this project will become more cross-platform focused in the near future rather than just Windows.

DaveAxiom commented 1 year ago

The CMake configuration worked giving me a successful build. Running the program gave me a window flashing on the screen and a core dump crash. I tried it.

The Premake file is unmodified and doesn't produce results on my Linux system. It'd probably be best to remove that file from this CMake Linux project branch to avoid confusion.

valerioformato commented 1 year ago

The CMake configuration worked giving me a successful build. Running the program gave me a window flashing on the screen and a core dump crash. I tried it.

The Premake file is unmodified and doesn't produce results on my Linux system. It'd probably be best to remove that file from this CMake Linux project branch to avoid confusion.

Did you also use the patched version of GLFW as stated in the PR description? If so it would be useful to run the main app in gdb and get a stack trace.

I am not sure about removing the premake files, the hope for this PR is to be merged in, lots of people on the windows side rely on those :)

glenpierce commented 5 months ago

Pulled this in on Windows using CLion and it worked beautifully, thank you :)

learn-more commented 4 months ago

This PR adds support for building Walnut under Linux using CMake.

Why not also use premake for the linux side?

valerioformato commented 2 months ago

This PR adds support for building Walnut under Linux using CMake.

Why not also use premake for the linux side?

Because I have a CMake project that uses Walnut as a dependency. This way I can integrate it seamlessly.