FindCoMISo.cmake 7.84 KB
Newer Older
Henrik Zimmer's avatar
Henrik Zimmer committed
1 2 3 4
# - Try to find COMISO
# Once done this will define
#  
#  COMISO_FOUND        - system has COMISO
5
#  COMISO_INCLUDE_DIRS - the COMISO include directory
Henrik Zimmer's avatar
Henrik Zimmer committed
6 7 8
#  COMISO_LIBRARY_DIR  - where the libraries are
#  COMISO_LIBRARY      - Link these to use COMISO

David Bommes's avatar
David Bommes committed
9

10
IF (COMISO_INCLUDE_DIRS)
David Bommes's avatar
David Bommes committed
11 12
  # Already in cache, be silent
  SET(COMISO_FIND_QUIETLY TRUE)
13
ENDIF (COMISO_INCLUDE_DIRS)
David Bommes's avatar
David Bommes committed
14

15 16 17 18 19 20 21 22 23 24 25
# search all lib directories in packages for OpenFlipper
file (
  GLOB _libdirs
           "${CMAKE_SOURCE_DIR}/libs"
           "${CMAKE_SOURCE_DIR}/Package-*/libs"
           "${CMAKE_BINARY_DIR}/libs"
           "${CMAKE_BINARY_DIR}/Package-*/libs"
           "${CMAKE_BINARY_DIR}/libs/CoMISo"
           "${CMAKE_BINARY_DIR}/Package-*/libs/CoMISo"
)

26 27 28 29
FIND_PATH( COMISO_INCLUDE_DIR CoMISo/Solver/MISolver.hh
           PATHS ${_libdirs}
                 "${CMAKE_SOURCE_DIR}"
                 "${CMAKE_SOURCE_DIR}/../" )
30

David Bommes's avatar
David Bommes committed
31
# Find CoMISo config file
32
FIND_PATH( COMISO_CONFIG_INCLUDE_DIR CoMISo/Config/config.hh
33 34
           PATHS ${_libdirs}
                 "${CMAKE_BINARY_DIR}/../"
35 36
                 "${CMAKE_BINARY_DIR}/../CoMISo/" 
                 "${COMISO_INCLUDE_DIR}" )
37 38

if ( COMISO_INCLUDE_DIR AND COMISO_CONFIG_INCLUDE_DIR )
David Bommes's avatar
David Bommes committed
39

40 41 42
  # add COMISO_INCLUDE_DIR/CoMISo so stuff in CoMISo/Base can be included by <Base/...>
  set(COMISO_INCLUDE_DIR "${COMISO_INCLUDE_DIR};${COMISO_INCLUDE_DIR}/CoMISo")

43
  FILE(READ ${COMISO_CONFIG_INCLUDE_DIR}/CoMISo/Config/config.hh CURRENT_COMISO_CONFIG)
David Bommes's avatar
David Bommes committed
44

David Bommes's avatar
David Bommes committed
45
  set(COMISO_OPT_DEPS "")
David Bommes's avatar
David Bommes committed
46 47


David Bommes's avatar
David Bommes committed
48
  STRING(REGEX MATCH "\#define COMISO_MPI_AVAILABLE 1" COMISO_MPI_BUILD_TIME_AVAILABLE ${CURRENT_COMISO_CONFIG} )
David Bommes's avatar
David Bommes committed
49

David Bommes's avatar
David Bommes committed
50
  if ( COMISO_MPI_BUILD_TIME_AVAILABLE )
David Bommes's avatar
David Bommes committed
51

David Bommes's avatar
David Bommes committed
52
   find_package(MPI)
David Bommes's avatar
David Bommes committed
53

David Bommes's avatar
David Bommes committed
54 55 56
   if ( NOT MPI_FOUND )
     message(ERROR "COMISO configured with mpi but mpi not available")
   endif()
David Bommes's avatar
David Bommes committed
57

David Bommes's avatar
David Bommes committed
58
   list (APPEND  COMISO_OPT_DEPS "MPI")
David Bommes's avatar
David Bommes committed
59

David Bommes's avatar
David Bommes committed
60
  endif()
David Bommes's avatar
David Bommes committed
61

David Bommes's avatar
David Bommes committed
62 63 64 65
  STRING(REGEX MATCH "\#define COMISO_BOOST_AVAILABLE 1" COMISO_BOOST_BUILD_TIME_AVAILABLE ${CURRENT_COMISO_CONFIG} )

  if ( COMISO_BOOST_BUILD_TIME_AVAILABLE )
   
David Bommes's avatar
David Bommes committed
66
   find_package( Boost 1.42.0 COMPONENTS system filesystem regex QUIET)
David Bommes's avatar
David Bommes committed
67 68 69 70 71 72 73 74 75 76

   if ( NOT Boost_FOUND )
     message(ERROR "COMISO configured with Boost but Boost not available")
   endif()

   list (APPEND  COMISO_OPT_DEPS "Boost")

  endif()


David Bommes's avatar
David Bommes committed
77 78 79 80 81 82 83 84 85 86 87 88 89 90
  STRING(REGEX MATCH "\#define COMISO_SUITESPARSE_AVAILABLE 1" COMISO_SUITESPARSE_BUILD_TIME_AVAILABLE ${CURRENT_COMISO_CONFIG} )

  if ( COMISO_SUITESPARSE_BUILD_TIME_AVAILABLE )

   find_package(SUITESPARSE)

   if ( NOT SUITESPARSE_FOUND )
     message(ERROR "COMISO configured with Suitesparse but Suitesparse not available")
   endif()

   list (APPEND  COMISO_OPT_DEPS "SUITESPARSE")

  endif()
  
David Bommes's avatar
David Bommes committed
91
  STRING(REGEX MATCH "\#define COMISO_PETSC_AVAILABLE 1" COMISO_PETSC_BUILD_TIME_AVAILABLE ${CURRENT_COMISO_CONFIG} )
David Bommes's avatar
David Bommes committed
92

David Bommes's avatar
David Bommes committed
93
  if ( COMISO_PETSC_BUILD_TIME_AVAILABLE )
David Bommes's avatar
David Bommes committed
94

David Bommes's avatar
David Bommes committed
95
   find_package(PETSC)
David Bommes's avatar
David Bommes committed
96

David Bommes's avatar
David Bommes committed
97 98 99
   if ( NOT PETSC_FOUND )
     message(ERROR "COMISO configured with petsc but petsc not available")
   endif()
David Bommes's avatar
David Bommes committed
100

David Bommes's avatar
David Bommes committed
101
   list (APPEND  COMISO_OPT_DEPS "PETSC")
David Bommes's avatar
David Bommes committed
102

David Bommes's avatar
David Bommes committed
103
  endif()
David Bommes's avatar
David Bommes committed
104

David Bommes's avatar
David Bommes committed
105
  STRING(REGEX MATCH "\#define COMISO_IPOPT_AVAILABLE 1" COMISO_IPOPT_BUILD_TIME_AVAILABLE ${CURRENT_COMISO_CONFIG} )
David Bommes's avatar
David Bommes committed
106

David Bommes's avatar
David Bommes committed
107
  if ( COMISO_IPOPT_BUILD_TIME_AVAILABLE )
David Bommes's avatar
David Bommes committed
108

David Bommes's avatar
David Bommes committed
109
   find_package(IPOPT)
David Bommes's avatar
David Bommes committed
110

David Bommes's avatar
David Bommes committed
111 112 113
   if ( NOT IPOPT_FOUND )
     message(ERROR "COMISO configured with ipopt but ipopt not available")
   endif()
David Bommes's avatar
David Bommes committed
114

David Bommes's avatar
David Bommes committed
115
   list (APPEND  COMISO_OPT_DEPS "IPOPT")
David Bommes's avatar
David Bommes committed
116

David Bommes's avatar
David Bommes committed
117
  endif()
David Bommes's avatar
David Bommes committed
118

David Bommes's avatar
David Bommes committed
119 120 121 122 123 124 125 126 127 128 129 130 131 132
  STRING(REGEX MATCH "\#define COMISO_METIS_AVAILABLE 1" COMISO_METIS_BUILD_TIME_AVAILABLE ${CURRENT_COMISO_CONFIG} )

  if ( COMISO_METIS_BUILD_TIME_AVAILABLE )

   find_package(METIS)

   if ( NOT METIS_FOUND )
     message(ERROR "COMISO configured with Metis but Metis not available")
   endif()

   list (APPEND  COMISO_OPT_DEPS "METIS")

  endif()
  
