| 1 |
# Distributed under the original FontForge BSD 3-clause license |
| 2 |
|
| 3 |
#[=======================================================================[.rst: |
| 4 |
FindMathLib |
| 5 |
----------- |
| 6 |
|
| 7 |
Determines if linking to 'm' is required for math functionality. |
| 8 |
|
| 9 |
Imported Targets |
| 10 |
^^^^^^^^^^^^^^^^ |
| 11 |
|
| 12 |
This module defines the following :prop_tgt:`IMPORTED` target: |
| 13 |
|
| 14 |
``MathLib::MathLib`` |
| 15 |
|
| 16 |
Result Variables |
| 17 |
^^^^^^^^^^^^^^^^ |
| 18 |
|
| 19 |
This module will set the following variables in your project: |
| 20 |
|
| 21 |
``MathLib_IS_BUILT_IN`` |
| 22 |
set if the math library is built-in to the C standard library |
| 23 |
``MathLib_LIBRARIES`` |
| 24 |
the math library to link against, if any |
| 25 |
|
| 26 |
#]=======================================================================] |
| 27 |
|
| 28 |
|
| 29 |
include(CheckFunctionExists) |
| 30 |
include(CMakePushCheckState) |
| 31 |
|
| 32 |
if(NOT DEFINED MathLib_IS_BUILT_IN) |
| 33 |
if(NOT DEFINED MathLib_LIBRARIES) |
| 34 |
cmake_push_check_state(RESET) |
| 35 |
set(CMAKE_REQUIRED_QUIET TRUE) |
| 36 |
check_function_exists(pow MathLib_IS_BUILT_IN) |
| 37 |
cmake_pop_check_state() |
| 38 |
else() |
| 39 |
set(MathLib_IS_BUILT_IN FALSE) |
| 40 |
endif() |
| 41 |
endif() |
| 42 |
|
| 43 |
if(NOT MathLib_IS_BUILT_IN) |
| 44 |
find_library(MathLib_LIBRARIES |
| 45 |
NAMES m |
| 46 |
DOC "math library") |
| 47 |
set(MathLib_OK ${MathLib_LIBRARIES}) |
| 48 |
else() |
| 49 |
set(MathLib_OK "built-in") |
| 50 |
endif() |
| 51 |
|
| 52 |
mark_as_advanced(MathLib_LIBRARIES) |
| 53 |
|
| 54 |
include(FindPackageHandleStandardArgs) |
| 55 |
find_package_handle_standard_args(MathLib REQUIRED_VARS MathLib_OK) |
| 56 |
|
| 57 |
if(MathLib_FOUND AND NOT TARGET MathLib::MathLib) |
| 58 |
add_library(MathLib::MathLib INTERFACE IMPORTED) |
| 59 |
set_property(TARGET MathLib::MathLib PROPERTY INTERFACE_LINK_LIBRARIES "${MathLib_LIBRARIES}") |
| 60 |
endif() |