Fixed support and documentation for Cmake CPLEX build on Linux
This commit is contained in:
@@ -37,14 +37,12 @@ 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})
|
||||
if(DEFINED ENV{UNIX_CPLEX_DIR})
|
||||
set(CPLEX_ROOT $ENV{UNIX_CPLEX_DIR})
|
||||
elseif(DEFINED ENV{CPLEX_ROOT})
|
||||
set(CPLEX_ROOT $ENV{CPLEX_ROOT})
|
||||
endif()
|
||||
endif()
|
||||
message(STATUS "CPLEX_ROOT: ${CPLEX_ROOT}")
|
||||
if(NOT CPLEX_ROOT)
|
||||
@@ -53,12 +51,24 @@ else()
|
||||
set(CPLEX_FOUND TRUE)
|
||||
endif()
|
||||
|
||||
# TODO(mizux) Bump support to CPLEX 20.1.0
|
||||
# ref: https://www.ibm.com/docs/en/icos/20.1.0?topic=cplex-setting-up-gnulinuxmacos
|
||||
# ref: https://www.ibm.com/docs/en/icos/20.1.0?topic=cplex-setting-up-windows
|
||||
|
||||
# ref: https://www.ibm.com/docs/en/icos/12.10.0?topic=cplex-setting-up-gnulinuxmacos
|
||||
if(CPLEX_FOUND AND NOT TARGET CPLEX::CPLEX)
|
||||
add_library(CPLEX::CPLEX UNKNOWN IMPORTED)
|
||||
target_include_directories(CPLEX::CPLEX SYSTEM INTERFACE "${CPLEX_ROOT}/cplex/include")
|
||||
|
||||
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")
|
||||
if(APPLE) # be aware that `UNIX` is `TRUE` on OS X, so this check must be first
|
||||
# FIXME(mizux) need actual macOS library path
|
||||
# target_link_libraries(CPLEX::CPLEX INTERFACE "${CPLEX_ROOT}/cplex/lib/libcplex.lib")
|
||||
message(FATAL_ERROR "CPLEX not yet supported for CMake builds on ${CMAKE_SYSTEM}")
|
||||
elseif(UNIX)
|
||||
target_link_libraries(CPLEX::CPLEX INTERFACE "${CPLEX_ROOT}/cplex/lib/x86-64_linux/static_pic/libcplex.a")
|
||||
elseif(MSVC)
|
||||
target_link_libraries(CPLEX::CPLEX INTERFACE "${CPLEX_ROOT}/cplex/lib/x64_windows_msvc14/stat_mda/cplex12100.lib")
|
||||
else()
|
||||
message(FATAL_ERROR "CPLEX not supported for ${CMAKE_SYSTEM}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@@ -94,6 +94,22 @@ solvers:
|
||||
**warning: Since these solvers require license and are proprietary, we can't
|
||||
test it on public CI and support can be broken.**
|
||||
|
||||
### Enabling CPLEX Support
|
||||
|
||||
To enable CPLEX support, configure with `-DUSE_CPLEX=ON` and `-DCPLEX_ROOT=/absolute/path/to/CPLEX/root/dir`,
|
||||
replacing `/absolute/path/to/CPLEX/root/dir` with the path to your CPLEX installation.
|
||||
`CPLEX_ROOT` can also be defined as an environment variable rather than an option at configure time.
|
||||
|
||||
For ease of migration from legacy `make third_party` builds, CMake will also read the CPLEX installation path from the
|
||||
`UNIX_CPLEX_DIR` environment variable, if defined.
|
||||
|
||||
### Enabling XPRESS Support
|
||||
|
||||
To enable XPRESS support, configure with `-DUSE_XPRESS=ON` and `-DXPRESS_ROOT=/absolute/path/to/XPRESS/root/dir`,
|
||||
replacing `/absolute/path/to/XPRESS/root/dir` with the path to your XPRESS
|
||||
installation. `XPRESS_ROOT` can also be defined as an environment variable rather than an option at configure time.
|
||||
|
||||
|
||||
<a name="options"></a>
|
||||
|
||||
## CMake Options
|
||||
|
||||
Reference in New Issue
Block a user