CMakeLists.txt 26.2 KB
Newer Older
1
cmake_minimum_required (VERSION 3.13)
2

Martin Heistermann's avatar
Martin Heistermann committed
3
project(CoMISo VERSION 1.1.0)
4

David Bommes's avatar
David Bommes committed
5 6 7 8
if(POLICY CMP0100)
  cmake_policy(SET CMP0100 NEW)
endif()

9
# add our macro directory to cmake search path
10
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_CURRENT_SOURCE_DIR}/cmake-library/finders ${CMAKE_CURRENT_SOURCE_DIR}/cmake-library/VCI)
Jane Tournois's avatar
Jane Tournois committed
11
set (CMAKE_DEBUG_POSTFIX "d")
12

Max Lyon's avatar
Max Lyon committed
13
include (VCICommon)
14

Max Lyon's avatar
Max Lyon committed
15
include(VCIQt)
16 17 18 19 20 21

# 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 )

22 23 24 25 26
  set(QT5_REQUIRED_PACKAGES
    Qt5Core
    Qt5Widgets
    )

Max Lyon's avatar
Max Lyon committed
27
  vci_qt5 ()
28

Jan Möbius's avatar
Jan Möbius committed
29
  if( QT5_FOUND)
30 31 32 33 34
    add_definitions (-DQT5_FOUND)
    set (COMISO_QT_CONFIG_FILE_SETTINGS "#define COMISO_QT_AVAILABLE 1" )
  else()
    set (COMISO_QT_CONFIG_FILE_SETTINGS "#define COMISO_QT_AVAILABLE 0" )
  endif()
35

36 37 38 39 40 41
  if ( QT5_FOUND )
    # Enable automoc
    set(CMAKE_AUTOMOC ON)
    set(CMAKE_AUTOUIC ON)
  endif()

42 43
endif( WANT_COMISO_QT )

44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
# source code directories
set (directories
  .
  Base/Code
  Base/Debug
  Base/Security
  Base/Utils
  Solver
  NSolver
  EigenSolver
  Config
  Utils
  QtWidgets
)

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

if( QT5_FOUND )
vci_append_files (ui "*.ui" ${directories})
endif()

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

vci_add_library (CoMISo SHARED ${ui} ${sources} ${headers} )
add_library(CoMISo::CoMISo ALIAS CoMISo)

target_include_directories(CoMISo
    PUBLIC
        $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/>
        $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..> # TODO: this is dangerous!
        $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/>
78 79
        $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
        $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/CoMISo>
80 81 82
)

if ( QT5_FOUND )
83
  target_link_libraries(CoMISo PUBLIC ${QT_LIBRARIES})
84 85
endif()

Max Lyon's avatar
Max Lyon committed
86
vci_get_version ()
87

Max Lyon's avatar
Max Lyon committed
88
include (VCIOutput)
89 90 91 92 93 94

set(COMISO_INCLUDE_DIRECTORIES "")
set(COMISO_LINK_DIRECTORIES "")
set(COMISO_LINK_LIBRARIES "")
set(NEED_LAPACK "")

95 96
option(COMISO_BUILD_WITHOUT_BOOST "Build CoMISo without boost" OFF)

Max Lyon's avatar
Max Lyon committed
97
FIND_PACKAGE( Boost 1.59.0 COMPONENTS system filesystem regex QUIET)
98
if(Boost_FOUND AND NOT COMISO_BUILD_WITHOUT_BOOST)
99 100 101 102
  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} )
103

104 105 106 107
  target_include_directories(CoMISo PRIVATE ${Boost_INCLUDE_DIRS})
  target_link_directories   (CoMISo PRIVATE ${Boost_LIBRARY_DIR})
  target_link_libraries     (CoMISo PRIVATE ${Boost_LIBRARIES})

108
  option(Boost_USE_STATIC_LIBS "Link with static Boost libraries" OFF)
109 110 111 112 113 114 115 116 117
  mark_as_advanced(Boost_USE_STATIC_LIBS)
  if(Boost_USE_STATIC_LIBS)
    set(Boost_USE_STATIC_LIBS ON)
  else()
      # One must add -DBOOST_ALL_DYN_LINK to DEFINITIONS to use Boost
      # auto-link with shared libraries.
    add_definitions( -DBOOST_ALL_DYN_LINK )
  endif()

118 119
else()
  set (COMISO_BOOST_CONFIG_FILE_SETTINGS "#define COMISO_BOOST_AVAILABLE 0" )
120 121 122 123 124
  if(COMISO_BUILD_WITHOUT_BOOST)
    message (STATUS "Building without boost (COMISO_BUILD_WITHOUT_BOOST flag is set)")
  else()
    message (STATUS "Boost not found!")
  endif()
125 126 127
endif ()


128
find_package (GMM REQUIRED)
129 130 131 132
if (GMM_FOUND)
  set (COMISO_GMM_CONFIG_FILE_SETTINGS "#define COMISO_GMM_AVAILABLE 1" )
  list( APPEND COMISO_INCLUDE_DIRECTORIES ${GMM_INCLUDE_DIR} )
  list (APPEND NEED_LAPACK "GMM")
133

Max Lyon's avatar
Max Lyon committed
134
  target_include_directories(CoMISo PUBLIC ${GMM_INCLUDE_DIR})
