FindCoMISo.cmake 6.16 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
# Find CoMISo config file
Jan Möbius's avatar
Jan Möbius committed
17
FIND_PATH( COMISO_INCLUDE_DIR CoMISo/Config/config.hh
David Bommes's avatar
David Bommes committed
18
19
20
           PATHS "${CMAKE_SOURCE_DIR}"
                 "${CMAKE_SOURCE_DIR}/libs/" 
                 "${CMAKE_SOURCE_DIR}/../" )
21

22
if ( COMISO_INCLUDE_DIR )
23

24
  FILE(READ ${COMISO_INCLUDE_DIR}/CoMISo/Config/config.hh CURRENT_COMISO_CONFIG)
25

26
  set(COMISO_OPT_DEPS "")
27
28


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

31
  if ( COMISO_MPI_BUILD_TIME_AVAILABLE )
32

33
   find_package(MPI)
34

35
36
37
   if ( NOT MPI_FOUND )
     message(ERROR "COMISO configured with mpi but mpi not available")
   endif()
38

39
   list (APPEND  COMISO_OPT_DEPS "MPI")
40

41
  endif()
42

David Bommes's avatar
David Bommes committed
43
44
45
46
  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
47
   find_package( Boost 1.42.0 COMPONENTS system filesystem regex QUIET)
David Bommes's avatar
David Bommes committed
48
49
50
51
52
53
54
55
56
57

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

   list (APPEND  COMISO_OPT_DEPS "Boost")

  endif()


58
59
60
61
62
63
64
65
66
67
68
69
70
71
  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()
  
72
  STRING(REGEX MATCH "\#define COMISO_PETSC_AVAILABLE 1" COMISO_PETSC_BUILD_TIME_AVAILABLE ${CURRENT_COMISO_CONFIG} )
73

74
  if ( COMISO_PETSC_BUILD_TIME_AVAILABLE )
75

76
   find_package(PETSC)
77

78
79
80
   if ( NOT PETSC_FOUND )
     message(ERROR "COMISO configured with petsc but petsc not available")
   endif()
81

82
   list (APPEND  COMISO_OPT_DEPS "PETSC")
83

84
  endif()
85

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

88
  if ( COMISO_IPOPT_BUILD_TIME_AVAILABLE )
89

90
   find_package(IPOPT)
91

92
93
94
   if ( NOT IPOPT_FOUND )
     message(ERROR "COMISO configured with ipopt but ipopt not available")
   endif()
95

96
   list (APPEND  COMISO_OPT_DEPS "IPOPT")
97

98
  endif()
99

100
101
102
103
104
105
106
107
108
109
110
111
112
113
  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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
  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()

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

130
  if ( COMISO_TAO_BUILD_TIME_AVAILABLE )
131

132
   find_package(TAO)
133

134
135
136
   if ( NOT TAO_FOUND )
     message(ERROR "COMISO configured with tao but tao not available")
   endif()
137

138
139
   list (APPEND  COMISO_OPT_DEPS "TAO")
  endif()
David Bommes's avatar
David Bommes committed
140
141
142
143
144
145
146
147
148
149
150
151
152
153
  
  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()
154

David Bommes's avatar
David Bommes committed
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
  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()


170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
  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()
197
  
198
  STRING(REGEX MATCH "\#define COMISO_EIGEN3_AVAILABLE 1" COMISO_EIGEN3_BUILD_TIME_AVAILABLE ${CURRENT_COMISO_CONFIG} )
199

200
  if ( COMISO_EIGEN3_BUILD_TIME_AVAILABLE )
201
                                                                          
202
   find_package(EIGEN3)
203
                                                                          
204
205
   if ( NOT EIGEN3_FOUND )
     message(ERROR "COMISO configured with EIGEN3 but EIGEN3 not available")
206
207
   endif()
                                                                          
208
   list (APPEND  COMISO_OPT_DEPS "EIGEN3")
209
210
                                                                          
  endif()
211

212
213
214
  add_definitions (-DCOMISODLL -DUSECOMISO )

endif(COMISO_INCLUDE_DIR)
215
216

IF (COMISO_INCLUDE_DIR)
David Bommes's avatar
David Bommes committed
217
  include(FindPackageHandleStandardArgs)
218
  SET(COMISO_FOUND TRUE)
Jan Möbius's avatar
Jan Möbius committed
219
  SET( COMISO_LIBRARY_DIR "${CMAKE_BINARY_DIR}/Build/${ACG_PROJECT_LIBDIR}" )
220
  SET( COMISO_LIBRARY "CoMISo")
David Bommes's avatar
David Bommes committed
221
#  SET( COMISO_DEPS "GMM;BLAS;SUITESPARSE" )
222
223
224
  SET( COMISO_DEPS "GMM")
#  SET( COMISO_OPT_DEPS ${COMISO_OPT_DEPS} CACHE STRING "Comiso optional dependecies")
#  mark_as_advanced(COMISO_DEPS COMISO_OPT_DEPS)
225
226
227
228
229
ELSE (COMISO_INCLUDE_DIR)
  SET( COMISO_FOUND FALSE )
  SET( COMISO_LIBRARY_DIR )
ENDIF (COMISO_INCLUDE_DIR)