Skip to content
Snippets Groups Projects
Commit e7c890a3 authored by Jonathan Youett's avatar Jonathan Youett
Browse files

Don't use pkgconfig to find ipopt and allow to give cmake a hint where to find...

Don't use pkgconfig to find ipopt and allow to give cmake a hint where to find the library. The reason for this is that find_package doesn't allow to give a preferred search path which is unflexible for multiple installed ipopt libraries.
Further also look for the libraries DL and HSL which are needed if the IpOpt solver shall be used with more elaborate linear solvers.
parent 678ac349
No related branches found
No related tags found
No related merge requests found
find_package(PkgConfig REQUIRED)
include(FindPackageHandleStandardArgs) include(FindPackageHandleStandardArgs)
pkg_check_modules(IPOPT ipopt) #find_package(PkgConfig REQUIRED)
find_package_handle_standard_args(Ipopt DEFAULT_MSG IPOPT_FOUND) #pkg_check_modules(IPOPT ipopt)
find_library(IPOPT_LIBRARY ipopt HINTS "${IPOPT_LIBDIR}")
# some versions of Ipopt need the DL library
find_library(DL_LIBRARY dl)
find_path(IPOPT_INCLUDE_DIR
NAMES "IpNLP.hpp"
HINTS ${IPOPT_PREFIX} ${IPOPT_ROOT}
PATH_SUFFIXES "include" "include/coin"
)
find_library(IPOPT_LIBRARY
NAMES ipopt
HINTS ${IPOPT_PREFIX} ${IPOPT_ROOT}
PATH_SUFFIXES "lib"
)
# If you want to want to use other linear solver
find_library(HSL_LIBRARY
NAMES coinhsl
HINTS ${IPOPT_PREFIX} ${IPOPT_ROOT}
PATH_SUFFIXES "lib"
)
find_package_handle_standard_args(hsl DEFAULT_MSG HSL_LIBRARY)
find_package_handle_standard_args(dl DEFAULT_MSG DL_LIBRARY)
find_package_handle_standard_args(Ipopt DEFAULT_MSG IPOPT_INCLUDE_DIR IPOPT_LIBRARY)
set(HAVE_IPOPT ENABLE_IPOPT) set(HAVE_IPOPT ENABLE_IPOPT)
if(IPOPT_FOUND) if(IPOPT_FOUND)
set(DUNE_IPOPT_CFLAGS ${IPOPT_CFLAGS} -DENABLE_IPOPT=1) set(DUNE_IPOPT_CFLAGS -I${IPOPT_INCLUDE_DIR})
foreach(dir ${PSURFACE_INCLUDE_DIRS}) set_property(GLOBAL APPEND PROPERTY ALL_PKG_FLAGS "-DENABLE_IPOPT")
set_property(GLOBAL APPEND PROPERTY ALL_PKG_FLAGS "-I${dir}") set_property(GLOBAL APPEND PROPERTY ALL_PKG_FLAGS ${DUNE_IPOPT_CFLAGS})
endforeach() set(IPOPT_LIBRARY ${IPOPT_LIBRARY})
if (HSL_FOUND)
set (IPOPT_LIBRARY ${HSL_LIBRARY} ${IPOPT_LIBRARY})
endif(HSL_FOUND)
if (DL_FOUND)
set (IPOPT_LIBRARY ${DL_LIBRARY} ${IPOPT_LIBRARY})
endif(DL_FOUND)
endif(IPOPT_FOUND) endif(IPOPT_FOUND)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment