CMakeLists.txt 13.9 KB
Newer Older
1 2 3 4 5 6 7 8 9
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)

10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36

# Flag to enable or disable QT widgets in CoMISo
set( WANT_COMISO_QT ON CACHE BOOL "Enable Qt support in CoMISo" )


if( WANT_COMISO_QT )

  # try to use QT5 if possible otherwise stick to QT4
  set (FORCE_QT4 ON CACHE BOOL "Use Qt4 even if Qt5 was found")

  # Qt5 or Qt4?
  if (NOT FORCE_QT4)
    acg_qt5 ()
  else()
    set (QT5_FOUND false)
  endif()

  # Fallback to qt4 if not found or forced
  if (NOT QT5_FOUND)
    message(STATUS "Using QT4 for CoMISo")
    acg_qt4 (4.7.0)
  else ()
    message(STATUS "Using QT5 for CoMISo")
  endif ()

  # QT4 settings in CoMISo
  if( QT4_FOUND)
37
    add_definitions (-DQT4_FOUND)
38 39 40
    set (COMISO_QT4_CONFIG_FILE_SETTINGS "#define COMISO_QT4_AVAILABLE 1" )
  else()
    set (COMISO_QT4_CONFIG_FILE_SETTINGS "#define COMISO_QT4_AVAILABLE 0" )
41
  endif ()
42 43 44 45 46 47 48 49 50 51

  # QT5 settings in CoMISo
  if( QT5_FOUND)
    add_definitions (-DQT5_FOUND)
    set (COMISO_QT5_CONFIG_FILE_SETTINGS "#define COMISO_QT5_AVAILABLE 1" )
  else()
    set (COMISO_QT5_CONFIG_FILE_SETTINGS "#define COMISO_QT5_AVAILABLE 0" )
  endif ()
  
endif( WANT_COMISO_QT )
52 53 54 55 56

acg_get_version ()

include (ACGOutput)

57
set(COMISO_INCLUDE_DIRECTORIES "")
58 59
set(COMISO_LINK_DIRECTORIES "")
set(COMISO_LINK_LIBRARIES "")
60

David Bommes's avatar
David Bommes committed
61 62 63 64 65 66 67 68 69 70 71 72
FIND_PACKAGE( Boost 1.42.0 COMPONENTS system filesystem regex )
if(Boost_FOUND)
  set (COMISO_BOOST_CONFIG_FILE_SETTINGS "#define COMISO_BOOST_AVAILABLE 1" )
  list( APPEND COMISO_INCLUDE_DIRECTORIES ${Boost_INCLUDE_DIRS} )
#  list( APPEND COMISO_LINK_DIRECTORIES    ${Boost_LIBRARY_DIR} )
  list( APPEND COMISO_LINK_LIBRARIES  ${Boost_LIBRARIES} )
else()
  set (COMISO_BOOST_CONFIG_FILE_SETTINGS "#define COMISO_BOOST_AVAILABLE 0" )
  message (STATUS "Boost not found!")
endif ()


73
find_package (GMM)
74 75
if (GMM_FOUND)
  set (COMISO_GMM_CONFIG_FILE_SETTINGS "#define COMISO_GMM_AVAILABLE 1" )
76
  list( APPEND COMISO_INCLUDE_DIRECTORIES ${GMM_INCLUDE_DIR} )
77 78
else()
  set (COMISO_GMM_CONFIG_FILE_SETTINGS "#define COMISO_GMM_AVAILABLE 0" )
79 80 81
  message (FATAL_ERROR "GMM not found!")
endif ()

82 83
# We require cgal with its blas on windows
  find_package(CGAL)
David Bommes's avatar
David Bommes committed
84 85 86 87 88 89 90 91
if (CGAL_FOUND)
  set (COMISO_CGAL_CONFIG_FILE_SETTINGS "#define COMISO_CGAL_AVAILABLE 1" )
  list( APPEND COMISO_INCLUDE_DIRECTORIES ${CGAL_INCLUDE_DIR} )
  list( APPEND COMISO_LINK_DIRECTORIES   ${CGAL_LIBRARY_DIR} )
  list( APPEND COMISO_LINK_LIBRARIES  ${CGAL_LIBRARIES} )
