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

9
10
11
12
13

IF (COMISO_INCLUDE_DIR)
  # Already in cache, be silent
  SET(COMISO_FIND_QUIETLY TRUE)
ENDIF (COMISO_INCLUDE_DIR)
David Bommes's avatar
David Bommes committed
14

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

David Bommes's avatar
David Bommes committed
22
          
23
# Find CoMISo config file
Jan Möbius's avatar
Jan Möbius committed
24
FIND_PATH( COMISO_INCLUDE_DIR CoMISo/Config/config.hh
David Bommes's avatar
David Bommes committed
25
26
           PATHS "${CMAKE_SOURCE_DIR}"
                 "${CMAKE_SOURCE_DIR}/libs/" 
27
                 "${_libdirs}"
David Bommes's avatar
David Bommes committed
28
                 "${CMAKE_SOURCE_DIR}/../" )
29

30
if ( COMISO_INCLUDE_DIR )
31

32
  FILE(READ ${COMISO_INCLUDE_DIR}/CoMISo/Config/config.hh CURRENT_COMISO_CONFIG)
33

34
  set(COMISO_OPT_DEPS "")
35
36


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

39
  if ( COMISO_MPI_BUILD_TIME_AVAILABLE )
40

41
   find_package(MPI)
42

43
44
45
   if ( NOT MPI_FOUND )
     message(ERROR "COMISO configured with mpi but mpi not available")
   endif()
46

47
   list (APPEND  COMISO_OPT_DEPS "MPI")
48

49
  endif()
50

David Bommes's avatar
David Bommes committed
51
52
53
54
  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
55
   find_package( Boost 1.42.0 COMPONENTS system filesystem regex QUIET)
David Bommes's avatar
David Bommes committed
56
57
58
59
60
61
62
63
64
65

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

   list (APPEND  COMISO_OPT_DEPS "Boost")

  endif()


66
67
68
69
70
71
72
73
74
75
76
77
78
79
  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()
  
80
  STRING(REGEX MATCH "\#define COMISO_PETSC_AVAILABLE 1" COMISO_PETSC_BUILD_TIME_AVAILABLE ${CURRENT_COMISO_CONFIG} )
81

82
  if ( COMISO_PETSC_BUILD_TIME_AVAILABLE )
83

84
   find_package(PETSC)
85

86
87
88
   if ( NOT PETSC_FOUND )
     message(ERROR "COMISO configured with petsc but petsc not available")
   endif()
89

90
   list (APPEND  COMISO_OPT_DEPS "PETSC")
91

92
  endif()
93

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

96
  if ( COMISO_IPOPT_BUILD_TIME_AVAILABLE )
97

98
   find_package(IPOPT)
99

100
101
102
   if ( NOT IPOPT_FOUND )
     message(ERROR "COMISO configured with ipopt but ipopt not available")
   endif()
103

104
   list (APPEND  COMISO_OPT_DEPS "IPOPT")
105

106
  endif()
107

108
109
110
111
112
113
114
115
116
117
118
119
120
121
  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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
  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()

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

138
  if ( COMISO_TAO_BUILD_TIME_AVAILABLE )
139

140
   find_package(TAO)
141

142
143
144
   if ( NOT TAO_FOUND )
     message(ERROR "COMISO configured with tao but tao not available")
   endif()
145

146
147
   list (APPEND  COMISO_OPT_DEPS "TAO")
  endif()
David Bommes's avatar
David Bommes committed
148
149
150
151
152
153
154
155
156
157
158
159
160
161
  
  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()
162

David Bommes's avatar
David Bommes committed
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
  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()


178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
  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()
205
  
206
  STRING(REGEX MATCH "\#define COMISO_EIGEN3_AVAILABLE 1" COMISO_EIGEN3_BUILD_TIME_AVAILABLE ${CURRENT_COMISO_CONFIG} )
207

208
  if ( COMISO_EIGEN3_BUILD_TIME_AVAILABLE )
209
                                                                          
210
   find_package(EIGEN3)
211
                                                                          
212
213
   if ( NOT EIGEN3_FOUND )
     message(ERROR "COMISO configured with EIGEN3 but EIGEN3 not available")
214
215
   endif()
                                                                          
216
   list (APPEND  COMISO_OPT_DEPS "EIGEN3")
217
218
                                                                          
  endif()
219

David Bommes's avatar
David Bommes committed
220
221
222
223
224
225
226
227
228
229
230
231
232
233
  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()

234
235
236
  add_definitions (-DCOMISODLL -DUSECOMISO )

endif(COMISO_INCLUDE_DIR)
237
238

IF (COMISO_INCLUDE_DIR)
David Bommes's avatar
David Bommes committed
239
  include(FindPackageHandleStandardArgs)
240
  SET(COMISO_FOUND TRUE)
Jan Möbius's avatar
Jan Möbius committed
241
  SET( COMISO_LIBRARY_DIR "${CMAKE_BINARY_DIR}/Build/${ACG_PROJECT_LIBDIR}" )
242
  SET( COMISO_LIBRARY "CoMISo")
David Bommes's avatar
David Bommes committed
243
#  SET( COMISO_DEPS "GMM;BLAS;SUITESPARSE" )
244
245
246
  SET( COMISO_DEPS "GMM")
#  SET( COMISO_OPT_DEPS ${COMISO_OPT_DEPS} CACHE STRING "Comiso optional dependecies")
#  mark_as_advanced(COMISO_DEPS COMISO_OPT_DEPS)
247
248
249
250
251
ELSE (COMISO_INCLUDE_DIR)
  SET( COMISO_FOUND FALSE )
  SET( COMISO_LIBRARY_DIR )
ENDIF (COMISO_INCLUDE_DIR)