135 136 137 138
else()
  set (COMISO_GMM_CONFIG_FILE_SETTINGS "#define COMISO_GMM_AVAILABLE 0" )
endif ()

Max Lyon's avatar
Max Lyon committed
139 140
set(TMP_CMAKE_FIND_LIBRARY_PREFIXES "${CMAKE_FIND_LIBRARY_PREFIXES}")
set(CMAKE_FIND_LIBRARY_PREFIXES lib "") #Our blas librariy is called libblas.lib. Is there a better way to find it than this?
141 142 143
find_package (BLAS)
if (BLAS_FOUND )
  set (COMISO_BLAS_CONFIG_FILE_SETTINGS "#define COMISO_BLAS_AVAILABLE 1" )
144

145 146 147
  list( APPEND COMISO_INCLUDE_DIRECTORIES ${BLAS_INCLUDE_DIRS} )
  list( APPEND COMISO_LINK_DIRECTORIES   ${BLAS_LIBRARY_DIRS} ${BLAS_LIBRARY_DIR} )
  list( APPEND COMISO_LINK_LIBRARIES  ${BLAS_LIBRARIES} )
148 149 150 151

  target_include_directories(CoMISo PRIVATE ${BLAS_INCLUDE_DIRS})
  target_link_directories   (CoMISo PRIVATE ${BLAS_LIBRARY_DIRS} ${BLAS_LIBRARY_DIR})
  target_link_libraries     (CoMISo PRIVATE ${BLAS_LIBRARIES})
152 153 154 155
else()
  set (COMISO_BLAS_CONFIG_FILE_SETTINGS "#define COMISO_BLAS_AVAILABLE 0" )
  message (STATUS "BLAS not found!")
endif ()
Max Lyon's avatar
Max Lyon committed
156
set(CMAKE_FIND_LIBRARY_PREFIXES "${TMP_CMAKE_FIND_LIBRARY_PREFIXES}")
157 158 159 160 161 162 163

find_package (ADOLC)
if (ADOLC_FOUND)
  set (COMISO_ADOLC_CONFIG_FILE_SETTINGS "#define COMISO_ADOLC_AVAILABLE 1" )
  list( APPEND COMISO_INCLUDE_DIRECTORIES ${ADOLC_INCLUDE_DIR} )
  list( APPEND COMISO_LINK_DIRECTORIES   ${ADOLC_LIBRARY_DIR} )
  list( APPEND COMISO_LINK_LIBRARIES  ${ADOLC_LIBRARIES} )
164 165 166
  target_include_directories(CoMISo PRIVATE ${ADOLC_INCLUDE_DIR})
  target_link_directories   (CoMISo PRIVATE ${ADOLC_LIBRARY_DIR})
  target_link_libraries     (CoMISo PRIVATE ${ADOLC_LIBRARIES})
167 168 169 170 171 172 173 174
else ()
  set (COMISO_ADOLC_CONFIG_FILE_SETTINGS "#define COMISO_ADOLC_AVAILABLE 0" )
  message (STATUS "ADOLC not found!")
endif ()

find_package (SUITESPARSE)
if (SUITESPARSE_FOUND )
  list (APPEND NEED_LAPACK "SUITESPARSE")
175

176
  set (COMISO_SUITESPARSE_CONFIG_FILE_SETTINGS "#define COMISO_SUITESPARSE_AVAILABLE 1" )
177

178 179 180
  list( APPEND COMISO_INCLUDE_DIRECTORIES ${SUITESPARSE_INCLUDE_DIRS} )
  list( APPEND COMISO_LINK_DIRECTORIES   ${SUITESPARSE_LIBRARY_DIRS} )
  list( APPEND COMISO_LINK_LIBRARIES  ${SUITESPARSE_LIBRARIES} )
181 182 183
  target_include_directories(CoMISo PUBLIC ${SUITESPARSE_INCLUDE_DIRS})
  target_link_directories   (CoMISo PUBLIC ${SUITESPARSE_LIBRARY_DIRS})
  target_link_libraries     (CoMISo PUBLIC ${SUITESPARSE_LIBRARIES})
184 185 186 187 188 189 190 191 192

  # 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()

193 194 195 196 197 198
else ()
  message (STATUS "SUITESPARSE not found!")
  set (COMISO_SUITESPARSE_CONFIG_FILE_SETTINGS "#define COMISO_SUITESPARSE_AVAILABLE 0" )
  set (COMISO_SUITESPARSE_SPQR_CONFIG_FILE_SETTINGS "#define COMISO_SUITESPARSE_SPQR_AVAILABLE 0" )
endif()

199 200 201 202 203 204
if(NOT DISABLE_MPI)
  find_package (MPI)
  if (MPI_FOUND )
    set (COMISO_MPI_CONFIG_FILE_SETTINGS "#define COMISO_MPI_AVAILABLE 1" )
    list( APPEND COMISO_INCLUDE_DIRECTORIES ${MPI_INCLUDE_PATH} )
    list( APPEND COMISO_LINK_LIBRARIES  ${MPI_CXX_LIBRARIES} )
205 206
    target_include_directories(CoMISo PRIVATE ${MPI_INCLUDE_PATH})
    target_link_libraries     (CoMISo PRIVATE ${MPI_CXX_LIBRARIES})
