FindCGAL.cmake 5.91 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13
# - Find CGAL
# Find the CGAL autolinking headers.
#
#  CGAL_INCLUDE_DIR -  where to find CGAL.h, etc.
#  CGAL_FOUND        - True if CGAL found.

IF (CGAL_INCLUDE_DIR)
  # Already in cache, be silent
  SET(CGAL_FIND_QUIETLY TRUE)
ENDIF (CGAL_INCLUDE_DIR)

GET_FILENAME_COMPONENT(module_file_path ${CMAKE_CURRENT_LIST_FILE} PATH )

Jan Möbius's avatar
Jan Möbius committed
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
# Check if the base path is set
if ( NOT CMAKE_WINDOWS_LIBS_DIR )
  # This is the base directory for windows library search used in the finders we shipp.
  set(CMAKE_WINDOWS_LIBS_DIR "c:/libs" CACHE STRING "Default Library search dir on windows." )
endif()

if ( CMAKE_GENERATOR MATCHES "^Visual Studio 11.*Win64" )
  SET(VS_SEARCH_PATH "${CMAKE_WINDOWS_LIBS_DIR}/vs2012/x64/")
elseif ( CMAKE_GENERATOR MATCHES "^Visual Studio 11.*" )
  SET(VS_SEARCH_PATH "${CMAKE_WINDOWS_LIBS_DIR}/vs2012/x32/")
elseif ( CMAKE_GENERATOR MATCHES "^Visual Studio 12.*Win64" )
  SET(VS_SEARCH_PATH "${CMAKE_WINDOWS_LIBS_DIR}/vs2013/x64/")
elseif ( CMAKE_GENERATOR MATCHES "^Visual Studio 12.*" )
  SET(VS_SEARCH_PATH "${CMAKE_WINDOWS_LIBS_DIR}/vs2013/x32/")
elseif ( CMAKE_GENERATOR MATCHES "^Visual Studio 14.*Win64" )
  SET(VS_SEARCH_PATH "${CMAKE_WINDOWS_LIBS_DIR}/vs2015/x64/")
elseif ( CMAKE_GENERATOR MATCHES "^Visual Studio 14.*" )
  SET(VS_SEARCH_PATH "${CMAKE_WINDOWS_LIBS_DIR}/vs2015/x32/")
elseif ( CMAKE_GENERATOR MATCHES "^Visual Studio 15.*Win64" )
  SET(VS_SEARCH_PATH "${CMAKE_WINDOWS_LIBS_DIR}/vs2017/x64/")
elseif ( CMAKE_GENERATOR MATCHES "^Visual Studio 15.*" )
  SET(VS_SEARCH_PATH "${CMAKE_WINDOWS_LIBS_DIR}/vs2017/x32/")
endif()

38 39 40
IF (NOT APPLE )
	# Look for the header file.
	FIND_PATH(CGAL_INCLUDE_DIR NAMES CGAL/auto_link/auto_link.h
Jan Möbius's avatar
Jan Möbius committed
41 42
        	                   PATHS "${VS_SEARCH_PATH}/CGAL-4.12/include"
							          /usr/include
43
        	                         ../../External/include
Jan Möbius's avatar
Jan Möbius committed
44 45 46 47 48
									 $ENV{CGAL_DIR}/include									 
                                     "C:/libs/CGAL-3.6/include"
									 "C:/Program Files/CGAL-3.5/include"
                                     "C:/Programme/CGAL-3.5/include"
                                     "C:/libs/CGAL-3.5/include"
49
                	                 "C:/Program Files/CGAL-3.4/include"
Jan Möbius's avatar
Jan Möbius committed
50 51 52 53 54
                                     "C:/Programme/CGAL-3.4/include"
                                     "C:/libs/CGAL-3.4/include"
									 "C:/Programme/CGAL-3.9/include"
									 "C:/Program Files/CGAL-3.9/include"
									 "C:/Program Files (x86)/CGAL-3.9/include"
55 56 57 58 59 60 61 62 63 64 65 66 67 68
	                                 ${module_file_path}/../../../External/include )
ELSE( NOT APPLE)
	# Look for the header file.
	FIND_PATH(CGAL_INCLUDE_DIR NAMES CGAL/auto_link/auto_link.h
        	                   PATHS "/opt/local/include"
                 )

ENDIF( NOT APPLE )



MARK_AS_ADVANCED(CGAL_INCLUDE_DIR)

if ("${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1}" MATCHES ".*clang.*")
Jan Möbius's avatar
Jan Möbius committed
69 70 71
  SET(CXX_IS_CLANG true)
elseif (CMAKE_CXX_COMPILER_ID MATCHES "[cC][lL][aA][nN][gG]")
  SET(CXX_IS_CLANG true)
