find_library.rst 3.8 KB

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