Debian Codegraph @

texk/xdvipsk/thirdparty/libtiff/cmake/FindCMath.cmake

raw
1 # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
2 # file Copyright.txt or https://cmake.org/licensing for details.
3
4 #[=======================================================================[.rst:
5 FindCMath
6 --------
7
8 Find the native CMath includes and library.
9
10 IMPORTED Targets
11 ^^^^^^^^^^^^^^^^
12
13 This module defines :prop_tgt:`IMPORTED` target ``CMath::CMath``, if
14 CMath has been found.
15
16 Result Variables
17 ^^^^^^^^^^^^^^^^
18
19 This module defines the following variables:
20
21 ::
22
23 CMath_INCLUDE_DIRS - Where to find math.h
24 CMath_LIBRARIES - List of libraries when using CMath.
25 CMath_FOUND - True if CMath found.
26
27 #]=======================================================================]
28
29
30 include(CheckSymbolExists)
31 include(CheckLibraryExists)
32
33 check_symbol_exists(pow "math.h" CMath_HAVE_LIBC_POW)
34 find_library(CMath_LIBRARY NAMES m)
35
36 if(NOT CMath_HAVE_LIBC_POW)
37 set(CMAKE_REQUIRED_LIBRARIES_SAVE ${CMAKE_REQUIRED_LIBRARIES})
38 set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${CMath_LIBRARY})
39 check_symbol_exists(pow "math.h" CMath_HAVE_LIBM_POW)
40 set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_SAVE})
41 endif()
42
43 set(CMath_pow FALSE)
44 if(CMath_HAVE_LIBC_POW OR CMath_HAVE_LIBM_POW)
45 set(CMath_pow TRUE)
46 endif()
47
48 set(CMath_INCLUDE_DIRS)
49
50 include(FindPackageHandleStandardArgs)
51 FIND_PACKAGE_HANDLE_STANDARD_ARGS(CMath REQUIRED_VARS CMath_pow)
52
53 if(CMath_FOUND)
54 if(NOT CMath_INCLUDE_DIRS)
55 set(CMath_INCLUDE_DIRS)
56 endif()
57 if(NOT CMath_LIBRARIES)
58 if (CMath_LIBRARY)
59 set(CMath_LIBRARIES ${CMath_LIBRARY})
60 endif()
61 endif()
62
63 if(NOT TARGET CMath::CMath)
64 if(CMath_LIBRARIES)
65 add_library(CMath::CMath UNKNOWN IMPORTED)
66 set_target_properties(CMath::CMath PROPERTIES
67 IMPORTED_LOCATION "${CMath_LIBRARY}")
68 else()
69 add_library(CMath::CMath INTERFACE IMPORTED)
70 endif()
71 endif()
72 endif()