I want to use CMAKE_PREFIX_PATH
to set a directory (say /usr/local2
) for cmake
to search for headers and libraries. I tried to use the command line
cmake -DCMAKE_PREFIX_PATH=/usr/local2 /path/to/src
But cmake
does not seem to take that hint (i.e. it still found the library in system path /usr/local
). I also tried ccmake
and cmake-gui
, but neither provide me the CMAKE_PREFIX_PATH
entry to edit. When I search for "PREFIX", the only one shows up is CMAKE_INSTALL_PREFIX
. Am I not looking at the right place? Or did I miss something when installing cmake
?
I am using cmake
version 3.1.3 (and also tried 3.0.2), which is installed with MacPorts. And I did remember to check the "advanced" box for all options.
My CMakeLists.txt
file is pretty simple
cmake_minimum_required (VERSION 3.0)
project (my_project CXX)
find_package (PNG REQUIRED)
include_directories (${PNG_INCLUDE_DIRS})
add_executable (my_executable test.cc)
target_link_libraries (my_executable ${PNG_LIBRARIES})
and I also made sure the /usr/local2/lib
contains the libpng.dylib
for cmake
to search for.
In the CMakeCache.txt
file, I found
//No help, variable specified on the command line.
CMAKE_PREFIX_PATH:UNINITIALIZED=/usr/local2
Thanks in advance for your help!