207 208 209 210
  else ()
    message (STATUS "MPI not found!")
    set (COMISO_MPI_CONFIG_FILE_SETTINGS "#define COMISO_MPI_AVAILABLE 0" )
  endif ()
211
else ()
212
  message (STATUS "MPI disabled!")
213 214 215
  set (COMISO_MPI_CONFIG_FILE_SETTINGS "#define COMISO_MPI_AVAILABLE 0" )
endif ()

216 217 218 219 220 221
if(NOT DISABLE_PETSC)
  find_package (PETSC)
  if (PETSC_FOUND AND MPI_FOUND)
    set (COMISO_PETSC_CONFIG_FILE_SETTINGS "#define COMISO_PETSC_AVAILABLE 1" )
    list( APPEND COMISO_INCLUDE_DIRECTORIES ${PETSC_INCLUDE_DIRS} )
    list( APPEND COMISO_LINK_LIBRARIES  ${PETSC_LIBRARY} )
222 223
    target_include_directories(CoMISo PRIVATE ${PETSC_INCLUDE_DIRS})
    target_link_libraries     (CoMISo PRIVATE ${PETSC_LIBRARY})
224 225 226 227
  else ()
    message (STATUS "PETSC or MPI not found!")
    set (COMISO_PETSC_CONFIG_FILE_SETTINGS "#define COMISO_PETSC_AVAILABLE 0" )
  endif ()
228
else ()
229
  message (STATUS "PETSC disabled!")
230
  set (COMISO_PETSC_CONFIG_FILE_SETTINGS "#define COMISO_PETSC_AVAILABLE 0" )
231
endif()
232 233


234 235 236 237 238 239 240
if(NOT DISABLE_TAO)
  find_package (TAO)
  if (TAO_FOUND AND PETSC_FOUND AND MPI_FOUND)
    set (COMISO_TAO_CONFIG_FILE_SETTINGS "#define COMISO_TAO_AVAILABLE 1" )
    list( APPEND COMISO_INCLUDE_DIRECTORIES ${TAO_INCLUDE_DIRS} )
    list( APPEND COMISO_LINK_DIRECTORIES ${TAO_LIBRARY_DIR} )
    list( APPEND COMISO_LINK_LIBRARIES  ${TAO_LIBRARY} )
241 242 243
    target_include_directories(CoMISo PRIVATE ${TAO_INCLUDE_DIRS})
    target_link_directories   (CoMISo PRIVATE ${TAO_LIBRARY_DIR})
    target_link_libraries     (CoMISo PRIVATE ${TAO_LIBRARY})
244 245 246 247
  else ()
    message (STATUS "TAO or PETSC or MPI not found!")
    set (COMISO_TAO_CONFIG_FILE_SETTINGS "#define COMISO_TAO_AVAILABLE 0" )
  endif ()
248
else ()
249
  message (STATUS "TAO disabled!")
250 251 252 253 254 255
  set (COMISO_TAO_CONFIG_FILE_SETTINGS "#define COMISO_TAO_AVAILABLE 0" )
endif ()

find_package (METIS)
if (METIS_FOUND )
  set (COMISO_METIS_CONFIG_FILE_SETTINGS "#define COMISO_METIS_AVAILABLE 1" )
256

257 258 259
  list( APPEND COMISO_INCLUDE_DIRECTORIES ${METIS_INCLUDE_DIRS} )
  list( APPEND COMISO_LINK_DIRECTORIES   ${METIS_LIBRARY_DIRS} )
  list( APPEND COMISO_LINK_LIBRARIES  ${METIS_LIBRARIES} )
260 261 262
  target_include_directories(CoMISo PRIVATE ${METIS_INCLUDE_DIRS})
  target_link_directories   (CoMISo PRIVATE ${METIS_LIBRARY_DIRS})
  target_link_libraries     (CoMISo PRIVATE ${METIS_LIBRARIES})
263 264 265 266 267 268 269 270 271 272
else()
  set (COMISO_METIS_CONFIG_FILE_SETTINGS "#define COMISO_METIS_AVAILABLE 0" )
  message (STATUS "METIS not found!")
endif ()

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} )
  list( APPEND COMISO_LINK_LIBRARIES ${MUMPS_LIBRARY} )
273 274
  target_include_directories(CoMISo PRIVATE ${MUMPS_INCLUDE_DIR})
  target_link_libraries     (CoMISo PRIVATE ${MUMPS_LIBRARY})
275 276 277 278 279 280 281 282
else ()
  message (STATUS "MUMPS not found!")
  set (COMISO_MUMPS_CONFIG_FILE_SETTINGS "#define COMISO_MUMPS_AVAILABLE 0" )
endif ()

find_package (IPOPT)
if (IPOPT_FOUND)
  set (COMISO_IPOPT_CONFIG_FILE_SETTINGS "#define COMISO_IPOPT_AVAILABLE 1" )
Max Lyon's avatar
Max Lyon committed
283 284 285
  list( APPEND COMISO_INCLUDE_DIRECTORIES ${IPOPT_INCLUDE_DIRS} )
  list( APPEND COMISO_LINK_DIRECTORIES ${IPOPT_LIBRARY_DIRS} )
  list( APPEND COMISO_LINK_LIBRARIES ${IPOPT_LIBRARIES} )