David Bommes's avatar
David Bommes committed
133
  STRING(REGEX MATCH "\#define COMISO_MUMPS_AVAILABLE 1" COMISO_MUMPS_BUILD_TIME_AVAILABLE ${CURRENT_COMISO_CONFIG} )
David Bommes's avatar
David Bommes committed
134

David Bommes's avatar
David Bommes committed
135
  if ( COMISO_MUMPS_BUILD_TIME_AVAILABLE )
David Bommes's avatar
David Bommes committed
136

David Bommes's avatar
David Bommes committed
137
   find_package(MUMPS)
David Bommes's avatar
David Bommes committed
138

David Bommes's avatar
David Bommes committed
139 140 141
   if ( NOT MUMPS_FOUND )
     message(ERROR "COMISO configured with mumps but mumps not available")
   endif()
David Bommes's avatar
David Bommes committed
142

David Bommes's avatar
David Bommes committed
143
   list (APPEND  COMISO_OPT_DEPS "MUMPS")
David Bommes's avatar
David Bommes committed
144

David Bommes's avatar
David Bommes committed
145
  endif()
David Bommes's avatar
David Bommes committed
146

David Bommes's avatar
David Bommes committed
147
  STRING(REGEX MATCH "\#define COMISO_TAO_AVAILABLE 1" COMISO_TAO_BUILD_TIME_AVAILABLE ${CURRENT_COMISO_CONFIG} )
David Bommes's avatar
David Bommes committed
148

David Bommes's avatar
David Bommes committed
149
  if ( COMISO_TAO_BUILD_TIME_AVAILABLE )
David Bommes's avatar
David Bommes committed
150

David Bommes's avatar
David Bommes committed
151
   find_package(TAO)
David Bommes's avatar
David Bommes committed
152

David Bommes's avatar
David Bommes committed
153 154 155
   if ( NOT TAO_FOUND )
     message(ERROR "COMISO configured with tao but tao not available")
   endif()
David Bommes's avatar
David Bommes committed
156

David Bommes's avatar
David Bommes committed
157 158
   list (APPEND  COMISO_OPT_DEPS "TAO")
  endif()
David Bommes's avatar
David Bommes committed
159 160 161 162 163 164 165 166 167 168 169
  
  STRING(REGEX MATCH "\#define COMISO_TAUCS_AVAILABLE 1" COMISO_TAUCS_BUILD_TIME_AVAILABLE ${CURRENT_COMISO_CONFIG} )

  if ( COMISO_TAUCS_BUILD_TIME_AVAILABLE )

   find_package(Taucs)

   if ( NOT TAUCS_FOUND )
     message(ERROR "COMISO configured with Taucs but Taucs not available")
   endif()

David Bommes's avatar
David Bommes committed
170
   list (APPEND  COMISO_OPT_DEPS "Taucs")
David Bommes's avatar
David Bommes committed
171 172

  endif()
Henrik Zimmer's avatar
Henrik Zimmer committed
173

David Bommes's avatar
David Bommes committed
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188
  STRING(REGEX MATCH "\#define COMISO_GUROBI_AVAILABLE 1" COMISO_GUROBI_BUILD_TIME_AVAILABLE ${CURRENT_COMISO_CONFIG} )

  if ( COMISO_GUROBI_BUILD_TIME_AVAILABLE )

   find_package(GUROBI)

   if ( NOT GUROBI_FOUND )
     message(ERROR "COMISO configured with GUROBI but GUROBI not available")
   endif()

   list (APPEND  COMISO_OPT_DEPS "GUROBI")

  endif()


David Bommes's avatar
David Bommes committed
189 190 191 192 193 194 195 196 197 198 199 200 201
  STRING(REGEX MATCH "\#define COMISO_ARPACK_AVAILABLE 1" COMISO_ARPACK_BUILD_TIME_AVAILABLE ${CURRENT_COMISO_CONFIG} )

  if ( COMISO_ARPACK_BUILD_TIME_AVAILABLE )

   find_package(ARPACK)

   if ( NOT ARPACK_FOUND )
     message(ERROR "COMISO configured with ARPACK but ARPACK not available")
   endif()

   list (APPEND  COMISO_OPT_DEPS "ARPACK")

  endif()
