CMakeLists.txt 14.5 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 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
  ${CMAKE_SOURCE_DIR}
  ${CMAKE_CURRENT_SOURCE_DIR}
  ${CMAKE_CURRENT_BINARY_DIR}
  ${OPENGL_INCLUDE_DIR}
  ${GLEW_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"
  )


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

  link_directories (
    ${GLEW_LIBRARY_DIR}
    ${ADDITIONAL_PLUGINLIB_LINK_DIRS}
  )

else (APPLE)
   link_directories (
      ${GLEW_LIBRARY_DIR}
   )
endif(APPLE)

41 42 43 44 45 46
if (WIN32)
	SET(WIN_EXTRA_DIRS "../StackWalker" )
else(WIN32)
	SET(WIN_EXTRA_DIRS "")
endif(WIN32)

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

# 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
83 84 85 86
if (QT5_FOUND)
  acg_qt5_autouic (uic_targets ${ui})
  acg_qt5_automoc (moc_targets ${headers})
else ()
87 88
acg_qt4_autouic (uic_targets ${ui})
acg_qt4_automoc (moc_targets ${headers})
Matthias Möller's avatar
Matthias Möller committed
89
endif()
90

91 92 93
set(RC_SRC "")

if ( EXISTS ${CMAKE_SOURCE_DIR}/branding/branding.qrc )
94 95 96 97 98 99 100
        if ( QT5_FOUND )
            QT5_ADD_RESOURCES(BRANDING_RC_SRC "${CMAKE_SOURCE_DIR}/branding/branding.qrc")
            list(APPEND RC_SRC ${BRANDING_RC_SRC})
        else()
    	    QT4_ADD_RESOURCES(BRANDING_RC_SRC "${CMAKE_SOURCE_DIR}/branding/branding.qrc")
  	    list(APPEND RC_SRC ${BRANDING_RC_SRC})
        endif()
101 102
endif()

103 104
if (WIN32)
  # add app icon rc file to windows build
105
  acg_add_executable (${OPENFLIPPER_PRODUCT_STRING} WIN32 ${CMAKE_CURRENT_SOURCE_DIR}/CoreApp.rc ${uic_targets} ${sources} ${headers} ${moc_targets} ${RC_SRC})
106
  # link to qtmain library to get WinMain function for a non terminal app
107
  target_link_libraries (${OPENFLIPPER_PRODUCT_STRING} ${QT_QTMAIN_LIBRARY})
108 109
elseif (APPLE)
  # generate bundle on mac
110
  acg_add_executable (${OPENFLIPPER_PRODUCT_STRING} MACOSX_BUNDLE ${uic_targets} ${sources} ${headers} ${moc_targets} ${RC_SRC})
111
else ()
112
  acg_add_executable (${OPENFLIPPER_PRODUCT_STRING} ${uic_targets} ${sources} ${headers} ${moc_targets} ${RC_SRC})
113 114
endif ()

Jan Möbius's avatar
Jan Möbius committed
115
# Mark this build part as building OpenFlippers Core
116 117
add_definitions(-DOPENFLIPPERCORE )

118 119
# Build app store compliant
if ( OPENFLIPPER_BUILD_APP_STORE_COMPLIANT )
Jan Möbius's avatar
Jan Möbius committed
120
   add_definitions( -DOPENFLIPPER_BUILD_APP_STORE_COMPLIANT )
121 122 123
endif()


Jan Möbius's avatar
Jan Möbius committed
124 125 126 127
if (WIN32)
  add_definitions( -DACGDLL
                   -DUSEACG )
endif ()
128

129 130
# ====================================================================================
# Get list of  ll plugin dependencies and handle special ones
131
# where we need to link the library directly into the core to prevent 
132 133 134 135 136 137 138 139 140 141 142 143
# 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)
144 145 146
  if ( MPI_FOUND )
    list(APPEND COREAPP_ADDITIONAL_LINK_LIBRARIES  ${MPI_LIBRARIES})
  endif()
147 148 149 150 151 152
endif()

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

158 159 160 161 162 163 164
# 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} )
165
    set(COREAPP_ADDITIONAL_LINK_LIBRARIES ${COREAPP_ADDITIONAL_LINK_LIBRARIES} ${QWT6_LIBRARIES})
166 167 168
  endif()
else()
  find_package(Qwt5)
169

170 171 172
  if(Qwt5_Qt4_FOUND)
    add_definitions(-DWITH_QWT)
    set(INCLUDE_DIRS ${INCLUDE_DIRS} ${Qwt5_INCLUDE_DIR} )
173
    set(COREAPP_ADDITIONAL_LINK_LIBRARIES ${COREAPP_ADDITIONAL_LINK_LIBRARIES} ${Qwt5_Qt4_LIBRARY})
174
  endif()
175 176 177
endif()


178 179 180 181
# ====================================================================================
# Linker Dependencies for Core app
# ====================================================================================

182
target_link_libraries (${OPENFLIPPER_PRODUCT_STRING}
183
  ACG
184
  OpenFlipperPluginLib
185 186 187 188
  ${QT_LIBRARIES}
  ${OPENGL_LIBRARIES}
  ${GLEW_LIBRARY}
  ${GLUT_LIBRARIES}
189
  ${COREAPP_ADDITIONAL_LINK_LIBRARIES}
190 191 192 193
)

if (APPLE)

194
   if ( EXISTS ${CMAKE_SOURCE_DIR}/branding )
Jan Möbius's avatar
Jan Möbius committed
195

196 197
     # Take bundle icon from branding dir
     IF ( NOT APPLE_BUNDLE_ICON )
198 199
        # option to set the used Icon for OpenFlipper
        set ( APPLE_BUNDLE_ICON "${CMAKE_SOURCE_DIR}\\branding\\mac\\OpenFlipper_Icon.icns" CACHE FILEPATH "Path to the Bundle Icon" )
200 201 202 203 204 205 206 207 208 209 210 211
     ENDIF(NOT APPLE_BUNDLE_ICON )    
 
     # Take plist from branding
     IF ( NOT APPLE_INFO_PLIST )
       if ( EXISTS ${CMAKE_SOURCE_DIR}/branding/mac/Info.plist )
         # option to configure the custom Info.plist
         set ( APPLE_INFO_PLIST "${CMAKE_SOURCE_DIR}\\branding\\mac\\Info.plist" CACHE FILEPATH "Path to the Info.plist file for Bundle" )
       else ( EXISTS ${CMAKE_SOURCE_DIR}/branding/mac/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( EXISTS ${CMAKE_SOURCE_DIR}/branding/mac/Info.plist )
     ENDIF(NOT APPLE_INFO_PLIST )
212 213 214 215 216

  else()

    IF ( NOT APPLE_BUNDLE_ICON )
        # option to set the used Icon for OpenFlipper
217 218 219 220 221
        if ( EXISTS ${CMAKE_SOURCE_DIR}/branding/Icons/OpenFlipper_Icon.icns )
          set ( APPLE_BUNDLE_ICON " ${CMAKE_SOURCE_DIR}/branding/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()
222 223
    ENDIF(NOT APPLE_BUNDLE_ICON )

Jan Möbius's avatar
Jan Möbius committed
224 225 226 227 228
    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 )

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

235 236 237 238
  # 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 (
239
      ${OPENFLIPPER_PRODUCT_STRING} PROPERTIES
240 241 242 243
       
      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
244 245 246
      MACOSX_BUNDLE_INFO_STRING "ACG OpenFlipper"
      MACOSX_BUNDLE_ICON_FILE "OpenFlipper.icns"
      MACOSX_BUNDLE_INFO_PLIST ${APPLE_INFO_PLIST}
247
  )  
Jan Möbius's avatar
Jan Möbius committed
248

249 250 251 252 253 254
endif ()

