CMakeLists.txt 22.2 KB
Newer Older
1
2
include (ACGCommon)

Jan Möbius's avatar
Jan Möbius committed
3

4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
include_directories (
  ..
  ${OPENMESH_INCLUDE_DIRS}
  ${ACG_INCLUDE_DIR}
  ${CMAKE_SOURCE_DIR}
  ${CMAKE_CURRENT_SOURCE_DIR}
  ${CMAKE_CURRENT_BINARY_DIR}
  ${OPENGL_INCLUDE_DIR}
)

# Linking for apple is special here as the linker pulls in the dependencies, we have to set them like in PluginLib!
if( APPLE )

  # search all ObjectTypes in the ObjectType directory for additional build information
  file (
     GLOB _plugin_buildinfos
     RELATIVE "${CMAKE_SOURCE_DIR}"
     "${CMAKE_SOURCE_DIR}/ObjectTypes/*/CMakeLists.txt"
     "${CMAKE_SOURCE_DIR}/Package*/ObjectTypes/*/CMakeLists.txt"
  )


Jan's avatar
Jan committed
26
  # include all cmake files found for objecttypes here
27
28
29
30
31
32
33
34
35
  foreach ( _buildInfo ${_plugin_buildinfos})
    include ("${CMAKE_SOURCE_DIR}/${_buildInfo}")
  endforeach ()

  link_directories (
    ${ADDITIONAL_PLUGINLIB_LINK_DIRS}
  )
endif(APPLE)

Jan Möbius's avatar
Jan Möbius committed
36
37
38
39
40
41
# collect all header,source and ui files
set (headers
  ../Core/Core.hh 
  ../Core/OpenFunctionThread.hh 
  ../Core/PluginInfo.hh 
  ../Core/SpinBoxEventFilter.hh 
42
  ../CommandLine/CommandLineParser.hh
43
44
  ../Logging/PluginLogging.hh
  ../OpenGL/OpenGLDetection.hh 
Jan Möbius's avatar
Jan Möbius committed
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
  ../Scripting/ScriptingWrapper.hh 
  ../Scripting/scriptPrototypes/prototypeDataType.hh 
  ../Scripting/scriptPrototypes/prototypeIdList.hh 
  ../Scripting/scriptPrototypes/prototypeMatrix4x4.hh 
  ../Scripting/scriptPrototypes/prototypeVec3d.hh 
  ../Scripting/scriptPrototypes/prototypeVec4d.hh 
  ../Scripting/scriptWrappers/DataTypeWrapper.hh 
  ../Scripting/scriptWrappers/idListWrapper.hh 
  ../Scripting/scriptWrappers/matrix4x4Wrapper.hh 
  ../Scripting/scriptWrappers/vec3dWrapper.hh 
  ../Scripting/scriptWrappers/vec4dWrapper.hh 
  ../widgets/aboutWidget/aboutWidget.hh 
  ../widgets/addEmptyWidget/addEmptyWidget.hh 
  ../widgets/loggerWidget/loggerWidget.hh 
  ../widgets/coreWidget/ColorStatusBar.hh 
  ../widgets/coreWidget/CoreWidget.hh 
  ../widgets/coreWidget/SideArea.hh 
  ../widgets/coreWidget/SideElement.hh 
  ../widgets/helpWidget/helpBrowser.hh 
  ../widgets/helpWidget/helpWidget.hh 
  ../widgets/processManagerWidget/BlockingWidget.hh 
  ../widgets/processManagerWidget/processManagerWidget.hh 
  ../widgets/loadWidget/FileOptionsDialog.hh 
  ../widgets/loadWidget/loadWidget.hh 
  ../widgets/optionsWidget/ShortcutButton.hh 
  ../widgets/optionsWidget/optionsWidget.hh 
  ../widgets/PluginDialog/PluginDialog.hh 
  ../widgets/viewModeWidget/viewModeChangeWidget.hh 
  ../widgets/viewModeWidget/viewModeWidget.hh 
  ../widgets/videoCaptureDialog/VideoCaptureDialog.hh 
  ../widgets/snapshotDialog/SnapshotDialog.hh 
  ../widgets/stereoSettingsWidget/stereoSettingsWidget.hh 
  ../widgets/postProcessorWidget/postProcessorWidget.hh 
  ../widgets/rendererWidget/TextBrowserWidget.hh 
  ../widgets/rendererWidget/renderObjectHighLighter.hh 
  ../widgets/rendererWidget/rendererObjectWidget.hh 
  ../widgets/rendererWidget/rendererWidget.hh
  ../widgets/pythonWidget/PythonSyntaxHighlighter.hh
  ../widgets/pythonWidget/pythonWidget.hh
84
  ../Windows/windows-startup.hh
Jan Möbius's avatar
Jan Möbius committed
85
86
87
88
89
90
91
  ../PythonInterpreter/PythonInterpreter.hh
  ../PythonInterpreter/PythonTypeConversions.hh
)

