summaryrefslogtreecommitdiff
path: root/cmake/FindGLPK.cmake
blob: 1587ca821431e7aa5af290f5841c4bf2b76fa30a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# Find GLPK-cut-log
# GLPK_FOUND - system has GLPK lib
# GLPK_INCLUDE_DIR - the GLPK include directory
# GLPK_LIBRARIES - Libraries needed to use GLPK


# Check default location of GLPK built with contrib/get-glpk-cut-log.
# If the user provides a directory we will not search the default paths and
# fail if GLPK was not found in the specified directory.
if(NOT GLPK_HOME)
  set(GLPK_HOME ${PROJECT_SOURCE_DIR}/glpk-cut-log)
  set(CHECK_SYSTEM_VERSION TRUE)
endif()

find_path(GLPK_INCLUDE_DIR
          NAMES glpk.h
          PATHS ${GLPK_HOME}/include
          NO_DEFAULT_PATH)
find_library(GLPK_LIBRARIES
             NAMES glpk
             PATHS ${GLPK_HOME}/lib
             NO_DEFAULT_PATH)

if(CHECK_SYSTEM_VERSION)
  find_path(GLPK_INCLUDE_DIR NAMES glpk.h)
  find_library(GLPK_LIBRARIES NAMES glpk)
endif()

# Check if we really have GLPK-cut-log.
if(GLPK_INCLUDE_DIR)
  include(CheckSymbolExists)
  set(CMAKE_REQUIRED_INCLUDES ${GLPK_INCLUDE_DIR})
  set(CMAKE_REQUIRED_LIBRARIES ${GLPK_LIBRARIES} m)
  check_symbol_exists(glp_ios_get_cut "glpk.h" HAVE_GLPK_CUT_LOG)
  if(NOT HAVE_GLPK_CUT_LOG)
    message(FATAL_ERROR "Could not link against GLPK-cut-log. "
                        "Did you forget to install GLPK-cut-log?")
  endif()
endif()

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(GLPK
  DEFAULT_MSG
  GLPK_INCLUDE_DIR GLPK_LIBRARIES)

mark_as_advanced(GLPK_INCLUDE_DIR GLPK_LIBRARIES)
if(GLPK_LIBRARIES)
  message(STATUS "Found GLPK libs: ${GLPK_LIBRARIES}")
endif()
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback