CMakeLists.txt 23 KB
Newer Older
Max Lyon's avatar
Max Lyon committed
1
cmake_minimum_required (VERSION 3.9)
2 3 4
if (WIN32)
  cmake_minimum_required (VERSION 3.13)
endif()
5

Martin Heistermann's avatar
Martin Heistermann committed
6
project(CoMISo VERSION 1.1.0)
7

David Bommes's avatar
David Bommes committed
8 9 10 11
if(POLICY CMP0100)
  cmake_policy(SET CMP0100 NEW)
endif()

12
# add our macro directory to cmake search path
13
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
Jane Tournois's avatar
Jane Tournois committed
14
set (CMAKE_DEBUG_POSTFIX "d")
15 16 17 18 19 20 21 22

include (ACGCommon)

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

Jan Möbius's avatar
Jan Möbius committed
23
  acg_qt5 ()
24

Jan Möbius's avatar
Jan Möbius committed
25
  if( QT5_FOUND)
26 27 28 29 30
    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()
31

32 33 34 35 36 37 38 39 40 41 42
endif( WANT_COMISO_QT )

acg_get_version ()

include (ACGOutput)

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

43 44
option(COMISO_BUILD_WITHOUT_BOOST "Build CoMISo without boost" OFF)

Max Lyon's avatar
Max Lyon committed
45
FIND_PACKAGE( Boost 1.59.0 COMPONENTS system filesystem regex QUIET)
46
if(Boost_FOUND AND NOT COMISO_BUILD_WITHOUT_BOOST)
47 48 49 50
  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} )
51

52
  option(Boost_USE_STATIC_LIBS "Link with static Boost libraries" OFF)
53 54 55 56 57 58 59 60 61
  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()

62 63
else()
  set (COMISO_BOOST_CONFIG_FILE_SETTINGS "#define COMISO_BOOST_AVAILABLE 0" )
64 65 66 67 68
  if(COMISO_BUILD_WITHOUT_BOOST)
    message (STATUS "Building without boost (COMISO_BUILD_WITHOUT_BOOST flag is set)")
  else()
    message (STATUS "Boost not found!")
  endif()
69 70 71
endif ()


72
find_package (GMM REQUIRED)
73 74 75 76 77 78 79 80
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")
else()
  set (COMISO_GMM_CONFIG_FILE_SETTINGS "#define COMISO_GMM_AVAILABLE 0" )
endif ()

Max Lyon's avatar
Max Lyon committed
81 82
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?
83 84 85
find_package (BLAS)
if (BLAS_FOUND )
  set (COMISO_BLAS_CONFIG_FILE_SETTINGS "#define COMISO_BLAS_AVAILABLE 1" )
86

87 88 89 90 91 92 93
  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} )
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
94
set(CMAKE_FIND_LIBRARY_PREFIXES "${TMP_CMAKE_FIND_LIBRARY_PREFIXES}")
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109

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} )
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")
110

111
  set (COMISO_SUITESPARSE_CONFIG_FILE_SETTINGS "#define COMISO_SUITESPARSE_AVAILABLE 1" )
112

113 114 115
  list( APPEND COMISO_INCLUDE_DIRECTORIES ${SUITESPARSE_INCLUDE_DIRS} )
  list( APPEND COMISO_LINK_DIRECTORIES   ${SUITESPARSE_LIBRARY_DIRS} )
  list( APPEND COMISO_LINK_LIBRARIES  ${SUITESPARSE_LIBRARIES} )
116 117 118 119 120 121 122 123 124

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

125 126 127 128 129 130
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()

131 132 133 134 135 136 137 138 139 140
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} )
  else ()
    message (STATUS "MPI not found!")
    set (COMISO_MPI_CONFIG_FILE_SETTINGS "#define COMISO_MPI_AVAILABLE 0" )
  endif ()
141
else ()
142
  message (STATUS "MPI disabled!")
143 144 145
  set (COMISO_MPI_CONFIG_FILE_SETTINGS "#define COMISO_MPI_AVAILABLE 0" )