set( sources
    ../OpenFlipper.cc
    ../Core/BackupCommunication.cc
92
    ../CommandLine/CommandLineParser.cc
Jan Möbius's avatar
Jan Möbius committed
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
    ../Core/Core.cc
    ../Core/Logging.cc
    ../Core/OpenFunctionThread.cc
    ../Core/ParseIni.cc
    ../Core/ParseObj.cc
    ../Core/PluginCommunication.cc
    ../Core/PluginLoader.cc
    ../Core/RPC.cc
    ../Core/SelectionCommunication.cc
    ../Core/SpinBoxEventFilter.cc
    ../Core/Video.cc
    ../Core/openFunctions.cc
    ../Core/optionHandling.cc
    ../Core/process.cc
    ../Core/saveFunctions.cc
    ../Core/saveSettings.cc
    ../Core/scripting.cc
    ../Logging/PluginLogging.cc
    ../Scripting/ScriptingWrapper.cc
    ../Scripting/scriptPrototypes/prototypeDataType.cc
    ../Scripting/scriptPrototypes/prototypeIdList.cc
    ../Scripting/scriptPrototypes/prototypeMatrix4x4.cc
    ../Scripting/scriptPrototypes/prototypeVec3d.cc
    ../Scripting/scriptPrototypes/prototypeVec4d.cc
    ../Scripting/scriptWrappers/DataTypeWrapper.cc
    ../Scripting/scriptWrappers/idListWrapper.cc
    ../Scripting/scriptWrappers/matrix4x4Wrapper.cc
    ../Scripting/scriptWrappers/vec3dWrapper.cc
    ../Scripting/scriptWrappers/vec4dWrapper.cc
    ../widgets/aboutWidget/aboutWidget.cc
    ../widgets/addEmptyWidget/addEmptyWidget.cc
    ../widgets/loggerWidget/loggerWidget.cc
    ../widgets/coreWidget/About.cc
    ../widgets/coreWidget/ColorStatusBar.cc
    ../widgets/coreWidget/ContextMenu.cc
    ../widgets/coreWidget/CoreLicenseInfos.cc
    ../widgets/coreWidget/CoreWidget.cc
    ../widgets/coreWidget/CoreWidgetLogging.cc
    ../widgets/coreWidget/CoreWidgetToolbar.cc
    ../widgets/coreWidget/Help.cc
    ../widgets/coreWidget/LoggerHandling.cc
    ../widgets/coreWidget/MenuBar.cc
    ../widgets/coreWidget/Python.cc
    ../widgets/coreWidget/SideArea.cc
    ../widgets/coreWidget/SideElement.cc
    ../widgets/coreWidget/StackWidget.cc
    ../widgets/coreWidget/StatusBar.cc
    ../widgets/coreWidget/dragAndDrop.cc
    ../widgets/coreWidget/keyHandling.cc
    ../widgets/coreWidget/picking.cc
    ../widgets/coreWidget/postProcessorDialog.cc
    ../widgets/coreWidget/rendererDialog.cc
    ../widgets/coreWidget/viewMode.cc
    ../widgets/coreWidget/viewerControl.cc
    ../widgets/helpWidget/helpBrowser.cc
    ../widgets/helpWidget/helpWidget.cc
    ../widgets/processManagerWidget/BlockingWidget.cc
    ../widgets/processManagerWidget/processManagerWidget.cc
    ../widgets/loadWidget/FileOptionsDialog.cc
    ../widgets/loadWidget/loadWidget.cc
    ../widgets/optionsWidget/ShortcutButton.cc
    ../widgets/optionsWidget/downloader.cc
    ../widgets/optionsWidget/keyBindings.cc
    ../widgets/optionsWidget/optionsWidget.cc
    ../widgets/PluginDialog/PluginDialog.cc
    ../widgets/viewModeWidget/viewModeChangeWidget.cc
    ../widgets/viewModeWidget/viewModeWidget.cc
    ../widgets/videoCaptureDialog/VideoCaptureDialog.cc
    ../widgets/snapshotDialog/SnapshotDialog.cc
    ../widgets/stereoSettingsWidget/stereoSettingsWidget.cc
    ../widgets/postProcessorWidget/postProcessorWidget.cc
    ../widgets/pythonWidget/PythonSyntaxHighlighter.cc
    ../widgets/pythonWidget/pythonWidget.cc
    ../widgets/rendererWidget/TextBrowserWidget.cc
    ../widgets/rendererWidget/renderObjectHighLighter.cc
    ../widgets/rendererWidget/rendererObjectWidget.cc
    ../widgets/rendererWidget/rendererWidget.cc
170
)
Jan Möbius's avatar
Jan Möbius committed
171

Jan Möbius's avatar
Jan Möbius committed
172
if (WIN32)	
Jan's avatar
Jan committed
173
	LIST(APPEND sources "../Windows/StackWalker/StackWalker.cc")
Jan's avatar
Jan committed
174
	LIST(APPEND sources "../Windows/windows-startup.cc")
Jan's avatar
Jan committed
175
	LIST(APPEND headers "../Windows/StackWalker/StackWalker.hh")
Jan's avatar
Jan committed
176
	LIST(APPEND headers "../Windows/windows-startup.hh")
Jan Möbius's avatar
Jan Möbius committed
177
178
endif(WIN32)

179
180

if ( PYTHON3_FOUND)
Jan Möbius's avatar
Jan Möbius committed
181
182
183
184
  include_directories (
    ${Python3_INCLUDE_DIRS}
  )

Jan Möbius's avatar
Jan Möbius committed
185
186
187
188
189
190
191
192
  list(APPEND headers 
     ../PythonInterpreter/PythonInterpreter.hh
     ../PythonInterpreter/PythonTypeConversions.hh
  )

  list(APPEND sources
     ../PythonInterpreter/PythonInterpreter.cc
  )
193
194
195
    
  link_directories(${Python3_LIBRARY_DIRS})
  add_definitions(-DPYTHON_ENABLED )
Jan Möbius's avatar
Jan Möbius committed
196
  
Jan Möbius's avatar
Jan Möbius committed
197
  message("OpenFlipper builds with Python interpreter")
Jan Möbius's avatar
Jan Möbius committed
198
199
endif()

200

Jan Möbius's avatar
Jan Möbius committed
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
set( uifiles 
../widgets/aboutWidget/aboutWidget.ui
../widgets/addEmptyWidget/addEmpty.ui
../widgets/helpWidget/helpWidget.ui
../widgets/processManagerWidget/processManagerWidget.ui
../widgets/optionsWidget/optionsWidget.ui
../widgets/PluginDialog/pluginDialog.ui
../widgets/viewModeWidget/viewMode.ui
../widgets/viewModeWidget/viewModeChange.ui
../widgets/videoCaptureDialog/VideoCaptureDialog.ui
../widgets/snapshotDialog/SnapshotDialog.ui
../widgets/stereoSettingsWidget/stereoSettingsWidget.ui
../widgets/postProcessorWidget/postProcessorWidget.ui
../widgets/pythonWidget/pythonWidget.ui
../widgets/rendererWidget/rendererObjectWidget.ui
../widgets/rendererWidget/rendererWidget.ui
)
218
219
220
221
222
223
224
225
226
227

set(RC_SRC "")