else()
  set (COMISO_CGAL_CONFIG_FILE_SETTINGS "#define COMISO_CGAL_AVAILABLE 0" )
  message (STATUS "CGAL not found!")
92 93
endif()

David Bommes's avatar
David Bommes committed
94

95
find_package (BLAS)
96 97
if (BLAS_FOUND )
  set (COMISO_BLAS_CONFIG_FILE_SETTINGS "#define COMISO_BLAS_AVAILABLE 1" )
98 99 100 101
  
  list( APPEND COMISO_INCLUDE_DIRECTORIES ${BLAS_INCLUDE_DIRS} )
  list( APPEND COMISO_LINK_DIRECTORIES   ${BLAS_LIBRARY_DIRS} )
  list( APPEND COMISO_LINK_LIBRARIES  ${BLAS_LIBRARIES} )
102 103
else()
  set (COMISO_BLAS_CONFIG_FILE_SETTINGS "#define COMISO_BLAS_AVAILABLE 0" )
David Bommes's avatar
David Bommes committed
104
  message (STATUS "BLAS not found!")
105 106
endif ()

Mike Kremer's avatar
Mike Kremer committed
107 108 109
find_package (ADOLC)
if (ADOLC_FOUND)
  set (COMISO_ADOLC_CONFIG_FILE_SETTINGS "#define COMISO_ADOLC_AVAILABLE 1" )
110 111
  list( APPEND COMISO_INCLUDE_DIRECTORIES ${ADOLC_INCLUDE_DIR} )
  list( APPEND COMISO_LINK_DIRECTORIES   ${ADOLC_LIBRARY_DIR} )
Mike Kremer's avatar
Mike Kremer committed
112 113 114 115 116 117
  list( APPEND COMISO_LINK_LIBRARIES  ${ADOLC_LIBRARIES} )
else ()
  set (COMISO_ADOLC_CONFIG_FILE_SETTINGS "#define COMISO_ADOLC_AVAILABLE 0" )
  message (STATUS "ADOLC not found!")
endif ()

118
find_package (SUITESPARSE)
119 120
if (SUITESPARSE_FOUND )
  set (COMISO_SUITESPARSE_CONFIG_FILE_SETTINGS "#define COMISO_SUITESPARSE_AVAILABLE 1" )
121
  
David Bommes's avatar
David Bommes committed
122
  list( APPEND COMISO_INCLUDE_DIRECTORIES ${SUITESPARSE_INCLUDE_DIRS} )
123 124
  list( APPEND COMISO_LINK_DIRECTORIES   ${SUITESPARSE_LIBRARY_DIRS} )
  list( APPEND COMISO_LINK_LIBRARIES  ${SUITESPARSE_LIBRARIES} )
125 126 127 128
else ()
  message (STATUS "SUITESPARSE not found!")
  set (COMISO_SUITESPARSE_CONFIG_FILE_SETTINGS "#define COMISO_SUITESPARSE_AVAILABLE 0" )
endif ()
David Bommes's avatar
David Bommes committed
129 130 131 132 133 134 135
# special handling, since spqr is incorrect in several distributions
if(SUITESPARSE_SPQR_VALID)
  set (COMISO_SUITESPARSE_SPQR_CONFIG_FILE_SETTINGS "#define COMISO_SUITESPARSE_SPQR_AVAILABLE 1" )
else()
  message (STATUS "SUITESPARSE SPQR seems to be invalid!")
  set (COMISO_SUITESPARSE_SPQR_CONFIG_FILE_SETTINGS "#define COMISO_SUITESPARSE_SPQR_AVAILABLE 0" )
endif()
136 137 138 139

find_package (MPI)
if (MPI_FOUND )
  set (COMISO_MPI_CONFIG_FILE_SETTINGS "#define COMISO_MPI_AVAILABLE 1" )
David Bommes's avatar
David Bommes committed
140
  list( APPEND COMISO_INCLUDE_DIRECTORIES ${MPI_INCLUDE_PATH} )
141
  list( APPEND COMISO_LINK_LIBRARIES  ${MPI_CXX_LIBRARIES} )
142 143 144 145
else ()
  message (STATUS "MPI not found!")
  set (COMISO_MPI_CONFIG_FILE_SETTINGS "#define COMISO_MPI_AVAILABLE 0" )
