this repo has no description
1# - Try to find Gurobi
2# Once done this will define
3# GUROBI_FOUND - System has GUROBI
4# GUROBI_INCLUDE_DIRS - The GUROBI include directories
5# GUROBI_LIBRARIES - The libraries needed to use GUROBI
6# GUROBI_COMPILE_FLAGS - The definitions required to compile with GUROBI
7# User can set GUROBI_ROOT to the preferred installation prefix
8
9list(INSERT CMAKE_PREFIX_PATH 0 "${GUROBI_ROOT}" "$ENV{GUROBI_ROOT}")
10
11option(GUROBI_PLUGIN "Build Gurobi binding as a plugin" ON)
12
13set(GUROBI_COMPILE_FLAGS "-fPIC -fno-strict-aliasing -fexceptions -DNDEBUG")
14
15set(GUROBI_VERSIONS 811 810 801 752 702)
16
17foreach(VERSION ${GUROBI_VERSIONS})
18 list(APPEND GUROBI_DEFAULT_LOC "/opt/gurobi${VERSION}/linux64")
19 list(APPEND GUROBI_DEFAULT_LOC "/opt/gurobi${VERSION}/linux64")
20 list(APPEND GUROBI_DEFAULT_LOC "C:\\gurobi${VERSION}\\win64")
21 list(APPEND GUROBI_DEFAULT_LOC "C:\\gurobi${VERSION}\\win32")
22 list(APPEND GUROBI_DEFAULT_LOC "/Library/gurobi${VERSION}/mac64")
23
24 string(SUBSTRING ${VERSION} 0 2 VERSION)
25 list(APPEND GUROBI_LIB_NAMES gurobi${VERSION})
26endforeach(VERSION)
27
28find_path(GUROBI_INCLUDE gurobi_c.h
29 PATHS $ENV{GUROBI_HOME}
30 HINTS ${GUROBI_DEFAULT_LOC}
31 PATH_SUFFIXES include)
32
33if(GUROBI_PLUGIN)
34 include(CheckIncludeFiles)
35 # TODO: Cleanup this mess
36 check_include_files(dlfcn.h HAS_DLFCN_H)
37 check_include_files(Windows.h HAS_WINDOWS_H)
38 if(HAS_DLFCN_H)
39 find_library(GUROBI_LIBRARY dl)
40 elseif(HAS_WINDOWS_H)
41 set(GUROBI_LIBRARY ${GUROBI_INCLUDE})
42 endif()
43else()
44 foreach(GUROBI_LIB ${GUROBI_LIB_NAMES})
45 find_library(GUROBI_LIBRARY NAMES ${GUROBI_LIB}
46 HINTS $ENV{GUROBI_HOME}
47 PATHS ${GUROBI_DEFAULT_LOC}
48 PATH_SUFFIXES lib)
49 if(NOT "${GUROBI_LIBRARY}" STREQUAL "GUROBI_LIBRARY-NOTFOUND")
50 break()
51 endif()
52 endforeach(GUROBI_LIB)
53endif()
54
55include(FindPackageHandleStandardArgs)
56# handle the QUIETLY and REQUIRED arguments and set CBC_FOUND to TRUE
57# if all listed variables are TRUE
58find_package_handle_standard_args(Gurobi DEFAULT_MSG
59 GUROBI_INCLUDE GUROBI_LIBRARY)
60
61if(GUROBI_PLUGIN AND HAS_WINDOWS_H AND NOT HAS_DLFCN_H)
62 unset(GUROBI_LIBRARY)
63endif()
64
65mark_as_advanced(GUROBI_INCLUDE GUROBI_LIBRARY)
66list(REMOVE_AT CMAKE_PREFIX_PATH 1 0)
67
68set(GUROBI_LIBRARIES ${GUROBI_LIBRARY})
69set(GUROBI_INCLUDE_DIRS ${GUROBI_INCLUDE})