-
Notifications
You must be signed in to change notification settings - Fork 552
Code samples: add CMakeLists.txt #249
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
Conversation
I hadn't had a chance to test this on a windows box. Only on linux (ubuntu) and osx. |
That is quite cool, nice setup! If this is merged, it should probably also be referenced by the tutorial as a possible example of how to set up Vulkan projects. I can try to test it on Windows sometime this week. |
Calling `cmake --build .` will build the sample code executables for each chapter in it's own folders, compile corresponding shaders and copy all required resources to appropriate sub-folders. After that any example is ready to be run from it's build sub-folder. CMake project requires following dependencies: * glfw3 dev package * glm dev package * stb_image header * tinyobjloader dev package * Vulkan sdk
I just realized I was calling |
I get the following errors when trying to build on Arch Linux:
When I change all |
This is interesting, looks like a "downstream" issue. Different distros may provide and maintain its own cmake configs for the dev packages. On my ubuntu box (20.04) the glm package (0.9.9.7) is installed from ubuntu repo. The library is declared as "glm::glm" (in /usr/lib/cmake/glm/glmConfig.cmake):
What's interesting is that on my macbook, the packages (installed via homebrew formulas) has the same target names. I was hoping this is universal naming convention. Since glm is a header-only library, the only reason to "findpackage" and "link" it to the executable is to configure include paths (imported targets usually has tinyobjloader on the other side, is an actual library we need to link against. And as far as I remember on mac, simply linking via Edit: For what it worth, the glm manual specifies its cmake module as "glm::glm" (https://github.com/g-truc/glm/blob/master/manual.md#-15-finding-glm-with-cmake):
|
@Overv what are the versions of installed |
The versions I have installed are:
I'm not sure why this is happening since I know very little about cmake myself. The line you mention (
I'm not sure why they are using a different name in the Arch Linux package. Update: I've created a bug report to ask about this: https://bugs.archlinux.org/task/71987 |
Weird, since glm release 0.9.9.8 cmake target should be glm::glm. On the other hand your tinyobjloader library is indeed old and don't have latest cmake changes. Anyway. This is not important. We know that correct targets are glm::glm and tinyobjloader::tinyobjloader. And this specific problem is in dev environment. Possible solutions are:
More importantly, I'd like to see if there are any issues on windows. |
I just tested it on Windows and ran into a few small issues:
It looks like it couldn't automatically find
However, it did find both After generating all of the projects I could build them just fine with Visual Studio 2017. However, the executables crash because they can't find I fixed this by changing the "Working Directory" in the "Debugging" section of the project settings from
I'm not sure what to do about the dll issue, but we should probably just recommend users to add |
Thanks! Where is This statement is basically searches for stb_image.h in standard include locations (e.g. /usr/include, /usr/include/ARCH, /usr/ARCH/include, etc.) with additional subdirectory stb to check below each standard directory:
In my case it is in /usr/include/stb/stb_image.h Solution would be to set |
I guess the runtime problem finding the dll is caused by changed location of the GLFW binary dir. Try this - instead of manually renaming GLFW folder to glfw3, configure and build GLFW with
When |
In
That didn't make a difference for me. I think that it'll only find With that said, we could avoid this situation by statically linking glfw3 on Windows. On a sidenote, the issue with the glm target being named differently in Arch will be fixed soon. |
Configuring with |
Alright, but then you might as well configure |
Unfortunately upstream STB is not providing any config packages, because it is designed to be project-level drop-in headers. If there is a well known windows development practice when it comes to 3rd party libraries locations, we could hard-code additional paths argument (called |
Right, but I don't think it's common to have all header files together in a single directory like with
I don't think there is any, unfortunately. I don't know of any myself and I couldn't find any suggestions online either. |
I agree - having headers for all libraries in single default location is not ideal. My point is that additional include paths (plural), if required, meant to be configured by user via well known Speaking of glfw3 runtime issue - adding glfw library location to |
Would you consider this ready to be merged now? |
Yes, I think it's ready. |
Nice, thanks again for the work in putting this together. |
Calling
cmake --build .
will build the sample code executables for eachchapter in it's own folders, compile corresponding shaders and copy all
required resources to appropriate sub-folders. After that any example is
ready to be run from it's build sub-folder.
CMake project requires following dependencies: