-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathCMakeLists.txt
361 lines (322 loc) · 12.5 KB
/
CMakeLists.txt
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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
78
79
80
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
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
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
# Set project's name
PROJECT( agros2d )
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
# For Win64
if(${CMAKE_CL_64})
set(WIN64 YES)
set(CMAKE_EXE_LINKER_FLAGS "/machine:X64")
SET (CMAKE_SHARED_LINKER_FLAGS "/machine:X64")
SET (CMAKE_MODULE_LINKER_FLAGS "/machine:X64")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /DWIN64")
else(${CMAKE_CL_64})
set(WIN64 NO)
endif(${CMAKE_CL_64})
# Policy handling
if(POLICY CMP0020)
cmake_policy(PUSH)
cmake_policy(SET CMP0020 OLD)
endif()
if (POLICY CMP0043)
cmake_policy(PUSH)
cmake_policy(SET CMP0043 OLD)
endif (POLICY CMP0043)
# Debug yes / no.
SET(AGROS_DEBUG NO)
SET(WITH_QT5 YES)
SET(CMAKE_AGROS_DIRECTORY "${CMAKE_HOME_DIRECTORY}/")
set(WITH_OPENMP YES)
# Allow to override the default values in CMake.vars:
INCLUDE(CMake.vars OPTIONAL)
# OpenGL
FIND_PACKAGE(OpenGLCustom REQUIRED)
# Handle Qt.
include(QtHandling.cmake)
# versions
SET(VERSION_MAJOR 3)
SET(VERSION_MINOR 2)
SET(VERSION_SUB 0)
# git revision
#execute_process(COMMAND git rev-list HEAD --count OUTPUT_VARIABLE NUMBER_OF_COMMITS)
#STRING(REGEX REPLACE "(\r?\n)+$" "" VERSION_GIT "${NUMBER_OF_COMMITS}")
# date
MACRO (TODAY RESULT)
IF (WIN32)
# EXECUTE_PROCESS(COMMAND "date" "/T" OUTPUT_VARIABLE ${RESULT})
EXECUTE_PROCESS(COMMAND "date" "+%d/%m/%Y" OUTPUT_VARIABLE ${RESULT})
string(REGEX REPLACE "(..)/(..)/..(..).*" "\\3\\2\\1" ${RESULT} ${${RESULT}})
ELSEIF (UNIX)
EXECUTE_PROCESS(COMMAND "date" "+%d/%m/%Y" OUTPUT_VARIABLE ${RESULT})
string(REGEX REPLACE "(..)/(..)/..(..).*" "\\3\\2\\1" ${RESULT} ${${RESULT}})
ELSE (WIN32)
MESSAGE(SEND_ERROR "date not implemented")
SET(${RESULT} 000000)
ENDIF (WIN32)
ENDMACRO (TODAY)
TODAY(RESULT)
string(SUBSTRING ${RESULT} 0 2 YEAR)
string(SUBSTRING ${RESULT} 2 2 MONTH)
string(SUBSTRING ${RESULT} 4 2 DAY)
SET(VERSION_YEAR 20${YEAR})
SET(VERSION_MONTH ${MONTH})
SET(VERSION_DAY ${DAY})
# Naming of projects built.
SET(AGROS_UTIL agros2d_util)
SET(PYTHONLAB_LIBRARY agros2d_pythonlab_library)
SET(PYTHONLAB_BINARY pythonlab_binary)
SET(AGROS_LIBRARY agros2d_library)
SET(AGROS_SOLVER agros2d_solver)
SET(AGROS_GENERATOR agros2d_generator)
SET(AGROS_BINARY agros2d_binary)
SET(AGROS_REMOTE agros2d_remote)
SET(PARALUTION_LIBRARY agros2d_3dparty_paralution)
SET(BSON_LIBRARY agros2d_3dparty_bson)
SET(CTEMPLATE_LIBRARY agros2d_3dparty_ctemplate)
SET(DXFLIB_LIBRARY agros2d_3dparty_dxflib)
SET(POLY2TRI_LIBRARY agros2d_3dparty_poly2tri)
SET(QCUSTOMPLOT_LIBRARY agros2d_3dparty_qcustomplot)
SET(QUAZIP_LIBRARY agros2d_3dparty_quazip)
SET(STB_TRUETYPE_LIBRARY agros2d_3dparty_stb_truetype)
SET(QTSINGLEAPPLICATION_LIBRARY agros2d_3dparty_qtsingleapplication)
SET(MATIO_LIBRARY agros2d_3dparty_matio)
SET(TRIANGLE_LIBRARY agros2d_3dparty_triangle)
SET(AGROS_SOLVER_EXTERNAL solver_external)
# Hermes and Hermes common
IF(MSVC)
IF(WIN64)
SET(HERMES_COMMON_LIBRARY hermes_common_64)
SET(HERMES_LIBRARY hermes2d_64)
ELSE(WIN64)
SET(HERMES_COMMON_LIBRARY hermes_common)
SET(HERMES_LIBRARY hermes2d)
ENDIF(WIN64)
ELSE(MSVC)
IF(AGROS_DEBUG)
SET(HERMES_COMMON_LIBRARY hermes_common-debug)
SET(HERMES_LIBRARY hermes2d-debug)
ElSE(AGROS_DEBUG)
SET(HERMES_COMMON_LIBRARY hermes_common)
SET(HERMES_LIBRARY hermes2d)
ENDIF(AGROS_DEBUG)
ENDIF()
# Output paths.
SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_AGROS_DIRECTORY})
SET(LIBRARY_OUTPUT_PATH ${CMAKE_AGROS_DIRECTORY}/libs)
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_AGROS_DIRECTORY})
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_AGROS_DIRECTORY}/libs)
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_AGROS_DIRECTORY}/libs)
IF(WIN32)
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_AGROS_DIRECTORY})
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_AGROS_DIRECTORY})
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_AGROS_DIRECTORY}/libs)
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_AGROS_DIRECTORY}/libs)
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${CMAKE_AGROS_DIRECTORY}/libs)
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${CMAKE_AGROS_DIRECTORY}/libs)
ENDIF(WIN32)
# Set global compiler parameters.
IF (WITH_OPENMP)
IF(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
ELSE()
find_package(OpenMP REQUIRED)
ENDIF()
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
ENDIF()
IF(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wno-deprecated")
INCLUDE_DIRECTORIES(/usr/include/google)
ENDIF()
IF(MSVC)
INCLUDE_DIRECTORIES(c:/hpfem/hermes/dependencies/include)
INCLUDE_DIRECTORIES(d:/hpfem/hermes/dependencies/include)
SET(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /NODEFAULTLIB:libcmtd /NODEFAULTLIB:libcmt")
ENDIF(MSVC)
# Python
FIND_PACKAGE(PythonLibs 2.7 REQUIRED)
INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_DIR})
# Include current dir
SET(CMAKE_INCLUDE_CURRENT_DIR ON)
# Turn on Unicode
ADD_DEFINITIONS(-DUNICODE -D_UNICODE)
# Enable debugging symbols for all files all the time:
IF(AGROS_DEBUG)
IF(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
# Disable all warnings and turn on only important ones:
# SET(CMAKE_CXX_FLAGS "-w ${CMAKE_CXX_FLAGS} -fPIC")
# SET(CMAKE_CXX_FLAGS "-Wuninitialized -Wvla -Wsign-compare ${CMAKE_CXX_FLAGS}")
SET(DEBUG_FLAGS "-g")
SET(CMAKE_BUILD_TYPE Debug)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${DEBUG_FLAGS}")
ENDIF()
ElSE(AGROS_DEBUG)
IF(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
SET(CMAKE_BUILD_TYPE Release)
SET(RELEASE_FLAGS "-DNDEBUG -g -O3 -Ofast")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${RELEASE_FLAGS}")
ADD_DEFINITIONS(-DQT_NO_DEBUG_OUTPUT)
ENDIF()
ENDIF(AGROS_DEBUG)
# This overrides CXX flags for MSVC
IF(MSVC)
# On MSVC, we will always use Debug, otherwise the plugins do not work.
SET(CMAKE_BUILD_TYPE Debug)
SET(MSVC_DEFINES "/DWIN32 /D_WINDOWS /Dpopen=_popen /Dpclose=_pclose /D__value=_value /Dfinite=_finite /Dhypot=_hypot /Disatty=_isatty /Dfileno=_fileno /D_CRT_SECURE_NO_WARNINGS /MP")
SET(CMAKE_CXX_FLAGS_DEBUG_INIT "/D_DEBUG /Od /Ob2 /MDd /Zi ${MSVC_DEFINES}")
SET(CMAKE_CXX_FLAGS_RELEASE_INIT "/DNDEBUG /O2 /Ob2 /MD ${MSVC_DEFINES}")
SET (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SAFESEH:NO")
SET (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SAFESEH:NO")
SET (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /SAFESEH:NO")
ENDIF(MSVC)
# Create file with preprocessor definitions exposing the build settings to the source code.
configure_file(
util/config.h.cmake
util/config.h)
configure_file(
resources_source/resources.rc.cmake
resources_source/resources.rc)
# Include OUR header files location
INCLUDE(IncludeSubdirs.cmake)
# Subdirectories.
ADD_SUBDIRECTORY(3rdparty)
# Also looks for Xerces, UMFPACK, etc.
ADD_SUBDIRECTORY(hermes)
# Include external directories.
INCLUDE_DIRECTORIES(${UMFPACK_INCLUDE_DIR})
INCLUDE_DIRECTORIES(${AMESOS_INCLUDE_PATH})
INCLUDE_DIRECTORIES(${AZTECOO_INCLUDE_PATH})
INCLUDE_DIRECTORIES(${EPETRA_INCLUDE_PATH})
INCLUDE_DIRECTORIES(${IFPACK_INCLUDE_PATH})
INCLUDE_DIRECTORIES(${LOCA_INCLUDE_PATH})
INCLUDE_DIRECTORIES(${ML_INCLUDE_PATH})
INCLUDE_DIRECTORIES(${NOX_INCLUDE_PATH})
INCLUDE_DIRECTORIES(${TEUCHOS_INCLUDE_PATH})
INCLUDE_DIRECTORIES(${KOMPLEX_INCLUDE_PATH})
INCLUDE_DIRECTORIES(${LOCA_EPETRA_INCLUDE_PATH})
INCLUDE_DIRECTORIES(${NOX_EPETRA_INCLUDE_PATH})
INCLUDE_DIRECTORIES(${EPETRAEXT_INCLUDE_PATH})
if(WITH_MPI)
find_package(MPI REQUIRED)
include_directories(${MPI_INCLUDE_PATH})
endif(WITH_MPI)
message("CMake: Start Agros2D")
message("=====================")
ADD_SUBDIRECTORY(util)
ADD_SUBDIRECTORY(pythonlab-library)
ADD_SUBDIRECTORY(pythonlab-binary)
ADD_SUBDIRECTORY(agros2d-library)
ADD_SUBDIRECTORY(agros2d-binary)
ADD_SUBDIRECTORY(agros2d-solver)
ADD_SUBDIRECTORY(agros2d-generator)
ADD_SUBDIRECTORY(agros2d-remote)
ADD_SUBDIRECTORY(solver-external)
#ADD_SUBDIRECTORY(agros2d-forms)
message("\nAgros2D Configuration results")
message("---------------------")
message(" Version: ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_SUB}")
IF(AGROS_DEBUG)
message(" Build version: Debug")
ELSE(AGROS_DEBUG)
message(" Build version: Release")
ENDIF(AGROS_DEBUG)
message("---------Qt---------")
IF(WITH_QT5)
message(" Build with Qt5")
ELSE(WITH_QT5)
message(" Build with Qt4")
message(" Qt use file: ${QT_USE_FILE}")
message(" Qt definitions: ${QT_DEFINITIONS}")
message(" Qt libraries: ${QT_LIBRARIES}")
ENDIF(WITH_QT5)
message("---------------------")
message("\n")
# pixmap
FILE(GLOB PIXMAP_FILES "resources/images/agros2d.xpm")
# desktop
FILE(GLOB DESKTOP_FILES "agros2d.desktop")
# resources
SET(RESOURCES_FILES "resources")
# share
INSTALL(FILES ${PIXMAP_FILES} DESTINATION ${CMAKE_INSTALL_PREFIX}/share/pixmaps)
INSTALL(FILES ${DESKTOP_FILES} DESTINATION ${CMAKE_INSTALL_PREFIX}/share/applications)
INSTALL(DIRECTORY ${RESOURCES_FILES} DESTINATION ${CMAKE_INSTALL_PREFIX}/share/agros2d)
# other files
MACRO(ADD_INFO_FILES)
FOREACH(_it ${ARGN})
IF(NOT IS_DIRECTORY ${_it})
GET_FILENAME_COMPONENT(name ${_it} NAME)
IF(NOT ${_it} MATCHES "^/\\\\..*$;~$")
SET_SOURCE_FILES_PROPERTIES(${_it} PROPERTIES HEADER_FILE_ONLY TRUE)
ENDIF()
ENDIF()
ENDFOREACH()
ENDMACRO()
set(info resources/modules/acoustic.xml
resources/modules/current.xml
resources/modules/elasticity.xml
resources/modules/electrostatic.xml
resources/modules/flow.xml
resources/modules/heat.xml
resources/modules/magnetic.xml
resources/modules/rf_te.xml
resources/modules/rf_tm.xml
resources/modules/richards.xml
resources/couplings/current-heat.xml
resources/couplings/heat-elasticity.xml
resources/couplings/magnetic-heat.xml
resources/couplings/flow-heat.xml
resources/python/functions_agros2d.py
resources/python/functions_pythonlab.py
resources/templates/generator/coupling_CMakeLists_txt.tpl
resources/templates/generator/coupling_interface_cpp.tpl
resources/templates/generator/coupling_interface_h.tpl
resources/templates/generator/filter_cpp.tpl
resources/templates/generator/filter_h.tpl
resources/templates/generator/errorcalculator_cpp.tpl
resources/templates/generator/errorcalculator_h.tpl
resources/templates/generator/force_cpp.tpl
resources/templates/generator/force_h.tpl
resources/templates/generator/localvalue_h.tpl
resources/templates/generator/localvalue_cpp.tpl
resources/templates/generator/surfaceintegral_cpp.tpl
resources/templates/generator/surfaceintegral_h.tpl
resources/templates/generator/volumeintegral_cpp.tpl
resources/templates/generator/volumeintegral_h.tpl
resources/templates/generator/interface_h.tpl
resources/templates/generator/module_CMakeLists_txt.tpl
resources/templates/generator/weakform_cpp.tpl
resources/templates/generator/weakform_h.tpl
resources/templates/generator/extfunction_cpp.tpl
resources/templates/generator/extfunction_h.tpl
resources/templates/generator/plugins_CMakeLists_txt.tpl
resources/templates/generator/interface_cpp.tpl
resources/templates/generator/doc_index.tpl
resources/templates/generator/equations.tpl
resources/templates/generator/equations.tex
resources/templates/panels/empty.tpl
resources/templates/panels/example_form.tpl
resources/templates/panels/example_problem.tpl
resources/templates/panels/example_python.tpl
resources/templates/panels/integrals.tpl
resources/templates/panels/local_point_values.tpl
resources/templates/panels/material.tpl
resources/templates/panels/problem.tpl
resources/templates/panels/welcome.tpl
resources/templates/panels/style_common.css
resources/templates/panels/style_results.css
resources_source/python/agros2d.pyx
resources_source/python/pyfield.pxi
resources_source/python/pygeometry.pxi
resources_source/python/pyparticletracing.pxi
resources_source/python/pyproblem.pxi
resources_source/python/pythonlab.pyx
resources_source/python/pyview.pxi
)
add_info_files(${info})
add_custom_target(other SOURCES ${info})
# Policy handling
if(POLICY CMP0020)
cmake_policy(POP)
endif()
if (POLICY CMP0043)
cmake_policy(POP)
endif (POLICY CMP0043)