check this post Configuring a C++ OpenCV project with CMake. It will automatically configure the project using CMake. It's not tested on macOS or with the Clang compiler, but it should work as well.