find_library.rst 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. find_library
  2. ------------
  3. .. |FIND_XXX| replace:: find_library
  4. .. |NAMES| replace:: NAMES name1 [name2 ...] [NAMES_PER_DIR]
  5. .. |SEARCH_XXX| replace:: library
  6. .. |SEARCH_XXX_DESC| replace:: library
  7. .. |prefix_XXX_SUBDIR| replace:: ``<prefix>/lib``
  8. .. |entry_XXX_SUBDIR| replace:: ``<entry>/lib``
  9. .. |FIND_PACKAGE_ROOT_PREFIX_PATH_XXX| replace::
  10. ``<prefix>/lib/<arch>`` if :variable:`CMAKE_LIBRARY_ARCHITECTURE` is set,
  11. and |FIND_PACKAGE_ROOT_PREFIX_PATH_XXX_SUBDIR|
  12. .. |CMAKE_PREFIX_PATH_XXX| replace::
  13. ``<prefix>/lib/<arch>`` if :variable:`CMAKE_LIBRARY_ARCHITECTURE` is set,
  14. and |CMAKE_PREFIX_PATH_XXX_SUBDIR|
  15. .. |CMAKE_XXX_PATH| replace:: :variable:`CMAKE_LIBRARY_PATH`
  16. .. |CMAKE_XXX_MAC_PATH| replace:: :variable:`CMAKE_FRAMEWORK_PATH`
  17. .. |SYSTEM_ENVIRONMENT_PATH_XXX| replace:: Directories in ``LIB``.
  18. On Windows hosts:
  19. ``<prefix>/lib/<arch>`` if :variable:`CMAKE_LIBRARY_ARCHITECTURE` is set,
  20. and |SYSTEM_ENVIRONMENT_PREFIX_PATH_XXX_SUBDIR|,
  21. and the directories in ``PATH`` itself.
  22. .. |CMAKE_SYSTEM_PREFIX_PATH_XXX| replace::
  23. ``<prefix>/lib/<arch>`` if :variable:`CMAKE_LIBRARY_ARCHITECTURE` is set,
  24. and |CMAKE_SYSTEM_PREFIX_PATH_XXX_SUBDIR|
  25. .. |CMAKE_SYSTEM_XXX_PATH| replace::
  26. :variable:`CMAKE_SYSTEM_LIBRARY_PATH`
  27. .. |CMAKE_SYSTEM_XXX_MAC_PATH| replace::
  28. :variable:`CMAKE_SYSTEM_FRAMEWORK_PATH`
  29. .. |CMAKE_FIND_ROOT_PATH_MODE_XXX| replace::
  30. :variable:`CMAKE_FIND_ROOT_PATH_MODE_LIBRARY`
  31. .. include:: FIND_XXX.txt
  32. When more than one value is given to the ``NAMES`` option this command by
  33. default will consider one name at a time and search every directory
  34. for it. The ``NAMES_PER_DIR`` option tells this command to consider one
  35. directory at a time and search for all names in it.
  36. Each library name given to the ``NAMES`` option is first considered
  37. as a library file name and then considered with platform-specific
  38. prefixes (e.g. ``lib``) and suffixes (e.g. ``.so``). Therefore one
  39. may specify library file names such as ``libfoo.a`` directly.
  40. This can be used to locate static libraries on UNIX-like systems.
  41. If the library found is a framework, then ``<VAR>`` will be set to the full
  42. path to the framework ``<fullPath>/A.framework``. When a full path to a
  43. framework is used as a library, CMake will use a ``-framework A``, and a
  44. ``-F<fullPath>`` to link the framework to the target.
  45. If the :variable:`CMAKE_FIND_LIBRARY_CUSTOM_LIB_SUFFIX` variable is set all
  46. search paths will be tested as normal, with the suffix appended, and with
  47. all matches of ``lib/`` replaced with
  48. ``lib${CMAKE_FIND_LIBRARY_CUSTOM_LIB_SUFFIX}/``. This variable overrides
  49. the :prop_gbl:`FIND_LIBRARY_USE_LIB32_PATHS`,
  50. :prop_gbl:`FIND_LIBRARY_USE_LIBX32_PATHS`,
  51. and :prop_gbl:`FIND_LIBRARY_USE_LIB64_PATHS` global properties.
  52. If the :prop_gbl:`FIND_LIBRARY_USE_LIB32_PATHS` global property is set
  53. all search paths will be tested as normal, with ``32/`` appended, and
  54. with all matches of ``lib/`` replaced with ``lib32/``. This property is
  55. automatically set for the platforms that are known to need it if at
  56. least one of the languages supported by the :command:`project` command
  57. is enabled.
  58. If the :prop_gbl:`FIND_LIBRARY_USE_LIBX32_PATHS` global property is set
  59. all search paths will be tested as normal, with ``x32/`` appended, and
  60. with all matches of ``lib/`` replaced with ``libx32/``. This property is
  61. automatically set for the platforms that are known to need it if at
  62. least one of the languages supported by the :command:`project` command
  63. is enabled.
  64. If the :prop_gbl:`FIND_LIBRARY_USE_LIB64_PATHS` global property is set
  65. all search paths will be tested as normal, with ``64/`` appended, and
  66. with all matches of ``lib/`` replaced with ``lib64/``. This property is
  67. automatically set for the platforms that are known to need it if at
  68. least one of the languages supported by the :command:`project` command
  69. is enabled.