FindCBC.cmake 3.69 KB
Newer Older
Jan Möbius's avatar
Jan Möbius committed
1 2 3 4 5 6
# - Try to find CBC
# Once done this will define
#  CBC_FOUND - System has CBC
#  CBC_INCLUDE_DIRS - The CBC include directories
#  CBC_LIBRARIES - The libraries needed to use CBC

Jan Möbius's avatar
Jan Möbius committed
7 8 9 10 11 12 13

# Check if the base path is set
if ( NOT CMAKE_WINDOWS_LIBS_DIR )
  # This is the base directory for windows library search used in the finders we shipp.
  set(CMAKE_WINDOWS_LIBS_DIR "c:/libs" CACHE STRING "Default Library search dir on windows." )
endif()

Jan Möbius's avatar
Jan Möbius committed
14
if ( CMAKE_GENERATOR MATCHES "^Visual Studio 11.*Win64" )
Jan Möbius's avatar
Jan Möbius committed
15
  SET(VS_SEARCH_PATH "${CMAKE_WINDOWS_LIBS_DIR}/vs2012/x64/")
Jan Möbius's avatar
Jan Möbius committed
16
elseif ( CMAKE_GENERATOR MATCHES "^Visual Studio 11.*" )
Jan Möbius's avatar
Jan Möbius committed
17
  SET(VS_SEARCH_PATH "${CMAKE_WINDOWS_LIBS_DIR}/vs2012/x32/")
Jan Möbius's avatar
Jan Möbius committed
18
elseif ( CMAKE_GENERATOR MATCHES "^Visual Studio 12.*Win64" )
Jan Möbius's avatar
Jan Möbius committed
19
  SET(VS_SEARCH_PATH "${CMAKE_WINDOWS_LIBS_DIR}/vs2013/x64/")
Jan Möbius's avatar
Jan Möbius committed
20
elseif ( CMAKE_GENERATOR MATCHES "^Visual Studio 12.*" )
Jan Möbius's avatar
Jan Möbius committed
21 22 23 24 25
  SET(VS_SEARCH_PATH "${CMAKE_WINDOWS_LIBS_DIR}/vs2013/x32/")
elseif ( CMAKE_GENERATOR MATCHES "^Visual Studio 14.*Win64" )
  SET(VS_SEARCH_PATH "${CMAKE_WINDOWS_LIBS_DIR}/vs2015/x64/")
elseif ( CMAKE_GENERATOR MATCHES "^Visual Studio 14.*" )
  SET(VS_SEARCH_PATH "${CMAKE_WINDOWS_LIBS_DIR}/vs2015/x32/")
26 27 28 29
elseif ( CMAKE_GENERATOR MATCHES "^Visual Studio 15.*Win64" )
  SET(VS_SEARCH_PATH "${CMAKE_WINDOWS_LIBS_DIR}/vs2017/x64/")
elseif ( CMAKE_GENERATOR MATCHES "^Visual Studio 15.*" )
  SET(VS_SEARCH_PATH "${CMAKE_WINDOWS_LIBS_DIR}/vs2017/x32/")
Jan Möbius's avatar
Jan Möbius committed
30 31 32
endif()


Jan Möbius's avatar
Jan Möbius committed
33
if (NOT CBC_FOUND )
Jan Möbius's avatar
Jan Möbius committed
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86

find_path(CBC_INCLUDE_DIR 
          NAMES CbcConfig.h
          PATHS "$ENV{CBC_DIR}/include/coin"
                 "/usr/include/coin"
                 "C:\\libs\\cbc\\include"
		 "${VS_SEARCH_PATH}CBC-2.9.7/Cbc/include"
		 "${VS_SEARCH_PATH}CBC-2.9.4/Cbc/include"
          )

find_library( CBC_LIBRARY_DEBUG
              NAMES Cbcd libCbcd
              PATHS "$ENV{CBC_DIR}/lib"
                    "/usr/lib"
                    "/usr/lib/coin"
                    "C:\\libs\\cbc\\lib"
		    "${VS_SEARCH_PATH}CBC-2.9.7/lib/${VS_SUBDIR}Debug"
                    "${VS_SEARCH_PATH}CBC-2.9.4/Cbc/lib"
              )

find_library( CBC_SOLVER_LIBRARY_DEBUG
              NAMES CbcSolverd libCbcSolverd
              PATHS "$ENV{CBC_DIR}/lib"
                    "/usr/lib"
                    "/usr/lib/coin"
                    "C:\\libs\\cbc\\lib"
	            "${VS_SEARCH_PATH}CBC-2.9.7/lib/${VS_SUBDIR}Debug"
                    "${VS_SEARCH_PATH}CBC-2.9.4/Cbc/lib"
              )

find_library( CBC_LIBRARY_RELEASE
              NAMES Cbc libCbc
              PATHS "$ENV{CBC_DIR}/lib"
                    "/usr/lib"
                    "/usr/lib/coin"
                    "C:\\libs\\cbc\\lib"
 		    "${VS_SEARCH_PATH}CBC-2.9.7/lib/${VS_SUBDIR}Release"
                    "${VS_SEARCH_PATH}CBC-2.9.4/Cbc/lib"
              )

find_library( CBC_SOLVER_LIBRARY_RELEASE
              NAMES CbcSolver libCbcSolver

              PATHS "$ENV{CBC_DIR}/lib"
                    "/usr/lib"
                    "/usr/lib/coin"
                    "C:\\libs\\cbc\\lib"
	  	    "${VS_SEARCH_PATH}CBC-2.9.7/lib/${VS_SUBDIR}Release"
                    "${VS_SEARCH_PATH}CBC-2.9.4/Cbc/lib"
              )


  include(SelectLibraryConfigurations)
Jan Möbius's avatar
Jan Möbius committed
87 88
  select_library_configurations( CBC )
  select_library_configurations( CBC_SOLVER )
Jan Möbius's avatar
Jan Möbius committed
89 90

set(CBC_INCLUDE_DIRS "${CBC_INCLUDE_DIR}" )
Jan Möbius's avatar
Jan Möbius committed
91
set(CBC_LIBRARIES "${CBC_LIBRARIES};${CBC_SOLVER_LIBRARIES}" )
Jan Möbius's avatar
Jan Möbius committed
92 93 94 95 96

include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set CBC_FOUND to TRUE
# if all listed variables are TRUE
find_package_handle_standard_args(CBC  DEFAULT_MSG
Jan Möbius's avatar
Jan Möbius committed
97
                                  CBC_LIBRARY CBC_SOLVER_LIBRARY CBC_INCLUDE_DIR CBC_LIBRARIES)
Jan Möbius's avatar
Jan Möbius committed
98

Jan Möbius's avatar
Jan Möbius committed
99
mark_as_advanced(CBC_INCLUDE_DIR CBC_LIBRARY CBC_SOLVER_LIBRARY CBC_LIBRARIES)
Jan Möbius's avatar
Jan Möbius committed
100

Jan Möbius's avatar
Jan Möbius committed
101
endif(NOT CBC_FOUND)