Max Lyon's avatar
Max Lyon committed
286 287 288
  target_include_directories(CoMISo PUBLIC ${IPOPT_INCLUDE_DIRS})
  target_link_directories   (CoMISo PUBLIC ${IPOPT_LIBRARY_DIRS})
  target_link_libraries     (CoMISo PUBLIC ${IPOPT_LIBRARIES})
289
  if ( IPOPT_HSL_LIBRARY_DIR )
290
    set (COMISO_HSL_CONFIG_FILE_SETTINGS "#define COMISO_HSL_AVAILABLE 1" )
291
  else ()
292
    set (COMISO_HSL_CONFIG_FILE_SETTINGS "#define COMISO_HSL_AVAILABLE 0" )
293 294 295 296 297 298 299 300 301 302 303
  endif()
else ()
  message (STATUS "IPOPT or dependency not found!")
  set (COMISO_IPOPT_CONFIG_FILE_SETTINGS "#define COMISO_IPOPT_AVAILABLE 0" )
  set (COMISO_HSL_CONFIG_FILE_SETTINGS "#define COMISO_HSL_AVAILABLE 0" )
endif ()

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} )
304
  target_include_directories   (CoMISo PUBLIC ${EIGEN3_INCLUDE_DIR})
305 306 307 308 309 310 311 312 313
else ()
  message (FATAL_ERROR "EIGEN3 not found!")
  set (COMISO_EIGEN3_CONFIG_FILE_SETTINGS "#define COMISO_EIGEN3_AVAILABLE 0" )
endif ()

find_package (DCO)
if (DCO_FOUND )
  set (COMISO_DCO_CONFIG_FILE_SETTINGS "#define COMISO_DCO_AVAILABLE 1" )
  list( APPEND COMISO_INCLUDE_DIRECTORIES ${DCO_INCLUDE_DIR} )
314
  target_include_directories   (CoMISo PUBLIC ${DCO_INCLUDE_DIR})
315 316 317 318 319 320 321 322 323 324
else ()
  message (STATUS "DCO not found!")
  set (COMISO_DCO_CONFIG_FILE_SETTINGS "#define COMISO_DCO_AVAILABLE 0" )
endif ()

find_package (CBC)
if (CBC_FOUND )
  set (COMISO_CBC_CONFIG_FILE_SETTINGS "#define COMISO_CBC_AVAILABLE 1" )
  list( APPEND COMISO_INCLUDE_DIRECTORIES ${CBC_INCLUDE_DIRS} )
  list( APPEND COMISO_LINK_LIBRARIES  ${CBC_LIBRARIES} )
325 326
  target_include_directories(CoMISo PRIVATE ${CBC_INCLUDE_DIRS})
  target_link_libraries     (CoMISo PRIVATE ${CBC_LIBRARIES})
327 328 329 330 331 332 333 334 335 336
else ()
  message (STATUS "CBC not found!")
  set (COMISO_CBC_CONFIG_FILE_SETTINGS "#define COMISO_CBC_AVAILABLE 0" )
endif ()

find_package (CLP)
if (CLP_FOUND )
  set (COMISO_CLP_CONFIG_FILE_SETTINGS "#define COMISO_CLP_AVAILABLE 1" )
  list( APPEND COMISO_INCLUDE_DIRECTORIES ${CLP_INCLUDE_DIRS} )
  list( APPEND COMISO_LINK_LIBRARIES  ${CLP_LIBRARIES} )
337 338
  target_include_directories(CoMISo PRIVATE ${CLP_INCLUDE_DIRS})
  target_link_libraries     (CoMISo PRIVATE ${CLP_LIBRARIES})
339 340 341 342 343 344 345 346 347 348
else ()
  message (STATUS "CLP not found!")
  set (COMISO_CLP_CONFIG_FILE_SETTINGS "#define COMISO_CLP_AVAILABLE 0" )
endif ()

find_package (CGL)
if (CGL_FOUND )
  set (COMISO_CGL_CONFIG_FILE_SETTINGS "#define COMISO_CGL_AVAILABLE 1" )
  list( APPEND COMISO_INCLUDE_DIRECTORIES ${CGL_INCLUDE_DIRS} )
  list( APPEND COMISO_LINK_LIBRARIES  ${CGL_LIBRARIES} )
349 350
  target_include_directories(CoMISo PRIVATE ${CGL_INCLUDE_DIRS})
  target_link_libraries     (CoMISo PRIVATE ${CGL_LIBRARIES})
351 352 353 354 355 356 357 358 359 360
else ()
  message (STATUS "CGL not found!")
  set (COMISO_CGL_CONFIG_FILE_SETTINGS "#define COMISO_CGL_AVAILABLE 0" )
endif ()

find_package (COINUTILS)
if (COINUTILS_FOUND )
  set (COMISO_COINUTILS_CONFIG_FILE_SETTINGS "#define COMISO_COINUTILS_AVAILABLE 1" )
  list( APPEND COMISO_INCLUDE_DIRECTORIES ${COINUTILS_INCLUDE_DIRS} )
  list( APPEND COMISO_LINK_LIBRARIES  ${COINUTILS_LIBRARIES} )
361 362
  target_include_directories(CoMISo PRIVATE ${COINUTILS_INCLUDE_DIRS})
  target_link_libraries     (CoMISo PRIVATE ${COINUTILS_LIBRARIES})