David Bommes's avatar
David Bommes committed
202 203 204 205 206 207 208 209 210 211 212 213 214 215
  
  STRING(REGEX MATCH "\#define COMISO_CPLEX_AVAILABLE 1" COMISO_CPLEX_BUILD_TIME_AVAILABLE ${CURRENT_COMISO_CONFIG} )

  if ( COMISO_CPLEX_BUILD_TIME_AVAILABLE )

   find_package(CPLEX)

   if ( NOT CPLEX_FOUND )
     message(ERROR "COMISO configured with CPLEX but CPLEX not available")
   endif()

   list (APPEND  COMISO_OPT_DEPS "CPLEX")

  endif()
David Bommes's avatar
David Bommes committed
216
  
217
  STRING(REGEX MATCH "\#define COMISO_EIGEN3_AVAILABLE 1" COMISO_EIGEN3_BUILD_TIME_AVAILABLE ${CURRENT_COMISO_CONFIG} )
David Bommes's avatar
David Bommes committed
218

219
  if ( COMISO_EIGEN3_BUILD_TIME_AVAILABLE )
David Bommes's avatar
David Bommes committed
220
                                                                          
221
   find_package(EIGEN3)
David Bommes's avatar
David Bommes committed
222
                                                                          
223 224
   if ( NOT EIGEN3_FOUND )
     message(ERROR "COMISO configured with EIGEN3 but EIGEN3 not available")
David Bommes's avatar
David Bommes committed
225 226
   endif()
                                                                          
227
   list (APPEND  COMISO_OPT_DEPS "EIGEN3")
David Bommes's avatar
David Bommes committed
228 229
                                                                          
  endif()
David Bommes's avatar
David Bommes committed
230

David Bommes's avatar
David Bommes committed
231 232 233 234 235 236 237 238 239 240 241 242 243 244
  STRING(REGEX MATCH "\#define COMISO_DCO_AVAILABLE 1" COMISO_DCO_BUILD_TIME_AVAILABLE ${CURRENT_COMISO_CONFIG} )

  if ( COMISO_DCO_BUILD_TIME_AVAILABLE )
                                                                          
   find_package(DCO)
                                                                          
   if ( NOT DCO_FOUND )
     message(ERROR "COMISO configured with DCO but DCO not available")
   endif()
                                                                          
   list (APPEND  COMISO_OPT_DEPS “DCO”)
                                                                          
  endif()

245
  add_definitions (-DCOMISODLL -DUSECOMISO -DBASEDLL -DUSEBASE )
David Bommes's avatar
David Bommes committed
246

David Bommes's avatar
David Bommes committed
247
  include(FindPackageHandleStandardArgs)
Henrik Zimmer's avatar
Henrik Zimmer committed
248
  SET(COMISO_FOUND TRUE)
249 250 251 252 253 254

  FIND_LIBRARY( COMISO_LIBRARY_DIR NAMES CoMISo
                PATHS ${SEARCH_PATHS}
                     "${CMAKE_BINARY_DIR}/Build/${ACG_PROJECT_LIBDIR}"
                PATH_SUFFIXES lib lib64)

Henrik Zimmer's avatar
Henrik Zimmer committed
255
  SET( COMISO_LIBRARY "CoMISo")
David Bommes's avatar
David Bommes committed
256
#  SET( COMISO_DEPS "GMM;BLAS;SUITESPARSE" )
David Bommes's avatar
David Bommes committed
257 258 259
  SET( COMISO_DEPS "GMM")
#  SET( COMISO_OPT_DEPS ${COMISO_OPT_DEPS} CACHE STRING "Comiso optional dependecies")
#  mark_as_advanced(COMISO_DEPS COMISO_OPT_DEPS)
260 261 262 263
  SET( COMISO_INCLUDE_DIRS ${COMISO_INCLUDE_DIR};${COMISO_CONFIG_INCLUDE_DIR} )
  # For backwards compat:
  SET( COMISO_INCLUDE_DIR ${COMISO_INCLUDE_DIRS} )
ELSE (COMISO_INCLUDE_DIR AND COMISO_CONFIG_INCLUDE_DIR)
Henrik Zimmer's avatar
Henrik Zimmer committed
264 265
  SET( COMISO_FOUND FALSE )
  SET( COMISO_LIBRARY_DIR )
266
ENDIF (COMISO_INCLUDE_DIR AND COMISO_CONFIG_INCLUDE_DIR)
Henrik Zimmer's avatar
Henrik Zimmer committed
267