BRabbit27
BRabbit27

Reputation: 6623

How to tell cmake to look in /usr/local/zlib/lib instead of /usr/lib?

I am trying to compile apitrace, however, when I run cmake, I got the following message

-- Could NOT find ZLIB: Found unsuitable version "1.2.5", but required
   is at least "1.2.6" (found /usr/lib/libz.dylib)

I have installed the most recent version of zlib in /usr/local/zlib, how can I tell cmake to look for it in that path? I already tried with cmake -DCMAKE_PREFIX_PATH=/usr/local/zlib/ but it didn't work.

Upvotes: 0

Views: 1591

Answers (2)

Robert
Robert

Reputation: 849

You can usually also set a variable like ZLIB_DIR to your preferred dependency location. The exact variable name depends on the definition in FindZLIB.cmake but you should usually find a corresponding variable using the cmake gui, e.g. ccmake.

Setting the CMAKE_PREFIX_PATH you specify where Find_XXX() macros will search for your dependencies.

Removing the build dir shouldn't be necessary. It's only required when cmake already successfully found a dependency and you want to find it a different one. However, in this case it suffices to remove CMackeCache.txt.

Upvotes: 1

BRabbit27
BRabbit27

Reputation: 6623

I erased all the files within the build directory and then run again cmake with the variable -DCMAKE_PREFIX_PATH set to where zlib was and it found it.

Upvotes: 1

Related Questions