endif ()
146 147

find_package (PETSC)
148 149
if (PETSC_FOUND AND MPI_FOUND)
  set (COMISO_PETSC_CONFIG_FILE_SETTINGS "#define COMISO_PETSC_AVAILABLE 1" )
David Bommes's avatar
David Bommes committed
150
  list( APPEND COMISO_INCLUDE_DIRECTORIES ${PETSC_INCLUDE_DIRS} )
151
  list( APPEND COMISO_LINK_LIBRARIES  ${PETSC_LIBRARY} )
152
else ()
153
  message (STATUS "PETSC or MPI not found!")
154 155
  set (COMISO_PETSC_CONFIG_FILE_SETTINGS "#define COMISO_PETSC_AVAILABLE 0" )
endif ()
156

157

158 159 160
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
161
  list( APPEND COMISO_INCLUDE_DIRECTORIES ${TAO_INCLUDE_DIRS} )
162 163
  list( APPEND COMISO_LINK_DIRECTORIES ${TAO_LIBRARY_DIR} )
  list( APPEND COMISO_LINK_LIBRARIES  ${TAO_LIBRARY} )
164
else ()
165
  message (STATUS "TAO or PETSC or MPI not found!")
166
  set (COMISO_TAO_CONFIG_FILE_SETTINGS "#define COMISO_TAO_AVAILABLE 0" )
167 168
endif ()

David Bommes's avatar
David Bommes committed
169 170 171 172 173 174 175 176 177 178 179 180
find_package (METIS)
if (METIS_FOUND )
  set (COMISO_METIS_CONFIG_FILE_SETTINGS "#define COMISO_METIS_AVAILABLE 1" )
  
  list( APPEND COMISO_INCLUDE_DIRECTORIES ${METIS_INCLUDE_DIRS} )
  list( APPEND COMISO_LINK_DIRECTORIES   ${METIS_LIBRARY_DIRS} )
  list( APPEND COMISO_LINK_LIBRARIES  ${METIS_LIBRARIES} )
else()
  set (COMISO_METIS_CONFIG_FILE_SETTINGS "#define COMISO_METIS_AVAILABLE 0" )
  message (STATUS "METIS not found!")
endif ()

David Bommes's avatar
David Bommes committed
181 182 183 184
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} )
185
  list( APPEND COMISO_LINK_LIBRARIES ${MUMPS_LIBRARY} )
David Bommes's avatar
David Bommes committed
186 187 188 189 190
else ()
  message (STATUS "MUMPS not found!")
  set (COMISO_MUMPS_CONFIG_FILE_SETTINGS "#define COMISO_MUMPS_AVAILABLE 0" )
endif ()

191
find_package (IPOPT)
192
if (IPOPT_FOUND)
193
  set (COMISO_IPOPT_CONFIG_FILE_SETTINGS "#define COMISO_IPOPT_AVAILABLE 1" )
194
  list( APPEND COMISO_INCLUDE_DIRECTORIES ${IPOPT_INCLUDE_DIR} )
195 196
  list( APPEND COMISO_LINK_DIRECTORIES ${IPOPT_LIBRARY_DIR} )
  list( APPEND COMISO_LINK_LIBRARIES ${IPOPT_LIBRARY} )
David Bommes's avatar
David Bommes committed
197
  if ( IPOPT_HSL_LIBRARY_DIR )
Jan Möbius's avatar
Jan Möbius committed
198 199 200 201
	set (COMISO_HSL_CONFIG_FILE_SETTINGS "#define COMISO_HSL_AVAILABLE 1" )
  else ()
	set (COMISO_HSL_CONFIG_FILE_SETTINGS "#define COMISO_HSL_AVAILABLE 0" )
  endif()
202
else ()
David Bommes's avatar
David Bommes committed
203
  message (STATUS "IPOPT or dependency not found!")
204
  set (COMISO_IPOPT_CONFIG_FILE_SETTINGS "#define COMISO_IPOPT_AVAILABLE 0" )
Jan Möbius's avatar
Jan Möbius committed
205
  set (COMISO_HSL_CONFIG_FILE_SETTINGS "#define COMISO_HSL_AVAILABLE 0" )
206 207
endif ()

