Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add FindXPRESS.cmake from or-tools repo and use it with option XPRESS… #235

Open
wants to merge 1 commit into
base: New-Antares-Emulator-4
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions INSTALL-centos.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ Here is a list of available CMake configure option :
|`USE_PRECOMPILED_EXT`| This option must be set if you use precompiled external librairies (default `OFF`)|
|`BUILD_TESTING`| Enable test build (default `OFF`)|
|`BUILD_OUTPUT_TEST`| Enable test with output compare build (default `OFF`)|
|`USE_XPRESS`| Build with XPress support (default `OFF`)|
|`XPRESS_ROOT`|Define XPress install root (for example `/opt/xpressmp/`)|


```
Expand Down
8 changes: 8 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,14 @@ message(STATUS "CMAKE_PREFIX_PATH : ${CMAKE_PREFIX_PATH}")
add_subdirectory(antares-deps)

# Define needed external library
option(XPRESS_USE "Compilation with XPRESS use" OFF)

if (XPRESS_USE)

list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/xpress)
find_package(XPRESS REQUIRED)

endif()

#libcurl
find_package(CURL REQUIRED)
Expand Down
75 changes: 75 additions & 0 deletions src/cmake/xpress/FindXPRESS.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#[=======================================================================[.rst:
FindXPRESS
--------

This module determines the XPRESS library of the system.

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

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

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

This module defines the following variables:

::

XPRESS_FOUND - True if XPRESS found.

Hints
^^^^^

A user may set ``XPRESS_ROOT`` to a XPRESS installation root to tell this
module where to look.
#]=======================================================================]
set(XPRESS_FOUND FALSE)

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

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

if(XPRESS_FOUND AND NOT TARGET XPRESS::XPRESS)
add_library(XPRESS::XPRESS UNKNOWN IMPORTED)

if(UNIX)
set_target_properties(XPRESS::XPRESS PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${XPRESS_ROOT}/include")
endif()

if(APPLE)
set_target_properties(XPRESS::XPRESS PROPERTIES
#INSTALL_RPATH_USE_LINK_PATH TRUE
#BUILD_WITH_INSTALL_RPATH TRUE
#INTERFACE_LINK_DIRECTORIES "${XPRESS_ROOT}/lib"
#INSTALL_RPATH "${XPRESS_ROOT}/lib;${INSTALL_RPATH}"
IMPORTED_LOCATION "${XPRESS_ROOT}/lib/libxprs.dylib")
elseif(UNIX)
set_target_properties(XPRESS::XPRESS PROPERTIES
INTERFACE_LINK_DIRECTORIES "${XPRESS_ROOT}/lib"
IMPORTED_LOCATION ${XPRESS_ROOT}/lib/libxprs.so)
elseif(MSVC)
set_target_properties(XPRESS::XPRESS PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${XPRESS_ROOT}\\include"
IMPORTED_LOCATION "${XPRESS_ROOT}\\lib\\xprs.lib")
endif()
endif()