CMakeLists.txt 8.69 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
cmake_minimum_required (VERSION 2.6)

project(CoMISo)

# add our macro directory to cmake search path
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake)

include (ACGCommon)

acg_qt4 ()
# change to 0 if QT should not be used
set( WANT_COMISO_QT 1 )
if( QT4_FOUND)
  #message( WARNING " QT4 FOUND" )
  if( WANT_COMISO_QT )
    add_definitions (-DQT4_FOUND)
  #  message( WARNING " USING QT4" )
  endif ()
endif ()

acg_get_version ()

include (ACGOutput)

25
set(COMISO_INCLUDE_DIRECTORIES "")
26
27
set(COMISO_LINK_DIRECTORIES "")
set(COMISO_LINK_LIBRARIES "")
28

29
find_package (GMM)
David Bommes's avatar
David Bommes committed
30
31
if (GMM_FOUND)
  set (COMISO_GMM_CONFIG_FILE_SETTINGS "#define COMISO_GMM_AVAILABLE 1" )
32
  list( APPEND COMISO_INCLUDE_DIRECTORIES ${GMM_INCLUDE_DIR} )
David Bommes's avatar
David Bommes committed
33
34
else()
  set (COMISO_GMM_CONFIG_FILE_SETTINGS "#define COMISO_GMM_AVAILABLE 0" )
35
36
37
  message (FATAL_ERROR "GMM not found!")
endif ()

38
39
40
# We require cgal with its blas on windows
if (WIN32)
  find_package(CGAL)
41
42
43
44
45
  if (CGAL_FOUND)
    list( APPEND COMISO_INCLUDE_DIRECTORIES ${CGAL_INCLUDE_DIR} )
    list( APPEND COMISO_LINK_DIRECTORIES   ${CGAL_LIBRARY_DIR} )
    list( APPEND COMISO_LINK_LIBRARIES  ${CGAL_LIBRARIES} )
  endif()
46
47
endif()

48
find_package (BLAS)
David Bommes's avatar
David Bommes committed
49
50
if (BLAS_FOUND )
  set (COMISO_BLAS_CONFIG_FILE_SETTINGS "#define COMISO_BLAS_AVAILABLE 1" )
51
52
53
54
  
  list( APPEND COMISO_INCLUDE_DIRECTORIES ${BLAS_INCLUDE_DIRS} )
  list( APPEND COMISO_LINK_DIRECTORIES   ${BLAS_LIBRARY_DIRS} )
  list( APPEND COMISO_LINK_LIBRARIES  ${BLAS_LIBRARIES} )
David Bommes's avatar
David Bommes committed
55
56
else()
  set (COMISO_BLAS_CONFIG_FILE_SETTINGS "#define COMISO_BLAS_AVAILABLE 0" )
57
58
59
60
  message (FATAL_ERROR "BLAS not found!")
endif ()

find_package (SUITESPARSE)
61
62
if (SUITESPARSE_FOUND )
  set (COMISO_SUITESPARSE_CONFIG_FILE_SETTINGS "#define COMISO_SUITESPARSE_AVAILABLE 1" )
63
  
David Bommes's avatar
David Bommes committed
64
  list( APPEND COMISO_INCLUDE_DIRECTORIES ${SUITESPARSE_INCLUDE_DIRS} )
65
66
  list( APPEND COMISO_LINK_DIRECTORIES   ${SUITESPARSE_LIBRARY_DIRS} )
  list( APPEND COMISO_LINK_LIBRARIES  ${SUITESPARSE_LIBRARIES} )
67
68
69
70
71
72
73
74
else ()
  message (STATUS "SUITESPARSE not found!")
  set (COMISO_SUITESPARSE_CONFIG_FILE_SETTINGS "#define COMISO_SUITESPARSE_AVAILABLE 0" )
endif ()

find_package (MPI)
if (MPI_FOUND )
  set (COMISO_MPI_CONFIG_FILE_SETTINGS "#define COMISO_MPI_AVAILABLE 1" )
David Bommes's avatar
David Bommes committed
75
  list( APPEND COMISO_INCLUDE_DIRECTORIES ${MPI_INCLUDE_PATH} )
76
  list( APPEND COMISO_LINK_LIBRARIES  ${MPI_CXX_LIBRARIES} )
77
78
79
80
else ()
  message (STATUS "MPI not found!")
  set (COMISO_MPI_CONFIG_FILE_SETTINGS "#define COMISO_MPI_AVAILABLE 0" )
endif ()
81
82

find_package (PETSC)
83
84
if (PETSC_FOUND AND MPI_FOUND)
  set (COMISO_PETSC_CONFIG_FILE_SETTINGS "#define COMISO_PETSC_AVAILABLE 1" )
David Bommes's avatar
David Bommes committed
85
  list( APPEND COMISO_INCLUDE_DIRECTORIES ${PETSC_INCLUDE_DIRS} )
86
87
  list( APPEND COMISO_LINK_DIRECTORIES ${PETSC_LIBRARY_DIR} )
  list( APPEND COMISO_LINK_LIBRARIES  ${PETSC_LIBRARY} )
