find_library.rst 3.9 KB

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