David Bommes's avatar
David Bommes committed
208 209 210 211
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} )
David Bommes's avatar
David Bommes committed
212
else ()
David Bommes's avatar
David Bommes committed
213 214
  message (STATUS "EIGEN3 not found!")
  set (COMISO_EIGEN3_CONFIG_FILE_SETTINGS "#define COMISO_EIGEN3_AVAILABLE 0" )
David Bommes's avatar
David Bommes committed
215 216
endif ()

David Bommes's avatar
David Bommes committed
217 218 219 220
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} )
221 222 223 224
  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
225 226 227 228 229
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
230 231 232
find_package (GUROBI)
if (GUROBI_FOUND )
  set (COMISO_GUROBI_CONFIG_FILE_SETTINGS "#define COMISO_GUROBI_AVAILABLE 1" )
David Bommes's avatar
David Bommes committed
233 234 235
  list( APPEND COMISO_INCLUDE_DIRECTORIES ${GUROBI_INCLUDE_DIRS} )
#  list( APPEND COMISO_LINK_DIRECTORIES    ${GUROBI_LIBRARY_DIR} )
  list( APPEND COMISO_LINK_LIBRARIES  ${GUROBI_LIBRARIES} )
David Bommes's avatar
David Bommes committed
236 237 238 239 240
else ()
  message (STATUS "GUROBI not found!")
  set (COMISO_GUROBI_CONFIG_FILE_SETTINGS "#define COMISO_GUROBI_AVAILABLE 0" )
endif ()

David Bommes's avatar
David Bommes committed
241 242 243 244 245 246 247 248 249 250 251
find_package (ARPACK)
if (ARPACK_FOUND )
  set (COMISO_ARPACK_CONFIG_FILE_SETTINGS "#define COMISO_ARPACK_AVAILABLE 1" )
  list( APPEND COMISO_INCLUDE_DIRECTORIES ${ARPACK_INCLUDE_DIR} )
#  list( APPEND COMISO_LINK_DIRECTORIES    ${ARPACK_LIBRARY_DIR} )
  list( APPEND COMISO_LINK_LIBRARIES  ${ARPACK_LIBRARY} )
else ()
  message (STATUS "ARPACK not found!")
  set (COMISO_ARPACK_CONFIG_FILE_SETTINGS "#define COMISO_ARPACK_AVAILABLE 0" )
endif ()

David Bommes's avatar
David Bommes committed
252 253 254 255 256
find_package (CPLEX)
if (CPLEX_FOUND )
  set (COMISO_CPLEX_CONFIG_FILE_SETTINGS "#define COMISO_CPLEX_AVAILABLE 1" )
  list( APPEND COMISO_INCLUDE_DIRECTORIES ${CPLEX_INCLUDE_DIRS} )
  list( APPEND COMISO_LINK_LIBRARIES  ${CPLEX_LIBRARIES} )
257 258 259
  
  #enable c++ support
   add_definitions(-DIL_STD)
David Bommes's avatar
David Bommes committed
260 261
else ()
  message (STATUS "CPLEX not found!")
262
  set (COMISO_CPLEX_CONFIG_FILE_SETTINGS "#define COMISO_CPLEX_AVAILABLE 0" )
David Bommes's avatar
David Bommes committed
263 264
endif ()

265 266 267
include_directories (
  ..
  ${CMAKE_CURRENT_SOURCE_DIR}
268
  ${CMAKE_CURRENT_SOURCE_DIR}/../
269
  ${CMAKE_CURRENT_BINARY_DIR}
270
  ${COMISO_INCLUDE_DIRECTORIES}
271 272 273 274 275
)

# generate dllexport macros on windows
if (WIN32)
  add_definitions(-DCOMISODLL)
Jan Möbius's avatar
Jan Möbius committed
276
  add_definitions(-D_SCL_SECURE_NO_DEPRECATE)
277 278 279 280
endif ()


link_directories (
281
  ${COMISO_LINK_DIRECTORIES}
282 283 284 285 286
)

# source code directories
set (directories 
  .
287 288
  Solver
  NSolver
David Bommes's avatar
David Bommes committed
289
  EigenSolver
290 291 292 293 294 295 296 297 298 299 300 301 302 303
  Config
  Utils
  QtWidgets
)

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})
304 305

