FindGUROBI.cmake 2.82 KB
Newer Older
David Bommes's avatar
David Bommes committed
1
# - Try to find GUROBI
Matthias Möller's avatar
Matthias Möller committed
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

Matthias Möller's avatar
Matthias Möller committed
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}" )
Matthias Möller's avatar
Matthias Möller committed
19
  set(GUROBI_LIBRARIES "${GUROBI_CXX_LIBRARY};${GUROBI_LIBRARY}" )
David Bommes's avatar
David Bommes committed
20 21
else (GUROBI_INCLUDE_DIR)

Matthias Möller's avatar
Matthias Möller committed
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"
David Bommes's avatar
David Bommes committed
28
                  "/Library/gurobi562/mac64/include"
David Bommes's avatar
David Bommes committed
29
                 "C:\\libs\\gurobi502\\include"
David Bommes's avatar
David Bommes committed
30
                 "C:\\libs\\gurobi562\\include"
Matthias Möller's avatar
Matthias Möller committed
31
				 "${GUROBI_BASE}/include"
David Bommes's avatar
David Bommes committed
32 33 34 35
          )

find_library( GUROBI_LIBRARY 
              NAMES gurobi
Matthias Möller's avatar
Matthias Möller committed
36
			        gurobi60
David Bommes's avatar
David Bommes committed
37
                    gurobi56
38
                    gurobi55
David Bommes's avatar
David Bommes committed
39 40 41 42 43
                    gurobi51
                    gurobi50 
        		    gurobi46
				    gurobi45

David Bommes's avatar
David Bommes committed
44
              PATHS "$ENV{GUROBI_HOME}/lib" 
David Bommes's avatar
David Bommes committed
45
                    "/Library/gurobi562/mac64/lib"
David Bommes's avatar
David Bommes committed
46
                    "/Library/gurobi502/mac64/lib"
David Bommes's avatar
David Bommes committed
47
                    "C:\\libs\\gurobi562\\lib"
David Bommes's avatar
David Bommes committed
48
                    "C:\\libs\\gurobi502\\lib"
Matthias Möller's avatar
Matthias Möller committed
49
				    "${GUROBI_BASE}/lib"
David Bommes's avatar
David Bommes committed
50 51
              )

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

set(GUROBI_INCLUDE_DIRS "${GUROBI_INCLUDE_DIR}" )
Matthias Möller's avatar
Matthias Möller committed
76
set(GUROBI_LIBRARIES "${GUROBI_CXX_LIBRARY};${GUROBI_LIBRARY}" )
David Bommes's avatar
David Bommes committed
77 78 79 80 81 82 83 84

# 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
Matthias Möller's avatar
Matthias Möller committed
85
                                  GUROBI_CXX_LIBRARY GUROBI_LIBRARY GUROBI_INCLUDE_DIR)
David Bommes's avatar
David Bommes committed
86

Matthias Möller's avatar
Matthias Möller committed
87
mark_as_advanced(GUROBI_INCLUDE_DIR GUROBI_LIBRARY GUROBI_CXX_LIBRARY GUROBI_BIN_DIR )
David Bommes's avatar
David Bommes committed
88

David Bommes's avatar
David Bommes committed
89
endif(GUROBI_INCLUDE_DIR)
Matthias Möller's avatar
Matthias Möller committed
90 91

endif()