Warning, /network/libktorrent/cmake/FindLibGMP.cmake is written in an unsupported language. File is not indexed.

0001 #.rst:
0002 # FindLibGMP
0003 # ----------
0004 #
0005 # Try to find the GNU MP Library (libgmp).
0006 #
0007 # This will define the following variables:
0008 #
0009 # ``LibGMP_FOUND``
0010 #     True if libgmp is available.
0011 #
0012 # ``LibGMP_VERSION``
0013 #     The version of LibGMP
0014 #
0015 # ``LibGMP_INCLUDE_DIRS``
0016 #     This should be passed to target_include_directories() if
0017 #     the target is not used for linking
0018 #
0019 # ``LibGMP_LIBRARIES``
0020 #     This can be passed to target_link_libraries() instead of
0021 #     the ``LibGMP::LibGMP`` target
0022 #
0023 # If ``LibGMP_FOUND`` is TRUE, the following imported target
0024 # will be available:
0025 #
0026 # ``LibGMP::LibGMP``
0027 #     The libgmp library
0028 #
0029 # Since 1.9.50.
0030 
0031 #=============================================================================
0032 # SPDX-FileCopyrightText: 2006 Laurent Montel <montel@kde.org>
0033 # SPDX-FileCopyrightText: 2016 Christophe Giboudeaux <cgiboudeaux@gmx.com>
0034 #
0035 # SPDX-License-Identifier: BSD-3-Clause
0036 #=============================================================================
0037 
0038 find_path(LibGMP_INCLUDE_DIRS NAMES gmp.h)
0039 
0040 find_library(LibGMP_LIBRARIES NAMES gmp libgmp)
0041 
0042 # Get version from gmp.h
0043 if(LibGMP_INCLUDE_DIRS)
0044     file(STRINGS ${LibGMP_INCLUDE_DIRS}/gmp.h _GMP_H REGEX "^#define __GNU_MP_VERSION.*$")
0045     if(_GMP_H)
0046         string(REGEX REPLACE "^.*__GNU_MP_VERSION[ ]+([0-9]+).*$" "\\1" LibGMP_MAJOR_VERSION "${_GMP_H}")
0047         string(REGEX REPLACE "^.*__GNU_MP_VERSION_MINOR[ ]+([0-9]+).*$" "\\1" LibGMP_MINOR_VERSION "${_GMP_H}")
0048         string(REGEX REPLACE "^.*__GNU_MP_VERSION_PATCHLEVEL[ ]+([0-9]+).*$" "\\1" LibGMP_PATCH_VERSION "${_GMP_H}")
0049 
0050         set(LibGMP_VERSION "${LibGMP_MAJOR_VERSION}.${LibGMP_MINOR_VERSION}.${LibGMP_PATCH_VERSION}")
0051         unset(_GMP_H)
0052     else()
0053         # parsing gmp.h failed, try test code instead
0054         set(_gmp_version_source "
0055 #include <stddef.h>
0056 #include <stdio.h>
0057 #include <gmp.h>
0058 int main()
0059 {
0060   printf(\"%d.%d.%d\",__GNU_MP_VERSION, __GNU_MP_VERSION_MINOR, __GNU_MP_VERSION_PATCHLEVEL);
0061 }
0062 "       )
0063         set(_gmp_version_source_file ${CMAKE_BINARY_DIR}/CMakeTmp/cmake_gmp_version_check.cpp)
0064         file(WRITE "${_gmp_version_source_file}" "${_gmp_version_source}")
0065         try_run(_gmp_version_compile_result _gmp_version_run_result ${CMAKE_BINARY_DIR} ${_gmp_version_source_file}
0066                 CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:STRING=${LibGMP_INCLUDE_DIRS}"
0067                 RUN_OUTPUT_VARIABLE _gmp_version_output )
0068 
0069         set(LibGMP_VERSION "${_gmp_version_output}")
0070     endif()
0071 endif()
0072 
0073 include(FindPackageHandleStandardArgs)
0074 find_package_handle_standard_args(LibGMP
0075     FOUND_VAR LibGMP_FOUND
0076     REQUIRED_VARS LibGMP_INCLUDE_DIRS LibGMP_LIBRARIES
0077     VERSION_VAR LibGMP_VERSION
0078 )
0079 
0080 if(LibGMP_FOUND AND NOT TARGET LibGMP::LibGMP)
0081     add_library(LibGMP::LibGMP UNKNOWN IMPORTED)
0082     set_target_properties(LibGMP::LibGMP PROPERTIES
0083         IMPORTED_LOCATION "${LibGMP_LIBRARIES}"
0084         INTERFACE_INCLUDE_DIRECTORIES "${LibGMP_INCLUDE_DIRS}")
0085 endif()
0086 
0087 mark_as_advanced(LibGMP_INCLUDE_DIRS LibGMP_LIBRARIES)
0088 
0089 include(FeatureSummary)
0090 set_package_properties(LibGMP PROPERTIES
0091     URL "https://gmplib.org/"
0092     DESCRIPTION "A library for calculating huge numbers (integer and floating point)."
0093 )