this repo has no description
1# - Try to find CBC
2# Once done this will define
3# OSICBC_FOUND - System has CBC
4# OSICBC_INCLUDE_DIRS - The CBC include directories
5# OSICBC_LIBRARIES - The libraries needed to use CBC
6# GOSICBC_TARGETS - The names of imported targets created for CBC
7# User can set OsiCBC_ROOT to the preferred installation prefix
8
9set(OSICBC_FIND_FILES coin/CbcSolver.hpp coin/CglPreProcess.hpp coin/ClpConfig.h coin/CoinSignal.hpp coin/OsiClpSolverInterface.hpp coin/OsiSolverInterface.hpp)
10
11foreach(OSICBC_FILE ${OSICBC_FIND_FILES})
12 set(OSICBC_FILE_LOC "OSICBC_LIB_LOC-NOTFOUND")
13 find_path(OSICBC_FILE_LOC ${OSICBC_FILE}
14 PATH_SUFFIXES cbc cgl clp coinutils osi include)
15 if("${OSICBC_FILE_LOC}" STREQUAL "OSICBC_FILE_LOC-NOTFOUND")
16# message(STATUS "OsiCBC: Could not find file `${OSICBC_FILE}`")
17 set(OSICBC_INCLUDE "")
18 break()
19 endif()
20 list(APPEND OSICBC_INCLUDE ${OSICBC_FILE_LOC})
21 # Add "/coin" for CBC internal dependencies
22 list(APPEND OSICBC_INCLUDE ${OSICBC_FILE_LOC}/coin)
23endforeach(OSICBC_FILE)
24
25list(REMOVE_DUPLICATES OSICBC_INCLUDE)
26unset(OSICBC_FIND_FILES)
27unset(OSICBC_FILE_LOC)
28
29find_file(CBC_CONFIG_LOC NAMES coin/config_cbc_default.h coin/CbcConfig.h
30 HINTS ${OSICBC_INCLUDE}
31 PATH_SUFFIXES cbc)
32
33if(NOT "${CBC_CONFIG_LOC}" STREQUAL "CBC_CONFIG_LOC-NOTFOUND")
34 file(READ "${CBC_CONFIG_LOC}" CBC_CONFIG)
35 string(REGEX MATCH "\#define +CBC_VERSION +\"([0-9]+.[0-9]+)\"" _ "${CBC_CONFIG}")
36 set(OSICBC_VERSION "${CMAKE_MATCH_1}")
37 unset(CBC_CONFIG)
38endif()
39unset(CBC_CONFIG_LOC)
40
41if(WIN32 AND NOT UNIX)
42 set(OSICBC_REQ_LIBS Osi OsiClp OsiCbc Clp Cgl Cbc CbcSolver CoinUtils)
43else()
44 set(OSICBC_REQ_LIBS CbcSolver Cbc Cgl OsiClp Clp Osi CoinUtils)
45endif()
46
47foreach(OSICBC_LIB ${OSICBC_REQ_LIBS})
48 set(OSICBC_LIB_LOC "OSICBC_LIB_LOC-NOTFOUND")
49 find_library(OSICBC_LIB_LOC NAMES ${OSICBC_LIB} lib${OSICBC_LIB}
50 PATH_SUFFIXES lib)
51 if("${OSICBC_LIB_LOC}" STREQUAL "OSICBC_LIB_LOC-NOTFOUND")
52# message(STATUS "OsiCBC: Could not find library `${OSICBC_LIB}`")
53 set(OSICBC_LIBRARY "")
54 break()
55 endif()
56 list(APPEND OSICBC_LIBRARY ${OSICBC_LIB_LOC})
57 add_library(${OSICBC_LIB} UNKNOWN IMPORTED)
58 set_target_properties(${OSICBC_LIB} PROPERTIES
59 IMPORTED_LOCATION ${OSICBC_LIB_LOC}
60 INTERFACE_INCLUDE_DIRECTORIES "${OSICBC_INCLUDE}")
61 list(APPEND OSICBC_TARGETS ${OSICBC_LIB})
62endforeach(OSICBC_LIB)
63
64unset(OSICBC_REQ_LIBS)
65unset(OSICBC_LIB_LOC)
66
67if(UNIX AND NOT WIN32 AND NOT DEFINED EMSCRIPTEN)
68 find_package(ZLIB)
69 if(NOT ZLIB_FOUND)
70 message(STATUS "OsiCBC: Missing dependency `Zlib`")
71 set(OSICBC_LIBRARY "")
72 else()
73 list(APPEND OSICBC_LIBRARY ${ZLIB_LIBRARIES})
74 list(APPEND OSICBC_TARGETS ${ZLIB_LIBRARIES})
75 endif()
76endif()
77
78include(FindPackageHandleStandardArgs)
79# handle the QUIETLY and REQUIRED arguments and set CBC_FOUND to TRUE
80# if all listed variables are TRUE
81find_package_handle_standard_args(OsiCBC
82 FOUND_VAR OSICBC_FOUND
83 REQUIRED_VARS OSICBC_INCLUDE OSICBC_LIBRARY
84 VERSION_VAR OSICBC_VERSION
85 FAIL_MESSAGE "Could NOT find OsiCBC, use OsiCBC_ROOT to hint its location"
86)
87
88mark_as_advanced(OSICBC_INCLUDE OSICBC_LIBRARY)
89
90set(OSICBC_LIBRARIES ${OSICBC_LIBRARY})
91set(OSICBC_INCLUDE_DIRS ${OSICBC_INCLUDE})