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

project(CoMISo)

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

include (ACGCommon)

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

acg_get_version ()

include (ACGOutput)

find_package (GMM)
David Bommes's avatar
David Bommes committed
26
27
28
29
if (GMM_FOUND)
  set (COMISO_GMM_CONFIG_FILE_SETTINGS "#define COMISO_GMM_AVAILABLE 1" )
else()
  set (COMISO_GMM_CONFIG_FILE_SETTINGS "#define COMISO_GMM_AVAILABLE 0" )
30
31
32
33
  message (FATAL_ERROR "GMM not found!")
endif ()

find_package (BLAS)
David Bommes's avatar
David Bommes committed
34
35
36
37
if (BLAS_FOUND )
  set (COMISO_BLAS_CONFIG_FILE_SETTINGS "#define COMISO_BLAS_AVAILABLE 1" )
else()
  set (COMISO_BLAS_CONFIG_FILE_SETTINGS "#define COMISO_BLAS_AVAILABLE 0" )
38
39
40
41
42
  message (FATAL_ERROR "BLAS not found!")
endif ()

#added by CAT
find_package (SUITESPARSE)
43
44
45
46
47
48
49
50
51
52
if (SUITESPARSE_FOUND )
  set (COMISO_SUITESPARSE_CONFIG_FILE_SETTINGS "#define COMISO_SUITESPARSE_AVAILABLE 1" )
else ()
  message (STATUS "SUITESPARSE not found!")
  set (COMISO_SUITESPARSE_CONFIG_FILE_SETTINGS "#define COMISO_SUITESPARSE_AVAILABLE 0" )
endif ()

find_package (MPI)
if (MPI_FOUND )
  set (COMISO_MPI_CONFIG_FILE_SETTINGS "#define COMISO_MPI_AVAILABLE 1" )
53
54
55
56
else ()
  message (STATUS "MPI not found!")
  set (COMISO_MPI_CONFIG_FILE_SETTINGS "#define COMISO_MPI_AVAILABLE 0" )
endif ()
57
58

find_package (PETSC)
59
60
61
62
63
64
if (PETSC_FOUND AND MPI_FOUND)
  set (COMISO_PETSC_CONFIG_FILE_SETTINGS "#define COMISO_PETSC_AVAILABLE 1" )
else ()
  message (STATUS "PETSC not found!")
  set (COMISO_PETSC_CONFIG_FILE_SETTINGS "#define COMISO_PETSC_AVAILABLE 0" )
endif ()
65

66

67
68
69
find_package (TAO)
if (TAO_FOUND AND PETSC_FOUND AND MPI_FOUND)
  set (COMISO_TAO_CONFIG_FILE_SETTINGS "#define COMISO_TAO_AVAILABLE 1" )
70
else ()
71
72
  message (STATUS "TAO not found!")
  set (COMISO_TAO_CONFIG_FILE_SETTINGS "#define COMISO_TAO_AVAILABLE 0" )
73
74
75
76
77
78
79
80
endif ()

find_package (IPOPT)
if (IPOPT_FOUND )
  set (COMISO_IPOPT_CONFIG_FILE_SETTINGS "#define COMISO_IPOPT_AVAILABLE 1" )
else ()
  message (STATUS "IPOPT not found!")
  set (COMISO_IPOPT_CONFIG_FILE_SETTINGS "#define COMISO_IPOPT_AVAILABLE 0" )
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
endif ()

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

include_directories (
  ..
  ${CMAKE_CURRENT_SOURCE_DIR}
  ${CMAKE_CURRENT_BINARY_DIR}
  ${GMM_INCLUDE_DIR}
  ${SUITESPARSE_INCLUDE_DIRS}
106
107
108
109
  ${MPI_INCLUDE_PATH}
  ${PETSC_INCLUDE_DIRS}
  ${TAO_INCLUDE_DIRS}
  ${IPOPT_INCLUDE_DIR}
110
111
112
113
114
115
116
117
118
119
)

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


link_directories (
  ${SUITESPARSE_LIBRARY_DIRS}
120
121
122
123
#  ${MPI_LIBRARY_DIR}
  ${PETSC_LIBRARY_DIR}
  ${TAO_LIBRARY_DIR}
  ${IPOPT_LIBRARY_DIR}
124
125
126
127
128
)

# source code directories
set (directories 
  .
129
130
  Solver
  NSolver
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
  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
170
if( QT4_FOUND)
171
172
173
# genereate uic and moc targets
acg_qt4_autouic (uic_targets ${ui})
acg_qt4_automoc (moc_targets ${headers})
Henrik Zimmer's avatar
Henrik Zimmer committed
174
endif()
175
176
177
178
179
180
181
182
183
184
185
186
187
acg_add_library (CoMISo SHARED ${uic_targets} ${sources} ${headers} ${moc_targets})

if (NOT APPLE)
	target_link_libraries (CoMISo 
	  ${QT_LIBRARIES}
	  ${SUITESPARSE_LIBRARIES}
	  ${BLAS_LIBRARIES}
	)
else(NOT APPLE)
	target_link_libraries (CoMISo
	  ${QT_LIBRARIES}
	  ${SUITESPARSE_LIBRARIES}
	  ${BLAS_LIBRARIES}
188
189
190
191
	  ${PETSC_LIBRARIES}
	  ${TAO_LIBRARIES}
	  ${MPI_LIBRARIES}
	  ${IPOPT_LIBRARIES}
192
193
194
195
196
197
	)
endif(NOT APPLE)

# display results
acg_print_configure_header (COMISO "CoMISo")

198
# write config file
Jan Möbius's avatar
Jan Möbius committed
199
200
201
configure_file ("${CMAKE_CURRENT_SOURCE_DIR}/Config/config.hh.in"
     "${CMAKE_CURRENT_SOURCE_DIR}/Config/config.hh" @ONLY IMMEDIATE)