CMakeLists.txt 15.7 KB
Newer Older
1
2
3
4
include (ACGCommon)

include_directories (
  ..
5
  ${OPENMESH_INCLUDE_DIRS}
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
  ${CMAKE_SOURCE_DIR}
  ${CMAKE_CURRENT_SOURCE_DIR}
  ${CMAKE_CURRENT_BINARY_DIR}
  ${OPENGL_INCLUDE_DIR}
  ${GLUT_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"
Jan Möbius's avatar
Jan Möbius committed
21
     "${CMAKE_SOURCE_DIR}/Package*/ObjectTypes/*/CMakeLists.txt"
22
23
24
25
26
27
28
29
30
31
32
33
34
  )


  # include all cmake files fouund for objecttypes here
  foreach ( _buildInfo ${_plugin_buildinfos})
    include ("${CMAKE_SOURCE_DIR}/${_buildInfo}")
  endforeach ()

  link_directories (
    ${ADDITIONAL_PLUGINLIB_LINK_DIRS}
  )
endif(APPLE)

35
36
37
38
39
40
if (WIN32)
	SET(WIN_EXTRA_DIRS "../StackWalker" )
else(WIN32)
	SET(WIN_EXTRA_DIRS "")
endif(WIN32)

41
# source code directories
42
43
set (directories 
  .. 
44
45
46
47
48
49
  ../Core
  ../Logging
  ../Scripting
  ../Scripting/scriptPrototypes
  ../Scripting/scriptWrappers
  ../SimpleOpt
50
  ../widgets/aboutWidget 
51
52
  ../widgets/addEmptyWidget
  ../widgets/loggerWidget
53
  ../widgets/coreWidget 
54
55
56
57
58
59
60
61
62
  ../widgets/helpWidget
  ../widgets/processManagerWidget
  ../widgets/loadWidget
  ../widgets/optionsWidget
  ../widgets/PluginDialog
  ../widgets/viewModeWidget
  ../widgets/videoCaptureDialog
  ../widgets/snapshotDialog
  ../widgets/stereoSettingsWidget
63
  ../widgets/postProcessorWidget
Jan Möbius's avatar
Jan Möbius committed
64
  ../widgets/rendererWidget
65
  ${WIN_EXTRA_DIRS}
66
67
68
69
70
71
72
73
74
75
76
)

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

# remove template cc files from source file list
acg_drop_templates (sources)

# genereate uic and moc targets
Matthias Möller's avatar
Matthias Möller committed
77
78
79
80
if (QT5_FOUND)
  acg_qt5_autouic (uic_targets ${ui})
  acg_qt5_automoc (moc_targets ${headers})
else ()
81
82
acg_qt4_autouic (uic_targets ${ui})
acg_qt4_automoc (moc_targets ${headers})
Matthias Möller's avatar
Matthias Möller committed
83
endif()
84

85
86
set(RC_SRC "")

87
if ( EXISTS ${BRANDING_DIRECTORY}/branding.qrc )
88
        if ( QT5_FOUND )
89
            QT5_ADD_RESOURCES(BRANDING_RC_SRC "${BRANDING_DIRECTORY}/branding.qrc")
90
91
            list(APPEND RC_SRC ${BRANDING_RC_SRC})
        else()
92
    	    QT4_ADD_RESOURCES(BRANDING_RC_SRC "${BRANDING_DIRECTORY}/branding.qrc")
93
94
  	    list(APPEND RC_SRC ${BRANDING_RC_SRC})
        endif()
95
96
endif()

97
98
99
100
101
102
103
104
105
106
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()

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

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

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

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

115
116
if (WIN32)
  # add app icon rc file to windows build
117
  acg_add_executable (${OPENFLIPPER_PRODUCT_STRING} WIN32 ${CMAKE_CURRENT_SOURCE_DIR}/CoreApp.rc ${uic_targets} ${sources} ${headers} ${moc_targets} ${RC_SRC})
118
  # link to qtmain library to get WinMain function for a non terminal app
119
  target_link_libraries (${OPENFLIPPER_PRODUCT_STRING} ${QT_QTMAIN_LIBRARY})
120
121
elseif (APPLE)
  # generate bundle on mac
122
  acg_add_executable (${OPENFLIPPER_PRODUCT_STRING} MACOSX_BUNDLE ${uic_targets} ${sources} ${headers} ${moc_targets} ${RC_SRC})
123
else ()
124
  acg_add_executable (${OPENFLIPPER_PRODUCT_STRING} ${uic_targets} ${sources} ${headers} ${moc_targets} ${RC_SRC})
125
126
endif ()

Jan Möbius's avatar
Jan Möbius committed
127
# Mark this build part as building OpenFlippers Core
128
129
add_definitions(-DOPENFLIPPERCORE )

130
131
# Build app store compliant
if ( OPENFLIPPER_BUILD_APP_STORE_COMPLIANT )
Jan Möbius's avatar
Jan Möbius committed
132
   add_definitions( -DOPENFLIPPER_BUILD_APP_STORE_COMPLIANT )
133
134
135
endif()


Jan Möbius's avatar
Jan Möbius committed
136
137
if (WIN32)
  add_definitions( -DACGDLL
138
139
140
141
                   -DUSEACG 
                   -DPLUGINLIBDLL
                   -DUSEPLUGINLIBDLL
                   )
Jan Möbius's avatar
Jan Möbius committed
142
endif ()
143

144
145
146
147
148
149

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

150
151
152
153
154
155
156
157
158
159
if (WIN32)
  set ( WIN_GET_DEBUG_CONSOLE False CACHE BOOL "Whether a debug console should be visible on windows" )
  if (WIN_GET_DEBUG_CONSOLE)
      add_definitions( -DWIN_GET_DEBUG_CONSOLE )
  endif()
endif ()




160
161
# ====================================================================================
# Get list of  ll plugin dependencies and handle special ones
162
# where we need to link the library directly into the core to prevent 
163
164
165
166
167
168
169
170
171
172
173
174
# 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 "")

# Special Handling for mpi
list( FIND global_dependency_list "MPI" found)
if ( NOT found EQUAL -1 )
  find_package(MPI)
175
176
177
  if ( MPI_FOUND )
    list(APPEND COREAPP_ADDITIONAL_LINK_LIBRARIES  ${MPI_LIBRARIES})
  endif()
178
179
180
181
182
183
endif()

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

189
190
191
192
193
194
195
# use Qwt6 for QT5
if (NOT FORCE_QT4 AND QT5_FOUND)
  find_package(Qwt6)

  if (QWT6_FOUND)
    add_definitions(-DWITH_QWT)
    set(INCLUDE_DIRS ${INCLUDE_DIRS} ${QWT6_INCLUDE_DIRS} )
196
    set(COREAPP_ADDITIONAL_LINK_LIBRARIES ${COREAPP_ADDITIONAL_LINK_LIBRARIES} ${QWT6_LIBRARIES})
197
198
199
  endif()
else()
  find_package(Qwt5)
200

201
202
203
  if(Qwt5_Qt4_FOUND)
    add_definitions(-DWITH_QWT)
    set(INCLUDE_DIRS ${INCLUDE_DIRS} ${Qwt5_INCLUDE_DIR} )
204
    set(COREAPP_ADDITIONAL_LINK_LIBRARIES ${COREAPP_ADDITIONAL_LINK_LIBRARIES} ${Qwt5_Qt4_LIBRARY})
205
  endif()
206
207
208
endif()


209
210
211
212
# ====================================================================================
# Linker Dependencies for Core app
# ====================================================================================

213
target_link_libraries (${OPENFLIPPER_PRODUCT_STRING}
214
  ACG
215
  OpenFlipperPluginLib
216
217
218
  ${QT_LIBRARIES}
  ${OPENGL_LIBRARIES}
  ${GLUT_LIBRARIES}
219
  ${COREAPP_ADDITIONAL_LINK_LIBRARIES}
220
  ${OPENFLIPPER_STATIC_PLUGINS}
221
222
223
224
)

if (APPLE)

225
   if ( EXISTS ${BRANDING_DIRECTORY} )
Jan Möbius's avatar
Jan Möbius committed
226

227
228
     # Take bundle icon from branding dir
     IF ( NOT APPLE_BUNDLE_ICON )
229
        # option to set the used Icon for OpenFlipper
230
        set ( APPLE_BUNDLE_ICON "${BRANDING_DIRECTORY}\\mac\\OpenFlipper_Icon.icns" CACHE FILEPATH "Path to the Bundle Icon" )
231
232
233
234
     ENDIF(NOT APPLE_BUNDLE_ICON )    
 
     # Take plist from branding
     IF ( NOT APPLE_INFO_PLIST )
235
       if ( EXISTS ${BRANDING_DIRECTORY}/mac/Info.plist )
236
         # option to configure the custom Info.plist
237
238
         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 )
