CMakeLists.txt 11.6 KB
Newer Older
1
cmake_minimum_required (VERSION 2.8.9)
2

3 4
if (NOT CMAKE_BUILD_TYPE)
  message(STATUS "No build type selected, default to Release")
5
  set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE)
6 7
endif()

Jan Möbius's avatar
Jan Möbius committed
8 9

IF ( APPLE )
10 11 12
	IF(CMAKE_BUILD_TYPE MATCHES Debug)
	    message(WARNING "WARNING: Mac Debug mode might mix debug and release libraries (Webkit, ...), which causes strange errors. If you use ports to provide qt, you might want to disable Qt debug libraries to make sure only release qt libraries are linked to OpenFlippers debug build.")
	ENDIF(CMAKE_BUILD_TYPE MATCHES Debug)
Jan Möbius's avatar
Jan Möbius committed
13 14 15
endif()


16 17 18 19 20 21 22 23 24 25
project (OpenFlipper)

# add our macro directory to cmake search path
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake)

# include our cmake files
include (ACGCommon)

acg_get_version (OpenFlipper)

26 27 28 29 30 31 32 33 34 35
# ========================================================================
# Branding Flags
# ========================================================================

if ( EXISTS ${CMAKE_SOURCE_DIR}/branding/branding.cmake )
	include(${CMAKE_SOURCE_DIR}/branding/branding.cmake)
endif()

set( OPENFLIPPER_PRODUCT_STRING "OpenFlipper" CACHE String "Product string used e.g. to determine the config file path. Should only contain alphanumeric characters (no spaces)." )
set( OPENFLIPPER_PRODUCT_NAME "OpenFlipper" CACHE String "Product name used in all visible places (e.g. about box)." )
36
set( BRANDING_HEADER false CACHE String "Indicate there is a branding.h inside the branding folder.")
37 38 39
add_definitions(-DPRODUCT_STRING=${OPENFLIPPER_PRODUCT_STRING})
add_definitions(-DPRODUCT_NAME=${OPENFLIPPER_PRODUCT_NAME})

40 41 42 43
if (BRANDING_HEADER)
add_definitions(-DBRANDING_HEADER)
endif ()

44 45 46
include (package)
include (ACGOutput)

Matthias Möller's avatar
Matthias Möller committed
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
# try to use QT5 if possible otherwise stick to QT4
set (FORCE_QT4 ON CACHE BOOL "Use Qt4 even if Qt5 was found")

if (NOT FORCE_QT4)
  acg_qt5 ()
else()
  set (QT5_FOUND false)
endif()


if (NOT QT5_FOUND)
  message(STATUS "Using QT4 for OpenFlipper")
  acg_qt4 (4.7.0)
else ()
  message(STATUS "Using QT5 for OpenFlipper")
endif ()
Jan Möbius's avatar
Jan Möbius committed
63

64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
acg_openmp ()
acg_ftgl ()

# check for OpenGL, GLEW and GLUT as our required dependencies
find_package (OpenGL)
if (NOT OPENGL_FOUND)
  message (FATAL_ERROR "OpengGL not found!")
endif ()

find_package (GLEW)
if (NOT GLEW_FOUND)
  message (FATAL_ERROR "GLEW not found!")
endif ()

find_package (GLUT)
if (NOT GLUT_FOUND)
  message (FATAL_ERROR "GLUT not found!")
endif ()
82 83 84 85

# using the internal openmesh delivered by the svn repo (default) or use some external installation
set (USE_INTERNAL_OPENMESH ON CACHE BOOL "Use and build internal version of OpenMesh found in libs_required")

Jan Möbius's avatar
Jan Möbius committed
86
# OpenMesh is a dependent project (in libs_required) so no finder is needed.
87 88 89 90
if (NOT USE_INTERNAL_OPENMESH)
  find_package (OpenMesh REQUIRED)
endif()

91 92 93 94
find_package (OpenVolumeMesh)
if (NOT OPENVOLUMEMESH_FOUND)
    message (FATAL_ERROR "OpenVolumeMesh not found!")
