I’m using VS to add in the Libraries of GLFW and GLM to my project. I’m very new but it gives me an error saying it’s not built.
CMake Error at C:\Users\patri\Documents\Game_dev\Engines\EndBullet\CMakeLists.txt:42 (target_link_libraries):
Attempt to add link library “glm” to target “Engine” which is not built
in this directory.
the ${CMAKE_PROJECT_NAME} should evaluate to EndBullet, not to Engine. It could be that one of the CMakeLists.txt’s in added sub-directories modifies this variable or something.
Also, from the only CMakeLists.txt file that you shared it seems that there is not a single target declared (neither a library nor an executable), which GLM and GLFW are supposed to be linked with.
I’d recommend avoiding using the CMAKE_PROJECT_NAME variable and just use the target name directly. If you look at the docs for CMAKE_PROJECT_NAME, pay attention to how it describes the variable’s behavior. You’re likely picking up the Engine project name from the top-level CMakeLists.txt that’s pulling in the one you’ve pasted. You likely are not creating a library named that and so the target_link_libraries is failing because the target doesn’t exist.
You may instead be meaning to use the PROJECT_NAME variable which likely has the behavior you’re looking for since it picks up the last call to project().
At any rate, you should be using EndBullet directly instead of trying to use the CMake variable. The name shouldn’t change often, so using the variable loses some of its benefit. It also avoids this sort of confusion on how these CMake variables behave.