Installing a C/C++ library with homebrew on M1 Macs
Add an environment variable as follows
export CPATH=/opt/homebrew/include
export LIBRARY_PATH=/opt/homebrew/lib

to the file corresponding to the shell, like ~/.bash_profile for bash.
Alternatively create CMake file with content like
link_directories(&quot;/opt/homebrew/lib&quot;)
include_directories(&quot;/opt/homebrew/include&quot;)

Or
set(CMAKE_EXE_LINKER_FLAGS &quot;-L/opt/homebrew/lib &quot; CACHE STRING &quot;&quot; FORCE)
set(CMAKE_C_FLAGS   &quot;-I/opt/homebrew/include &quot; CACHE STRING &quot;&quot; FORCE )
set(CMAKE_CXX_FLAGS &quot;-I/opt/homebrew/include &quot; CACHE STRING &quot;&quot; FORCE)

and create projects like cmake -C ../link_dir.cmake -B ../build -S .