239
240
         # 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" )
241
       endif( EXISTS ${BRANDING_DIRECTORY}/mac/Info.plist )
242
     ENDIF(NOT APPLE_INFO_PLIST )
243
244
245
246
247

  else()

    IF ( NOT APPLE_BUNDLE_ICON )
        # option to set the used Icon for OpenFlipper
248
249
        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" )
250
251
252
        else()
          set ( APPLE_BUNDLE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/../Icons/OpenFlipper_Icon.icns" CACHE FILEPATH "Path to the Bundle Icon" )
        endif()
253
254
    ENDIF(NOT APPLE_BUNDLE_ICON )

Jan Möbius's avatar
Jan Möbius committed
255
256
257
258
259
    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 )

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

266
267
268
269
  # 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 (
270
      ${OPENFLIPPER_PRODUCT_STRING} PROPERTIES
271
272
273
274
       
      RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/Build/"
      RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/Build/"
      RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/Build/"
Jan Möbius's avatar
Jan Möbius committed
275
276
277
      MACOSX_BUNDLE_INFO_STRING "ACG OpenFlipper"
      MACOSX_BUNDLE_ICON_FILE "OpenFlipper.icns"
      MACOSX_BUNDLE_INFO_PLIST ${APPLE_INFO_PLIST}
278
  )  
