简体   繁体   中英

why cmake pick the wrong library?

I have this line in my cmake to pick glog library:

find_library(GLOG_LIBRARY libglog $ENV{GLOG_DIR}/x64/Release)
message(${GLOG_LIBRARY})

and in the release folder I have these files:

03/03/2015  15:00           308,736 libglog.dll
03/03/2015  15:00            64,998 libglog.exp
03/03/2015  15:00           104,884 libglog.lib
03/03/2015  15:00         3,248,128 libglog.pdb

But when I run cmake, I can see that GLOG_LIBRARY is set to libglog_static.lib

why cmake get the wrong library?

Ok, so the problem was that most probably the change in the code to use hint was made after first execution of the script. CMake by default caches most values of its standard functions.

find routines by default first check whether the variable is present in the cache, thus even if you change your code, it might appear not to work. One does need to clear cache manually before trying new version, or if somehow configuration changed - eg some flag that changes version or alters resolution process is used - if the name of the variable is the same it will be pulled from cache.

The search process as well as parameters are described in the documentation: http://www.cmake.org/cmake/help/v3.0/command/find_library.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM