diff options
author | Ray Molenkamp <github@lazydodo.com> | 2020-07-31 18:34:26 +0300 |
---|---|---|
committer | Ray Molenkamp <github@lazydodo.com> | 2020-07-31 18:34:26 +0300 |
commit | 83f8223543f58c3b0881a03b6e9ddffff918b680 (patch) | |
tree | 958e27296ccac727cd1f1c5dd3f134f2728f42a5 /build_files/cmake/Modules/FindGMP.cmake | |
parent | a2c6c51647d3a8f80e8057262882d9bf61055074 (diff) |
Deps builder: Add support for building GMP
Required for the new boolean code, disabled by default
until all platforms have landed the libs and the boolean
code actually lands in master.
Reviewed By: brecht
Differential Revision: https://developer.blender.org/D8384
Diffstat (limited to 'build_files/cmake/Modules/FindGMP.cmake')
-rw-r--r-- | build_files/cmake/Modules/FindGMP.cmake | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/build_files/cmake/Modules/FindGMP.cmake b/build_files/cmake/Modules/FindGMP.cmake new file mode 100644 index 00000000000..4469f32c785 --- /dev/null +++ b/build_files/cmake/Modules/FindGMP.cmake @@ -0,0 +1,96 @@ +# - Find GMP library +# Find the native GMP includes and library +# This module defines +# GMP_INCLUDE_DIRS, where to find gmp.h, Set when +# GMP_INCLUDE_DIR is found. +# GMP_LIBRARIES, libraries to link against to use GMP. +# GMP_ROOT_DIR, The base directory to search for GMP. +# This can also be an environment variable. +# GMP_FOUND, If false, do not try to use GMP. +# +# also defined, but not for general use are +# GMP_LIBRARY, where to find the GMP library. + +#============================================================================= +# Copyright 2011 Blender Foundation. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= + +# If GMP_ROOT_DIR was defined in the environment, use it. +IF(NOT GMP_ROOT_DIR AND NOT $ENV{GMP_ROOT_DIR} STREQUAL "") + SET(GMP_ROOT_DIR $ENV{GMP_ROOT_DIR}) +ENDIF() + +SET(_gmp_SEARCH_DIRS + ${GMP_ROOT_DIR} + /opt/lib/gmp +) + +FIND_PATH(GMP_INCLUDE_DIR + NAMES + gmp.h + HINTS + ${_gmp_SEARCH_DIRS} + PATH_SUFFIXES + include/gmp +) + +FIND_PATH(GMPXX_INCLUDE_DIR + NAMES + gmpxx.h + HINTS + ${_gmp_SEARCH_DIRS} + PATH_SUFFIXES + include/gmp +) + +FIND_LIBRARY(GMP_LIBRARY + NAMES + gmp + HINTS + ${_gmp_SEARCH_DIRS} + PATH_SUFFIXES + lib64 lib + ) + +FIND_LIBRARY(GMPXX_LIBRARY + NAMES + gmpxx + HINTS + ${_gmp_SEARCH_DIRS} + PATH_SUFFIXES + lib64 lib + ) + +if(GMP_INCLUDE_DIR) + SET(_version_regex "^#define[ \t]+__GNU_MP_VERSION[ \t]+\"([^\"]+)\".*") + file(STRINGS "${GMP_INCLUDE_DIR}/gmp.h" + GMP_VERSION REGEX "${_version_regex}") + string(REGEX REPLACE "${_version_regex}" "\\1" + GMP_VERSION "${GMP_VERSION}") + unset(_version_regex) +endif() + +# handle the QUIETLY and REQUIRED arguments and set GMP_FOUND to TRUE if +# all listed variables are TRUE +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(GMP DEFAULT_MSG + GMP_LIBRARY GMPXX_LIBRARY GMP_INCLUDE_DIR GMPXX_INCLUDE_DIR) + +IF(GMP_FOUND) + SET(GMP_LIBRARIES ${GMP_LIBRARY} ${GMPXX_LIBRARY}) + SET(GMP_INCLUDE_DIRS ${GMP_INCLUDE_DIR} ${GMPXX_INCLUDE_DIR}) +ENDIF(GMP_FOUND) + +MARK_AS_ADVANCED( + GMP_INCLUDE_DIR + GMP_LIBRARY + GMPXX_INCLUDE_DIR + GMPXX_LIBRARY +) |