72
else()
Jan Möbius's avatar
Jan Möbius committed
73
  SET(CXX_IS_CLANG false)
74 75 76 77 78 79 80 81 82 83 84 85 86
endif()

# Copy the results to the output variables.
IF(CGAL_INCLUDE_DIR )
  SET(CGAL_FOUND 1)
  SET(CGAL_INCLUDE_DIR ${CGAL_INCLUDE_DIR})
  # Look for the taucs dir.
  FIND_PATH(CGAL_TAUCS_DIR NAMES include/taucs.h
                           PATHS ${CGAL_INCLUDE_DIR}/../auxiliary/taucs)

  IF(WIN32)
    include(CGAL_GeneratorSpecificSettings)
    find_path(CGAL_LIBRARY_DIR 
Jan Möbius's avatar
Jan Möbius committed
87 88 89 90 91
                NAMES "CGAL-${CGAL_TOOLSET}-mt.lib" 
				      "CGAL-${CGAL_TOOLSET}-mt-gd.lib" 
					  "CGAL-${CGAL_TOOLSET}-mt-4.12.lib" 
					  "CGAL-${CGAL_TOOLSET}-mt-4.7.lib" 
					  "CGAL-${CGAL_TOOLSET}-mt-4.5.lib"
92 93 94 95 96 97
                PATHS "${CGAL_INCLUDE_DIR}/../lib"
                DOC "Directory containing the CGAL library"
               ) 
			
    # Binary dir for DLLs			
	find_path(CGAL_BIN_DIR 
Jan Möbius's avatar
Jan Möbius committed
98 99 100 101
                NAMES "CGAL-${CGAL_TOOLSET}-mt-4.12.dll" 
				      "CGAL-${CGAL_TOOLSET}-mt-4.7.dll" 
				      "CGAL-${CGAL_TOOLSET}-mt-4.5.dll" 
					  "CGAL-${CGAL_TOOLSET}-mt-gd.dll"
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165
                PATHS "${CGAL_INCLUDE_DIR}/../bin"
                DOC "Directory containing the CGAL DLLs"
               ) 
			   
	MARK_AS_ADVANCED(CGAL_BIN_DIR )
    #add_definitions (-DCGAL_AUTOLINK)
  ELSEIF( APPLE)
    find_path(CGAL_LIBRARY_DIR 
                NAMES "libCGAL.dylib"
                PATHS "/opt/local/lib/"
                DOC "Directory containing the CGAL library"
               ) 
    list ( APPEND CGAL_LIBRARIES CGAL CGAL_Core CGAL_ImageIO mpfr )
    if (NOT CXX_IS_CLANG)
        set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -frounding-math")
        set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -frounding-math")
    endif()

  ELSE( WIN32 )
    find_path(CGAL_LIBRARY_DIR
              NAMES "libCGAL.so"
              PATHS "/usr/lib/" "/usr/lib64" 
              DOC "Directory containing the CGAL library"
             )
    list ( APPEND CGAL_LIBRARIES CGAL CGAL_Core CGAL_ImageIO) 
    if (NOT CXX_IS_CLANG)
        set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -frounding-math")
    endif()


    # This is needed to link correctly against lapack
    add_definitions (-DCGAL_USE_F2C)
  ENDIF(WIN32)


 

ELSE(CGAL_INCLUDE_DIR )
  SET(CGAL_FOUND 0)
  SET(CGAL_INCLUDE_DIR)
ENDIF(CGAL_INCLUDE_DIR )

#use eigen if available
find_package(EIGEN3)
if ( EIGEN3_FOUND )
  add_definitions(-DCGAL_EIGEN3_ENABLED)
endif()

# Report the results.
IF(NOT CGAL_FOUND)
  SET(CGAL_DIR_MESSAGE
    "CGAL was not found. Make sure CGAL_INCLUDE_DIR is set to the directories containing the include files for CGAL. .")
  IF(CGAL_FIND_REQUIRED)
      MESSAGE(FATAL_ERROR "${CGAL_DIR_MESSAGE}")
  ELSEIF(NOT CGAL_FIND_QUIETLY)
    MESSAGE(STATUS "${CGAL_DIR_MESSAGE}")
  ELSE(NOT CGAL_FIND_QUIETLY)
  ENDIF(CGAL_FIND_REQUIRED)
ELSE (NOT CGAL_FOUND)
  IF(NOT CGAL_FIND_QUIETLY)
    MESSAGE(STATUS "Looking for CGAL - found")
  ENDIF(NOT CGAL_FIND_QUIETLY)
ENDIF(NOT CGAL_FOUND)