FindCoMISo.cmake 7.68 KB
Newer Older
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
6
7
#  COMISO_LIBRARY_DIR  - where the libraries are
#  COMISO_LIBRARY      - Link these to use COMISO
David Bommes's avatar
David Bommes committed
8

9

10
IF (COMISO_INCLUDE_DIRS)
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
# search all lib directories in packages for OpenFlipper
file (
  GLOB _libdirs
           "${CMAKE_SOURCE_DIR}/libs"
           "${CMAKE_SOURCE_DIR}/Package-*/libs"
20
21
           "${CMAKE_BINARY_DIR}/libs"
           "${CMAKE_BINARY_DIR}/Package-*/libs"
22
23
           "${CMAKE_BINARY_DIR}/libs/CoMISo"
           "${CMAKE_BINARY_DIR}/Package-*/libs/CoMISo"
24
25
)

26

27
# Find CoMISo config file
28
29
FIND_PATH( COMISO_CONFIG_INCLUDE_DIR CoMISo/Config/config.hh
           PATHS ${_libdirs}
30
31
                 "${CMAKE_BINARY_DIR}/../"
                 "${CMAKE_BINARY_DIR}/../CoMISo/" )
32
33
34
35

FIND_PATH( COMISO_INCLUDE_DIR CoMISo/Solver/MISolver.hh
           PATHS ${_libdirs}
                 "${CMAKE_SOURCE_DIR}"
David Bommes's avatar
David Bommes committed
36
                 "${CMAKE_SOURCE_DIR}/../" )
37

38
if ( COMISO_INCLUDE_DIR AND COMISO_CONFIG_INCLUDE_DIR )
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)
44

45
  set(COMISO_OPT_DEPS "")
46
47


48
  STRING(REGEX MATCH "\#define COMISO_MPI_AVAILABLE 1" COMISO_MPI_BUILD_TIME_AVAILABLE ${CURRENT_COMISO_CONFIG} )
49

50
  if ( COMISO_MPI_BUILD_TIME_AVAILABLE )
51

52
   find_package(MPI)
53

54
55
56
   if ( NOT MPI_FOUND )
     message(ERROR "COMISO configured with mpi but mpi not available")
   endif()
57

58
   list (APPEND  COMISO_OPT_DEPS "MPI")
59

60
  endif()
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()


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()
  
91
  STRING(REGEX MATCH "\#define COMISO_PETSC_AVAILABLE 1" COMISO_PETSC_BUILD_TIME_AVAILABLE ${CURRENT_COMISO_CONFIG} )
92

93
  if ( COMISO_PETSC_BUILD_TIME_AVAILABLE )
94

95
   find_package(PETSC)
96

97
98
99
   if ( NOT PETSC_FOUND )
     message(ERROR "COMISO configured with petsc but petsc not available")
   endif()
100

101
   list (APPEND  COMISO_OPT_DEPS "PETSC")
102

103
  endif()
104

105
  STRING(REGEX MATCH "\#define COMISO_IPOPT_AVAILABLE 1" COMISO_IPOPT_BUILD_TIME_AVAILABLE ${CURRENT_COMISO_CONFIG} )
106

107
  if ( COMISO_IPOPT_BUILD_TIME_AVAILABLE )
108

109
   find_package(IPOPT)
110

111
112
113
   if ( NOT IPOPT_FOUND )
     message(ERROR "COMISO configured with ipopt but ipopt not available")
   endif()
114

115
   list (APPEND  COMISO_OPT_DEPS "IPOPT")
116

117
  endif()
118

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
134
135
136
137
138
139
140
141
142
143
144
145
146
  STRING(REGEX MATCH "\#define COMISO_MUMPS_AVAILABLE 1" COMISO_MUMPS_BUILD_TIME_AVAILABLE ${CURRENT_COMISO_CONFIG} )

  if ( COMISO_MUMPS_BUILD_TIME_AVAILABLE )

   find_package(MUMPS)

   if ( NOT MUMPS_FOUND )
     message(ERROR "COMISO configured with mumps but mumps not available")
   endif()

   list (APPEND  COMISO_OPT_DEPS "MUMPS")

  endif()

147
  STRING(REGEX MATCH "\#define COMISO_TAO_AVAILABLE 1" COMISO_TAO_BUILD_TIME_AVAILABLE ${CURRENT_COMISO_CONFIG} )
148

149
  if ( COMISO_TAO_BUILD_TIME_AVAILABLE )
150

151
   find_package(TAO)
152

153
154
155
   if ( NOT TAO_FOUND )
     message(ERROR "COMISO configured with tao but tao not available")
   endif()
156

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
170
171
172
  
  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()

   list (APPEND  COMISO_OPT_DEPS "Taucs")

  endif()
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()


189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
  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()
  
  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()
216
  
217
  STRING(REGEX MATCH "\#define COMISO_EIGEN3_AVAILABLE 1" COMISO_EIGEN3_BUILD_TIME_AVAILABLE ${CURRENT_COMISO_CONFIG} )
218

219
  if ( COMISO_EIGEN3_BUILD_TIME_AVAILABLE )
220
                                                                          
221
   find_package(EIGEN3)
222
                                                                          
223
224
   if ( NOT EIGEN3_FOUND )
     message(ERROR "COMISO configured with EIGEN3 but EIGEN3 not available")
225
226
   endif()
                                                                          
227
   list (APPEND  COMISO_OPT_DEPS "EIGEN3")
228
229
                                                                          
  endif()
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 )
246

David Bommes's avatar
David Bommes committed
247
  include(FindPackageHandleStandardArgs)
248
  SET(COMISO_FOUND TRUE)
Jan Möbius's avatar
Jan Möbius committed
249
  SET( COMISO_LIBRARY_DIR "${CMAKE_BINARY_DIR}/Build/${ACG_PROJECT_LIBDIR}" )
250
  SET( COMISO_LIBRARY "CoMISo")
David Bommes's avatar
David Bommes committed
251
#  SET( COMISO_DEPS "GMM;BLAS;SUITESPARSE" )
252
253
254
  SET( COMISO_DEPS "GMM")
#  SET( COMISO_OPT_DEPS ${COMISO_OPT_DEPS} CACHE STRING "Comiso optional dependecies")
#  mark_as_advanced(COMISO_DEPS COMISO_OPT_DEPS)
255
256
257
258
  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)
259
260
  SET( COMISO_FOUND FALSE )
  SET( COMISO_LIBRARY_DIR )
261
ENDIF (COMISO_INCLUDE_DIR AND COMISO_CONFIG_INCLUDE_DIR)
262