CheckCXXSymbolExists.cmake 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. # file Copyright.txt or https://cmake.org/licensing for details.
  3. #[=======================================================================[.rst:
  4. CheckCXXSymbolExists
  5. --------------------
  6. Check if a symbol exists as a function, variable, or macro in C++
  7. .. code-block:: cmake
  8. CHECK_CXX_SYMBOL_EXISTS(<symbol> <files> <variable>)
  9. Check that the ``<symbol>`` is available after including given header
  10. ``<files>`` and store the result in a ``<variable>``. Specify the list of
  11. files in one argument as a semicolon-separated list.
  12. CHECK_CXX_SYMBOL_EXISTS() can be used to check in C++ files, as
  13. opposed to CHECK_SYMBOL_EXISTS(), which works only for C.
  14. If the header files define the symbol as a macro it is considered
  15. available and assumed to work. If the header files declare the symbol
  16. as a function or variable then the symbol must also be available for
  17. linking. If the symbol is a type or enum value it will not be
  18. recognized (consider using CheckTypeSize or CheckCSourceCompiles).
  19. The following variables may be set before calling this macro to modify
  20. the way the check is run:
  21. ``CMAKE_REQUIRED_FLAGS``
  22. string of compile command line flags
  23. ``CMAKE_REQUIRED_DEFINITIONS``
  24. list of macros to define (-DFOO=bar)
  25. ``CMAKE_REQUIRED_INCLUDES``
  26. list of include directories
  27. ``CMAKE_REQUIRED_LIBRARIES``
  28. list of libraries to link
  29. ``CMAKE_REQUIRED_QUIET``
  30. execute quietly without messages
  31. #]=======================================================================]
  32. include_guard(GLOBAL)
  33. include(CheckSymbolExists)
  34. macro(CHECK_CXX_SYMBOL_EXISTS SYMBOL FILES VARIABLE)
  35. __CHECK_SYMBOL_EXISTS_IMPL("${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckSymbolExists.cxx" "${SYMBOL}" "${FILES}" "${VARIABLE}" )
  36. endmacro()