CMakeLists.txt 12.7 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
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 ()
David Bommes's avatar
David Bommes committed
19 20 21
  set (COMISO_QT4_CONFIG_FILE_SETTINGS "#define COMISO_QT4_AVAILABLE 1" )
else()
  set (COMISO_QT4_CONFIG_FILE_SETTINGS "#define COMISO_QT4_AVAILABLE 0" )
22 23 24 25 26 27
endif ()

acg_get_version ()

include (ACGOutput)

28
set(COMISO_INCLUDE_DIRECTORIES "")
29 30
set(COMISO_LINK_DIRECTORIES "")
set(COMISO_LINK_LIBRARIES "")
31

David Bommes's avatar
David Bommes committed
32 33 34 35 36 37 38 39 40 41 42 43
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 ()


44
find_package (GMM)
45 46
if (GMM_FOUND)
  set (COMISO_GMM_CONFIG_FILE_SETTINGS "#define COMISO_GMM_AVAILABLE 1" )
47
  list( APPEND COMISO_INCLUDE_DIRECTORIES ${GMM_INCLUDE_DIR} )
48 49
else()
  set (COMISO_GMM_CONFIG_FILE_SETTINGS "#define COMISO_GMM_AVAILABLE 0" )
50 51 52
  message (FATAL_ERROR "GMM not found!")
endif ()

53 54 55
# We require cgal with its blas on windows
if (WIN32)
  find_package(CGAL)
56 57 58 59 60
  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()
61 62
endif()

63
find_package (BLAS)
64 65
if (BLAS_FOUND )
  set (COMISO_BLAS_CONFIG_FILE_SETTINGS "#define COMISO_BLAS_AVAILABLE 1" )
66 67 68 69
  
  list( APPEND COMISO_INCLUDE_DIRECTORIES ${BLAS_INCLUDE_DIRS} )
  list( APPEND COMISO_LINK_DIRECTORIES   ${BLAS_LIBRARY_DIRS} )
  list( APPEND COMISO_LINK_LIBRARIES  ${BLAS_LIBRARIES} )
70 71
else()
  set (COMISO_BLAS_CONFIG_FILE_SETTINGS "#define COMISO_BLAS_AVAILABLE 0" )
72 73 74
  message (FATAL_ERROR "BLAS not found!")
endif ()

Mike Kremer's avatar
Mike Kremer committed
75 76 77
find_package (ADOLC)
if (ADOLC_FOUND)
  set (COMISO_ADOLC_CONFIG_FILE_SETTINGS "#define COMISO_ADOLC_AVAILABLE 1" )
78 79
  list( APPEND COMISO_INCLUDE_DIRECTORIES ${ADOLC_INCLUDE_DIR} )
  list( APPEND COMISO_LINK_DIRECTORIES   ${ADOLC_LIBRARY_DIR} )
Mike Kremer's avatar
Mike Kremer committed
80 81 82 83 84 85
  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 ()

86
find_package (SUITESPARSE)
87 88
if (SUITESPARSE_FOUND )
  set (COMISO_SUITESPARSE_CONFIG_FILE_SETTINGS "#define COMISO_SUITESPARSE_AVAILABLE 1" )
89
  
David Bommes's avatar
David Bommes committed
90
  list( APPEND COMISO_INCLUDE_DIRECTORIES ${SUITESPARSE_INCLUDE_DIRS} )
91 92
  list( APPEND COMISO_LINK_DIRECTORIES   ${SUITESPARSE_LIBRARY_DIRS} )
  list( APPEND COMISO_LINK_LIBRARIES  ${SUITESPARSE_LIBRARIES} )
93 94 95 96
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
97 98 99 100 101 102 103
# 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()
104 105 106 107

find_package (MPI)
if (MPI_FOUND )
  set (COMISO_MPI_CONFIG_FILE_SETTINGS "#define COMISO_MPI_AVAILABLE 1" )
David Bommes's avatar
David Bommes committed
108
  list( APPEND COMISO_INCLUDE_DIRECTORIES ${MPI_INCLUDE_PATH} )
109
  list( APPEND COMISO_LINK_LIBRARIES  ${MPI_CXX_LIBRARIES} )
110 111 112 113
else ()
  message (STATUS "MPI not found!")
  set (COMISO_MPI_CONFIG_FILE_SETTINGS "#define COMISO_MPI_AVAILABLE 0" )
endif ()
114 115

