find_library.rst 4.2 KB

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