SET(CPLEX_ROOT_DIR "" CACHE PATH "CPLEX root directory")

FIND_PATH(CPLEX_INCLUDE_DIR
  ilcplex/cplex.h
  PATHS "/home/gramak/ILOG/CPLEX_Studio_AcademicResearch122/cplex/include"
  HINTS ${CPLEX_ROOT_DIR}/include
)
FIND_LIBRARY(CPLEX_LIBRARY_MAIN
  cplex
  PATHS "/home/gramak/ILOG/CPLEX_Studio_AcademicResearch122/cplex/lib/x86-64_sles10_4.1/static_pic"
  HINTS ${CPLEX_ROOT_DIR}/lib
)
FIND_LIBRARY(CPLEX_LIBRARY_ILO
  ilocplex
  PATHS "/home/gramak/ILOG/CPLEX_Studio_AcademicResearch122/cplex/lib/x86-64_sles10_4.1/static_pic"
  HINTS ${CPLEX_ROOT_DIR}/lib
)

INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(CPLEX DEFAULT_MSG CPLEX_LIBRARY_MAIN CPLEX_LIBRARY_ILO CPLEX_INCLUDE_DIR)

FIND_PATH(CPLEX_BIN_DIR
  libcplex122.so
  PATHS "/home/gramak/ILOG/CPLEX_Studio_AcademicResearch122/cplex/bin/x86-64_sles10_4.1"
  HINTS ${CPLEX_ROOT_DIR}/bin/x86-64_sles10_4.1
)

IF(CPLEX_FOUND)
  SET(CPLEX_INCLUDE_DIRS ${CPLEX_INCLUDE_DIR})
  SET(CPLEX_LIBRARIES ${CPLEX_LIBRARY_MAIN} ${CPLEX_LIBRARY_ILO})
  IF(CMAKE_SYSTEM_NAME STREQUAL "Linux")
    SET(CPLEX_LIBRARIES "${CPLEX_LIBRARIES};m;pthread")
  ENDIF(CMAKE_SYSTEM_NAME STREQUAL "Linux")
ENDIF(CPLEX_FOUND)

MARK_AS_ADVANCED(CPLEX_LIBRARY CPLEX_INCLUDE_DIR CPLEX_BIN_DIR)
