I have an assignment to create a C program, and one of the libraries we are encouraged to use is GLM, found on this GitHub link here:
So as you can see, being so new to this I can't really identify yet what the overarching process looks like. Here's what my first attempt looked like: (here, I had downloaded the library as a .zip, uncompressed it and copied the whole thing into a lib folder)
It seems CMake was able to find GLM, since it printed a version number. But it still won't find the library when writing the "#include" line, so I must be missing a step somewhere. Any and all help is greatly appreciated. If you need any more information from me, just ask!
CodePudding user response:
With the help of a friend, I managed to solve it! For posterity, here's the setup that worked for me.
I downloaded the library from GitHub using the releases page on the right sidebar:
I extracted the downloaded .zip, and placed the entire resulting folder in my project structure. For that, I made a "lib" folder (though I suspect folder names or structure isn't as important as I first thought). This is my working project structure:
As you can see, I also no longer have a separate "src" folder, though I'm sure I could add one if need be. The important part here is that each folder level has its own CMakeLists.txt. In short, the CMakeLists in the project root links the "lib" folder, and the CMakeLists in the lib folder links the "glm" folder. And the one in the glm folder was in the library I downloaded, and it already handles all the linking for subsequent folders and files. Here's what the CMakeLists in the project root looks like:
Line 7 links the lib folder. Line 8 creates an executable from the source files I've created (main.cpp, set on line 5). And line 9 links the glm library and my executable. Here's what the CMakeLists in the lib folder looks like:
Not much in there but linking the glm subdirectory, which then already has a library named glm that I can use in the root CMakeLists.
With all that set up, I can now successfully use the "#include" command in my main.cpp, and it finds the library:
Hopefully any other libraries I add can follow the same process. If anyone else runs into the same roadblock, I hope this helps clarify things.