if ( EXISTS ${BRANDING_DIRECTORY}/branding.qrc )
        if ( QT5_FOUND )
            QT5_ADD_RESOURCES(BRANDING_RC_SRC "${BRANDING_DIRECTORY}/branding.qrc")
            list(APPEND RC_SRC ${BRANDING_RC_SRC})
        endif()
endif()

Jan's avatar
Jan committed
228
229
230
231

# =======================================================
# Generate import file for static plugins
# =======================================================
232
233
234
235
236
237
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/static_plugins.cc" "#include <QtPlugin>\n\n")

foreach (plugin ${OPENFLIPPER_STATIC_PLUGIN_NAMES})
file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/static_plugins.cc" "Q_IMPORT_PLUGIN(${plugin});\n")
endforeach()

Jan's avatar
Jan committed
238
239

# Create a static variable containing plugin filenames to skip the dynamic version while loading plugins.
240
241
242
243
244
245
246
247
248
249
250
251
file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/static_plugins.cc" "\nnamespace cmake {\n")

file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/static_plugins.cc" "\nconst char *static_plugins = \"\"\n")

foreach (plugin ${OPENFLIPPER_STATIC_PLUGIN_FILES})
  file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/static_plugins.cc" "\"${plugin}\\n\"\n")
endforeach()

file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/static_plugins.cc" ";\n} /* namespace cmake */\n")

list(APPEND RC_SRC "${CMAKE_CURRENT_BINARY_DIR}/static_plugins.cc")

Jan's avatar
Jan committed
252
253
254
255
256


# =======================================================
# Sort files into one OpenFLipper Tree in the IDE
# =======================================================
Jan Möbius's avatar
Jan Möbius committed
257
source_group(TREE ${CMAKE_SOURCE_DIR} FILES ${sources} ${headers} ${uifiles} ) 
258

Jan's avatar
Jan committed
259
260
261
262

# =======================================================
# Create Executable file
# =======================================================
263
264
if (WIN32)
  # add app icon rc file to windows build
265
  acg_add_executable (${OPENFLIPPER_PRODUCT_STRING} WIN32 ${CMAKE_CURRENT_SOURCE_DIR}/CoreApp.rc ${sources} ${headers} ${RC_SRC})
266
267
268
269
  # link to qtmain library to get WinMain function for a non terminal app
  target_link_libraries (${OPENFLIPPER_PRODUCT_STRING} ${QT_QTMAIN_LIBRARY})
elseif (APPLE)
  # generate bundle on mac
270
  acg_add_executable (${OPENFLIPPER_PRODUCT_STRING} MACOSX_BUNDLE ${sources} ${headers} ${RC_SRC})
271
else ()
Jan Möbius's avatar
Jan Möbius committed
272
  acg_add_executable (${OPENFLIPPER_PRODUCT_STRING} ${sources} ${headers} ${RC_SRC} )
273
274
endif ()

Jan's avatar
Jan committed
275

Jan Möbius's avatar
Jan Möbius committed
276
if ( PYTHON3_FOUND)
277
  target_link_libraries(${OPENFLIPPER_PRODUCT_STRING} ${PYTHON_LIBRARY} pybind11::module pybind11::embed Python3::Python )
Jan Möbius's avatar
Jan Möbius committed
278
279
endif()

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
# Mark this build part as building OpenFlippers Core
add_definitions(-DOPENFLIPPERCORE )

# Build app store compliant
if ( OPENFLIPPER_BUILD_APP_STORE_COMPLIANT )
   add_definitions( -DOPENFLIPPER_BUILD_APP_STORE_COMPLIANT )
endif()


if (WIN32)
  add_definitions( -DACGDLL
                   -DUSEACG 
                   -DPLUGINLIBDLL
                   -DUSEPLUGINLIBDLL
                   )
endif ()


set ( CATCH_SIGSEGV True CACHE BOOL "Whether SIGSEGV should be catched. Set this to false in order to get a core dump with usable call stack. Set to true in order to get a stack trace at the time of crash." )
if (NOT CATCH_SIGSEGV)
    add_definitions( -DNO_CATCH_SIGSEGV )
endif()




