Using Third Party Libraries Like RayLib in Your Project with CMake

  Рет қаралды 12,224

Kea Sigma Delta

Kea Sigma Delta

Күн бұрын

Пікірлер: 39
@botchedaledrugikanal4215
@botchedaledrugikanal4215 11 ай бұрын
You're a complete lifesaver. I haven't jumped into CMake until recently and it really feels like a black box. Makefiles were much simpler to use, but oh well. It takes time to learn all of this.
@KeaSigmaDelta
@KeaSigmaDelta 11 ай бұрын
You're welcome
@dcdfm18bf18
@dcdfm18bf18 Жыл бұрын
Amazing! you solved a week of struggling that no one else could fix! Thanks sooo much!!
@KeaSigmaDelta
@KeaSigmaDelta Жыл бұрын
Glad it was helpful.
@killacam2971
@killacam2971 11 ай бұрын
Ugh thank you sir. Spent 2 days dealing with vcpkg issues and of course there's a much more simple way 😅. Much appreciated!
@KeaSigmaDelta
@KeaSigmaDelta 11 ай бұрын
You're welcome.
@Mikey-gs1dx
@Mikey-gs1dx 4 ай бұрын
Same
@Artistic_Nyungu
@Artistic_Nyungu 6 ай бұрын
Huge thanks... A little something for the algorithm. I hope more people can find you. This was very helpful
@KeaSigmaDelta
@KeaSigmaDelta 6 ай бұрын
Thanks. I'm glad that this helped you.
@stevenbroshar7948
@stevenbroshar7948 Ай бұрын
I'm struggling to learn CMake. I have questions about why you did certain things. Thanks in advance for your time. 1) Since you used ${PROJECT_NAME} for add_executable(), apparently CMake allows a target to have the same name as a project, but that confuses me since now two different things have the same name, and the target_link_libraries() looks like it's associating raylib with the project, but I guess it's associating it with the target that happens to have the same name as the project. Why do it that way? 2) The project fetches raylib which I assume includes compiled code (either a static or dynamic/shared lib) since you don't reference raylib source files. Where exactly will the lib file be such that the build will find it?
@KeaSigmaDelta
@KeaSigmaDelta Ай бұрын
1) It makes sense for the project and the main/only executable to have the same name. The project is there to build the app, so why try to be creative and give the project and app different names? Target_link_libraries() is linking raylib to the target executable. 2) CMake will download and build Raylib in a subdirectory of the build directory. You can take a peek inside the build directory to see all the files that it creates.
@kevinmarques9334
@kevinmarques9334 3 ай бұрын
life saver, thanks! Now the next problem is to fix the LSP of my editor hahaha
@KeaSigmaDelta
@KeaSigmaDelta 3 ай бұрын
You're welcome.
@rodrigozaldivaralanis698
@rodrigozaldivaralanis698 5 ай бұрын
Thanks a lot, dude. This really helped me out
@KeaSigmaDelta
@KeaSigmaDelta 5 ай бұрын
You're welcome. I'm glad it's helped you.
@adeolaibigbemi8612
@adeolaibigbemi8612 2 ай бұрын
Thanks
@KeaSigmaDelta
@KeaSigmaDelta 2 ай бұрын
You're welcome.
@Mikey-gs1dx
@Mikey-gs1dx 4 ай бұрын
Excellent! TY!!
@KeaSigmaDelta
@KeaSigmaDelta 4 ай бұрын
Glad it was helpful!
@N.G.Dreamer
@N.G.Dreamer 3 ай бұрын
Hi Sir, I want to set window icon. Would you share how to set an icon on game window?
@KeaSigmaDelta
@KeaSigmaDelta 3 ай бұрын
For which OS/platform? If you're asking for Windows, then you need to add a resource file that sets IDI_ICON1 to your game's chosen icon. This will set the game exe's icon, which is used in multiple places, including the Window. I couldn't find a full tutorial, but here is an example in brief: www.aloneguid.uk/posts/2021/11/cmake-app-icon/
@N.G.Dreamer
@N.G.Dreamer 3 ай бұрын
​@@KeaSigmaDelta Sir, Thank you for your reply. I am trying with the windows version for now. I followed your instructions. It sets an icon for the exe file and displayed icons on terminal window. But it doesn't show icons on the game window opened by InitWindow function from raylib.h. The raylib tutorial states SetWindowIcon function sets icon, but it doesn't work when I try with cmake while it's working correctly without cmake in visual studio 2022. If you would help me, I would really appreciate it. Thanks again.
@KeaSigmaDelta
@KeaSigmaDelta 3 ай бұрын
Strange that Raylib won't use the icon you set in the resource. I didn't realize that. Anyway, for SetWindowIcon() you need to make sure that the icon is in the right format. I tried loading an icon file and got the following error: INFO: FILEIO: [Scarfy.ico] File loaded successfully WARNING: IMAGE: Data format not supported WARNING: IMAGE: Failed to load image data WARNING: GLFW: Window icon image must be in R8G8B8A8 pixel format Note the last warning. When I converted the icon to an RGBA32 PNG, then it worked.
@N.G.Dreamer
@N.G.Dreamer 3 ай бұрын
​@@KeaSigmaDelta Thank you so much sir. It works for me. It shows icons on the game window and taskbar on windows 11. But I have another problem. It doesn't show icon on macOS. This is the last problem. Would you help me once more? Thanks a million.
@KeaSigmaDelta
@KeaSigmaDelta 3 ай бұрын
​@@N.G.Dreamer Looking at the source code, I think you're out of luck on MacOS X. Here's the relevant snippet from raylib/src/external/glfw/src /cocoa_window.m: void _glfwSetWindowIconCocoa(_GLFWwindow* window, int count, const GLFWimage* images) { _glfwInputError(GLFW_FEATURE_UNAVAILABLE, "Cocoa: Regular windows do not have icons on macOS"); }
@imxande6930
@imxande6930 6 ай бұрын
thank you so much for the video, works perfectly, a question is how do you go about finding the correct URL for these libraries? I tried to do the same for ImGui and I get a 404 error code when fetching it.
@KeaSigmaDelta
@KeaSigmaDelta 6 ай бұрын
I cover this in The CMake Tutorial (cmaketutorial.com/). For GitHub, visit the project you want in a web-browser, and choose the branch or tag that you want to fetch. Now click on the green "Code" button, and you'll see a "Download ZIP" menu item at the bottom of the drop-down. You can copy the URL from there.
@imxande6930
@imxande6930 6 ай бұрын
@@KeaSigmaDelta thank you so much for such a fast a thoughtful replay, I will check it out thank you so much!
@bklan9899
@bklan9899 10 күн бұрын
Shot in the dark: let’s say I’m using a static library as a wrapper for another 3rd party library. This static library will have a dependency on SDL. My application links against this static library, but Im finding that the application ends up having the same dependencies, making my separate wrapper library useless . Is there a way to get around that dependency, to where the application only needs to link against the library, and the dependencies of that static library are invisible to the application?
@KeaSigmaDelta
@KeaSigmaDelta 7 күн бұрын
If you use CMake's FetchContent, then using the wrapper static library, should automatically pull in and build SDL2. An alternative approach is to include SDL2 in your static wrapper library's repository. This technique is used a fair bit, but can get messy if a project uses both your wrapper and another library that also depends on SDL2.
@bklan9899
@bklan9899 6 күн бұрын
@ thanks so much for replying, my issue turned out to be improper encapsulation, and some the SDL headers were being exposed to the client of the wrapper library, which will (now obviously) cause linker issues. Everyone mentions fetch content though, seems like something I should get my head around.
@accountprincipale2293
@accountprincipale2293 Жыл бұрын
how can i do this with multiple files(i.e. having a main.cpp and a window.cpp etc) i tried everything but everytime it says "undefined reference to `InitWindow'" and other function names
@KeaSigmaDelta
@KeaSigmaDelta Жыл бұрын
I have a video on compiling multiple files: kzbin.info/www/bejne/fHe7dKSBgrqNbbs It sounds like you either: - Need to write a window.h header file with prototypes for InitWindow() and other functions (and then #include "window.h" in main.cpp) - Or, need to add #include "window.h" in main.cpp
@Konamech
@Konamech 2 ай бұрын
5:31
The CMake Tutorial is Available (Prerelease)
1:27
Kea Sigma Delta
Рет қаралды 972
CMake - the essential package
27:54
Code for yourself
Рет қаралды 13 М.
Какой я клей? | CLEX #shorts
0:59
CLEX
Рет қаралды 1,9 МЛН
Вопрос Ребром - Джиган
43:52
Gazgolder
Рет қаралды 3,8 МЛН
Better CMake Part 10 -- When to use FetchContent
16:14
Jefferson Amstutz
Рет қаралды 6 М.
C++ Super Optimization: 1000X Faster
15:33
Dave's Garage
Рет қаралды 334 М.
Creating CMake Libraries - That others can find and use.
26:29
How to: Modern CMAKE
28:06
Practical Software
Рет қаралды 5 М.
CMake vs Meson - a real life comparison with actual code
12:20
Kea Sigma Delta
Рет қаралды 3,1 М.
Introduction to CMake Crash Course
14:08
PunchedTape
Рет қаралды 30 М.
Static vs. Shared Libraries
11:00
Dave Xiang
Рет қаралды 66 М.
"Clean" Code, Horrible Performance
22:41
Molly Rocket
Рет қаралды 945 М.
how Google writes gorgeous C++
7:40
Low Level
Рет қаралды 994 М.
Deep CMake for Library Authors - Craig Scott - CppCon 2019
1:01:35