# Translations
set (trans_files ${sources})
list (APPEND trans_files ${ui})
list (APPEND trans_files ${headers})
255
acg_add_translations (${OPENFLIPPER_PRODUCT_STRING} "de_DE" "${trans_files}")
256 257 258 259


# 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
260 261 262 263 264 265 266
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")
267 268

if ( EXISTS ${CMAKE_SOURCE_DIR}/branding )
269
  if ( WIN32 ) 
270
    acg_copy_after_build (${OPENFLIPPER_PRODUCT_STRING} "${CMAKE_SOURCE_DIR}/branding/win/Icons" "${CMAKE_BINARY_DIR}/Build/${ACG_PROJECT_DATADIR}/Icons")
271
  elseif( APPLE )
272
    acg_copy_after_build (${OPENFLIPPER_PRODUCT_STRING} "${CMAKE_SOURCE_DIR}/branding/mac/Icons" "${CMAKE_BINARY_DIR}/Build/${ACG_PROJECT_DATADIR}/Icons")
273
  elseif()
274
    acg_copy_after_build (${OPENFLIPPER_PRODUCT_STRING} "${CMAKE_SOURCE_DIR}/branding/linux/Icons" "${CMAKE_BINARY_DIR}/Build/${ACG_PROJECT_DATADIR}/Icons")
275 276 277 278
  endif()
endif()


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

282
 if ( EXISTS /opt/local/lib/Resources/qt_menu.nib )
283
  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
284
 elseif ( EXISTS /usr/bin/qt_menu.nib )
285
   acg_copy_after_build( ${OPENFLIPPER_PRODUCT_STRING} "/usr/bin/qt_menu.nib" "${CMAKE_BINARY_DIR}/Build/${ACG_PROJECT_DATADIR}/qt_menu.nib")
286
 elseif ( EXISTS "/opt/local/libexec/qt4-mac/lib/QtGui.framework/Versions/4/Resources/qt_menu.nib" )
287
   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")
288 289
 endif ()

290 291 292 293 294 295 296 297
 # 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.*" )
298
       add_custom_command(TARGET ${OPENFLIPPER_PRODUCT_STRING} POST_BUILD
299 300 301 302 303
         COMMAND ${CMAKE_COMMAND} -E copy_if_different "${QT_PLUGINS_DIR}/${_file}" "${CMAKE_BINARY_DIR}/Build/${ACG_PROJECT_DATADIR}/QtPlugins/${_file}"
       )
     endif()

   else ()
304
     
305 306
     # 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.*" )
307
       add_custom_command(TARGET ${OPENFLIPPER_PRODUCT_STRING} POST_BUILD
308 309 310 311 312
         COMMAND ${CMAKE_COMMAND} -E copy_if_different "${QT_PLUGINS_DIR}/${_file}" "${CMAKE_BINARY_DIR}/Build/${ACG_PROJECT_DATADIR}/QtPlugins/${_file}"
       )
     endif()

   endif()
313
    
314 315
 endforeach ()

316 317 318 319 320 321 322 323
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 ()
324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339

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

342 343 344 345 346 347
  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)
348 349 350
  
  if ( EXISTS ${CMAKE_SOURCE_DIR}/branding/win )
    if ( WIN32 ) 
351 352 353
      acg_install_dir ( "${CMAKE_SOURCE_DIR}/branding/win" "${ACG_PROJECT_DATADIR}/Icons")
     endif()
  endif()
354 355 356 357

endif ()


358 359
if ( EXISTS ${CMAKE_SOURCE_DIR}/branding/Icons )
  # Overwrite generic Icons with branded ones.
360
  acg_copy_after_build (${OPENFLIPPER_PRODUCT_STRING} "${CMAKE_SOURCE_DIR}/branding/Icons" "${CMAKE_BINARY_DIR}/Build/${ACG_PROJECT_DATADIR}/Icons")
361
  acg_install_dir ("${CMAKE_SOURCE_DIR}/branding/Icons" "${ACG_PROJECT_DATADIR}/Icons")
362
endif()