endif ()
95

96

97 98 99 100
# ========================================================================
# Configure the executables path for tests
# ========================================================================
if (APPLE)
101
  SET( OPENFLIPPER_EXECUTABLE "${CMAKE_BINARY_DIR}/Build/OpenFlipper.app/Contents/MacOS/${OPENFLIPPER_PRODUCT_STRING}" )
102
elseif( WIN32 )
103
  SET( OPENFLIPPER_EXECUTABLE "${CMAKE_BINARY_DIR}/Build/${OPENFLIPPER_PRODUCT_STRING}.exe" )
104
else()
105
  SET( OPENFLIPPER_EXECUTABLE "${CMAKE_BINARY_DIR}/Build/bin/${OPENFLIPPER_PRODUCT_STRING}" )
106
endif()
107 108 109
SET(OPENFLIPPER_TEST_FILES    ${CMAKE_BINARY_DIR}/tests/globalTestFiles )
SET(OPENFLIPPER_TEST_RESULTS  ${CMAKE_BINARY_DIR}/tests/testResults )
SET(OPENFLIPPER_TEST_BINARIES ${CMAKE_BINARY_DIR}/tests/testBinaries )
110

111 112
enable_testing()

113
# ========================================================================
Matthias Möller's avatar
Matthias Möller committed
114
# Build all additional libraries
115 116
# ========================================================================

Matthias Möller's avatar
Matthias Möller committed
117
# search all libs in the libs directory
118
# (required and optional libraries
119 120 121
file (
  GLOB _local_libs_in
  RELATIVE "${CMAKE_SOURCE_DIR}"
122
           "${CMAKE_SOURCE_DIR}/libs_required/*/CMakeLists.txt"
Jan Möbius's avatar
Jan Möbius committed
123
           "${CMAKE_SOURCE_DIR}/libs/*/CMakeLists.txt"
124 125
)

Jan Möbius's avatar
Jan Möbius committed
126 127 128 129
set( REMAINING_LOCAL_LIBS "" )

# Special Comiso case:
# The library has to be configured first
130
foreach (_localLib ${_local_libs_in})
Jan Möbius's avatar
Jan Möbius committed
131 132
  if ( "${_localLib}" MATCHES .*CoMISo.* )
    get_filename_component (_local_lib_dir ${_localLib} PATH)
133 134 135 136 137 138 139
    if ( NOT DEFINED LIB_COMISO_BUILD )
      set( LIB_COMISO_BUILD true CACHE BOOL "Enable or disable build of COMISO Library" )
    endif()

    if ( LIB_COMISO_BUILD )
      add_subdirectory (${CMAKE_SOURCE_DIR}/${_local_lib_dir})
    endif()
Jan Möbius's avatar
Jan Möbius committed
140
  else()
141 142 143
    if ( NOT "${_localLib}" MATCHES OpenMesh OR USE_INTERNAL_OPENMESH)
      LIST(APPEND REMAINING_LOCAL_LIBS ${_localLib})
    endif()
Jan Möbius's avatar
Jan Möbius committed
144 145 146 147 148 149
  endif()
endforeach ()


# add all found libs to the build
foreach (_localLib ${REMAINING_LOCAL_LIBS})
150

151
  get_filename_component (_local_lib_dir ${_localLib} PATH)
152 153 154

  # If the library is in the required folder, we have to build it anyway, so
  # detect it here
Matthias Möller's avatar
Matthias Möller committed
155
  SET(REQUIRED FALSE)
156 157 158 159 160 161 162
  if ( _localLib MATCHES ".*libs_required.*" )
    SET(REQUIRED TRUE )
  endif()

  # Extract upper case library dir name for the human readable entries in the cmake config
  string(TOUPPER ${_local_lib_dir} _local_lib_dir_upper)
  string(REGEX REPLACE "LIBS[/\\]" "" _local_lib_dir_upper ${_local_lib_dir_upper} )
Matthias Möller's avatar
Matthias Möller committed
163

164 165 166 167 168 169
  # Only generate setting if the lib is not required (otherwise, we will always build it)
  if ( NOT DEFINED LIB_${_local_lib_dir_upper}_BUILD AND NOT REQUIRED)
      set( LIB_${_local_lib_dir_upper}_BUILD true CACHE BOOL "Enable or disable build of ${_local_lib_dir_upper} Library" )
  endif()

  # Build if this library is required or if it is enabled
Jan Möbius's avatar
Jan Möbius committed
170
  if ( LIB_${_local_lib_dir_upper}_BUILD OR REQUIRED)
171 172
    add_subdirectory (${CMAKE_SOURCE_DIR}/${_local_lib_dir})
  endif()
173 174
endforeach ()

Jan Möbius's avatar
Jan Möbius committed
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193
# ========================================================================
# Core Library Components (Except the Core application)
# ========================================================================
add_subdirectory (ACG)
add_subdirectory (OpenFlipper/PluginLib)

# ========================================================================
# Tests
# ========================================================================
add_subdirectory (tests)

# ========================================================================
# Documentation generators
# ========================================================================

# Create dirs to make doxygen happy
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/Build/${ACG_PROJECT_DATADIR}/Doc )
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/Build/${ACG_PROJECT_DATADIR}/Help )

194
# Add the documentation targets
Jan Möbius's avatar
Jan Möbius committed
195 196 197 198 199
add_subdirectory (OpenFlipper/Documentation/DeveloperTarget)
add_subdirectory (OpenFlipper/Documentation/DeveloperQtHelpTarget)
add_subdirectory (OpenFlipper/Documentation/UserTarget)
add_subdirectory (OpenFlipper/Documentation/UserQtHelpTarget)

200 201 202 203
# ========================================================================
# PolyLine extension special case
# ========================================================================

Matthias Möller's avatar
Matthias Möller committed
204
if ( EXISTS ${CMAKE_SOURCE_DIR}/libs/MeshIntegration )
205 206 207
  add_definitions( -DEXTENDED_POLY_LINE )
endif()

208 209 210 211 212 213 214
# ========================================================================
# License Manager
# ========================================================================
if ( NOT DEFINED OPENFLIPPER_ENABLE_LICENSE_MANAGER )
  set( OPENFLIPPER_ENABLE_LICENSE_MANAGER true CACHE BOOL "Enable or disable license management in all plugins" )
endif()

215 216 217 218
if ( NOT DEFINED OPENFLIPPER_ENABLE_LICENSE_KEY_GENERATOR )
  set( OPENFLIPPER_ENABLE_LICENSE_KEY_GENERATOR true CACHE BOOL "Enable or disable building the license key generators in all plugins" )
endif()

219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235
# ========================================================================
# Apple Mac Store Flags
# ========================================================================
if ( APPLE AND NOT DEFINED OPENFLIPPER_BUILD_APP_STORE_COMPLIANT )
  set( OPENFLIPPER_BUILD_APP_STORE_COMPLIANT true CACHE BOOL "Enable app store compliant build (No internal update, different paths,...)" )
endif()

# ========================================================================
# Plugins
# ========================================================================

# start with an empty plugin list
acg_set (OPENFLIPPER_PLUGINS "")

# add plugins
of_add_plugins ()

Jan Möbius's avatar
Jan Möbius committed
236 237 238
# ========================================================================
# Build core as we now know all dependencies
# ========================================================================
239

Jan Möbius's avatar
Jan Möbius committed
240
add_subdirectory (OpenFlipper/CoreApp)
241

242 243 244 245 246 247 248

# ========================================================================
# Bundle generation
# ========================================================================

if (WIN32 )

Matthias Möller's avatar
Matthias Möller committed
249
  # Plugins collected a list of required libdirs for getting
250 251
  # their DLLS on windows:
  get_property( WINDOWS_COPY_LIBDIRS GLOBAL PROPERTY WINDOWS_LIBRARY_DIR_LIST )
