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
30find_path(LIBM_INCLUDE_DIRS
31  NAMES math.h
32  PATHS /usr/include /usr/local/include /usr/local/bic/include
33  NO_DEFAULT_PATH
34)
35find_library(LIBM_LIBRARIES m)
36include(FindPackageHandleStandardArgs)
37find_package_handle_standard_args(LibM DEFAULT_MSG LIBM_LIBRARIES LIBM_INCLUDE_DIRS)
38mark_as_advanced(LIBM_INCLUDE_DIRS LIBM_LIBRARIES)
39
40if(LIBM_FOUND)
41    if(NOT TARGET LIBM::LIBM)
42      add_library(LIBM::LIBM UNKNOWN IMPORTED)
43      set_target_properties(LIBM::LIBM PROPERTIES
44        IMPORTED_LOCATION "${LIBM_LIBRARIES}"
45        INTERFACE_INCLUDE_DIRECTORIES "${LIBM_INCLUDE_DIRS}")
46    endif()
47endif()
48