this repo has no description
at develop 3.0 kB view raw
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 9list(INSERT CMAKE_PREFIX_PATH 0 "${OSICBC_ROOT}" "$ENV{OSICBC_ROOT}") 10 11set(OSICBC_FIND_FILES coin/CbcSolver.hpp coin/CglPreProcess.hpp coin/ClpConfig.h coin/CoinSignal.hpp coin/OsiClpSolverInterface.hpp coin/OsiSolverInterface.hpp) 12 13foreach(OSICBC_FILE ${OSICBC_FIND_FILES}) 14 set(OSICBC_FILE_LOC "OSICBC_LIB_LOC-NOTFOUND") 15 find_path(OSICBC_FILE_LOC ${OSICBC_FILE} 16 PATH_SUFFIXES cbc cgl clp coinutils osi include) 17 if("${OSICBC_FILE_LOC}" STREQUAL "OSICBC_FILE_LOC-NOTFOUND") 18# message(STATUS "OsiCBC: Could not find file `${OSICBC_FILE}`") 19 set(OSICBC_INCLUDE "") 20 break() 21 endif() 22 list(APPEND OSICBC_INCLUDE ${OSICBC_FILE_LOC}) 23 # Add "/coin" for CBC internal dependencies 24 list(APPEND OSICBC_INCLUDE ${OSICBC_FILE_LOC}/coin) 25endforeach(OSICBC_FILE) 26 27list(REMOVE_DUPLICATES OSICBC_INCLUDE) 28unset(OSICBC_FIND_FILES) 29unset(OSICBC_FILE_LOC) 30 31if(WIN32 AND NOT UNIX) 32 set(OSICBC_REQ_LIBS Osi OsiClp OsiCbc Clp Cgl Cbc CbcSolver CoinUtils) 33else() 34 set(OSICBC_REQ_LIBS CbcSolver Cbc Cgl OsiClp Clp Osi CoinUtils) 35endif() 36 37foreach(OSICBC_LIB ${OSICBC_REQ_LIBS}) 38 set(OSICBC_LIB_LOC "OSICBC_LIB_LOC-NOTFOUND") 39 find_library(OSICBC_LIB_LOC NAMES ${OSICBC_LIB} lib${OSICBC_LIB} 40 PATH_SUFFIXES lib) 41 if("${OSICBC_LIB_LOC}" STREQUAL "OSICBC_LIB_LOC-NOTFOUND") 42# message(STATUS "OsiCBC: Could not find library `${OSICBC_LIB}`") 43 set(OSICBC_LIBRARY "") 44 break() 45 endif() 46 list(APPEND OSICBC_LIBRARY ${OSICBC_LIB_LOC}) 47 add_library(${OSICBC_LIB} UNKNOWN IMPORTED) 48 set_target_properties(${OSICBC_LIB} PROPERTIES 49 IMPORTED_LOCATION ${OSICBC_LIB_LOC} 50 INTERFACE_INCLUDE_DIRECTORIES "${OSICBC_INCLUDE}") 51 list(APPEND OSICBC_TARGETS ${OSICBC_LIB}) 52endforeach(OSICBC_LIB) 53 54unset(OSICBC_REQ_LIBS) 55unset(OSICBC_LIB_LOC) 56 57if(UNIX AND NOT WIN32 AND NOT DEFINED EMSCRIPTEN) 58 find_package(ZLIB) 59 if(NOT ZLIB_FOUND) 60 message(STATUS "OsiCBC: Missing dependency `Zlib`") 61 set(OSICBC_LIBRARY "") 62 else() 63 list(APPEND OSICBC_LIBRARY ${ZLIB_LIBRARIES}) 64 list(APPEND OSICBC_TARGETS ${ZLIB_LIBRARIES}) 65 endif() 66endif() 67 68include(FindPackageHandleStandardArgs) 69# handle the QUIETLY and REQUIRED arguments and set CBC_FOUND to TRUE 70# if all listed variables are TRUE 71find_package_handle_standard_args(OsiCBC 72 FOUND_VAR OSICBC_FOUND 73 REQUIRED_VARS OSICBC_INCLUDE OSICBC_LIBRARY 74 FAIL_MESSAGE "Could NOT find OsiCBC, use OSICBC_ROOT to hint its location" 75) 76 77mark_as_advanced(OSICBC_INCLUDE OSICBC_LIBRARY) 78list(REMOVE_AT CMAKE_PREFIX_PATH 1 0) 79 80set(OSICBC_LIBRARIES ${OSICBC_LIBRARY}) 81set(OSICBC_INCLUDE_DIRS ${OSICBC_INCLUDE})