Matthias Möller's avatar
Matthias Möller committed
252

253 254 255 256 257 258 259 260 261 262 263 264
  if ( WINDOWS_COPY_LIBDIRS )
    list(REMOVE_DUPLICATES WINDOWS_COPY_LIBDIRS)
  endif()

  # prepare bundle generation cmake file and add a build target for it
  configure_file ("${CMAKE_SOURCE_DIR}/OpenFlipper/cmake/fixbundle.cmake.win.in"
     "${CMAKE_BINARY_DIR}/fixbundle.win.cmake" @ONLY IMMEDIATE)

  add_custom_target (fixbundle ALL
    COMMAND ${CMAKE_COMMAND} -P "${CMAKE_BINARY_DIR}/fixbundle.win.cmake" )

  # let bundle generation depend on all targets
Jan Möbius's avatar
Jan Möbius committed
265
  add_dependencies (fixbundle ${OPENFLIPPER_PRODUCT_STRING} PluginLib ${OPENFLIPPER_PLUGINS})
Matthias Möller's avatar
Matthias Möller committed
266

267 268
endif(WIN32)

269
# ========================================================================
270
# Custom command to create a bundle and a package on mac
271
# ========================================================================
272

273 274 275 276 277 278 279
if ( APPLE )

   # Configuration option about fixbundle
   if ( APPLE AND NOT DEFINED OPENFLIPPER_CALL_FIX_BUNDLE )
     set( OPENFLIPPER_CALL_FIX_BUNDLE false CACHE BOOL "After building OpenFlipper, a bundle creation step is executed (which copies all dependencies into the bundle) to create a valid MacOs Bundle. This step is only necessary if creating a package." )
   endif()

280 281
  # prepare bundle generation cmake file and add a build target for it
  configure_file ("${CMAKE_SOURCE_DIR}/OpenFlipper/cmake/fixbundle.cmake.in"
Matthias Möller's avatar
Matthias Möller committed
282
     "${CMAKE_BINARY_DIR}/fixbundle.cmake" @ONLY IMMEDIATE)
283 284

  # Fixbundle is only necessary, when we wan't a shippable package.
Matthias Möller's avatar
Matthias Möller committed
285
  # Otherwise the original rpaths are used
286
  if ( OPENFLIPPER_CALL_FIX_BUNDLE )
Matthias Möller's avatar
Matthias Möller committed
287 288
    # Call fixbundle every time
    add_custom_target (fixbundle ALL
289 290 291 292
      COMMAND ${CMAKE_COMMAND} -P "${CMAKE_BINARY_DIR}/fixbundle.cmake"
    )
  else()
    # Call fixbundle only as a dependency
Matthias Möller's avatar
Matthias Möller committed
293
    add_custom_target (fixbundle
294 295 296 297
      COMMAND ${CMAKE_COMMAND} -P "${CMAKE_BINARY_DIR}/fixbundle.cmake"
    )
  endif()

298
  # let bundle generation depend on all targets
Jan Möbius's avatar
Jan Möbius committed
299
  add_dependencies (fixbundle ${OPENFLIPPER_PRODUCT_STRING} PluginLib ${OPENFLIPPER_PLUGINS})
300 301 302 303

  # install bundle
  install (DIRECTORY ${CMAKE_BINARY_DIR}/Build/OpenFlipper.app DESTINATION .
           USE_SOURCE_PERMISSIONS)
304

305
  # Extra target for building an OpenFlipper package on mac
306 307 308 309 310 311 312 313 314 315
  # Call fixbundle first
  # afterwards we call make package as an external command, as we can't
  # add a dependency on build in targets of cake
  add_custom_target (OpenFlipper_package
    DEPENDS fixbundle
    COMMAND make package
  )

endif()

316 317 318 319 320 321 322 323
# ========================================================================
# Output log information
# ========================================================================

# display results
acg_print_configure_header (OPENFLIPPER "OpenFlipper")
of_print_plugin_stats ()
acg_print_configure_footer ()