Skip to content

Commit

Permalink
FindGUROBI.cmake: Gurobi 11
Browse files Browse the repository at this point in the history
  • Loading branch information
glebbelov committed Apr 22, 2024
1 parent cef6d72 commit 4eaab06
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 39 deletions.
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -564,3 +564,9 @@ if (NOT SKIP_BUILD_MP)
endif()

endif() ## NOT SKIP_BUILD_MP

############## Features summary ##############
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
include(FeatureSummary)
feature_summary(WHAT ALL)
endif()
73 changes: 34 additions & 39 deletions support/cmake/FindGUROBI.cmake
Original file line number Diff line number Diff line change
@@ -1,51 +1,46 @@
# Try to find the GUROBI library
# Find GUROBI library
#
# The original file was downloaded from
# https://support.gurobi.com/hc/en-us/articles/360039499751-CMake-C-C-compilation-of-Gurobi-projects
# on March 11, 2020
# https://support.gurobi.com/hc/en-us/articles/360039499751-How-do-I-use-CMake-to-build-Gurobi-C-C-projects
# on April 22, 2024
#
# Modified to check GUROBI_INCLUDE_DIRS and some lib subdirs

find_path(GUROBI_INCLUDE_DIRS
NAMES gurobi_c.h
HINTS ${GUROBI_DIR} $ENV{GUROBI_HOME}
PATH_SUFFIXES include)
NAMES gurobi_c.h
HINTS ${GUROBI_DIR} $ENV{GUROBI_HOME}
PATH_SUFFIXES include)

find_library(GUROBI_LIBRARY
NAMES gurobi gurobi105 gurobi102 gurobi101 gurobi100 gurobi95 gurobi92 gurobi91 gurobi90 gurobi81
HINTS ${GUROBI_DIR} $ENV{GUROBI_HOME}
PATH_SUFFIXES lib lib/linux64 lib/osx64 lib/win64)
NAMES gurobi gurobi110 gurobi100
HINTS ${GUROBI_DIR} $ENV{GUROBI_HOME}
PATH_SUFFIXES lib lib/linux64 lib/osx64 lib/win64)

if(CXX)
if(MSVC)
# determine Visual Studio year
if(MSVC_TOOLSET_VERSION EQUAL 142)
set(MSVC_YEAR "2019")
elseif(MSVC_TOOLSET_VERSION EQUAL 141)
set(MSVC_YEAR "2017")
elseif(MSVC_TOOLSET_VERSION EQUAL 140)
set(MSVC_YEAR "2015")
endif()
if(MSVC)
set(MSVC_YEAR "2017")

if(MT)
set(M_FLAG "mt")
else()
set(M_FLAG "md")
endif()

if(MT)
set(M_FLAG "mt")
else()
set(M_FLAG "md")
endif()

find_library(GUROBI_CXX_LIBRARY
NAMES gurobi_c++${M_FLAG}${MSVC_YEAR}
HINTS ${GUROBI_DIR} $ENV{GUROBI_HOME}
PATH_SUFFIXES lib)
find_library(GUROBI_CXX_DEBUG_LIBRARY
NAMES gurobi_c++${M_FLAG}d${MSVC_YEAR}
HINTS ${GUROBI_DIR} $ENV{GUROBI_HOME}
PATH_SUFFIXES lib)
else()
find_library(GUROBI_CXX_LIBRARY
NAMES gurobi_c++
HINTS ${GUROBI_DIR} $ENV{GUROBI_HOME}
PATH_SUFFIXES lib)
set(GUROBI_CXX_DEBUG_LIBRARY ${GUROBI_CXX_LIBRARY})
endif()
find_library(GUROBI_CXX_LIBRARY
NAMES gurobi_c++${M_FLAG}${MSVC_YEAR}
HINTS ${GUROBI_DIR} $ENV{GUROBI_HOME}
PATH_SUFFIXES lib)
find_library(GUROBI_CXX_DEBUG_LIBRARY
NAMES gurobi_c++${M_FLAG}d${MSVC_YEAR}
HINTS ${GUROBI_DIR} $ENV{GUROBI_HOME}
PATH_SUFFIXES lib)
else()
find_library(GUROBI_CXX_LIBRARY
NAMES gurobi_c++
HINTS ${GUROBI_DIR} $ENV{GUROBI_HOME}
PATH_SUFFIXES lib)
set(GUROBI_CXX_DEBUG_LIBRARY ${GUROBI_CXX_LIBRARY})
endif()
endif()

include(FindPackageHandleStandardArgs)
Expand Down

0 comments on commit 4eaab06

Please sign in to comment.