find_package (PETSC)
116 117
if (PETSC_FOUND AND MPI_FOUND)
  set (COMISO_PETSC_CONFIG_FILE_SETTINGS "#define COMISO_PETSC_AVAILABLE 1" )
David Bommes's avatar
David Bommes committed
118
  list( APPEND COMISO_INCLUDE_DIRECTORIES ${PETSC_INCLUDE_DIRS} )
119 120
  list( APPEND COMISO_LINK_DIRECTORIES ${PETSC_LIBRARY_DIR} )
  list( APPEND COMISO_LINK_LIBRARIES  ${PETSC_LIBRARY} )
121
else ()
David Bommes's avatar
David Bommes committed
122
  message (STATUS "PETSC or dependency not found!")
123 124
  set (COMISO_PETSC_CONFIG_FILE_SETTINGS "#define COMISO_PETSC_AVAILABLE 0" )
endif ()
125

126

127 128 129
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
130
  list( APPEND COMISO_INCLUDE_DIRECTORIES ${TAO_INCLUDE_DIRS} )
131 132
  list( APPEND COMISO_LINK_DIRECTORIES ${TAO_LIBRARY_DIR} )
  list( APPEND COMISO_LINK_LIBRARIES  ${TAO_LIBRARY} )
133
else ()
David Bommes's avatar
David Bommes committed
134
  message (STATUS "TAO or dependency not found!")
135
  set (COMISO_TAO_CONFIG_FILE_SETTINGS "#define COMISO_TAO_AVAILABLE 0" )
136 137
endif ()

David Bommes's avatar
David Bommes committed
138 139 140 141 142 143 144 145 146 147 148 149
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
150 151 152 153
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} )
154
  list( APPEND COMISO_LINK_LIBRARIES ${MUMPS_LIBRARY} )
David Bommes's avatar
David Bommes committed
155 156 157 158 159
else ()
  message (STATUS "MUMPS not found!")
  set (COMISO_MUMPS_CONFIG_FILE_SETTINGS "#define COMISO_MUMPS_AVAILABLE 0" )
endif ()

160
find_package (IPOPT)
161
if (IPOPT_FOUND)
162
  set (COMISO_IPOPT_CONFIG_FILE_SETTINGS "#define COMISO_IPOPT_AVAILABLE 1" )
163
  list( APPEND COMISO_INCLUDE_DIRECTORIES ${IPOPT_INCLUDE_DIR} )
164 165
  list( APPEND COMISO_LINK_DIRECTORIES ${IPOPT_LIBRARY_DIR} )
  list( APPEND COMISO_LINK_LIBRARIES ${IPOPT_LIBRARY} )
David Bommes's avatar
David Bommes committed
166
  if ( IPOPT_HSL_LIBRARY_DIR )
Jan Möbius's avatar
Jan Möbius committed
167 168 169 170
	set (COMISO_HSL_CONFIG_FILE_SETTINGS "#define COMISO_HSL_AVAILABLE 1" )
  else ()
	set (COMISO_HSL_CONFIG_FILE_SETTINGS "#define COMISO_HSL_AVAILABLE 0" )
  endif()
171
else ()
David Bommes's avatar
David Bommes committed
172
  message (STATUS "IPOPT or dependency not found!")
173
  set (COMISO_IPOPT_CONFIG_FILE_SETTINGS "#define COMISO_IPOPT_AVAILABLE 0" )
Jan Möbius's avatar
Jan Möbius committed
174
  set (COMISO_HSL_CONFIG_FILE_SETTINGS "#define COMISO_HSL_AVAILABLE 0" )
175 176
endif ()

David Bommes's avatar
David Bommes committed
177 178 179 180 181 182 183 184 185
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
186 187 188 189
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} )
190 191 192 193
  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
194 195 196 197 198
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
199 200 201
find_package (GUROBI)
if (GUROBI_FOUND )
  set (COMISO_GUROBI_CONFIG_FILE_SETTINGS "#define COMISO_GUROBI_AVAILABLE 1" )
David Bommes's avatar
David Bommes committed
202 203 204
  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
205 206 207 208 209
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
210 211 212 213 214 215 216 217 218 219 220
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
221 222 223 224 225 226 227
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_DIRECTORIES    ${CPLEX_LIBRARY_DIR} )
#  list( APPEND COMISO_LINK_DIRECTORIES    ${CPLEX_CONCERT_LIBRARY_DIR} )
  list( APPEND COMISO_LINK_LIBRARIES  ${CPLEX_LIBRARIES} )