endif ()

146 147 148 149 150 151 152 153 154 155
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} )
  else ()
    message (STATUS "PETSC or MPI not found!")
    set (COMISO_PETSC_CONFIG_FILE_SETTINGS "#define COMISO_PETSC_AVAILABLE 0" )
  endif ()
156
else ()
157
  message (STATUS "PETSC disabled!")
158
  set (COMISO_PETSC_CONFIG_FILE_SETTINGS "#define COMISO_PETSC_AVAILABLE 0" )
159
endif()
160 161


162 163 164 165 166 167 168 169 170 171 172
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} )
  else ()
    message (STATUS "TAO or PETSC or MPI not found!")
    set (COMISO_TAO_CONFIG_FILE_SETTINGS "#define COMISO_TAO_AVAILABLE 0" )
  endif ()
173
else ()
174
  message (STATUS "TAO disabled!")
175 176 177 178 179 180
  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" )
181

182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202
  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 ()

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} )
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
203 204 205
  list( APPEND COMISO_INCLUDE_DIRECTORIES ${IPOPT_INCLUDE_DIRS} )
  list( APPEND COMISO_LINK_DIRECTORIES ${IPOPT_LIBRARY_DIRS} )
  list( APPEND COMISO_LINK_LIBRARIES ${IPOPT_LIBRARIES} )
206
  if ( IPOPT_HSL_LIBRARY_DIR )
207
    set (COMISO_HSL_CONFIG_FILE_SETTINGS "#define COMISO_HSL_AVAILABLE 1" )
208
  else ()
209
    set (COMISO_HSL_CONFIG_FILE_SETTINGS "#define COMISO_HSL_AVAILABLE 0" )
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 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 277 278 279 280 281 282 283 284
  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} )
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} )
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} )
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} )
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} )
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} )
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} )
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
285
find_package (Taucs QUIET)
286 287
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
288
  list (APPEND NEED_LAPACK "Taucs")
289 290 291
  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} )
292

293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308
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} )
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
309 310 311 312 313 314 315 316 317 318 319 320
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} )
else ()
  message (STATUS "MOSEK not found!")
  set (COMISO_MOSEK_CONFIG_FILE_SETTINGS "#define COMISO_MOSEK_AVAILABLE 0" )
endif ()


321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336
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 ()

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} )
337

338 339 340 341 342 343 344
  #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
345
set(TMP_CMAKE_FIND_LIBRARY_PREFIXES "${CMAKE_FIND_LIBRARY_PREFIXES}")
346 347
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)
348 349 350 351 352 353 354 355
  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} )
  else()
    message(STATUS "LAPACK not found!")
  endif()
356
endif(NEED_LAPACK AND NOT SUITESPARSE_FOUND)
Max Lyon's avatar
Max Lyon committed
357
set(CMAKE_FIND_LIBRARY_PREFIXES "${TMP_CMAKE_FIND_LIBRARY_PREFIXES}")
358 359

# source code directories
360
set (directories
361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377
  .
  Base/Code
  Base/Debug
  Base/Security
  Base/Utils
  Solver
  NSolver
  EigenSolver
  Config
  Utils
  QtWidgets
)

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

Jan Möbius's avatar
Jan Möbius committed
378
if( QT5_FOUND )
379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397
acg_append_files (ui "*.ui" ${directories})
endif()

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)

Jan Möbius's avatar
Jan Möbius committed
398
if ( QT5_FOUND )
399 400
  # Enable automoc
  set(CMAKE_AUTOMOC ON)
Jan Möbius's avatar
Jan Möbius committed
401
  set(CMAKE_AUTOUIC ON)
402

Jan Möbius's avatar
Jan Möbius committed
403
  list (APPEND COMISO_LINK_LIBRARIES ${QT_LIBRARIES})
Jan Möbius's avatar
Jan Möbius committed
404 405
endif()

406 407 408 409
# TODO: remove this line when we can assume people have a cmake 3.13.
# Then link directories is set as target property below.
link_directories(${COMISO_LINK_DIRECTORIES})

