Issue
I'm trying to include OpenCv in a project, I actually have 2 times the same version of this lib on my computer. One compiled with additionnal needed functions ( Cuda&OpenGl support) at /good/path and one compiled without thoses needed function at /old/non/suitable/path.
I'm curently doing this in my cmake :
message(${OpenCV_LIBS})
message(${OpenCV_INCLUDE_DIRS})
message(${HINTS})
find_package( OpenCV 3.2.0 REQUIRED CONFIG PATHS "/good/path" NO_DEFAULT_PATH )
message(${OpenCV_INCLUDE_DIRS})
The first 3 messages reports errors, in other words the variable are empty. And the last message writes "/old/non/suitable/path/include"
According to the find package documentation, with adding the NO_DEFAULT_PATH option I should check only the explicit PATHS and HINTS but HINTS is empty as I checked it.
Does anyone have any idee on why I find the other old library instead of the one in the /good/path which once more should be the only path checked ?
Edit : For anyone having the same issue of not successfully selecting the wanted library, one solution is to rename the LibConfig.cmake of the old library to anything else. That will force cmake to find the last library. Still, that's pretty awful and I have no idee why NO_DEAULF_PATH ins't working as it should be. I'm waiting here a few days in case somebody sees an answer and if there isn't any response, I will open an issue directly on the cmake website.
Solution
Removing the build directory is the way to go.
Otherwise a cached path in the build directory overwrite the path modification in the cmake.
Ps : The answer is in Tsyvarev comment, I'm answering myself to close the question.
Answered By - TTDM