Richard Macwan
Richard Macwan

Reputation: 452

Clear CMake's internal cache

I am sure there is a simple command for this.

I had installed opencv 2.4.3 manually in /usr/local.

Then I removed it and installed OpenCV 2.4.5 from the arch community(I am using Arch linux) which gets installed in /usr

Now when I try to use OpenCV in a cmake project, cmake returns the old paths from /usr/local.

I did some digging around and found that if remove "CACHE" from the line: get_filename_component(OpenCV_CONFIG_PATH ="${CMAKE_CURRENT_LIST_FILE}" PATCH CACHE) in /usr/share/opencv/OpenCVConfig.cmake I get the correct path.

This points to my question. How do I clear the cmake cache?I am talking about cmake's internal cache not the application's cache which can be deleted by removing CMakeCache.txt. Is there a command? Or where is the cmake cache directory/file located? I am sure there's a simple answer for this. I know how to set/unset a CACHE variable, but don't know how to clear the complete cache.

Upvotes: 6

Views: 32429

Answers (2)

Yuanhui
Yuanhui

Reputation: 479

Recompiling the dependency library solved my problem.

I have a project that depends on Opencv. When I still using Xcode 7.2beta, the path of SDK of MacOSX is "/Applications/xcode7.2beta.app/Content/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk". So, the cmake generated and compiled opencv libraries with MacOSX10.11.sdk under "/Applications/xcode7.2beta.app/".

A few days ago, I upgraded my xcode to 8.0, the new path of xcode and its SDK is "/Applications/xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk". But anyway, when cmake generates my project, the reference to opencv always points to the old xcode.

Later I realized that opencv was generated using the old Xcode, so I re-compiled the opencv with the new Xcode, and my project was compiled correctly.

Upvotes: 0

Richard Macwan
Richard Macwan

Reputation: 452

The problem was with pkg-config settings. I hadn't removed the old .pc file and adjusted the PKG_CONFIG_PATH. pkg-config was using the opencv.pc file present in /usr/local/lib/pkgconfig rather than the one present in /usr/lib/pkgconfig. There isn't any cache that cmake uses internally, i think.

Upvotes: 1

Related Questions