FindCPLEX.cmake 1.58 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 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
#[=======================================================================[.rst:
FindCPLEX
--------

This module determines the CPLEX library of the system.

IMPORTED Targets
^^^^^^^^^^^^^^^^

This module defines :prop_tgt:`IMPORTED` target ``CPLEX::CPLEX``, if
CPLEX has been found.

Result Variables
^^^^^^^^^^^^^^^^

This module defines the following variables:

::

CPLEX_FOUND          - True if CPLEX found.

Hints
^^^^^

A user may set ``CPLEX_ROOT`` to a CPLEX installation root to tell this
module where to look.
#]=======================================================================]
set(CPLEX_FOUND FALSE)

if(CMAKE_C_COMPILER_LOADED)
  include (CheckIncludeFile)
  include (CheckCSourceCompiles)
elseif(CMAKE_CXX_COMPILER_LOADED)
  include (CheckIncludeFileCXX)
  include (CheckCXXSourceCompiles)
else()
  message(FATAL_ERROR "FindCPLEX only works if either C or CXX language is enabled")
endif()

if(APPLE)
  message(FATAL_ERROR "CPLEX not yet supported on macOS")
elseif(UNIX)
  message(FATAL_ERROR "CPLEX not yet supported on Linux")
endif()

if(NOT CPLEX_ROOT)
  set(CPLEX_ROOT $ENV{CPLEX_ROOT})
endif()
message(STATUS "CPLEX_ROOT: ${CPLEX_ROOT}")
if(NOT CPLEX_ROOT)
  message(FATAL_ERROR "CPLEX_ROOT: not found")
else()
  set(CPLEX_FOUND TRUE)
endif()

if(CPLEX_FOUND AND NOT TARGET CPLEX::CPLEX)
  add_library(CPLEX::CPLEX UNKNOWN IMPORTED)

  set_target_properties(CPLEX::CPLEX PROPERTIES
    INTERFACE_INCLUDE_DIRECTORIES "${CPLEX_INCLUDE_DIRS}")

  set_target_properties(CPLEX::CPLEX PROPERTIES
    IMPORTED_LOCATION "${CPLEX_ROOT}/cplex/lib/x64_windows_msvc14/stat_mda/cplex12100.lib")
endif()