find_library.rst 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. and :prop_gbl:`FIND_LIBRARY_USE_LIB64_PATHS` global properties.
  48. If the :prop_gbl:`FIND_LIBRARY_USE_LIB32_PATHS` global property is set
  49. all search paths will be tested as normal, with ``32/`` appended, and
  50. with all matches of ``lib/`` replaced with ``lib32/``. This property is
  51. automatically set for the platforms that are known to need it if at
  52. least one of the languages supported by the :command:`project` command
  53. is enabled.
  54. If the :prop_gbl:`FIND_LIBRARY_USE_LIB64_PATHS` global property is set
  55. all search paths will be tested as normal, with ``64/`` appended, and
  56. with all matches of ``lib/`` replaced with ``lib64/``. This property is
  57. automatically set for the platforms that are known to need it if at
  58. least one of the languages supported by the :command:`project` command
  59. is enabled.