228 229 230
  
  #enable c++ support
   add_definitions(-DIL_STD)
David Bommes's avatar
David Bommes committed
231 232
else ()
  message (STATUS "CPLEX not found!")
233
  set (COMISO_CPLEX_CONFIG_FILE_SETTINGS "#define COMISO_CPLEX_AVAILABLE 0" )
David Bommes's avatar
David Bommes committed
234 235
endif ()

236 237 238
include_directories (
  ..
  ${CMAKE_CURRENT_SOURCE_DIR}
239
  ${CMAKE_CURRENT_SOURCE_DIR}/../
240
  ${CMAKE_CURRENT_BINARY_DIR}
241
  ${COMISO_INCLUDE_DIRECTORIES}
242 243 244 245 246 247 248 249 250
)

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


link_directories (
251
  ${COMISO_LINK_DIRECTORIES}
252 253 254 255 256
)

# source code directories
set (directories 
  .
257 258
  Solver
  NSolver
David Bommes's avatar
David Bommes committed
259
  EigenSolver
260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298
  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
299
if( QT4_FOUND)
300 301 302
# genereate uic and moc targets
acg_qt4_autouic (uic_targets ${ui})
acg_qt4_automoc (moc_targets ${headers})
Henrik Zimmer's avatar
Henrik Zimmer committed
303
endif()
304 305 306 307 308
acg_add_library (CoMISo SHARED ${uic_targets} ${sources} ${headers} ${moc_targets})

if (NOT APPLE)
	target_link_libraries (CoMISo 
	  ${QT_LIBRARIES}
309
	  ${COMISO_LINK_LIBRARIES}
310 311 312 313
	)
else(NOT APPLE)
	target_link_libraries (CoMISo
	  ${QT_LIBRARIES}
314
	  ${COMISO_LINK_LIBRARIES}
315 316 317 318 319 320
	)
endif(NOT APPLE)

# display results
acg_print_configure_header (COMISO "CoMISo")

321
# write config file
Jan Möbius's avatar
Jan Möbius committed
322 323
configure_file ("${CMAKE_CURRENT_SOURCE_DIR}/Config/config.hh.in"
     "${CMAKE_CURRENT_SOURCE_DIR}/Config/config.hh" @ONLY IMMEDIATE)
324 325 326 327 328 329 330
     
     
     
#######################################################################
# Configure the examples last to be sure, that all configure files
# of the library are already there
#######################################################################
David Bommes's avatar
David Bommes committed
331

332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350
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
351 352 353
if( EXISTS "${CMAKE_SOURCE_DIR}/Examples/eigen_solver/CMakeLists.txt" )
	add_subdirectory (Examples/eigen_solver)
endif()
David Bommes's avatar
David Bommes committed
354 355 356
if( EXISTS "${CMAKE_SOURCE_DIR}/Examples/small_nsolver/CMakeLists.txt" )
	add_subdirectory (Examples/small_nsolver)
endif()
357 358 359
if( EXISTS "${CMAKE_SOURCE_DIR}/Examples/small_eigenproblem/CMakeLists.txt" )
	add_subdirectory (Examples/small_eigenproblem)
endif()
360 361 362
if( EXISTS "${CMAKE_SOURCE_DIR}/Examples/small_miqp/CMakeLists.txt" )
	add_subdirectory (Examples/small_miqp)
endif()
David Bommes's avatar
David Bommes committed
363 364 365
if( EXISTS "${CMAKE_SOURCE_DIR}/Examples/small_nleast_squares/CMakeLists.txt" )
	add_subdirectory (Examples/small_nleast_squares)
endif()
366 367 368
if( EXISTS "${CMAKE_SOURCE_DIR}/Examples/small_sparseqr/CMakeLists.txt" )
	add_subdirectory (Examples/small_sparseqr)
endif()
369 370 371
if( EXISTS "${CMAKE_SOURCE_DIR}/Examples/small_quadratic_resolve_example/CMakeLists.txt" )
	add_subdirectory (Examples/small_quadratic_resolve_example)
endif()
372 373 374
if( EXISTS "${CMAKE_SOURCE_DIR}/Examples/small_cplex_soc/CMakeLists.txt" )
	add_subdirectory (Examples/small_cplex_soc)
endif()