if( QT4_FOUND)
306
acg_append_files (ui "*.ui" ${directories})
307
endif()
308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326


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
327
if( QT4_FOUND)
328 329 330
# genereate uic and moc targets
acg_qt4_autouic (uic_targets ${ui})
acg_qt4_automoc (moc_targets ${headers})
331
list (APPEND COMISO_LINK_LIBRARIES ${QT_LIBRARIES})
Henrik Zimmer's avatar
Henrik Zimmer committed
332
endif()
333

334 335 336 337
acg_add_library (CoMISo SHARED ${uic_targets} ${sources} ${headers} ${moc_targets})

if (NOT APPLE)
	target_link_libraries (CoMISo 
338
	  ${COMISO_LINK_LIBRARIES}
339 340 341
	)
else(NOT APPLE)
	target_link_libraries (CoMISo
342
	  ${COMISO_LINK_LIBRARIES}
343 344 345 346 347 348
	)
endif(NOT APPLE)

# display results
acg_print_configure_header (COMISO "CoMISo")

349
# write config file
Jan Möbius's avatar
Jan Möbius committed
350 351
configure_file ("${CMAKE_CURRENT_SOURCE_DIR}/Config/config.hh.in"
     "${CMAKE_CURRENT_SOURCE_DIR}/Config/config.hh" @ONLY IMMEDIATE)
352 353 354 355 356 357 358
     
     
     
#######################################################################
# Configure the examples last to be sure, that all configure files
# of the library are already there
#######################################################################
David Bommes's avatar
David Bommes committed
359

360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378
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()
David Bommes's avatar
David Bommes committed
379 380 381
if( EXISTS "${CMAKE_SOURCE_DIR}/Examples/eigen_solver/CMakeLists.txt" )
	add_subdirectory (Examples/eigen_solver)
endif()
David Bommes's avatar
David Bommes committed
382 383 384
if( EXISTS "${CMAKE_SOURCE_DIR}/Examples/small_nsolver/CMakeLists.txt" )
	add_subdirectory (Examples/small_nsolver)
endif()
385 386 387
if( EXISTS "${CMAKE_SOURCE_DIR}/Examples/small_eigenproblem/CMakeLists.txt" )
	add_subdirectory (Examples/small_eigenproblem)
endif()
388 389 390
if( EXISTS "${CMAKE_SOURCE_DIR}/Examples/small_miqp/CMakeLists.txt" )
	add_subdirectory (Examples/small_miqp)
endif()
David Bommes's avatar
David Bommes committed
391 392 393
if( EXISTS "${CMAKE_SOURCE_DIR}/Examples/small_nleast_squares/CMakeLists.txt" )
	add_subdirectory (Examples/small_nleast_squares)
endif()
394 395 396
if( EXISTS "${CMAKE_SOURCE_DIR}/Examples/small_sparseqr/CMakeLists.txt" )
	add_subdirectory (Examples/small_sparseqr)
endif()
397 398 399
if( EXISTS "${CMAKE_SOURCE_DIR}/Examples/small_quadratic_resolve_example/CMakeLists.txt" )
	add_subdirectory (Examples/small_quadratic_resolve_example)
endif()
400 401 402
if( EXISTS "${CMAKE_SOURCE_DIR}/Examples/small_cplex_soc/CMakeLists.txt" )
	add_subdirectory (Examples/small_cplex_soc)
endif()
David Bommes's avatar
David Bommes committed
403 404 405 406 407 408 409 410 411
if( EXISTS "${CMAKE_SOURCE_DIR}/Examples/small_adolc/CMakeLists.txt" )
	add_subdirectory (Examples/small_adolc)
endif()
if( EXISTS "${CMAKE_SOURCE_DIR}/Examples/vector1_adolc/CMakeLists.txt" )
	add_subdirectory (Examples/vector1_adolc)
endif()
if( EXISTS "${CMAKE_SOURCE_DIR}/Examples/vector2_adolc/CMakeLists.txt" )
	add_subdirectory (Examples/vector2_adolc)
endif()
412 413 414
if( EXISTS "${CMAKE_SOURCE_DIR}/Examples/small_linear_problem/CMakeLists.txt" )
	add_subdirectory (Examples/small_linear_problem)
endif()
David Bommes's avatar
David Bommes committed
415