CMake find_library匹配行为? [英] CMake find_library matching behavior?

查看:1455
本文介绍了CMake find_library匹配行为?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个指定find_library(名称PATHS path1..pathn)



我的问题是find_library如何匹配库文件的名称(在Windows和Linux) p>

例如,我无法让find_library在提供的GraphicsMagicK的Windows二进制安装中识别MagicK和MagicK ++ dll文件:



文件是:CORE_RL_magick_.dll



搜索查询:



magick
CORE_RL_magick



无效。

解决方案

请查看此文档链接:



http://www.cmake.org/cmake/help/v2.8.10/cmake.html#command:find_library



http://www.cmake.org/cmake/help/v2.8.10/cmake。 html#variable:CMAKE_FIND_LIBRARY_PREFIXES



http://www.cmake.org/cmake/help/v2.8.10/cmake.html#variable:CMAKE_FIND_LIBRARY_SUFFIXES



find_library可以接受一个或多个库名称。这些名称的前缀为CMAKE_FIND_LIBRARY_PREFIXES,并附加了CMAKE_FIND_LIBRARY_SUFFIXES



在您的情况下,我会为Windows写入

  SET(CMAKE_FIND_LIBRARY_PREFIXES)
SET(CMAKE_FIND_LIBRARY_SUFFIXES.lib.dll)



和Linux

  SET(CMAKE_FIND_LIBRARY_PREFIXES lib)
SET(CMAKE_FIND_LIBRARY_SUFFIXES.so.a)

  find_library(
magick
CORE_RL_magick_(如果同一个库上有多个名称不同的系统)

PATHS
path1
path2
...
(在文档中指定的其他选项,对您来说是有用的)


One specifies find_library( name PATHS path1..pathn)

My question is how does find_library match name to the library file (on Windows and Linux)?

For example, I am unable to have find_library identify the MagicK and MagicK++ dll files in the provided windows binary installation of GraphicsMagicK:

The files is: CORE_RL_magick_.dll

Searching for the queries:

magick CORE_RL_magick

does not work.

解决方案

You might want to take a look at this documentation links:

http://www.cmake.org/cmake/help/v2.8.10/cmake.html#command:find_library

http://www.cmake.org/cmake/help/v2.8.10/cmake.html#variable:CMAKE_FIND_LIBRARY_PREFIXES

http://www.cmake.org/cmake/help/v2.8.10/cmake.html#variable:CMAKE_FIND_LIBRARY_SUFFIXES

find_library may accept one or more library names. Those names get the value of CMAKE_FIND_LIBRARY_PREFIXES prepended and CMAKE_FIND_LIBRARY_SUFFIXES appended. This two variables should be set for each OS depending on how the librares are prefixed or suffixed there.

In your case I'd write for Windows

SET(CMAKE_FIND_LIBRARY_PREFIXES "")
SET(CMAKE_FIND_LIBRARY_SUFFIXES ".lib" ".dll")

and for Linux

SET(CMAKE_FIND_LIBRARY_PREFIXES "lib")
SET(CMAKE_FIND_LIBRARY_SUFFIXES ".so" ".a")

and then write

find_library(
    magick
    CORE_RL_magick_ (or NAMES if there are multiple names for the same library on different systems)

    PATHS
      path1
      path2
    ...
    (other options that are specified in documentation and would be usefull to you)
)

这篇关于CMake find_library匹配行为?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