Commit 0d407924 authored by Aron Zingler's avatar Aron Zingler
Browse files

Update CMakeLists.txt, FindXpress.cmake

parent 1e49017e
cmake_minimum_required(VERSION 3.15 FATAL_ERROR)
message("Checking files for XPRESS.")
project(xpress CXX)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}")
find_package(Xpress)
if(${Xpress_FOUND})
add_library(xpress INTERFACE)
set_target_properties(xpress PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${XPRESS_INCLUDE_DIRS})
set_target_properties(xpress PROPERTIES INTERFACE_COMPILE_DEFINITIONS HAVE_XPRESS)
#set_target_link_directories(xpress INTERFACE target_link_directories)
add_library(xpress-cxx SHARED IMPORTED)
set_target_properties(xpress-cxx PROPERTIES IMPORTED_LOCATION ${XPRESS_LIBRARY} )
add_library(xpress-cpp SHARED IMPORTED)
set_target_properties(xpress-cpp PROPERTIES IMPORTED_LOCATION ${XPRESS_LIBRARY_cpp})
#if(WIN32)
#
# add_library(xpress-cxx-d STATIC IMPORTED)
# set_target_properties(xpress-cxx-d PROPERTIES IMPORTED_LOCATION ${GUROBI_CXX_LIBRARY_D})
# target_link_libraries(xpress INTERFACE debug xpress-cxx-d)
# target_link_libraries(xpress INTERFACE optimized xpress-cxx)
#
#else()
find_package(Threads REQUIRED)
target_link_libraries(xpress INTERFACE xpress-cxx xpress-cpp Threads::Threads)
#endif()
else()
add_library(xpress INTERFACE)
message("No supported version of Xpress could be found. A dummy target will be used instead and the flag HAVE_XPRESS will not be defined.")
message("This may be OK depending on the application (e.g., in MAiNGO), but you will not be able to actually use Xpress.")
endif()
#adapted from SCIPOPT
find_path(XPRESS_INCLUDE_DIRS
xprs.h
HINTS ${XPRESS_DIR} $ENV{XPRESS_DIR}
PATH_SUFFIXES include)
# todo: enable recursive search
find_library(XPRESS_LIBRARY
NAMES xprs
HINTS ${XPRESS_DIR} $ENV{XPRESS_DIR}
PATH_SUFFIXES lib)
find_library(XPRESS_LIBRARY_cpp
NAMES xprb
HINTS ${XPRESS_DIR} $ENV{XPRESS_DIR}
PATH_SUFFIXES lib)
# todo properly check when pthread is necessary
set(XPRESS_LIBRARIES ${XPRESS_LIBRARY} ${XPRESS_LIBRARY_cpp})
message(STATUS "XPRESS C++ library: ${XPRESS_LIBRARIES}")
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Xpress DEFAULT_MSG
XPRESS_INCLUDE_DIRS)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Xpress DEFAULT_MSG XPRESS_LIBRARY)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Xpress DEFAULT_MSG XPRESS_LIBRARY_cpp)
#FIND_PACKAGE_HANDLE_STANDARD_ARGS(Xpress DEFAULT_MSG XPRESS_LINK_DIR)
mark_as_advanced(XPRESS_INCLUDE_DIRS)
mark_as_advanced(XPRESS_LIBRARY)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment