File: FindNTL.cmake

package info (click to toggle)
cgal 6.1.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 144,952 kB
  • sloc: cpp: 811,597; ansic: 208,576; sh: 493; python: 411; makefile: 286; javascript: 174
file content (102 lines) | stat: -rw-r--r-- 2,887 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# NTL needs GMP 3.1.1 or newer, this script will fail if an old version is
# detected

find_package( GMP REQUIRED )

if( (TARGET CGAL AND NOT WITH_GMP) OR NOT GMP_FOUND )

  message( FATAL_ERROR "NTL requires GMP" )
  set( NTL_FOUND FALSE )

else( (TARGET CGAL AND NOT WITH_GMP) OR NOT GMP_FOUND )

  include( ${CMAKE_CURRENT_LIST_DIR}/CGAL_VersionUtils.cmake )

  get_dependency_version( GMP )

  IS_VERSION_LESS("${GMP_VERSION}" "3.1.1" _IS_GMP_VERSION_TOO_LOW)

  if( _IS_GMP_VERSION_TOO_LOW )

    message( FATAL_ERROR, "NTL needs GMP>=3.1.1. Your GMP version is ${GMP_VERSION}." )

  else( _IS_GMP_VERSION_TOO_LOW )

    find_path(NTL_INCLUDE_DIR
              NAMES NTL/ZZ.h
              HINTS ENV NTL_INC_DIR
                    ENV NTL_DIR
              PATH_SUFFIXES include
              DOC "The directory containing the NTL include files"
             )

    find_library(NTL_LIBRARY
                 NAMES ntl
                 HINTS ENV NTL_LIB_DIR
                       ENV NTL_DIR
                 PATH_SUFFIXES lib
                 DOC "Path to the NTL library"
                )

    if ( NTL_INCLUDE_DIR AND NTL_LIBRARY )

       #check version

       set( NTL_VERSION_H "${NTL_INCLUDE_DIR}/NTL/version.h" )

       if ( EXISTS ${NTL_VERSION_H} )

         file( READ "${NTL_VERSION_H}" NTL_VERSION_H_CONTENTS )

         string( REGEX MATCH "[0-9]+(\\.[0-9]+)+" CGAL_NTL_VERSION "${NTL_VERSION_H_CONTENTS}" )

         message( STATUS "DETECTED NTL_VERSION = '${CGAL_NTL_VERSION}'" )

         IS_VERSION_GREATER( "${CGAL_NTL_VERSION}" "5.0.0" _IS_NTL_VERSION_GREATER )

         if ( _IS_NTL_VERSION_GREATER )
           set( NTL_FOUND TRUE )
         else ( _IS_NTL_VERSION_GREATER )
           set( NTL_FOUND FALSE )
         endif ( _IS_NTL_VERSION_GREATER )


       endif (EXISTS ${NTL_VERSION_H} )

    endif ( NTL_INCLUDE_DIR AND NTL_LIBRARY )

    if ( NTL_FOUND )

      #message( STATUS "Found NTL in version '${CGAL_NTL_VERSION}'" )
      set ( NTL_INCLUDE_DIRS ${NTL_INCLUDE_DIR} )
      set ( NTL_LIBRARIES ${NTL_LIBRARY} )

      get_filename_component(NTL_LIBRARIES_DIR ${NTL_LIBRARIES} PATH CACHE )

      include(FindPackageHandleStandardArgs)

      find_package_handle_standard_args( NTL
                                         DEFAULT_MSG
                                         NTL_LIBRARY
                                         NTL_INCLUDE_DIR )

      mark_as_advanced( NTL_INCLUDE_DIR NTL_LIBRARY )

      # TODO add flag to CGAL Polynomials

    endif( NTL_FOUND )


  endif( _IS_GMP_VERSION_TOO_LOW )

endif( (TARGET CGAL AND NOT WITH_GMP) OR NOT GMP_FOUND )

if ( NTL_FOUND )
#  if ( NOT NTL_FIND_QUIETLY )
#    message(STATUS "Found NTL: ${NTL_LIBRARY}")
#  endif (NOT NTL_FIND_QUIETLY )
else ( NTL_FOUND )
  if ( NTL_FIND_REQUIRED )
    message( FATAL_ERROR "Could not find NTL" )
  endif ( NTL_FIND_REQUIRED )
endif ( NTL_FOUND )