FindCPLEX.cmake 2.45 KB
Newer Older
David Bommes's avatar
David Bommes committed
1 2 3 4 5 6 7 8 9
# - Try to find CPLEX
# Once done this will define
#  CPLEX_FOUND - System has Cplex
#  CPLEX_INCLUDE_DIRS - The Cplex include directories
#  CPLEX_LIBRARIES - The libraries needed to use Cplex

if (CPLEX_INCLUDE_DIR)
  # in cache already
  set(CPLEX_FOUND TRUE)
10
  set(CPLEX_INCLUDE_DIRS "${CPLEX_INCLUDE_DIR};${CPLEX_CONCERT_INCLUDE_DIR}" )
David Bommes's avatar
David Bommes committed
11
  set(CPLEX_LIBRARIES "${CPLEX_LIBRARY};${CPLEX_ILO_LIBRARY};${CPLEX_CONCERT_LIBRARY};${CPLEX_PTHREAD_LIBRARY}" )
David Bommes's avatar
David Bommes committed
12 13
else (CPLEX_INCLUDE_DIR)

14 15 16 17 18 19 20 21 22 23 24 25 26
find_path(CPLEX_INCLUDE_DIR 
          NAMES ilcplex/cplex.h
          PATHS "$ENV{CPLEX_DIR}/cplex/include"
          )
          
find_path(CPLEX_CONCERT_INCLUDE_DIR 
          NAMES ilconcert/ilomodel.h
          PATHS "$ENV{CPLEX_DIR}/concert/include"
          )

find_library( CPLEX_LIBRARY 
              cplex
              PATHS "$ENV{CPLEX_DIR}/cplex/lib/x86-64_sles10_4.1/static_pic" 
27
                    "$ENV{CPLEX_DIR}/cplex/lib/x86-64_darwin/static_pic/"
28 29 30 31 32
              )

find_library( CPLEX_ILO_LIBRARY 
              ilocplex
              PATHS "$ENV{CPLEX_DIR}/cplex/lib/x86-64_sles10_4.1/static_pic" 
33
                    "$ENV{CPLEX_DIR}/cplex/lib/x86-64_darwin/static_pic/"
34 35 36 37 38
              )

find_library( CPLEX_CONCERT_LIBRARY 
              concert
              PATHS "$ENV{CPLEX_DIR}/concert/lib/x86-64_sles10_4.1/static_pic" 
39
                    "$ENV{CPLEX_DIR}/concert/lib/x86-64_darwin/static_pic/"
David Bommes's avatar
David Bommes committed
40 41 42 43 44 45 46 47 48
              ) 

find_library( CPLEX_PTHREAD_LIBRARY 
              pthread
              PATHS "/usr/lib" 
                    "/usr/lib64"
		    "/lib" 
		    "/lib64" 
              )      
49
                 
David Bommes's avatar
David Bommes committed
50 51

set(CPLEX_INCLUDE_DIRS "${CPLEX_INCLUDE_DIR};${CPLEX_CONCERT_INCLUDE_DIR}" )
David Bommes's avatar
David Bommes committed
52 53 54
#set(CPLEX_LIBRARIES "${CPLEX_LIBRARY};${CPLEX_ILO_LIBRARY};${CPLEX_CONCERT_LIBRARY}" )
set(CPLEX_LIBRARIES "${CPLEX_LIBRARY};${CPLEX_ILO_LIBRARY};${CPLEX_CONCERT_LIBRARY};${CPLEX_PTHREAD_LIBRARY}" )

David Bommes's avatar
David Bommes committed
55

56 57 58
# use c++ headers as default
set(CPLEX_COMPILER_FLAGS "-DIL_STD" CACHE STRING "Cplex Compiler Flags")

David Bommes's avatar
David Bommes committed
59 60 61 62
include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set LIBCPLEX_FOUND to TRUE
# if all listed variables are TRUE
find_package_handle_standard_args(CPLEX  DEFAULT_MSG
David Bommes's avatar
David Bommes committed
63
                                  CPLEX_LIBRARY CPLEX_INCLUDE_DIR CPLEX_CONCERT_INCLUDE_DIR CPLEX_ILO_LIBRARY CPLEX_CONCERT_LIBRARY)
David Bommes's avatar
David Bommes committed
64

David Bommes's avatar
David Bommes committed
65
mark_as_advanced(CPLEX_INCLUDE_DIR CPLEX_LIBRARY CPLEX_CONCERT_INCLUDE_DIR CPLEX_ILO_LIBRARY CPLEX_CONCERT_LIBRARY CPLEX_PTHREAD_LIBRARY)
David Bommes's avatar
David Bommes committed
66

67
endif(CPLEX_INCLUDE_DIR)