- My Development Notes/
- Posts/
- Where are the include and link directories for packages installed through Homebrew/
Where are the include and link directories for packages installed through Homebrew
I was trying to build a project which had dependencies of gflags
and glog
and used cmake
as the build tools.
I was using Homebrew on MacOSX, so I went ahead and installed the dependencies like so:
shell brew install glog brew install gflag
Now, I wanted to add include path and link path for these libs in the project.
My first shot was to add a CXXFLAGS
variable and expected that cmake
would pick it up.
export CXXFLAGS="-I/usr/local/Cellar/glog/0.3.4/include -I/usr/local/Cellar/gflags/2.1.2/include/"
cmake
did not pick up this because it never used CFLAGS or CXXFLAGS.
Next, I added the dependency manually in the CMakeLists.txt
file using the include_directories
and link_directories
like so:
include_directories(/usr/local/Cellar/glog/0.3.4/include)
include_directories(/usr/local/Cellar/gflags/2.1.2/include/)
link_directories(/usr/local/Cellar/glog/0.3.4/lib)
link_directories(/usr/local/Cellar/gflags/2.1.2/lib)
This approach was not scalable. I searched for a bit and found an acceptable solution. I added /usr/local/include
and /usr/local/lib
in the include and the link path respectively.
include_directories(/usr/local/include)
link_directories(/usr/local/lib)
This works! I am of the opinion that we can do better, but as of now I am okay with this.