find_library.rst 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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 :prop_gbl:`FIND_LIBRARY_USE_LIB32_PATHS` global property is set
  43. all search paths will be tested as normal, with ``32/`` appended, and
  44. with all matches of ``lib/`` replaced with ``lib32/``. This property is
  45. automatically set for the platforms that are known to need it if at
  46. least one of the languages supported by the :command:`project` command
  47. is enabled.
  48. If the :prop_gbl:`FIND_LIBRARY_USE_LIB64_PATHS` global property is set
  49. all search paths will be tested as normal, with ``64/`` appended, and
  50. with all matches of ``lib/`` replaced with ``lib64/``. 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.