FindGUROBI.cmake 2.91 KB
Newer Older
David Bommes's avatar
David Bommes committed
1
# - Try to find GUROBI
2
3
4

#  GUROBI_BASE - The libraries needed to use Gurobi

David Bommes's avatar
David Bommes committed
5
6
7
8
9
# Once done this will define
#  GUROBI_FOUND - System has Gurobi
#  GUROBI_INCLUDE_DIRS - The Gurobi include directories
#  GUROBI_LIBRARIES - The libraries needed to use Gurobi

10
11
12
13
14
set (GUROBI_ENABLE OFF CACHE BOOL "Enable gurobi?")

if ( GUROBI_ENABLE )
set (GUROBI_BASE "c:" CACHE PATH "Base path of your gurobi installation")

David Bommes's avatar
David Bommes committed
15
16
17
if (GUROBI_INCLUDE_DIR)
  # in cache already
  set(GUROBI_FOUND TRUE)
David Bommes's avatar
David Bommes committed
18
  set(GUROBI_INCLUDE_DIRS "${GUROBI_INCLUDE_DIR}" )
19
  set(GUROBI_LIBRARIES "${GUROBI_CXX_LIBRARY};${GUROBI_LIBRARY}" )
David Bommes's avatar
David Bommes committed
20
21
else (GUROBI_INCLUDE_DIR)

22
23
  

David Bommes's avatar
David Bommes committed
24
25
26
27
find_path(GUROBI_INCLUDE_DIR 
          NAMES gurobi_c++.h
          PATHS "$ENV{GUROBI_HOME}/include"
                  "/Library/gurobi502/mac64/include"
28
                  "/Library/gurobi562/mac64/include"
David Bommes's avatar
David Bommes committed
29
                 "C:\\libs\\gurobi502\\include"
30
                 "C:\\libs\\gurobi562\\include"
31
				 "${GUROBI_BASE}/include"
David Bommes's avatar
David Bommes committed
32
33
34
35
          )

find_library( GUROBI_LIBRARY 
              NAMES gurobi
36
                    gurobi70
37
                    gurobi65
38
                    gurobi60
39
40
41
                    gurobi56
                    gurobi55
                    gurobi51
David Bommes's avatar
David Bommes committed
42
                    gurobi50 
43
44
                    gurobi46
                    gurobi45
45

David Bommes's avatar
David Bommes committed
46
              PATHS "$ENV{GUROBI_HOME}/lib" 
47
                    "/Library/gurobi562/mac64/lib"
David Bommes's avatar
David Bommes committed
48
                    "/Library/gurobi502/mac64/lib"
49
                    "C:\\libs\\gurobi562\\lib"
David Bommes's avatar
David Bommes committed
50
                    "C:\\libs\\gurobi502\\lib"
51
				    "${GUROBI_BASE}/lib"
David Bommes's avatar
David Bommes committed
52
53
              )

54
55
56
57
  if ( CMAKE_GENERATOR MATCHES "^Visual Studio 12.*Win64" )
    SET(GUROBI_LIB_NAME "gurobi_c++md2013")
  endif()
  
David Bommes's avatar
David Bommes committed
58
find_library( GUROBI_CXX_LIBRARY 
59
60
              NAMES gurobi_c++ 
			        ${GUROBI_LIB_NAME}
David Bommes's avatar
David Bommes committed
61
              PATHS "$ENV{GUROBI_HOME}/lib" 
62
                    "/Library/gurobi562/mac64/lib"
David Bommes's avatar
David Bommes committed
63
                    "/Library/gurobi502/mac64/lib"
64
                    "C:\\libs\\gurobi562\\lib"
David Bommes's avatar
David Bommes committed
65
                    "C:\\libs\\gurobi502\\lib"
66
					"${GUROBI_BASE}/lib"
David Bommes's avatar
David Bommes committed
67
              )
68
69
70
71
			  
# Binary dir for DLLs			
find_path(GUROBI_BIN_DIR 
                NAMES "gurobi60.dll" 
Matthias Möller's avatar
Matthias Möller committed
72
                PATHS "${GUROBI_INCLUDE_DIR}/../bin"
Jan Möbius's avatar
Jan Möbius committed
73
				      "${GUROBI_BASE}/bin"
74
75
                DOC "Directory containing the GUROBI DLLs"
               ) 		  
David Bommes's avatar
David Bommes committed
76
77

set(GUROBI_INCLUDE_DIRS "${GUROBI_INCLUDE_DIR}" )
78
set(GUROBI_LIBRARIES "${GUROBI_CXX_LIBRARY};${GUROBI_LIBRARY}" )
David Bommes's avatar
David Bommes committed
79
80
81
82
83
84
85
86

# use c++ headers as default
# set(GUROBI_COMPILER_FLAGS "-DIL_STD" CACHE STRING "Gurobi Compiler Flags")

include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set LIBCPLEX_FOUND to TRUE
# if all listed variables are TRUE
find_package_handle_standard_args(GUROBI  DEFAULT_MSG
87
                                  GUROBI_CXX_LIBRARY GUROBI_LIBRARY GUROBI_INCLUDE_DIR)
David Bommes's avatar
David Bommes committed
88

89
mark_as_advanced(GUROBI_INCLUDE_DIR GUROBI_LIBRARY GUROBI_CXX_LIBRARY GUROBI_BIN_DIR )
David Bommes's avatar
David Bommes committed
90

91
endif(GUROBI_INCLUDE_DIR)
92

93
endif()