88
else ()
David Bommes's avatar
David Bommes committed
89
  message (STATUS "PETSC or dependency not found!")
90
91
  set (COMISO_PETSC_CONFIG_FILE_SETTINGS "#define COMISO_PETSC_AVAILABLE 0" )
endif ()
92

93

94
95
96
find_package (TAO)
if (TAO_FOUND AND PETSC_FOUND AND MPI_FOUND)
  set (COMISO_TAO_CONFIG_FILE_SETTINGS "#define COMISO_TAO_AVAILABLE 1" )
David Bommes's avatar
David Bommes committed
97
  list( APPEND COMISO_INCLUDE_DIRECTORIES ${TAO_INCLUDE_DIRS} )
98
99
  list( APPEND COMISO_LINK_DIRECTORIES ${TAO_LIBRARY_DIR} )
  list( APPEND COMISO_LINK_LIBRARIES  ${TAO_LIBRARY} )
100
else ()
David Bommes's avatar
David Bommes committed
101
  message (STATUS "TAO or dependency not found!")
102
  set (COMISO_TAO_CONFIG_FILE_SETTINGS "#define COMISO_TAO_AVAILABLE 0" )
103
104
endif ()

David Bommes's avatar
David Bommes committed
105
106
107
108
find_package (MUMPS)
if (MUMPS_FOUND )
  set (COMISO_MUMPS_CONFIG_FILE_SETTINGS "#define COMISO_MUMPS_AVAILABLE 1" )
  list( APPEND COMISO_INCLUDE_DIRECTORIES ${MUMPS_INCLUDE_DIR} )
109
  list( APPEND COMISO_LINK_LIBRARIES ${MUMPS_LIBRARY} )
David Bommes's avatar
David Bommes committed
110
111
112
113
114
else ()
  message (STATUS "MUMPS not found!")
  set (COMISO_MUMPS_CONFIG_FILE_SETTINGS "#define COMISO_MUMPS_AVAILABLE 0" )
endif ()

115
find_package (IPOPT)
116
if (IPOPT_FOUND)
117
  set (COMISO_IPOPT_CONFIG_FILE_SETTINGS "#define COMISO_IPOPT_AVAILABLE 1" )
118
  list( APPEND COMISO_INCLUDE_DIRECTORIES ${IPOPT_INCLUDE_DIR} )
119
120
  list( APPEND COMISO_LINK_DIRECTORIES ${IPOPT_LIBRARY_DIR} )
  list( APPEND COMISO_LINK_LIBRARIES ${IPOPT_LIBRARY} )
Jan Möbius's avatar
Typo    
Jan Möbius committed
121
  if ( HSL_LIBRARY_DIR )
Jan Möbius's avatar
Jan Möbius committed
122
123
124
125
	set (COMISO_HSL_CONFIG_FILE_SETTINGS "#define COMISO_HSL_AVAILABLE 1" )
  else ()
	set (COMISO_HSL_CONFIG_FILE_SETTINGS "#define COMISO_HSL_AVAILABLE 0" )
  endif()
126
else ()
David Bommes's avatar
David Bommes committed
127
  message (STATUS "IPOPT or dependency not found!")
128
  set (COMISO_IPOPT_CONFIG_FILE_SETTINGS "#define COMISO_IPOPT_AVAILABLE 0" )
Jan Möbius's avatar
Jan Möbius committed
129
  set (COMISO_HSL_CONFIG_FILE_SETTINGS "#define COMISO_HSL_AVAILABLE 0" )
130
131
endif ()

David Bommes's avatar
David Bommes committed
132
133
134
135
136
137
138
139
140
find_package (Eigen3)
if (Eigen3_FOUND )
  set (COMISO_Eigen3_CONFIG_FILE_SETTINGS "#define COMISO_Eigen3_AVAILABLE 1" )
  list( APPEND COMISO_INCLUDE_DIRECTORIES ${Eigen3_INCLUDE_DIR} )
else ()
  message (STATUS "Eigen3 not found!")
  set (COMISO_Eigen3_CONFIG_FILE_SETTINGS "#define COMISO_Eigen3_AVAILABLE 0" )
endif ()

David Bommes's avatar
David Bommes committed
141
142
143
144
find_package (Taucs)
if (TAUCS_FOUND )
  set (COMISO_TAUCS_CONFIG_FILE_SETTINGS "#define COMISO_TAUCS_AVAILABLE 1" )
  list( APPEND COMISO_INCLUDE_DIRECTORIES ${TAUCS_INCLUDE_DIR} )
145
146
147
148
  list( APPEND COMISO_INCLUDE_DIRECTORIES ${LAPACK_INCLUDE_DIR} )
  list( APPEND COMISO_LINK_DIRECTORIES    ${LAPACK_LIBRARY_DIR} )
  list( APPEND COMISO_LINK_LIBRARIES  ${TAUCS_LIBRARY} )
  list( APPEND COMISO_LINK_LIBRARIES  ${LAPACK_LIBRARIES} )
David Bommes's avatar
David Bommes committed
149
150
151
152
153
else ()
  message (STATUS "TAUCS not found!")
  set (COMISO_TAUCS_CONFIG_FILE_SETTINGS "#define COMISO_TAUCS_AVAILABLE 0" )