363 364 365 366 367 368 369 370 371 372
else ()
  message (STATUS "COINUTILS not found!")
  set (COMISO_COINUTILS_CONFIG_FILE_SETTINGS "#define COMISO_COINUTILS_AVAILABLE 0" )
endif ()

find_package (OSI)
if (OSI_FOUND )
  set (COMISO_OSI_CONFIG_FILE_SETTINGS "#define COMISO_OSI_AVAILABLE 1" )
  list( APPEND COMISO_INCLUDE_DIRECTORIES ${OSI_INCLUDE_DIRS} )
  list( APPEND COMISO_LINK_LIBRARIES  ${OSI_LIBRARIES} )
373 374
  target_include_directories(CoMISo PRIVATE ${OSI_INCLUDE_DIRS})
  target_link_libraries     (CoMISo PRIVATE ${OSI_LIBRARIES})
375 376 377 378 379
else ()
  message (STATUS "OSI not found!")
  set (COMISO_OSI_CONFIG_FILE_SETTINGS "#define COMISO_OSI_AVAILABLE 0" )
endif ()

Martin Heistermann's avatar
Martin Heistermann committed
380
find_package (Taucs QUIET)
381 382
set (SUPRESS_TAUCS OFF CACHE BOOL "Set to ON if CoMISo should be built without TAUCS.")
if (TAUCS_FOUND AND NOT SUPRESS_TAUCS)
Max Lyon's avatar
Max Lyon committed
383
  list (APPEND NEED_LAPACK "Taucs")
384 385 386
  set (COMISO_TAUCS_CONFIG_FILE_SETTINGS "#define COMISO_TAUCS_AVAILABLE 1" )
  list( APPEND COMISO_INCLUDE_DIRECTORIES ${TAUCS_INCLUDE_DIR} )
  list( APPEND COMISO_LINK_LIBRARIES  ${TAUCS_LIBRARY} )
387 388
  target_include_directories(CoMISo PRIVATE ${TAUCS_INCLUDE_DIR})
  target_link_libraries     (CoMISo PRIVATE ${TAUCS_LIBRARY})
389

390 391 392 393 394 395 396 397 398 399 400
else ()
  message (STATUS "TAUCS not found!")
  set (COMISO_TAUCS_CONFIG_FILE_SETTINGS "#define COMISO_TAUCS_AVAILABLE 0" )
endif ()

find_package (GUROBI)
if (GUROBI_FOUND )
  set (COMISO_GUROBI_CONFIG_FILE_SETTINGS "#define COMISO_GUROBI_AVAILABLE 1" )
  list( APPEND COMISO_INCLUDE_DIRECTORIES ${GUROBI_INCLUDE_DIRS} )
#  list( APPEND COMISO_LINK_DIRECTORIES    ${GUROBI_LIBRARY_DIR} )
  list( APPEND COMISO_LINK_LIBRARIES  ${GUROBI_LIBRARIES} )
401 402 403
  target_include_directories(CoMISo PRIVATE ${GUROBI_INCLUDE_DIRS})
#  target_link_directories   (CoMISo PRIVATE ${GUROBI_LIBRARY_DIR})
  target_link_libraries     (CoMISo PRIVATE ${GUROBI_LIBRARIES})
404 405 406 407 408
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
409 410 411 412 413 414
find_package (MOSEK)
if (MOSEK_FOUND )
  set (COMISO_MOSEK_CONFIG_FILE_SETTINGS "#define COMISO_MOSEK_AVAILABLE 1" )
  list( APPEND COMISO_INCLUDE_DIRECTORIES ${MOSEK_INCLUDE_DIRS} )
  list( APPEND COMISO_LINK_DIRECTORIES    ${MOSEK_LIBRARY_DIR} )
  list( APPEND COMISO_LINK_LIBRARIES  ${MOSEK_LIBRARIES} )
415 416 417
  target_include_directories(CoMISo PRIVATE ${MOSEK_INCLUDE_DIRS})
  target_link_directories   (CoMISo PRIVATE ${MOSEK_LIBRARY_DIR})
  target_link_libraries     (CoMISo PRIVATE ${MOSEK_LIBRARIES})
David Bommes's avatar
David Bommes committed
418 419 420 421 422 423
else ()
  message (STATUS "MOSEK not found!")
  set (COMISO_MOSEK_CONFIG_FILE_SETTINGS "#define COMISO_MOSEK_AVAILABLE 0" )
endif ()


424 425 426 427 428 429
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} )
430 431 432
  target_include_directories(CoMISo PRIVATE ${ARPACK_INCLUDE_DIR})
#  target_link_directories   (CoMISo PRIVATE ${ARPACK_LIBRARY_DIR})
  target_link_libraries     (CoMISo PRIVATE ${ARPACK_LIBRARY})
433 434 435 436 437 438 439 440 441 442
else ()
  message (STATUS "ARPACK not found!")
  set (COMISO_ARPACK_CONFIG_FILE_SETTINGS "#define COMISO_ARPACK_AVAILABLE 0" )
endif ()

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} )
443 444
  target_include_directories(CoMISo PRIVATE ${CPLEX_INCLUDE_DIRS})
  target_link_libraries     (CoMISo PRIVATE ${CPLEX_LIBRARIES})