# ====================================================================================
Jan's avatar
Jan committed
307
# Get list of plugin dependencies and handle special ones
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
# where we need to link the library directly into the core to prevent 
# linker problems
# ====================================================================================

# Get the property containing the list of all dependencies of the plugins
# List is created when the plugins are added
get_property( global_dependency_list GLOBAL PROPERTY GLOBAL_PLUGIN_DEPENDENCIES_LIST)

set(COREAPP_ADDITIONAL_LINK_LIBRARIES "")

# Get additional libraries from plugins that should be linked into the core
get_property( global_core_app_libraries GLOBAL PROPERTY GLOBAL_CORE_APP_LIBRARIES)
foreach (_val ${global_core_app_libraries})
  list(APPEND COREAPP_ADDITIONAL_LINK_LIBRARIES ${_val})
endforeach ()

# Special Handling for mpi
list( FIND global_dependency_list "MPI" found)
if ( NOT found EQUAL -1 )
  find_package(MPI)
  if ( MPI_FOUND )
    list(APPEND COREAPP_ADDITIONAL_LINK_LIBRARIES  ${MPI_LIBRARIES})
  endif()
endif()

# Special Handling for openni
list( FIND global_dependency_list "OPENNI" found)
if ( NOT found EQUAL -1 )
  find_package(OPENNI)
  if ( OPENNI_FOUND )
    list(APPEND COREAPP_ADDITIONAL_LINK_LIBRARIES  ${OPENNI_LIBRARY})
  endif()
endif()

# use Qwt6 for QT5
if (QT5_FOUND)
  find_package(Qwt6)

  if (QWT6_FOUND)
    add_definitions(-DWITH_QWT)
    set(INCLUDE_DIRS ${INCLUDE_DIRS} ${QWT6_INCLUDE_DIRS} )
    set(COREAPP_ADDITIONAL_LINK_LIBRARIES ${COREAPP_ADDITIONAL_LINK_LIBRARIES} ${QWT6_LIBRARIES})
  endif()

endif()


# ====================================================================================
# Linker Dependencies for Core app
# ====================================================================================

target_link_libraries (${OPENFLIPPER_PRODUCT_STRING}
  ACG
  OpenFlipperPluginLib
  ${QT_LIBRARIES}
  ${OPENGL_LIBRARIES}
  ${COREAPP_ADDITIONAL_LINK_LIBRARIES}
  ${OPENFLIPPER_STATIC_PLUGINS}
Jan Möbius's avatar
Jan Möbius committed
366
  libglew_shared
367
368
)

Jan Möbius's avatar
Jan Möbius committed
369

370
371
372
373
374
375
376
377
378
379
380
381
382
if (APPLE)

   if ( EXISTS ${BRANDING_DIRECTORY} )

     # Take bundle icon from branding dir
     IF ( NOT APPLE_BUNDLE_ICON )

        # Check if the branding directory contains an Icon 
        if ( EXISTS ${BRANDING_DIRECTORY}/mac/OpenFlipper_Icon.icns )
          # Use branding Icon
          set ( APPLE_BUNDLE_ICON ${BRANDING_DIRECTORY}/mac/OpenFlipper_Icon.icns CACHE FILEPATH "Path to the Bundle Icon" )
        else()
          # Use default icon
Jan Möbius's avatar
Jan Möbius committed
383
          set ( APPLE_BUNDLE_ICON ${CMAKE_CURRENT_SOURCE_DIR}/../Icons/OpenFlipper_Icon.icns CACHE FILEPATH "Path to the Bundle Icon" )
Jan Möbius's avatar
Jan Möbius committed
384
          message (WARNING "Branding directory found but no branding icon called OpenFlipper_Icon.icns. Using default icon! You can set your icon via APPLE_BUNDLE_ICON")
385
386
387
388
389
390
391
392
393
394
395
        endif()
     ENDIF(NOT APPLE_BUNDLE_ICON )    
 
     # Take plist from branding 
     IF ( NOT APPLE_INFO_PLIST )
       if ( EXISTS ${BRANDING_DIRECTORY}/mac/Info.plist )
         # Take custom plist from branding directory
         set ( APPLE_INFO_PLIST ${BRANDING_DIRECTORY}/mac/Info.plist CACHE FILEPATH "Path to the Info.plist file for Bundle" )
       else ( EXISTS ${BRANDING_DIRECTORY}/mac/Info.plist )
         # Take default plist from OpenFlipper
         set ( APPLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/../installer/mac/Info.plist CACHE FILEPATH "Path to the Info.plist file for Bundle" )