endif ()

David Bommes's avatar
David Bommes committed
154
155
156
157
158
159
160
161
162
163
164
find_package (GUROBI)
if (GUROBI_FOUND )
  set (COMISO_GUROBI_CONFIG_FILE_SETTINGS "#define COMISO_GUROBI_AVAILABLE 1" )
  list( APPEND COMISO_INCLUDE_DIRECTORIES ${GUROBI_INCLUDE_DIR} )
  list( APPEND COMISO_LINK_DIRECTORIES    ${GUROBI_LIBRARY_DIR} )
  list( APPEND COMISO_LINK_LIBRARIES  ${GUROBI_LIBRARY} )
else ()
  message (STATUS "GUROBI not found!")
  set (COMISO_GUROBI_CONFIG_FILE_SETTINGS "#define COMISO_GUROBI_AVAILABLE 0" )
endif ()

165
166
167
168
include_directories (
  ..
  ${CMAKE_CURRENT_SOURCE_DIR}
  ${CMAKE_CURRENT_BINARY_DIR}
169
  ${COMISO_INCLUDE_DIRECTORIES}
170
171
172
173
174
175
176
177
178
)

# generate dllexport macros on windows
if (WIN32)
  add_definitions(-DCOMISODLL)
endif ()


link_directories (
179
  ${COMISO_LINK_DIRECTORIES}
180
181
182
183
184
)

# source code directories
set (directories 
  .
185
186
  Solver
  NSolver
187
188
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
216
217
218
219
220
221
222
223
224
225
  Config
  Utils
  QtWidgets
)

# generate dllexport macros on windows
if (WIN32)
  add_definitions(-DCOMISODLL)
endif ()

if (WIN32)
  add_definitions(
      -D_USE_MATH_DEFINES -DNOMINMAX
  )
endif ()

# collect all header,source and ui files
acg_append_files (headers "*.hh" ${directories})
acg_append_files (sources "*.cc" ${directories})
acg_append_files (ui "*.ui" ${directories})


macro (of_list_filter _list)
  if (WIN32)
   foreach (_element ${${_list}})
     if (_element MATCHES "gnuplot_i\\.(cc|hh)$")
       list (REMOVE_ITEM ${_list} ${_element})
     endif ()
   endforeach ()
  endif ()
endmacro ()

of_list_filter  ( headers )
of_list_filter  ( sources )


# remove template cc files from source file list
acg_drop_templates (sources)

Henrik Zimmer's avatar
Henrik Zimmer committed
226
if( QT4_FOUND)
227
228
229
# genereate uic and moc targets
acg_qt4_autouic (uic_targets ${ui})
acg_qt4_automoc (moc_targets ${headers})
Henrik Zimmer's avatar
Henrik Zimmer committed
230
endif()
231
232
233
234
235
acg_add_library (CoMISo SHARED ${uic_targets} ${sources} ${headers} ${moc_targets})

if (NOT APPLE)
	target_link_libraries (CoMISo 
	  ${QT_LIBRARIES}
236
	  ${COMISO_LINK_LIBRARIES}
237
238
239
240
	)
else(NOT APPLE)
	target_link_libraries (CoMISo
	  ${QT_LIBRARIES}
241
	  ${COMISO_LINK_LIBRARIES}
242
243
244
245
246
247
	)
endif(NOT APPLE)

# display results
acg_print_configure_header (COMISO "CoMISo")

248
# write config file
Jan Möbius's avatar
Jan Möbius committed
249
250
configure_file ("${CMAKE_CURRENT_SOURCE_DIR}/Config/config.hh.in"
     "${CMAKE_CURRENT_SOURCE_DIR}/Config/config.hh" @ONLY IMMEDIATE)
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
     
     
     
#######################################################################
# Configure the examples last to be sure, that all configure files
# of the library are already there
#######################################################################
if( EXISTS "${CMAKE_SOURCE_DIR}/Examples/factored_solver/CMakeLists.txt" )
	add_subdirectory (Examples/factored_solver)
endif()

if( EXISTS "${CMAKE_SOURCE_DIR}/Examples/quadratic_solver/CMakeLists.txt" )
	add_subdirectory (Examples/quadratic_solver)
endif()
if( EXISTS "${CMAKE_SOURCE_DIR}/Examples/test2/CMakeLists.txt" )
	add_subdirectory (Examples/test2)
endif()
if( EXISTS "${CMAKE_SOURCE_DIR}/Examples/small_quadratic_example/CMakeLists.txt" )
	add_subdirectory (Examples/small_quadratic_example)
endif()
if( EXISTS "${CMAKE_SOURCE_DIR}/Examples/small_factored_example/CMakeLists.txt" )
	add_subdirectory (Examples/small_factored_example)
endif()
if( EXISTS "${CMAKE_SOURCE_DIR}/Examples/super_sparse_matrix/CMakeLists.txt" )
	add_subdirectory (Examples/super_sparse_matrix)
endif()
Jan Möbius's avatar
Jan Möbius committed
277

Jan Möbius's avatar
Newline    
Jan Möbius committed
278