(I’ve used CMake before, this is my first time writing a CMakeLists.txt. Sorry for any cluelessness.)
I wanted to build some code using the OpenGL library, which in modern times is provided through two libraries: GLEW and GLFW. I installed them on my macOS laptop using Homebrew. The good news is that it all worked in a simple and elegant fashion:
cmake_minimum_required(VERSION 3.10)
project(Project)
add_executable(Project main.cpp)
find_package(GLFW3 REQUIRED)
find_package(GLEW REQUIRED)
target_link_libraries(Project glfw GLEW::glew)
The bad news was that it took a lot of tries to get there, with many visits to cmake.org and stackoverflow, and many much longer versions of the CMakeLists.txt file. Eventually I found this approach. It worked for me to say “glfw” but not “GLFW::glfw” in that call to target_link_libraries(). The latter (GLFW::glfw) seemed more consistent, and was given in examples in several of the SO answers.
I am fine with whatever it take to make it work, but is this the way it is suppose to work?
Thanks,
Craig