Cannot add stb to cmake build
kirhgoff opened this issue · 3 comments
Hello,
Thank you for your great project, started with it following OpenGL tutorial and it was very easy to jump to the coding. But I stumbled on textures part and would appreciate a help here. Glitter README.md does not contain any instructions how to add stb library to the build and I believe setting up a build is the most complicated part in C++ development.
What I did:
- Used stbi_load function to load image file in main .cpp (included stb header)
- CMakeLists.txt - added Glitter/Vendor/stb to inclide_directories
- CMakeLists.txt - added stb to target_link_libraries
Getting an error:
CMake Error at CMakeLists.txt:21 (add_subdirectory): The source directory /Users/klastovirya/Projects/opengl-sandbox/Glitter/Vendor/stb does not contain a CMakeLists.txt file.
And this is true - there are just headers and c file.
I tried another approach - I removed target link, added stb folder/*.c to vendor sources, still an error, now builder cannot find symbols for stb functions.
Would be very grateful for any advice. Cmake file is here https://github.com/kirhgoff/opengl-sandbox/blob/master/CMakeLists.txt
Seems that I managed to do that:
- added stb/*.h as vendor source
- added #define STB_IMAGE_IMPLEMENTATION to main.cpp
Hi there! You may find these four lines to be of help. 😄
You shouldn't need to modify the CMakeLists.txt file to use STB. It should just work out of the box as configured here ...
👍