Jan Möbius's avatar
Jan Möbius committed
279

280
281
282
283
284
285
endif ()

# Translations
set (trans_files ${sources})
list (APPEND trans_files ${ui})
list (APPEND trans_files ${headers})
286
acg_add_translations (${OPENFLIPPER_PRODUCT_STRING} "de_DE" "${trans_files}")
287
288
289
290


# 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
291
292
293
294
295
296
297
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")
298

299
if ( EXISTS ${BRANDING_DIRECTORY} )
300
  if ( WIN32 ) 
301
    acg_copy_after_build (${OPENFLIPPER_PRODUCT_STRING} "${BRANDING_DIRECTORY}/win/Icons" "${CMAKE_BINARY_DIR}/Build/${ACG_PROJECT_DATADIR}/Icons")
302
  elseif( APPLE )
303
    acg_copy_after_build (${OPENFLIPPER_PRODUCT_STRING} "${BRANDING_DIRECTORY}/mac/Icons" "${CMAKE_BINARY_DIR}/Build/${ACG_PROJECT_DATADIR}/Icons")
304
  elseif()
305
    acg_copy_after_build (${OPENFLIPPER_PRODUCT_STRING} "${BRANDING_DIRECTORY}/linux/Icons" "${CMAKE_BINARY_DIR}/Build/${ACG_PROJECT_DATADIR}/Icons")
306
307
308
309
  endif()
endif()


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

313
 if ( EXISTS /opt/local/lib/Resources/qt_menu.nib )
314
  acg_copy_after_build( ${OPENFLIPPER_PRODUCT_STRING} "/opt/local/lib/Resources/qt_menu.nib" "${CMAKE_BINARY_DIR}/Build/${ACG_PROJECT_DATADIR}/qt_menu.nib")
Jan Möbius's avatar
Jan Möbius committed
315
 elseif ( EXISTS /usr/bin/qt_menu.nib )
316
   acg_copy_after_build( ${OPENFLIPPER_PRODUCT_STRING} "/usr/bin/qt_menu.nib" "${CMAKE_BINARY_DIR}/Build/${ACG_PROJECT_DATADIR}/qt_menu.nib")
317
 elseif ( EXISTS "/opt/local/libexec/qt4-mac/lib/QtGui.framework/Versions/4/Resources/qt_menu.nib" )
318
   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")
319
320
 endif ()

321
322
323
324
325
326
327
328
 # 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.*" )
329
       add_custom_command(TARGET ${OPENFLIPPER_PRODUCT_STRING} POST_BUILD
330
331
332
333
334
         COMMAND ${CMAKE_COMMAND} -E copy_if_different "${QT_PLUGINS_DIR}/${_file}" "${CMAKE_BINARY_DIR}/Build/${ACG_PROJECT_DATADIR}/QtPlugins/${_file}"
       )
     endif()

   else ()
335
     
336
337
     # 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.*" )
338
       add_custom_command(TARGET ${OPENFLIPPER_PRODUCT_STRING} POST_BUILD
339
340
341
342
343
         COMMAND ${CMAKE_COMMAND} -E copy_if_different "${QT_PLUGINS_DIR}/${_file}" "${CMAKE_BINARY_DIR}/Build/${ACG_PROJECT_DATADIR}/QtPlugins/${_file}"
       )
     endif()

   endif()
344
    
345
346
 endforeach ()

347
348
349
350
351
352
353
354
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})
	file(COPY "${QT_PLUGINS_DIR}/${qtplugin}" DESTINATION "${CMAKE_BINARY_DIR}/Build/QtPlugins/")
 endforeach ()
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370

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")
371
  #acg_install_dir ("${CMAKE_CURRENT_SOURCE_DIR}/../Doc" "${ACG_PROJECT_DATADIR}/Doc") Disabled as we don't want html docs inside of the binaries
372

373
374
  if ( WIN32 )
    # create qt config file and install it
Matthias Möller's avatar
Matthias Möller committed
375
376
	file(WRITE "${CMAKE_BINARY_DIR}/Build/qt.conf" "[Paths]\nPlugins = QtPlugins")
	install( FILES "${CMAKE_BINARY_DIR}/Build/qt.conf" DESTINATION "${ACG_PROJECT_DATADIR}/" )
377
378
	acg_install_dir ("${CMAKE_BINARY_DIR}/Build/QtPlugins/" "${ACG_PROJECT_DATADIR}/QtPlugins")
  endif(WIN32)
379
  
380
  if ( EXISTS ${BRANDING_DIRECTORY}/win )
381
    if ( WIN32 ) 
382
      acg_install_dir ( "${BRANDING_DIRECTORY}/win" "${ACG_PROJECT_DATADIR}/Icons")
383
384
     endif()
  endif()
385
386
387
388

endif ()


389
if ( EXISTS ${BRANDING_DIRECTORY}/Icons )
390
  # Overwrite generic Icons with branded ones.
391
392
  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")
393
endif()