xiaochen
xiaochen

Reputation: 33

find_library() only finds the path of the first library name

I am referring the official doc to use find_library() and my cmake version is 3.9.1.

In short, my find_library() only deals with the first library name and ignore the rest.

For example, when I do something like,

find_library (var NAMES libname1 libname2 PATHS libpath)

var will only get the full path-name of library libname1 not the counterpart of libname2. Both the libraries are placed correctly in libpath. In fact, if I reverse the order as NAMES libname2 libname1, var will only get the full path-name of library libname2

Any suggestion?

Upvotes: 3

Views: 786

Answers (1)

vre
vre

Reputation: 6744

The find_librarycommand finds a library by trying the NAMES one after another. So the NAMES are synonyms for the library (e.g. libjpg libjpeg). After the first match it saves the path to the library in the variable var. You need to use two find_library calls to accomplish what you are after.

Upvotes: 3

Related Questions