445

446 447 448 449 450 451 452
  #enable c++ support
   add_definitions(-DIL_STD)
else ()
  message (STATUS "CPLEX not found!")
  set (COMISO_CPLEX_CONFIG_FILE_SETTINGS "#define COMISO_CPLEX_AVAILABLE 0" )
endif ()

Max Lyon's avatar
Max Lyon committed
453
set(TMP_CMAKE_FIND_LIBRARY_PREFIXES "${CMAKE_FIND_LIBRARY_PREFIXES}")
454 455
set(CMAKE_FIND_LIBRARY_PREFIXES lib "") #Our lapack library is called liblapack.lib. Is there a better way to find it than this?
if (NEED_LAPACK AND NOT SUITESPARSE_FOUND)
456 457 458 459 460
  FIND_PACKAGE(LAPACK)
  if (LAPACK_FOUND)
    list( APPEND COMISO_INCLUDE_DIRECTORIES ${LAPACK_INCLUDE_DIR} )
    list( APPEND COMISO_LINK_DIRECTORIES    ${LAPACK_LIBRARY_DIR} )
    list( APPEND COMISO_LINK_LIBRARIES  ${LAPACK_LIBRARIES} )
461 462 463
    target_include_directories(CoMISo PRIVATE ${LAPACK_INCLUDE_DIR})
    target_link_directories   (CoMISo PRIVATE ${LAPACK_LIBRARY_DIR})
    target_link_libraries     (CoMISo PRIVATE ${LAPACK_LIBRARIES})
464 465 466
  else()
    message(STATUS "LAPACK not found!")
  endif()
467
endif(NEED_LAPACK AND NOT SUITESPARSE_FOUND)
Max Lyon's avatar
Max Lyon committed
468
set(CMAKE_FIND_LIBRARY_PREFIXES "${TMP_CMAKE_FIND_LIBRARY_PREFIXES}")
469 470


471
#target_include_directories(CoMISo PRIVATE "${COMISO_INCLUDE_DIRECTORIES}")
Max Lyon's avatar
Max Lyon committed
472

Martin Heistermann's avatar
Martin Heistermann committed
473 474
#get_target_property(INC_DIRS CoMISo INCLUDE_DIRECTORIES)
#get_target_property(INT_INC_DIRS CoMISo INTERFACE_INCLUDE_DIRECTORIES)
Martin Heistermann's avatar
Martin Heistermann committed
475
#message("Target CoMISo include dirs: ${INC_DIRS}")
Martin Heistermann's avatar
Martin Heistermann committed
476
#message("Target CoMISo int include dirs: ${INT_INC_DIRS}")
Martin Heistermann's avatar
Martin Heistermann committed
477 478
#message("COMISO_INCLUDE_DIRECTORIES: ${COMISO_INCLUDE_DIRECTORIES}")
#message("COMISO_LINK_DIRECTORIES: ${COMISO_LINK_DIRECTORIES}")
Max Lyon's avatar
Max Lyon committed
479

Max Lyon's avatar
Max Lyon committed
480 481 482 483 484 485 486 487 488 489 490 491 492
# generate dllexport macros on windows
if (WIN32)
  add_definitions(-DCOMISODLL)
  add_definitions(-DBASEDLL)
  add_definitions(-D_SCL_SECURE_NO_DEPRECATE)
  # ignore "... needs to have dll-interface to be used by clients"
  #add_definitions(/wd4251)
  target_compile_definitions(CoMISo PRIVATE /wd4251)
endif ()

# enable debug stuff
set (COMISO_ENABLE_DEBUG_OUTPUT TRUE CACHE BOOL "Enable CoMISo Debug Output")
if (COMISO_ENABLE_DEBUG_OUTPUT)
493
  target_compile_definitions(CoMISo PUBLIC -DDEB_ON)
Max Lyon's avatar
Max Lyon committed
494 495 496 497 498 499 500 501 502 503 504 505
endif ()

if (WIN32)
  #add_definitions(-D_USE_MATH_DEFINES -DNOMINMAX)
  target_compile_definitions(CoMISo PRIVATE -D_USE_MATH_DEFINES -DNOMINMAX)
endif ()

if (CMAKE_CXX_COMPILER_ID MATCHES "[cC][lL][aA][nN][gG]")
  # disable unused parameter warning
  #add_definitions(-Wno-unused-parameter -Wno-deprecated-register)
  target_compile_options(CoMISo PRIVATE -Wno-unused-parameter -Wno-deprecated-register)
endif()
Jan Möbius's avatar
Jan Möbius committed
506 507 508
if ( QT5_FOUND )

  if ( NOT WIN32 )
Max Lyon's avatar
Max Lyon committed
509
    # Allow targets depending on VCI find the autogenerated header files
Martin Heistermann's avatar
Martin Heistermann committed
510 511
    #target_include_directories( CoMISo PUBLIC
    #                           ${CMAKE_CURRENT_BINARY_DIR}/CoMISo_autogen/include )
Jan Möbius's avatar
Jan Möbius committed
512
  else()
Max Lyon's avatar
Max Lyon committed
513
     # Allow targets depending on VCI find the autogenerated header files
