find_library.rst 3.6 KB

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