FindIPOPT.cmake 2.61 KB
Newer Older
David Bommes's avatar
changed    
David Bommes committed
1
2
3
4
5
6
7
8
# - Try to find IPOPT
# Once done this will define
#  IPOPT_FOUND - System has IpOpt
#  IPOPT_INCLUDE_DIRS - The IpOpt include directories
#  IPOPT_LIBRARY_DIRS - The library directories needed to use IpOpt
#  IPOPT_LIBRARIES    - The libraries needed to use IpOpt


9
10
11
12
13
14
if (IPOPT_INCLUDE_DIR)
  # in cache already
  SET(IPOPT_FIND_QUIETLY TRUE)
endif (IPOPT_INCLUDE_DIR)

if (WIN32)
Jan Möbius's avatar
Jan Möbius committed
15
   find_path(IPOPT_INCLUDE_DIR NAMES IpNLP.hpp
16
     PATHS
Jan Möbius's avatar
Jan Möbius committed
17
     "C:\\libs\\Ipopt-3.8.2\\include\\coin"
18
19
20
     ${IPOPT_DIR}/include
   )

21
22
23
24
25
26
27
   IF(IPOPT_INCLUDE_DIR)
      find_library( IPOPT_LIBRARY_RELEASE 
                    Ipopt
                    PATHS "C:\\libs\\Ipopt-3.8.2\\lib\\win32\\release" )
      find_library( IPOPT_LIBRARY_DEBUG
                    Ipopt
                    PATHS "C:\\libs\\Ipopt-3.8.2\\lib\\win32\\debug" )
28

29
      set ( IPOPT_LIBRARY "optimized;${IPOPT_LIBRARY_RELEASE};debug;${IPOPT_LIBRARY_DEBUG}" CACHE  STRING "IPOPT Libraries" )
30

Jan Möbius's avatar
Jan Möbius committed
31
32
33
34
35
36
37
38
39
      SET(IPOPT_FOUND TRUE)
      SET(IPOPT_INCLUDE_DIR ${IPOPT_INCLUDE_DIR})
	  # Todo, set right version depending on build type (debug/release)
	  #GET_FILENAME_COMPONENT( IPOPT_LIBRARY_DIR ${GLEW_LIBRARY} PATH )
    ELSE(IPOPT_INCLUDE_DIR)
      SET(IPOPT_FOUND FALSE)
      SET(IPOPT_INCLUDE_DIR ${IPOPT_INCLUDE_DIR})
    ENDIF(IPOPT_INCLUDE_DIR)

40
41
ELSE( WIN32 )
   find_path(IPOPT_INCLUDE_DIR NAMES IpNLP.hpp
David Bommes's avatar
changed    
David Bommes committed
42
43
44
     PATHS  "$ENV{IPOPT_HOME}/include/coin"
            "/usr/include/coin"
    
45
46
47
48
   )

   find_library( IPOPT_LIBRARY 
                 ipopt
David Bommes's avatar
changed    
David Bommes committed
49
50
51
52
53
54
                 PATHS "$ENV{IPOPT_HOME}/lib"
                       "/usr/lib" )   
    
    #wrong config under Debian workaround
    add_definitions( -DHAVE_CSTDDEF )

55
56
   
   # set optional path to HSL Solver
David Bommes's avatar
David Bommes committed
57
58
59
60
61
   find_path(IPOPT_HSL_LIBRARY_DIR 
             NAMES libhsl.so
                   libhsl.dylib
             PATHS "$ENV{IPOPT_HSL_LIBRARY_PATH}"
                   "$ENV{HOME}/opt/HSL/lib"
62
63
   )
   
David Bommes's avatar
David Bommes committed
64
   IF( IPOPT_HSL_LIBRARY_DIR)
Jan Möbius's avatar
Jan Möbius committed
65
66
67
     IF( NOT IPOPT_FIND_QUIETLY )
        message ( "IPOPT_HSL_LIBRARY_DIR found at ${IPOPT_HSL_LIBRARY_DIR} ")
     ENDIF()
68
     set(IPOPT_LIBRARY_DIR ${IPOPT_HSL_LIBRARY_DIR})
Jan Möbius's avatar
Jan Möbius committed
69
     LIST( APPEND IPOPT_LIBRARY_DIRS "${IPOPT_HSL_LIBRARY_DIR}")
70
   ENDIF(IPOPT_HSL_LIBRARY_DIR)
David Bommes's avatar
changed    
David Bommes committed
71
72
73
74
75
76
77
78
79
80
81
82
83
   
   
   set(IPOPT_INCLUDE_DIRS "${IPOPT_INCLUDE_DIR}" )
   set(IPOPT_LIBRARIES "${IPOPT_LIBRARY}" )

   include(FindPackageHandleStandardArgs)
   # handle the QUIETLY and REQUIRED arguments and set LIBCPLEX_FOUND to TRUE
   # if all listed variables are TRUE
   find_package_handle_standard_args(IPOPT  DEFAULT_MSG
                                     IPOPT_LIBRARY IPOPT_INCLUDE_DIR)

   mark_as_advanced(IPOPT_INCLUDE_DIR IPOPT_LIBRARY )
   
84
ENDIF()