Martin Heistermann's avatar
Martin Heistermann committed
514 515 516
     #target_include_directories( CoMISo PUBLIC
     #                          $<$<CONFIG:Debug>:${CMAKE_CURRENT_BINARY_DIR}/CoMISo_autogen/include_Debug/>
     #                          $<$<CONFIG:Release>:${CMAKE_CURRENT_BINARY_DIR}/CoMISo_autogen/include_Release/> )
Jan Möbius's avatar
Jan Möbius committed
517 518
  endif()

519 520
endif()

521
target_link_libraries (CoMISo PUBLIC
Max Lyon's avatar
Max Lyon committed
522 523
  ${COMISO_LINK_LIBRARIES}
)
524

525 526 527 528 529
if (NOT TARGET osqp)
  find_package(osqp)
endif()
if (TARGET osqp)
  target_link_libraries (CoMISo PRIVATE osqp)
Max Lyon's avatar
Max Lyon committed
530 531 532 533 534
  set (COMISO_OSQP_CONFIG_FILE_SETTINGS "#define COMISO_OSQP_AVAILABLE 1" )
else()
  set (COMISO_OSQP_CONFIG_FILE_SETTINGS "#define COMISO_OSQP_AVAILABLE 0" )
endif()

535
set_target_properties(CoMISo PROPERTIES INSTALL_RPATH_USE_LINK_PATH 1)
536 537

# display results
Max Lyon's avatar
Max Lyon committed
538
vci_print_configure_header (COMISO "CoMISo")
539 540 541 542

# write config file
configure_file ("${CMAKE_CURRENT_SOURCE_DIR}/Config/config.hh.in"
     "CoMISo/Config/config.hh" @ONLY IMMEDIATE)
543 544 545



546 547 548 549 550
#######################################################################
# Configure the examples last to be sure, that all configure files
# of the library are already there
#######################################################################

551
if(${CMAKE_PROJECT_NAME} MATCHES "CoMISo")
Max Lyon's avatar
Max Lyon committed
552 553 554 555
  set (COMISO_BUILD_EXAMPLES TRUE CACHE BOOL "Build CoMISo Examples")
else()
  set (COMISO_BUILD_EXAMPLES FALSE CACHE BOOL "Build CoMISo Examples")
endif()
556

557
if (COMISO_BUILD_EXAMPLES )
Max Lyon's avatar
Max Lyon committed
558
  if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Examples/factored_solver/CMakeLists.txt" )
559
    add_subdirectory (Examples/factored_solver)
560
  endif()
Max Lyon's avatar
Max Lyon committed
561
  if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Examples/quadratic_solver/CMakeLists.txt" )
562
    add_subdirectory (Examples/quadratic_solver)
563
  endif()
Max Lyon's avatar
Max Lyon committed
564
  if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Examples/test2/CMakeLists.txt" )
565
    add_subdirectory (Examples/test2)
566
  endif()
Max Lyon's avatar
Max Lyon committed
567
  if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Examples/small_quadratic_example/CMakeLists.txt" )
568
    add_subdirectory (Examples/small_quadratic_example)
569
  endif()
Max Lyon's avatar
Max Lyon committed
570
  if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Examples/small_factored_example/CMakeLists.txt" )
571
    add_subdirectory (Examples/small_factored_example)
572
  endif()
Max Lyon's avatar
Max Lyon committed
573
  if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Examples/super_sparse_matrix/CMakeLists.txt" )
574
    add_subdirectory (Examples/super_sparse_matrix)
575
  endif()
Max Lyon's avatar
Max Lyon committed
576
  if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Examples/eigen_solver/CMakeLists.txt" )
577
    add_subdirectory (Examples/eigen_solver)
578
  endif()
Max Lyon's avatar
Max Lyon committed
579
  if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Examples/small_nsolver/CMakeLists.txt" )
580
    add_subdirectory (Examples/small_nsolver)
581
  endif()
Max Lyon's avatar
Max Lyon committed
582
  if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Examples/small_eigenproblem/CMakeLists.txt" )
583
    add_subdirectory (Examples/small_eigenproblem)
584
  endif()
Max Lyon's avatar
Max Lyon committed
585
  if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Examples/small_miqp/CMakeLists.txt" )
586
    add_subdirectory (Examples/small_miqp)
587
  endif()
Max Lyon's avatar
Max Lyon committed
588
  if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Examples/small_nleast_squares/CMakeLists.txt" )
589
    add_subdirectory (Examples/small_nleast_squares)
590
  endif()
Max Lyon's avatar
Max Lyon committed
591
  if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Examples/small_sparseqr/CMakeLists.txt" )
592
    add_subdirectory (Examples/small_sparseqr)
593
  endif()
Max Lyon's avatar
Max Lyon committed
594
  if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Examples/small_quadratic_resolve_example/CMakeLists.txt" )
595
    add_subdirectory (Examples/small_quadratic_resolve_example)
596
  endif()
Max Lyon's avatar
Max Lyon committed
597
  if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Examples/small_cplex_soc/CMakeLists.txt" )
598
    add_subdirectory (Examples/small_cplex_soc)
599
  endif()
Max Lyon's avatar
Max Lyon committed
600
  if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Examples/small_adolc/CMakeLists.txt" )
601
    add_subdirectory (Examples/small_adolc)
602
  endif()
Max Lyon's avatar
Max Lyon committed
603
  if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Examples/small_dco/CMakeLists.txt" )
