Add /opt/local/lib, and any other likely install paths, to the set of paths searched by cmake in your CMakeLists.txt file:
set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} /opt/local/lib)
This appends /opt/local/lib to the set of paths in which cmake searches for libraries. This CMAKE_LIBRARY_PATH technique will affect all find_library
commands after you set the variable.
For a more surgical, library-by-library approach, modify the individual find_library commands:
find_library(Foo foo
PATHS /opt/local/lib)
Note that this does not hardcode /opt/local/lib as the only place to look for the library. Rather, it merely appends /opt/local/lib to the set of locations in which to search for the library. I often end up adding many such paths, covering the locations observed on all of the machines I know about. See the find_library documentation for more variations on this theme.
You might also wish to change CMAKE_INCLUDE_PATH, which affects the behavior of find_file()
and find_path()
commands.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…