FindGUROBI.cmake 2.54 KB
Newer Older
David Bommes's avatar
David Bommes committed
1
2
3
4
5
6
if (GUROBI_INCLUDE_DIR)
  # in cache already
  set(GUROBI_FOUND TRUE)
else (GUROBI_INCLUDE_DIR)

if (WIN32)
7
   find_path(GUROBI_INCLUDE_DIR NAMES SRC/gurobi_c++.h
David Bommes's avatar
David Bommes committed
8
     PATHS
David Bommes's avatar
David Bommes committed
9
     "C:\\libs\\gurobi45"
David Bommes's avatar
David Bommes committed
10
11
12
13
14
     ${GUROBI_INCLUDE_PATH}
   )

   find_library( GUROBI_LIBRARY_RELEASE 
                 SuperLU
David Bommes's avatar
David Bommes committed
15
                 PATHS "C:\\libs\\gurobi45\\lib" )
David Bommes's avatar
David Bommes committed
16
17
   find_library( GUROBI_LIBRARY_DEBUG
                   SuperLUd
David Bommes's avatar
David Bommes committed
18
                   PATHS "C:\\libs\\gurobi45\\lib" )
David Bommes's avatar
David Bommes committed
19
20
21
22
23
24
25
26
27


   set ( GUROBI_LIBRARY "optimized;${GUROBI_LIBRARY_RELEASE};debug;${GUROBI_LIBRARY_DEBUG}" CACHE  STRING "GUROBI Libraries" )

ELSEIF(APPLE)

   find_path(GUROBI_INCLUDE_DIR NAMES gurobi_c++.h
	     PATHS "${CMAKE_SOURCE_DIR}/MacOS/Libs/gurobi40"
	     	   ${GUROBI_INCLUDE_PATH}
Mike Kremer's avatar
Mike Kremer committed
28
               "${GUROBI_HOME}/include"
David Bommes's avatar
David Bommes committed
29
30
31
            )

   find_library( GUROBI_LIBRARY 
Mike Kremer's avatar
Mike Kremer committed
32
33
34
                 gurobi
                 PATHS "${CMAKE_SOURCE_DIR}/MacOS/Libs/gurobi40"
                 "${GUROBI_HOME}/lib")
David Bommes's avatar
David Bommes committed
35
36
37
38
39
40
41
42
43

ELSE( WIN32 )
   find_path(GUROBI_INCLUDE_DIR NAMES gurobi_c++.h
     PATHS "$ENV{GUROBI_HOME}/include"
     ${GUROBI_INCLUDE_PATH}
   )

#   MESSAGE(STATUS "$ENV{GUROBI_HOME}/include")
   IF(GUROBI_INCLUDE_DIR)
44
45
46
47
48
49
     SET(GUROBI_FOUND TRUE)
     SET(GUROBI_INCLUDE_DIR ${GUROBI_INCLUDE_DIR})
   ELSE(GUROBI_INCLUDE_DIR)
     SET(GUROBI_FOUND FALSE)
     SET(GUROBI_INCLUDE_DIR ${GUROBI_INCLUDE_DIR})
   ENDIF(GUROBI_INCLUDE_DIR)
David Bommes's avatar
David Bommes committed
50
51
52
53
54
55

   #find_library( GUROBI_LIBRARY 
    #             gurobi
     #            PATHS "${GUROBI_HOME}/lib" )
ENDIF()

56
endif(GUROBI_INCLUDE_DIR)
David Bommes's avatar
David Bommes committed
57

58
59
60
61
62
63
64
65
66
67
68

IF(UNIX)
IF(GUROBI_INCLUDE_DIR AND NOT GUROBI_LIBRARY)
  IF (NOT DEFINED ENV{GUROBI_HOME})
    message(FATAL_ERROR "Environment variable GUROBI_HOME not set. Set it so I can find the gurobi libs in \${GUROBI_HOME}/lib/.")
  ENDIF()
  SET(GUROBI_LIBRARY_DIR "$ENV{GUROBI_HOME}/lib/" CACHE PATH "Path to GUROBI Library")
  IF (EXISTS "${GUROBI_LIBRARY_DIR}/libgurobi45.so")
    SET(GUROBI_LIBRARY "gurobi45;gurobi_c++;pthread" CACHE STRING "GUROBI Libraries")  
  ELSEIF(EXISTS "${GUROBI_LIBRARY_DIR}/libgurobi46.so")
    SET(GUROBI_LIBRARY "gurobi46;gurobi_c++;pthread" CACHE STRING "GUROBI Libraries")  
Henrik Zimmer's avatar
Henrik Zimmer committed
69
70
  ELSEIF(EXISTS "${GUROBI_LIBRARY_DIR}/libgurobi50.so")
    SET(GUROBI_LIBRARY "gurobi50;gurobi_c++;pthread" CACHE STRING "GUROBI Libraries")  
Mike Kremer's avatar
Mike Kremer committed
71
72
  ELSEIF(EXISTS "${GUROBI_LIBRARY_DIR}/libgurobi50.dylib")
    SET(GUROBI_LIBRARY "gurobi50;gurobi_c++;pthread" CACHE STRING "GUROBI Libraries")  
73
74
75
76
  ELSE()
    message(FATAL_ERROR "Couldn't find a gurobi lib in ${GUROBI_LIBRARY_DIR}. Maybe it's a version I don't know about, yet.")
  ENDIF()
ENDIF()
Henrik Zimmer's avatar
Henrik Zimmer committed
77
ENDIF(UNIX)