604
    add_subdirectory (Examples/small_dco)
605
  endif()
Max Lyon's avatar
Max Lyon committed
606
  if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Examples/vector1_adolc/CMakeLists.txt" )
607
    add_subdirectory (Examples/vector1_adolc)
608
  endif()
Max Lyon's avatar
Max Lyon committed
609
  if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Examples/small_linear_problem/CMakeLists.txt" )
610
    add_subdirectory (Examples/small_linear_problem)
611
  endif()
Max Lyon's avatar
Max Lyon committed
612
  if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Examples/crossfield3d/CMakeLists.txt" )
613
    add_subdirectory (Examples/crossfield3d)
614
  endif()
Max Lyon's avatar
Max Lyon committed
615
  if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Examples/crossfield3d/CMakeLists.txt" )
616
    add_subdirectory (Examples/crossfield3d_dco)
617
  endif()
Max Lyon's avatar
Max Lyon committed
618
  if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Examples/small_finite_element/CMakeLists.txt" )
619
    add_subdirectory (Examples/small_finite_element)
620
  endif()
Max Lyon's avatar
Max Lyon committed
621
  if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Examples/small_AQP/CMakeLists.txt" )
622
    add_subdirectory (Examples/small_AQP)
623
  endif()
Max Lyon's avatar
Max Lyon committed
624
  if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Examples/finite_element_integrability_problem/CMakeLists.txt" )
625
    add_subdirectory (Examples/finite_element_integrability_problem)
David Bommes's avatar
David Bommes committed
626
  endif()
Max Lyon's avatar
Max Lyon committed
627
  if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Examples/small_mosek_native/CMakeLists.txt" )
628
    add_subdirectory (Examples/small_mosek_native)
David Bommes's avatar
David Bommes committed
629
  endif()
Max Lyon's avatar
Max Lyon committed
630
  if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Examples/small_mosek_fusion_sdp/CMakeLists.txt" )
631
    add_subdirectory (Examples/small_mosek_fusion_sdp)
David Bommes's avatar
David Bommes committed
632
  endif()
Max Lyon's avatar
Max Lyon committed
633
  if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Examples/small_symmetric_dirichlet/CMakeLists.txt" )
634 635
  add_subdirectory (Examples/small_symmetric_dirichlet)
  endif()
636
  if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Examples/small_exact_constraint_satifaction_example/CMakeLists.txt" )
637 638
  add_subdirectory (Examples/small_exact_constraint_satifaction_example)
  endif()
639

640
endif (COMISO_BUILD_EXAMPLES )
641

642
# Only create install target, when we are building CoMISo standalone
Martin Heistermann's avatar
Martin Heistermann committed
643 644
if(NOT COMISO_NO_INSTALL)

645 646
  include(CMakePackageConfigHelpers)
  include(GNUInstallDirs)
647

648
  set(INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake/CoMISo)
Martin Heistermann's avatar
Martin Heistermann committed
649

650 651 652
  write_basic_package_version_file(
      CoMISoConfigVersion.cmake
      VERSION ${PROJECT_VERSION}
653
      COMPATIBILITY SameMajorVersion)
Martin Heistermann's avatar
Martin Heistermann committed
654

655 656 657
  install(FILES
      "${CMAKE_CURRENT_BINARY_DIR}/CoMISoConfigVersion.cmake"
      DESTINATION ${INSTALL_CONFIGDIR})
658

Jan Möbius's avatar
Jan Möbius committed
659
  # Install library
660
  install(TARGETS CoMISo EXPORT CoMISoTargets
661
          RUNTIME DESTINATION bin
662 663
          LIBRARY DESTINATION lib
          ARCHIVE DESTINATION lib)
Jan Möbius's avatar
Jan Möbius committed
664

665
  # Install Header Files
666
  install(DIRECTORY .
667
          DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/CoMISo # include/CoMISo
668
          FILES_MATCHING
669 670 671 672 673 674 675 676 677 678 679 680
          PATTERN "*.hh"
          PATTERN "*T.cc"
          PATTERN "CVS" EXCLUDE
          PATTERN ".svn" EXCLUDE
          PATTERN ".git" EXCLUDE
          PATTERN "Examples" EXCLUDE
          PATTERN "CI" EXCLUDE
          PATTERN "tmp" EXCLUDE
          PATTERN "Templates" EXCLUDE
          PATTERN "Debian*" EXCLUDE)

  # Install Config File
Jane Tournois's avatar
Jane Tournois committed
681
  install(FILES ${CMAKE_CURRENT_BINARY_DIR}/CoMISo/Config/config.hh
682
          DESTINATION include/CoMISo/Config)
Max Lyon's avatar
Max Lyon committed
683

684
  # Create export target to reference CoMISo installation
Max Lyon's avatar
Max Lyon committed
685
  install(EXPORT CoMISoTargets
686
          FILE CoMISoConfig.cmake
Max Lyon's avatar
Max Lyon committed
687
          NAMESPACE CoMISo::
688
          DESTINATION ${INSTALL_CONFIGDIR})
689

690 691 692 693
  export(EXPORT CoMISoTargets
         NAMESPACE CoMISo::
         FILE CoMISoConfig.cmake)
  export(PACKAGE CoMISo)
694
endif()