410
acg_add_library (CoMISo SHARED ${ui} ${sources} ${headers} )
411
add_library(CoMISo::CoMISo ALIAS CoMISo)
Jan Möbius's avatar
Jan Möbius committed
412

Martin Heistermann's avatar
Martin Heistermann committed
413 414 415 416 417
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}/>
Max Lyon's avatar
Max Lyon committed
418 419
)

420
target_include_directories(CoMISo PUBLIC "${COMISO_INCLUDE_DIRECTORIES}")
Max Lyon's avatar
Max Lyon committed
421

Martin Heistermann's avatar
Martin Heistermann committed
422 423
#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
424
#message("Target CoMISo include dirs: ${INC_DIRS}")
Martin Heistermann's avatar
Martin Heistermann committed
425
#message("Target CoMISo int include dirs: ${INT_INC_DIRS}")
Martin Heistermann's avatar
Martin Heistermann committed
426 427
#message("COMISO_INCLUDE_DIRECTORIES: ${COMISO_INCLUDE_DIRECTORIES}")
#message("COMISO_LINK_DIRECTORIES: ${COMISO_LINK_DIRECTORIES}")
Max Lyon's avatar
Max Lyon committed
428

Max Lyon's avatar
Max Lyon committed
429
if (COMISO_LINK_DIRECTORIES)
Max Lyon's avatar
Max Lyon committed
430
  set_target_properties(CoMISo PROPERTIES LINK_DIRECTORIES "${COMISO_LINK_DIRECTORIES}")
431
endif()
432 433 434 435
if (WIN32)
#TODO: do this also for non windows platforms as soon as we can require cmake 3.13
  target_link_directories(CoMISo PUBLIC ${COMISO_LINK_DIRECTORIES})
endif()
Max Lyon's avatar
Max Lyon committed
436 437 438 439 440 441 442 443 444 445 446 447 448 449

# 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)
450
  target_compile_definitions(CoMISo PUBLIC -DDEB_ON)
Max Lyon's avatar
Max Lyon committed
451 452 453 454 455 456 457 458 459 460 461 462
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
463 464 465 466
if ( QT5_FOUND )

  if ( NOT WIN32 )
    # Allow targets depending on ACG find the autogenerated header files
Martin Heistermann's avatar
Martin Heistermann committed
467 468
    #target_include_directories( CoMISo PUBLIC
    #                           ${CMAKE_CURRENT_BINARY_DIR}/CoMISo_autogen/include )
Jan Möbius's avatar
Jan Möbius committed
469 470
  else()
     # Allow targets depending on ACG find the autogenerated header files
Martin Heistermann's avatar
Martin Heistermann committed
471 472 473
     #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
474 475
  endif()

476 477
endif()

Max Lyon's avatar
Max Lyon committed
478 479 480
target_link_libraries (CoMISo
  ${COMISO_LINK_LIBRARIES}
)
481 482


Max Lyon's avatar
Max Lyon committed
483 484 485
find_package(NASOQ REQUIRED)
target_link_libraries(CoMISo PUBLIC NASOQ::NASOQ)

486 487 488 489 490 491
# display results
acg_print_configure_header (COMISO "CoMISo")

# write config file
configure_file ("${CMAKE_CURRENT_SOURCE_DIR}/Config/config.hh.in"
     "CoMISo/Config/config.hh" @ONLY IMMEDIATE)
492 493 494



495 496 497 498 499
#######################################################################
# Configure the examples last to be sure, that all configure files
# of the library are already there
#######################################################################

Max Lyon's avatar
Max Lyon committed
500 501 502 503 504
if(${PROJECT_NAME} MATCHES "CoMISo")
  set (COMISO_BUILD_EXAMPLES TRUE CACHE BOOL "Build CoMISo Examples")
else()
  set (COMISO_BUILD_EXAMPLES FALSE CACHE BOOL "Build CoMISo Examples")
endif()
505

506
if (COMISO_BUILD_EXAMPLES )
Max Lyon's avatar
Max Lyon committed
507
  if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Examples/factored_solver/CMakeLists.txt" )