Jan Möbius's avatar
Jan Möbius committed
396
          message (WARNING "Branding directory found but no branding plist file found. Using default. You can set your own plist via APPLE_INFO_PLIST")
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
       endif( EXISTS ${BRANDING_DIRECTORY}/mac/Info.plist )
     ENDIF(NOT APPLE_INFO_PLIST )

  else()

    IF ( NOT APPLE_BUNDLE_ICON )
        # option to set the used Icon for OpenFlipper
        if ( EXISTS ${BRANDING_DIRECTORY}/Icons/OpenFlipper_Icon.icns )
          set ( APPLE_BUNDLE_ICON " ${BRANDING_DIRECTORY}/Icons/OpenFlipper_Icon.icns" CACHE FILEPATH "Path to the Bundle Icon" )
        else()
          set ( APPLE_BUNDLE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/../Icons/OpenFlipper_Icon.icns" CACHE FILEPATH "Path to the Bundle Icon" )
        endif()
    ENDIF(NOT APPLE_BUNDLE_ICON )

    IF ( NOT APPLE_INFO_PLIST )
        # option to configure a custum Info.plist but configure with default one
        set ( APPLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/../installer/mac/Info.plist" CACHE FILEPATH "Path to the Info.plist file for Bundle" )
    ENDIF(NOT APPLE_INFO_PLIST )

  endif()
 
  add_custom_command(TARGET ${OPENFLIPPER_PRODUCT_STRING} POST_BUILD                                                              
    COMMAND ${CMAKE_COMMAND} -E copy_if_different "${APPLE_BUNDLE_ICON}" "${CMAKE_BINARY_DIR}/Build/${ACG_PROJECT_DATADIR}/OpenFlipper.icns"            
  )    

  # create bundle in "Build" directory and set icon
  # no install needed here, because the whole bundle will be installed in the
  # toplevel CMakeLists.txt
  set_target_properties (
      ${OPENFLIPPER_PRODUCT_STRING} PROPERTIES
       
      RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/Build/"
      RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/Build/"
      RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/Build/"
      MACOSX_BUNDLE_INFO_STRING "ACG OpenFlipper"
      MACOSX_BUNDLE_ICON_FILE "OpenFlipper.icns"
      MACOSX_BUNDLE_INFO_PLIST ${APPLE_INFO_PLIST}
  )  

endif ()

# Translations
set (trans_files ${sources})
list (APPEND trans_files ${ui})
list (APPEND trans_files ${headers})
acg_add_translations (${OPENFLIPPER_PRODUCT_STRING} "de_DE" "${trans_files}")


# copy all needed files to "Build" directory to allow a direct execution from it
# the copy_after_build macro (common.cmake) copies the whole directory without svn files
acg_copy_after_build (${OPENFLIPPER_PRODUCT_STRING} "${CMAKE_CURRENT_SOURCE_DIR}/../Shaders" "${CMAKE_BINARY_DIR}/Build/${ACG_PROJECT_DATADIR}/Shaders")
acg_copy_after_build (${OPENFLIPPER_PRODUCT_STRING} "${CMAKE_CURRENT_SOURCE_DIR}/../Textures" "${CMAKE_BINARY_DIR}/Build/${ACG_PROJECT_DATADIR}/Textures")
acg_copy_after_build (${OPENFLIPPER_PRODUCT_STRING} "${CMAKE_CURRENT_SOURCE_DIR}/../Scripts" "${CMAKE_BINARY_DIR}/Build/${ACG_PROJECT_DATADIR}/Scripts")
acg_copy_after_build (${OPENFLIPPER_PRODUCT_STRING} "${CMAKE_CURRENT_SOURCE_DIR}/../Licenses" "${CMAKE_BINARY_DIR}/Build/${ACG_PROJECT_DATADIR}/Licenses")
acg_copy_after_build (${OPENFLIPPER_PRODUCT_STRING} "${CMAKE_CURRENT_SOURCE_DIR}/../Icons" "${CMAKE_BINARY_DIR}/Build/${ACG_PROJECT_DATADIR}/Icons")
acg_copy_after_build (${OPENFLIPPER_PRODUCT_STRING} "${CMAKE_CURRENT_SOURCE_DIR}/../Fonts" "${CMAKE_BINARY_DIR}/Build/${ACG_PROJECT_DATADIR}/Fonts")
acg_copy_after_build (${OPENFLIPPER_PRODUCT_STRING} "${CMAKE_CURRENT_SOURCE_DIR}/../Documentation/QtHelpResources" "${CMAKE_BINARY_DIR}/Build/${ACG_PROJECT_DATADIR}/Help")

if ( EXISTS ${BRANDING_DIRECTORY} )
  if ( WIN32 ) 
    acg_copy_after_build (${OPENFLIPPER_PRODUCT_STRING} "${BRANDING_DIRECTORY}/win/Icons" "${CMAKE_BINARY_DIR}/Build/${ACG_PROJECT_DATADIR}/Icons")
  elseif( APPLE )
    acg_copy_after_build (${OPENFLIPPER_PRODUCT_STRING} "${BRANDING_DIRECTORY}/mac/Icons" "${CMAKE_BINARY_DIR}/Build/${ACG_PROJECT_DATADIR}/Icons")
  elseif()
    acg_copy_after_build (${OPENFLIPPER_PRODUCT_STRING} "${BRANDING_DIRECTORY}/linux/Icons" "${CMAKE_BINARY_DIR}/Build/${ACG_PROJECT_DATADIR}/Icons")
  endif()
endif()


if ( APPLE ) 
  # we need qt_menu.nib in our resources dir so try to get it

 if ( EXISTS /opt/local/lib/Resources/qt_menu.nib )
  acg_copy_after_build( ${OPENFLIPPER_PRODUCT_STRING} "/opt/local/lib/Resources/qt_menu.nib" "${CMAKE_BINARY_DIR}/Build/${ACG_PROJECT_DATADIR}/qt_menu.nib")
 elseif ( EXISTS /usr/bin/qt_menu.nib )
   acg_copy_after_build( ${OPENFLIPPER_PRODUCT_STRING} "/usr/bin/qt_menu.nib" "${CMAKE_BINARY_DIR}/Build/${ACG_PROJECT_DATADIR}/qt_menu.nib")
 elseif ( EXISTS "/opt/local/libexec/qt4-mac/lib/QtGui.framework/Versions/4/Resources/qt_menu.nib" )
   acg_copy_after_build( ${OPENFLIPPER_PRODUCT_STRING} "/opt/local/libexec/qt4-mac/lib/QtGui.framework/Versions/4/Resources/qt_menu.nib" "${CMAKE_BINARY_DIR}/Build/${ACG_PROJECT_DATADIR}/qt_menu.nib")
 endif ()

 # Copy qt plugins into bundle but omit debug libraries when in release mode and vice versa
 acg_unset (_files)
 acg_get_files_in_dir (_files ${QT_PLUGINS_DIR})
 foreach (_file ${_files})
   if ( CMAKE_BUILD_TYPE MATCHES "Release" )

     # In release mode, we don't want debug binaries in the bundle as it could cause crashes due to wrong linking or mixing of debug and release
     if ( NOT _file MATCHES ".*debug.*" )
       add_custom_command(TARGET ${OPENFLIPPER_PRODUCT_STRING} POST_BUILD
         COMMAND ${CMAKE_COMMAND} -E copy_if_different "${QT_PLUGINS_DIR}/${_file}" "${CMAKE_BINARY_DIR}/Build/${ACG_PROJECT_DATADIR}/QtPlugins/${_file}"
       )
     endif()

   else ()
     
     # In debug mode, we don't want release binaries in the bundle as it could cause crashes due to wrong linking or mixing of debug and release
     if ( _file MATCHES ".*debug.*" )
       add_custom_command(TARGET ${OPENFLIPPER_PRODUCT_STRING} POST_BUILD
         COMMAND ${CMAKE_COMMAND} -E copy_if_different "${QT_PLUGINS_DIR}/${_file}" "${CMAKE_BINARY_DIR}/Build/${ACG_PROJECT_DATADIR}/QtPlugins/${_file}"
       )
     endif()

   endif()
    
 endforeach ()

elseif(WIN32)

 #copy qt plugins to Build directory and configure qt.conf file
 file (GLOB qtplugin_dirs RELATIVE  "${QT_PLUGINS_DIR}"  "${QT_PLUGINS_DIR}/*"  )
 file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/Build/QtPlugins" )
 foreach (qtplugin ${qtplugin_dirs})
509
510
511

        # Exclude PDB files if we build release mode
        if ( CMAKE_BUILD_TYPE MATCHES "Debug" )
512
513
  	   file(COPY "${QT_PLUGINS_DIR}/${qtplugin}" 
                DESTINATION "${CMAKE_BINARY_DIR}/Build/QtPlugins/" )
514
        else()
515
516
517
           file(COPY        "${QT_PLUGINS_DIR}/${qtplugin}" 
                DESTINATION "${CMAKE_BINARY_DIR}/Build/QtPlugins/" 
                PATTERN "*.pdb" EXCLUDE  )
518
        endif()
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
 endforeach ()

endif( APPLE )



if (NOT APPLE)
  # install all needed files
  # the install_dir macro (common.cmake) installs the whole directory without svn files
  # no install for mac needed here, because the whole bundle will be installed in the
  # toplevel CMakeLists.txt
  acg_install_dir ("${CMAKE_CURRENT_SOURCE_DIR}/../Shaders" "${ACG_PROJECT_DATADIR}/Shaders")
  acg_install_dir ("${CMAKE_CURRENT_SOURCE_DIR}/../Textures" "${ACG_PROJECT_DATADIR}/Textures")
  acg_install_dir ("${CMAKE_CURRENT_SOURCE_DIR}/../Scripts" "${ACG_PROJECT_DATADIR}/Scripts")
  acg_install_dir ("${CMAKE_CURRENT_SOURCE_DIR}/../Icons" "${ACG_PROJECT_DATADIR}/Icons")
  acg_install_dir ("${CMAKE_CURRENT_SOURCE_DIR}/../Licenses" "${ACG_PROJECT_DATADIR}/Licenses")
  acg_install_dir ("${CMAKE_CURRENT_SOURCE_DIR}/../Fonts" "${ACG_PROJECT_DATADIR}/Fonts")
  #acg_install_dir ("${CMAKE_CURRENT_SOURCE_DIR}/../Doc" "${ACG_PROJECT_DATADIR}/Doc") Disabled as we don't want html docs inside of the binaries

  if ( WIN32 )
    # create qt config file and install it
	file(WRITE "${CMAKE_BINARY_DIR}/Build/qt.conf" "[Paths]\nPlugins = QtPlugins")
	install( FILES "${CMAKE_BINARY_DIR}/Build/qt.conf" DESTINATION "${ACG_PROJECT_DATADIR}/" )
	acg_install_dir ("${CMAKE_BINARY_DIR}/Build/QtPlugins/" "${ACG_PROJECT_DATADIR}/QtPlugins")
  endif(WIN32)
  
  if ( EXISTS ${BRANDING_DIRECTORY}/win )
    if ( WIN32 ) 
      acg_install_dir ( "${BRANDING_DIRECTORY}/win" "${ACG_PROJECT_DATADIR}/Icons")
     endif()
  endif()

endif ()


if ( EXISTS ${BRANDING_DIRECTORY}/Icons )
  # Overwrite generic Icons with branded ones.
  acg_copy_after_build (${OPENFLIPPER_PRODUCT_STRING} "${BRANDING_DIRECTORY}/Icons" "${CMAKE_BINARY_DIR}/Build/${ACG_PROJECT_DATADIR}/Icons")
  acg_install_dir ("${BRANDING_DIRECTORY}/Icons" "${ACG_PROJECT_DATADIR}/Icons")
endif()