Programming OpenGL on MacOS without XCode

I'm trying to use CLion (thus CMake) to create OpenGL applications using C++ on MacOS Monterey using a 2021 (so M1 based) Macbook.
Glew2 and GLFW3 are installed correctly using Homebrew, XCode and the commandline tools are installed as well.

Creating and compiling/running through XCode works fine, but using the same libraries and C++ source code from CLion doesn't work.
First it can't find the OpenGL library headers, I fixed that by placing a symlink from their location inside the XCode application libraries in a public location.
Problem is that now I get a linker error stating that Glew and GLFW are Arch64 and it's trying to build an x64 application from CLion. When forcing CLion to compile to arch64 I get an error that the OpenGL core libraries it's trying to link to are x64. Apparently XCode is smart enough to link to the correct libraries automagically but CMake can't find them.

Any ideas as to why this happens and what to do to resolve the problem?