508
    add_subdirectory (Examples/factored_solver)
509
  endif()
Max Lyon's avatar
Max Lyon committed
510
  if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Examples/quadratic_solver/CMakeLists.txt" )
511
    add_subdirectory (Examples/quadratic_solver)
512
  endif()
Max Lyon's avatar
Max Lyon committed
513
  if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Examples/test2/CMakeLists.txt" )
514
    add_subdirectory (Examples/test2)
515
  endif()
Max Lyon's avatar
Max Lyon committed
516
  if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Examples/small_quadratic_example/CMakeLists.txt" )
517
    add_subdirectory (Examples/small_quadratic_example)
518
  endif()
Max Lyon's avatar
Max Lyon committed
519
  if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Examples/small_factored_example/CMakeLists.txt" )
520
    add_subdirectory (Examples/small_factored_example)
521
  endif()
Max Lyon's avatar
Max Lyon committed
522
  if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Examples/super_sparse_matrix/CMakeLists.txt" )
523
    add_subdirectory (Examples/super_sparse_matrix)
524
  endif()
Max Lyon's avatar
Max Lyon committed
525
  if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Examples/eigen_solver/CMakeLists.txt" )
526
    add_subdirectory (Examples/eigen_solver)
527
  endif()
Max Lyon's avatar
Max Lyon committed
528
  if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Examples/small_nsolver/CMakeLists.txt" )
529
    add_subdirectory (Examples/small_nsolver)
530
  endif()
Max Lyon's avatar
Max Lyon committed
531
  if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Examples/small_eigenproblem/CMakeLists.txt" )
532
    add_subdirectory (Examples/small_eigenproblem)
533
  endif()
Max Lyon's avatar
Max Lyon committed
534
  if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Examples/small_miqp/CMakeLists.txt" )
535
    add_subdirectory (Examples/small_miqp)
536
  endif()
Max Lyon's avatar
Max Lyon committed
537
  if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Examples/small_nleast_squares/CMakeLists.txt" )
538
    add_subdirectory (Examples/small_nleast_squares)
539
  endif()
Max Lyon's avatar
Max Lyon committed
540
  if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Examples/small_sparseqr/CMakeLists.txt" )
541
    add_subdirectory (Examples/small_sparseqr)
542
  endif()
Max Lyon's avatar
Max Lyon committed
543
  if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Examples/small_quadratic_resolve_example/CMakeLists.txt" )
544
    add_subdirectory (Examples/small_quadratic_resolve_example)
545
  endif()
Max Lyon's avatar
Max Lyon committed
546
  if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Examples/small_cplex_soc/CMakeLists.txt" )
547
    add_subdirectory (Examples/small_cplex_soc)
548
  endif()
Max Lyon's avatar
Max Lyon committed
549
  if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Examples/small_adolc/CMakeLists.txt" )
550
    add_subdirectory (Examples/small_adolc)
551
  endif()
Max Lyon's avatar
Max Lyon committed
552
  if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Examples/small_dco/CMakeLists.txt" )
553
    add_subdirectory (Examples/small_dco)
554
  endif()
Max Lyon's avatar
Max Lyon committed
555
  if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Examples/vector1_adolc/CMakeLists.txt" )
556
    add_subdirectory (Examples/vector1_adolc)
557
  endif()
Max Lyon's avatar
Max Lyon committed
558
  if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Examples/small_linear_problem/CMakeLists.txt" )
559
    add_subdirectory (Examples/small_linear_problem)
560
  endif()
Max Lyon's avatar
Max Lyon committed
561
  if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Examples/crossfield3d/CMakeLists.txt" )
562
    add_subdirectory (Examples/crossfield3d)
563
  endif()
Max Lyon's avatar
Max Lyon committed
564
  if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Examples/crossfield3d/CMakeLists.txt" )
565
    add_subdirectory (Examples/crossfield3d_dco)
566
  endif()
Max Lyon's avatar
Max Lyon committed
567
  if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Examples/small_finite_element/CMakeLists.txt" )
