-
Notifications
You must be signed in to change notification settings - Fork 56
/
CMakeLists.txt
539 lines (469 loc) · 22.1 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
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
# This is the CMake script for compiling MEPP
# Martial TOLA - February 2016
IF(APPLE) #cmake .. -DCMAKE_C_FLAGS='-arch x86_64 -arch i386'
cmake_minimum_required(VERSION 2.8)
else(APPLE)
cmake_minimum_required(VERSION 2.6)
endif(APPLE)
if (WITH_QT5)
cmake_minimum_required(VERSION 2.8.9) # because 2.8.8 has a bug with QT5_USE_MODULES
endif(WITH_QT5)
# Find includes in corresponding build directories
#set(CMAKE_INCLUDE_CURRENT_DIR ON)
if (COMMAND cmake_policy)
cmake_policy(SET CMP0003 NEW)
IF(POLICY CMP0017)
cmake_policy(SET CMP0017 NEW)
ENDIF(POLICY CMP0017)
IF(POLICY CMP0020)
cmake_policy(SET CMP0020 NEW)
ENDIF(POLICY CMP0020)
if(POLICY CMP0042)
cmake_policy(SET CMP0042 NEW) # https://cmake.org/cmake/help/v3.0/policy/CMP0042.html
endif(POLICY CMP0042)
if(POLICY CMP0043)
cmake_policy(SET CMP0043 OLD)
endif(POLICY CMP0043)
if(POLICY CMP0053)
cmake_policy(SET CMP0053 OLD)
endif(POLICY CMP0053)
if(POLICY CMP0054)
cmake_policy(SET CMP0054 OLD)
endif(POLICY CMP0054)
endif (COMMAND cmake_policy)
# Project configuration
set(PRJ_NAME mepp)
set(PRJ_VERSION 0.52.1) # TODO
project( ${PRJ_NAME} )
set(CMAKE_INSTALL_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/${PRJ_NAME}_deploy_${PRJ_VERSION}")
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
set(DOC_DIR ${CMAKE_CURRENT_BINARY_DIR}/doc)
# set Release as default build target
if (NOT CMAKE_BUILD_TYPE)
set (CMAKE_BUILD_TYPE Release CACHE STRING
"Choose the type of build, options are: Debug, Release."
FORCE)
endif ()
message("Build type : ${CMAKE_BUILD_TYPE}")
OPTION(USE_FFMPEG "Use FFmpeg (only on windows)" OFF)
#------------------------------------------------------------------------------
# Specific compiler options
#------------------------------------------------------------------------------
# Clang (export CXX=clang++ CC=clang)
#------------------------------------------------------------------------------
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Qunused-arguments")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Qunused-arguments")
message(STATUS "Clang compiler detected")
if ( ${CMAKE_BUILD_TYPE} MATCHES "Debug" )
# SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wdocumentation")
endif( ${CMAKE_BUILD_TYPE} MATCHES "Debug" )
endif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
#ELO+beg
if(CMAKE_COMPILER_IS_GNUCXX)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
endif()
#ELO+end
#------------------------------------------------------------------------------
# MSVC
#------------------------------------------------------------------------------
# /MP for multiple compilation units (cl.exe) ; without any value, it is set automatically depending on your number of main threads
# If you are compiling on Windows, the preprocessor symbols 'min' or 'max' are defined. Do #define NOMINMAX to prevent windows.h from defining these symbols.
if(MSVC)
SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP /D \"NOMINMAX\"")
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS _CRT_SECURE_NO_WARNINGS)
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS _SCL_SECURE_NO_WARNINGS)
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "16") # 16 = vs2010
include( "${CMAKE_SOURCE_DIR}/cmake/msvc/kit.cmake" )
endif()
endif()
#----------------------------------------------------------------------------
# APPLE OS X
#----------------------------------------------------------------------------
if(APPLE)
set(CMAKE_MACOSX_RPATH ON) # see cmake POLICY CMP0042
endif(APPLE)
#----------------------------------------------------------------------------
file(
GLOB_RECURSE
mepp_components
src/components/*/CMakeLists.txt
src/private_components/*/CMakeLists.txt
)
FOREACH (MEPP_COMPONENT ${mepp_components})
get_filename_component (MEPP_COMPONENT_DIR "${MEPP_COMPONENT}" PATH)
get_filename_component (MEPP_SHORT_COMPONENT_NAME "${MEPP_COMPONENT_DIR}" NAME)
set(MEPP_COMPONENT_NAME component_${MEPP_SHORT_COMPONENT_NAME})
message(STATUS "FIND MEPP_COMPONENT_DIR: ${MEPP_COMPONENT_DIR}")
if ("${MEPP_COMPONENT_NAME}" STREQUAL "component_MSDM2") # component_MSDM2 not working with cgal >= 4.9
OPTION(BUILD_${MEPP_COMPONENT_NAME} "Build ${MEPP_COMPONENT_NAME} " OFF)
else()
OPTION(BUILD_${MEPP_COMPONENT_NAME} "Build ${MEPP_COMPONENT_NAME} " ON)
endif()
if (BUILD_${MEPP_COMPONENT_NAME})
ADD_SUBDIRECTORY(${MEPP_COMPONENT_DIR})
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/src/mepp/_enrichment_.in/polyhedron_enrichment_define.h.in ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/h.tmp/polyhedron_enrichment_define_${MEPP_SHORT_COMPONENT_NAME}.h)
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/src/mepp/_enrichment_.in/polyhedron_enrichment_include.h.in ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/h.tmp/polyhedron_enrichment_include_${MEPP_SHORT_COMPONENT_NAME}.h)
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/src/mepp/_enrichment_.in/polyhedron_enrichment_facet.h.in ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/h.tmp/polyhedron_enrichment_facet_${MEPP_SHORT_COMPONENT_NAME}.h)
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/src/mepp/_enrichment_.in/polyhedron_enrichment_halfedge.h.in ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/h.tmp/polyhedron_enrichment_halfedge_${MEPP_SHORT_COMPONENT_NAME}.h)
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/src/mepp/_enrichment_.in/polyhedron_enrichment_vertex.h.in ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/h.tmp/polyhedron_enrichment_vertex_${MEPP_SHORT_COMPONENT_NAME}.h)
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/src/mepp/_enrichment_.in/polyhedron_enrichment_polyhedron.h.in ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/h.tmp/polyhedron_enrichment_polyhedron_${MEPP_SHORT_COMPONENT_NAME}.h)
else (BUILD_${MEPP_COMPONENT_NAME})
FILE( REMOVE ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/h.tmp/polyhedron_enrichment_define_${MEPP_SHORT_COMPONENT_NAME}.h)
FILE( REMOVE ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/h.tmp/polyhedron_enrichment_include_${MEPP_SHORT_COMPONENT_NAME}.h)
FILE( REMOVE ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/h.tmp/polyhedron_enrichment_facet_${MEPP_SHORT_COMPONENT_NAME}.h)
FILE( REMOVE ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/h.tmp/polyhedron_enrichment_halfedge_${MEPP_SHORT_COMPONENT_NAME}.h)
FILE( REMOVE ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/h.tmp/polyhedron_enrichment_vertex_${MEPP_SHORT_COMPONENT_NAME}.h)
FILE( REMOVE ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/h.tmp/polyhedron_enrichment_polyhedron_${MEPP_SHORT_COMPONENT_NAME}.h)
endif (BUILD_${MEPP_COMPONENT_NAME})
ENDFOREACH(MEPP_COMPONENT)
if (WIN32)
set(CAT gnu_cat.bat)
set(BASH "")
else (WIN32)
set(CAT cat.sh)
set(BASH bash)
endif (WIN32)
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/src/mepp/mepp_config.h.in ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/include/mepp_config.h)
Execute_process(COMMAND ${BASH} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/${CAT} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/ ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/h.tmp/polyhedron_enrichment_define_ ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/include/polyhedron_enrichment_define h)
Execute_process(COMMAND ${BASH} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/${CAT} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/ ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/h.tmp/polyhedron_enrichment_include_ ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/include/polyhedron_enrichment_include h)
Execute_process(COMMAND ${BASH} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/${CAT} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/ ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/h.tmp/polyhedron_enrichment_facet_ ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/include/polyhedron_enrichment_facet h)
Execute_process(COMMAND ${BASH} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/${CAT} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/ ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/h.tmp/polyhedron_enrichment_halfedge_ ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/include/polyhedron_enrichment_halfedge h)
Execute_process(COMMAND ${BASH} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/${CAT} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/ ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/h.tmp/polyhedron_enrichment_vertex_ ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/include/polyhedron_enrichment_vertex h)
Execute_process(COMMAND ${BASH} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/${CAT} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/ ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/h.tmp/polyhedron_enrichment_polyhedron_ ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/include/polyhedron_enrichment_polyhedron h)
INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/include )
INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR}/src/mepp )
# Find Boost
find_package(Boost)
if(Boost_FOUND)
include_directories(${Boost_INCLUDE_DIRS})
endif(Boost_FOUND)
# Find CGAL libraries
set(CGAL_DONT_OVERRIDE_CMAKE_FLAGS TRUE CACHE BOOL "Prevent CGAL to override CMAKE flags")
FIND_PACKAGE(CGAL COMPONENTS Core)
IF(CGAL_FOUND)
INCLUDE(${CGAL_USE_FILE})
MESSAGE(STATUS "Found CGAL: ${CGAL_LIBRARIES}")
MESSAGE(STATUS "Found CGAL 3RD PARTY LIBRARIES: ${CGAL_3RD_PARTY_LIBRARIES}")
ELSE(CGAL_FOUND)
MESSAGE(FATAL_ERROR "CGAL not found. Please set CGAL_DIR.")
ENDIF(CGAL_FOUND)
# Find OpenMesh library
#if (OPENMESH_DIR)
# set( ENV{OPENMESH_DIR} ${OPENMESH_DIR} )
#endif()
#find_package(OpenMesh)
#if(OPENMESH_FOUND)
# include_directories(${OPENMESH_INCLUDE_DIR})
#else(OPENMESH_FOUND)
# message(FATAL_ERROR "OpenMesh not found. Please set OPENMESH_DIR.")
#endif(OPENMESH_FOUND)
# Find QT4/QT5 libraries
if (WITH_QT5)
# QT5 Handling
if(DEFINED ENV{QT5_DIR})
set( QT5_DIR $ENV{QT5_DIR} )
endif()
SET(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${QT5_DIR})
# Instruct CMake to run moc automatically when needed
set(CMAKE_AUTOMOC ON)
FIND_PACKAGE(Qt5Core)
if(${Qt5Core_FOUND})
message(STATUS "--> Qt5Core found.")
FIND_PACKAGE(Qt5Widgets)
if(${Qt5Widgets_FOUND})
message(STATUS "--> Qt5Widgets found.")
FIND_PACKAGE(Qt5Xml)
if(${Qt5Xml_FOUND})
message(STATUS "--> Qt5Xml found.")
FIND_PACKAGE(Qt5OpenGL)
if(${Qt5OpenGL_FOUND})
message(STATUS "--> Qt5OpenGL found.")
if (WITH_QT3D)
FIND_PACKAGE(Qt53D)
if(${Qt53D_FOUND})
message(STATUS "--> Qt53D found.")
else(${Qt53D_FOUND})
message(FATAL_ERROR "Qt53D not found.")
endif(${Qt53D_FOUND})
endif(WITH_QT3D)
else(${Qt5OpenGL_FOUND})
message(FATAL_ERROR "Qt5OpenGL not found.")
endif(${Qt5OpenGL_FOUND})
else(${Qt5Xml_FOUND})
message(FATAL_ERROR "Qt5Xml not found.")
endif(${Qt5Xml_FOUND})
else(${Qt5Widgets_FOUND})
message(FATAL_ERROR "Qt5Widgets not found.")
endif(${Qt5Widgets_FOUND})
else(${Qt5Core_FOUND})
message(FATAL_ERROR "Qt5Core not found. Please set QT5_DIR.")
endif(${Qt5Core_FOUND})
else(WITH_QT5)
# QT4 Handling
if (QTDIR)
set( ENV{QTDIR} ${QTDIR} )
endif()
set( QT_USE_QTMAIN TRUE )
set( QT_USE_QTXML TRUE )
set( QT_USE_QTOPENGL TRUE )
FIND_PACKAGE(Qt4)
if(QT4_FOUND)
INCLUDE(${QT_USE_FILE})
else(QT4_FOUND)
message(FATAL_ERROR "Qt4 not found. Please set QTDIR.")
endif(QT4_FOUND)
endif(WITH_QT5)
message("Qt version used : ${QTDIR}")
# Find OpenGL
find_package(OpenGL REQUIRED)
include_directories(${OPENGL_INCLUDE_DIR})
if (APPLE)
INCLUDE_DIRECTORIES(/usr/X11/include)
endif (APPLE)
# Find GLEW (for OpenGL-1.5 and OpenGL extensions)
#find_package(GLEW)
# Find QGLViewer
if (QGLVIEWERROOT)
set( ENV{QGLVIEWERROOT} ${QGLVIEWERROOT} )
endif()
find_package(QGLViewer)
if(QGLVIEWER_FOUND)
include_directories(${QGLVIEWER_INCLUDE_DIR})
else(QGLVIEWER_FOUND)
message(FATAL_ERROR "QGLViewer not found. Please set QGLVIEWERROOT.")
endif(QGLVIEWER_FOUND)
# Find XercesC
find_package(XercesC)
if (XERCESC_FOUND)
set (XML_PARSER_INCLUDE_DIR ${XERCESC_INCLUDE_DIR})
set (XML_PARSER_LIBRARY ${XERCESC_LIBRARIES})
else(XERCESC_FOUND)
message(FATAL_ERROR "XercesC not found. Please set XERCESC_ROOT_DIR.")
endif(XERCESC_FOUND)
# Find FFmpeg
if (FFMPEG_DIR)
set( ENV{FFMPEG_DIR} ${FFMPEG_DIR} )
endif()
find_package(FFmpeg)
if (FFMPEG_FOUND)
set(my_COMPILE_DEFINITIONS ${my_COMPILE_DEFINITIONS} ";WITH_FFMPEG")
else(FFMPEG_FOUND)
message(STATUS "FFmpeg (optional) (but only on windows) not found. Please first set USE_FFMPEG variable to ON and then set FFMPEG_DIR.")
endif(FFMPEG_FOUND)
# Find ASSIMP
find_package(ASSIMP)
if(ASSIMP_FOUND)
include_directories(${ASSIMP_INCLUDE_PATH})
set(my_COMPILE_DEFINITIONS ${my_COMPILE_DEFINITIONS} ";WITH_ASSIMP")
else(ASSIMP_FOUND)
message(STATUS "ASSIMP (optional) not found. Please set ASSIMP_ROOT_DIR.")
endif(ASSIMP_FOUND)
include_directories ( ${XML_PARSER_INCLUDE_DIR} )
if (GLEW_FOUND)
include_directories ( ${GLEW_INCLUDE_PATH} )
else(GLEW_FOUND)
# message(STATUS "NOTICE: GLEW library is not found. VBO rendering will not be available.")
endif(GLEW_FOUND)
if (FFMPEG_FOUND)
include_directories ( ${FFMPEG_INCLUDE_DIRS} )
endif (FFMPEG_FOUND)
file(
GLOB_RECURSE
hxx_header_files
src/mepp/*.hxx
)
file(
GLOB_RECURSE
all_ui_files
src/mepp/*.ui
)
if (WITH_QT5)
set( MOC_FILES "" ) # because CMAKE_AUTOMOC is ON
qt5_wrap_ui( UI_FILES ${all_ui_files} )
qt5_add_resources( RESOURCE_FILES src/mepp/mepp.qrc )
else(WITH_QT5)
qt4_wrap_cpp( MOC_FILES ${hxx_header_files} OPTIONS -DBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION -DBOOST_TT_HAS_OPERATOR_HPP_INCLUDED )
qt4_wrap_ui( UI_FILES ${all_ui_files} )
qt4_add_resources( RESOURCE_FILES src/mepp/mepp.qrc )
endif(WITH_QT5)
# Configuration de l'exécutable
file(
GLOB_RECURSE
source_files
src/mepp/*
)
# For Windows set the ico file with the rc file
IF(WIN32)
SET(source_files ${source_files} ${CMAKE_CURRENT_SOURCE_DIR}/src/mepp/Pictures/${PRJ_NAME}.rc)
ENDIF(WIN32)
# For Apple set the icns file containing icons
IF(APPLE)
# set how it shows up in the Info.plist file
SET(MACOSX_BUNDLE_ICON_FILE ${PRJ_NAME}.icns)
# set where in the bundle to put the icns file
SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_SOURCE_DIR}/src/mepp/Pictures/${PRJ_NAME}.icns PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
# include the icns file in the target
SET(source_files ${source_files} ${CMAKE_CURRENT_SOURCE_DIR}/src/mepp/Pictures/${PRJ_NAME}.icns)
ENDIF(APPLE)
add_executable(
${PRJ_NAME} MACOSX_BUNDLE
${source_files}
${MOC_FILES}
${UI_FILES}
${RESOURCE_FILES}
)
if (WITH_QT5)
set(my_COMPILE_DEFINITIONS ${my_COMPILE_DEFINITIONS} ";WITH_QT5")
endif(WITH_QT5)
SET_TARGET_PROPERTIES(${PRJ_NAME} PROPERTIES COMPILE_DEFINITIONS "${my_COMPILE_DEFINITIONS}")
# Configuration de l'édition de liens
# Link with Qt libraries
if (WITH_QT5)
QT5_USE_MODULES( ${PRJ_NAME} Widgets Xml OpenGL )
else(WITH_QT5)
target_link_libraries( ${PRJ_NAME} ${QT_LIBRARIES} )
endif(WITH_QT5)
# Link with CGAL
target_link_libraries( ${PRJ_NAME} ${CGAL_LIBRARIES} ${CGAL_3RD_PARTY_LIBRARIES} )
# Link with libQGLViewer, OpenGL
target_link_libraries( ${PRJ_NAME} ${QGLVIEWER_LIBRARIES} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY} )
# Link with ASSIMP
if(ASSIMP_FOUND)
target_link_libraries( ${PRJ_NAME} ${ASSIMP_LIBRARY} )
endif(ASSIMP_FOUND)
# Link with XercesC
target_link_libraries( ${PRJ_NAME} ${XML_PARSER_LIBRARY} )
# Link with OpenMesh
if (OPENMESH_FOUND)
target_link_libraries( ${PRJ_NAME} ${OPENMESH_LIBRARIES} )
endif (OPENMESH_FOUND)
if (GLEW_FOUND)
target_link_libraries( ${PRJ_NAME} ${GLEW_LIBRARIES} )
endif(GLEW_FOUND)
if (FFMPEG_FOUND)
target_link_libraries( ${PRJ_NAME} ${FFMPEG_LIBRARIES} )
endif (FFMPEG_FOUND)
#Documentation
#option(BUILD_doc_${PRJ_NAME} "Build Doxygen documentation for ${PRJ_NAME}" ON)
#if(BUILD_doc_${PRJ_NAME})
include(TargetDoc)
#endif(BUILD_doc_${PRJ_NAME})
if (WITH_QT5)
if( NOT DEFINED QT_PLUGINS_DIR )
set( QT_PLUGINS_DIR "${QT5_DIR}/plugins" )
endif( NOT DEFINED QT_PLUGINS_DIR )
endif(WITH_QT5)
IF(WIN32)
#--------------------------------------------------------------------------------
# Copy Qt plugins to 'Debug and Release' directories and configure qt.conf file
#--------------------------------------------------------------------------------
file (GLOB qtplugin_dirs RELATIVE "${QT_PLUGINS_DIR}" "${QT_PLUGINS_DIR}/imageformats*" "${QT_PLUGINS_DIR}/platforms*" )
file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/Debug/QtPlugins" )
file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/Release/QtPlugins" )
foreach (qtplugin ${qtplugin_dirs})
file(COPY "${QT_PLUGINS_DIR}/${qtplugin}" DESTINATION "${CMAKE_BINARY_DIR}/Debug/QtPlugins")
file(COPY "${QT_PLUGINS_DIR}/${qtplugin}" DESTINATION "${CMAKE_BINARY_DIR}/Release/QtPlugins")
endforeach ()
file(WRITE "@CMAKE_BINARY_DIR@/Debug/qt.conf" "[Paths]\nPlugins = QtPlugins")
file(WRITE "@CMAKE_BINARY_DIR@/Release/qt.conf" "[Paths]\nPlugins = QtPlugins")
ENDIF(WIN32)
#--------------------------------------------------------------------------------
# Now the installation stuff : http://www.cmake.org/Wiki/BundleUtilitiesExample
#--------------------------------------------------------------------------------
SET(plugin_dest_dir .)
SET(qtconf_dest_dir .)
SET(APPS "\${CMAKE_INSTALL_PREFIX}/${PRJ_NAME}")
IF(APPLE)
SET(plugin_dest_dir ${PRJ_NAME}.app/Contents/MacOS)
SET(qtconf_dest_dir ${PRJ_NAME}.app/Contents/Resources)
SET(APPS "\${CMAKE_INSTALL_PREFIX}/${PRJ_NAME}.app")
ENDIF(APPLE)
IF(WIN32)
SET(APPS "\${CMAKE_INSTALL_PREFIX}/${PRJ_NAME}.exe")
ENDIF(WIN32)
#--------------------------------------------------------------------------------
# Install the application, on Apple, the bundle is at the root of the
# install tree, and on other platforms it'll go to the same directory.
INSTALL(TARGETS ${PRJ_NAME}
BUNDLE DESTINATION . COMPONENT ${PRJ_NAME}
RUNTIME DESTINATION . COMPONENT ${PRJ_NAME}
)
#--------------------------------------------------------------------------------
# Install needed Qt plugins by copying directories from the qt installation
# One can cull what gets copied by using 'REGEX "..." EXCLUDE'
INSTALL(DIRECTORY "${QT_PLUGINS_DIR}/imageformats" DESTINATION ${plugin_dest_dir}/plugins COMPONENT ${PRJ_NAME})
if (WITH_QT5)
INSTALL(DIRECTORY "${QT_PLUGINS_DIR}/platforms" DESTINATION ${plugin_dest_dir}/plugins COMPONENT ${PRJ_NAME})
endif(WITH_QT5)
# OSG plugins
if(OPENSCENEGRAPH_FOUND)
INCLUDE(BundleOSGPlugins)
install_osg_plugins( osg_plugins )
MESSAGE( STATUS "OSG plugins: " ${osg_plugins} )
endif(OPENSCENEGRAPH_FOUND)
#--------------------------------------------------------------------------------
# install a qt.conf file
# this inserts some cmake code into the install script to write the file
INSTALL(CODE "
file(WRITE \"\${CMAKE_INSTALL_PREFIX}/${qtconf_dest_dir}/qt.conf\" \"[Paths]\nPlugins = plugins\")
" COMPONENT ${PRJ_NAME})
IF(APPLE)
INSTALL(CODE "
file(WRITE \"\${CMAKE_INSTALL_PREFIX}/${qtconf_dest_dir}/qt.conf\" \"[Paths]\nPlugins = MacOS/plugins\")
" COMPONENT ${PRJ_NAME})
ENDIF(APPLE)
# install qt_menu.nib (APPLE)
IF(APPLE)
IF(EXISTS ${QT_LIBRARY_DIR}/Resources/qt_menu.nib)
INSTALL(CODE "execute_process(COMMAND cp -R \"${QT_LIBRARY_DIR}/Resources/qt_menu.nib\" \"${qtconf_dest_dir}\"
WORKING_DIRECTORY \$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX})")
ELSE(EXISTS ${QT_LIBRARY_DIR}/Resources/qt_menu.nib)
IF(EXISTS ${QT_LIBRARY_DIR}/QtGui.framework/Resources/qt_menu.nib)
INSTALL(CODE "execute_process(COMMAND cp -R \"${QT_LIBRARY_DIR}/QtGui.framework/Resources/qt_menu.nib\" \"${qtconf_dest_dir}\"
WORKING_DIRECTORY \$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX})")
ENDIF(EXISTS ${QT_LIBRARY_DIR}/QtGui.framework/Resources/qt_menu.nib)
ENDIF(EXISTS ${QT_LIBRARY_DIR}/Resources/qt_menu.nib)
ENDIF(APPLE)
#--------------------------------------------------------------------------------
# Use BundleUtilities to get all other dependencies for the application to work.
# It takes a bundle or executable along with possible plugins and inspects it
# for dependencies. If they are not system dependencies, they are copied.
# directories to look for dependencies
SET(DIRS ${QT_LIBRARY_DIRS})
# Now the work of copying dependencies into the bundle/package
# The quotes are escaped and variables to use at install time have their $ escaped
# An alternative is the do a configure_file() on a script and use install(SCRIPT ...).
# Note that the image plugins depend on QtSvg and QtXml, and it got those copied
# over.
INSTALL(CODE "
file(GLOB_RECURSE PLUGINS
\"\${CMAKE_INSTALL_PREFIX}/${plugin_dest_dir}/plugins/*${CMAKE_SHARED_LIBRARY_SUFFIX}\" \"\${CMAKE_INSTALL_PREFIX}/${plugin_dest_dir}/osgPlugins-${OPENSCENEGRAPH_VERSION}/osgdb_*${CMAKE_SHARED_LIBRARY_SUFFIX}\" \"\${CMAKE_INSTALL_PREFIX}/${plugin_dest_dir}/*component_*${CMAKE_SHARED_LIBRARY_SUFFIX}\")
include(BundleUtilities)
fixup_bundle(\"${APPS}\" \"\${PLUGINS}\" \"${DIRS}\")
" COMPONENT ${PRJ_NAME})
# CPack Configuration
set(CPACK_PACKAGE_NAME ${PRJ_NAME})
set(CPACK_PACKAGE_VERSION ${PRJ_VERSION})
set(CPACK_PACKAGE_VENDOR "Liris / CNRS")
#set(CPACK_PACKAGE_DESCRIPTION_FILE ${CMAKE_CURRENT_SOURCE_DIR}/README)
#set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/licence_gpl_v3.txt)
# To Create a package, one can run "cpack -G DragNDrop CPackConfig.cmake" on Mac OS X
# where CPackConfig.cmake is created by including CPack
# And then there's ways to customize this as well
IF(APPLE)
set(CPACK_BINARY_DRAGNDROP ON)
set(CPACK_BINARY_TGZ "OFF")
set(CPACK_BINARY_STGZ "OFF")
set(CPACK_BINARY_PACKAGEMAKER "OFF")
include(CPack)
ENDIF(APPLE)
IF(WIN32)
set(CPACK_GENERATOR "NSIS64")
set(CPACK_NSIS_MENU_LINKS "${PRJ_NAME}" "${PRJ_NAME}")
#MESSAGE( STATUS "PRJ_NAME: " ${PRJ_NAME} )
include(CPack)
ENDIF(WIN32)
#--------------------------------------------------------------------------------
# Now the installation stuff : end
#--------------------------------------------------------------------------------