FindLibM.cmake 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #.rst:
  2. # FindLibM
  3. # --------
  4. #
  5. # Find the native realtime includes and library.
  6. #
  7. # IMPORTED Targets
  8. # ^^^^^^^^^^^^^^^^
  9. #
  10. # This module defines :prop_tgt:`IMPORTED` target ``LIBM::LIBM``, if
  11. # LIBM has been found.
  12. #
  13. # Result Variables
  14. # ^^^^^^^^^^^^^^^^
  15. #
  16. # This module defines the following variables:
  17. #
  18. # ::
  19. #
  20. # LIBM_INCLUDE_DIRS - where to find math.h, etc.
  21. # LIBM_LIBRARIES - List of libraries when using libm.
  22. # LIBM_FOUND - True if math library found.
  23. #
  24. # Hints
  25. # ^^^^^
  26. #
  27. # A user may set ``LIBM_ROOT`` to a math library installation root to tell this
  28. # module where to look.
  29. find_path(LIBM_INCLUDE_DIRS
  30. NAMES math.h
  31. PATHS /usr/include /usr/local/include /usr/local/bic/include
  32. NO_DEFAULT_PATH
  33. )
  34. find_library(LIBM_LIBRARIES m)
  35. include(FindPackageHandleStandardArgs)
  36. find_package_handle_standard_args(LibM DEFAULT_MSG LIBM_LIBRARIES LIBM_INCLUDE_DIRS)
  37. mark_as_advanced(LIBM_INCLUDE_DIRS LIBM_LIBRARIES)
  38. if(LIBM_FOUND)
  39. if(NOT TARGET LIBM::LIBM)
  40. add_library(LIBM::LIBM UNKNOWN IMPORTED)
  41. set_target_properties(LIBM::LIBM PROPERTIES
  42. IMPORTED_LOCATION "${LIBM_LIBRARIES}"
  43. INTERFACE_INCLUDE_DIRECTORIES "${LIBM_INCLUDE_DIRS}")
  44. endif()
  45. endif()