568
    add_subdirectory (Examples/small_finite_element)
569
  endif()
Max Lyon's avatar
Max Lyon committed
570
  if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Examples/small_AQP/CMakeLists.txt" )
571
    add_subdirectory (Examples/small_AQP)
572
  endif()
Max Lyon's avatar
Max Lyon committed
573
  if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Examples/finite_element_integrability_problem/CMakeLists.txt" )
574
    add_subdirectory (Examples/finite_element_integrability_problem)
David Bommes's avatar
David Bommes committed
575
  endif()
Max Lyon's avatar
Max Lyon committed
576
  if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Examples/small_mosek_native/CMakeLists.txt" )
577
    add_subdirectory (Examples/small_mosek_native)
David Bommes's avatar
David Bommes committed
578
  endif()
Max Lyon's avatar
Max Lyon committed
579
  if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Examples/small_mosek_fusion_sdp/CMakeLists.txt" )
580
    add_subdirectory (Examples/small_mosek_fusion_sdp)
David Bommes's avatar
David Bommes committed
581
  endif()
Max Lyon's avatar
Max Lyon committed
582
  if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Examples/small_symmetric_dirichlet/CMakeLists.txt" )
583 584
  add_subdirectory (Examples/small_symmetric_dirichlet)
  endif()
585
  if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Examples/small_exact_constraint_satifaction_example/CMakeLists.txt" )
586 587
  add_subdirectory (Examples/small_exact_constraint_satifaction_example)
  endif()
588

589
endif (COMISO_BUILD_EXAMPLES )
590

591
# Only create install target, when we are building CoMISo standalone
Martin Heistermann's avatar
Martin Heistermann committed
592 593
if(NOT COMISO_NO_INSTALL)

594 595
  include(CMakePackageConfigHelpers)
  include(GNUInstallDirs)
596 597 598 599 600 601 602
  
  target_include_directories(CoMISo
    PUBLIC
        $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
        $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/CoMISo>
  )
  
603
  set(INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake/CoMISo)
Martin Heistermann's avatar
Martin Heistermann committed
604

605 606 607
  write_basic_package_version_file(
      CoMISoConfigVersion.cmake
      VERSION ${PROJECT_VERSION}
608
      COMPATIBILITY SameMajorVersion)
Martin Heistermann's avatar
Martin Heistermann committed
609

610 611 612
  install(FILES
      "${CMAKE_CURRENT_BINARY_DIR}/CoMISoConfigVersion.cmake"
      DESTINATION ${INSTALL_CONFIGDIR})
613

Jan Möbius's avatar
Jan Möbius committed
614
  # Install library
615 616 617 618
  install(TARGETS CoMISo EXPORT CoMISoTargets
          RUNTIME DESTINATION lib
          LIBRARY DESTINATION lib
          ARCHIVE DESTINATION lib)
Jan Möbius's avatar
Jan Möbius committed
619

620
  # Install Header Files
621
  install(DIRECTORY .
622
          DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/CoMISo # include/CoMISo
623
          FILES_MATCHING
624 625 626 627 628 629 630 631 632 633 634 635
          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
636
  install(FILES ${CMAKE_CURRENT_BINARY_DIR}/CoMISo/Config/config.hh
637
          DESTINATION include/CoMISo/Config)
Max Lyon's avatar
Max Lyon committed
638

639
  # Create export target to reference CoMISo installation
Max Lyon's avatar
Max Lyon committed
640
  install(EXPORT CoMISoTargets
641
          FILE CoMISoConfig.cmake
Max Lyon's avatar
Max Lyon committed
642
          NAMESPACE CoMISo::
643
          DESTINATION ${INSTALL_CONFIGDIR})
644

645 646 647 648
  export(EXPORT CoMISoTargets
         NAMESPACE CoMISo::
         FILE CoMISoConfig.cmake)
  export(PACKAGE CoMISo)
649
endif()
650

651
list(REMOVE_AT CMAKE_MODULE_PATH -1)