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

3 4 5 6 7
if ( WIN32 )
  # This is the base directory for windows library search used in the finders we shipp.
  set(CMAKE_WINDOWS_LIBS_DIR "c:/libs" CACHE STRING "Default Library search dir on windows." )
endif

8 9
if (NOT CMAKE_BUILD_TYPE)
  message(STATUS "No build type selected, default to Release")
10
  set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE)
11 12
endif()

Jan Möbius's avatar
Jan Möbius committed
13 14

IF ( APPLE )
15 16 17
	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
18 19 20
endif()


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)

26 27 28 29 30 31 32
# search for more macro directories in Package-* folders
file (
  GLOB _more_macro_directories
       "${CMAKE_SOURCE_DIR}/Package-*/cmake"
)
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${_more_macro_directories})

33 34 35 36 37
# include our cmake files
include (ACGCommon)

acg_get_version (OpenFlipper)

38
# ========================================================================
39
# Branding 
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


# search all branding dirs in the packages and in toplevel
file (
  GLOB _local_branding_in
  RELATIVE "${CMAKE_SOURCE_DIR}"
           "${CMAKE_SOURCE_DIR}/branding"
           "${CMAKE_SOURCE_DIR}/Package-*/branding"
)

# Get number of found branding dirs
list(LENGTH _local_branding_in branding_dir_count)

# Check if we found at least one branding directory
if (  ${branding_dir_count} GREATER 0 )

  list(GET _local_branding_in 0 BRANDING_DIRECTORY_TMP)
  set( BRANDING_DIRECTORY "${CMAKE_SOURCE_DIR}/${BRANDING_DIRECTORY_TMP}" CACHE PATH "Path to the branding files")

  if ( ${branding_dir_count} GREATER 1 )
    message(WARNING "Found multiple branding dirs in : ${_local_branding_in}")
    message(WARNING "Using only first branding directory: ${BRANDING_DIRECTORY}")    
  endif()
  
elseif()
  set( BRANDING_DIRECTORY "branding" CACHE PATH "Path to the branding files")

endif()

if ( EXISTS ${BRANDING_DIRECTORY}/branding.cmake )
	include(${BRANDING_DIRECTORY}/branding.cmake)
73 74
endif()

75 76 77 78 79 80
if ( EXISTS ${BRANDING_DIRECTORY}/branding.h )
  set( BRANDING_HEADER true CACHE String "Indicate there is a branding.h inside the branding folder that should be included.")
endif()


#Initialize with defaults, if not already set via branding cmake file
81 82 83
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)." )

84 85 86 87
if (BRANDING_HEADER)
add_definitions(-DBRANDING_HEADER)
endif ()

88 89 90 91 92 93
add_definitions(-DPRODUCT_STRING=${OPENFLIPPER_PRODUCT_STRING})
add_definitions(-DPRODUCT_NAME=${OPENFLIPPER_PRODUCT_NAME})

# ========================================================================
# ========================================================================

94 95 96
include (package)
include (ACGOutput)

Matthias Möller's avatar
Matthias Möller committed
97
# try to use QT5 if possible otherwise stick to QT4
Matthias Möller's avatar
Matthias Möller committed
98
set (FORCE_QT4 OFF CACHE BOOL "Use Qt4 even if Qt5 was found")
Matthias Möller's avatar
Matthias Möller committed
99 100 101 102 103 104 105 106

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

if (NOT QT5_FOUND)
Matthias Möller's avatar
Matthias Möller committed
107
  message(STATUS "Could not find QT5, searching for QT4")
Matthias Möller's avatar
Matthias Möller committed
108
  acg_qt4 (4.7.0)
Matthias Möller's avatar
Matthias Möller committed
109 110 111 112 113 114
endif()

if (QT4_FOUND)
	message(STATUS "Using QT4 for OpenFlipper")
elseif(QT5_FOUND)
	message(STATUS "Using QT5 for OpenFlipper")
115
	set (OF_MAX_QT_VERSION "5.5.1")
116 117 118 119
    if (${Qt5Core_VERSION_STRING} STRGREATER ${OF_MAX_QT_VERSION})
      message(WARNING "Detected QT Version higher than ${OF_MAX_QT_VERSION}!\n"
        "OpenFlipper has not been tested with this QT Version on Windows.")
    endif()
Matthias Möller's avatar
Matthias Möller committed
120
else()
Matthias Möller's avatar
Matthias Möller committed
121
	message(FATAL_ERROR "Could not found any QT Version. Please specify QT5_INSTALL_PATH (path to bin and include dir) to build with QT5 or specify the QT_QMAKE_EXECUTABLE to build with QT4")
Matthias Möller's avatar
Matthias Möller committed
122
endif()
Jan Möbius's avatar
Jan Möbius committed
123

124 125
acg_openmp ()

126
# check for OpenGL and GLUT as our required dependencies
127 128 129 130 131 132 133 134 135
find_package (OpenGL)
if (NOT OPENGL_FOUND)
  message (FATAL_ERROR "OpengGL not found!")
endif ()

find_package (GLUT)
if (NOT GLUT_FOUND)
  message (FATAL_ERROR "GLUT not found!")
endif ()
136 137 138 139

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

140 141 142 143 144 145
# enable/disable openmesh warnings
set(NO_DECREMENT_DEPRECATED_WARNINGS OFF CACHE BOOL "Disables all deprecated warnings warning about decrement operations on normal circulators.")
if(NO_DECREMENT_DEPRECATED_WARNINGS)
  add_definitions( -DNO_DECREMENT_DEPRECATED_WARNINGS )
endif()

Jan Möbius's avatar
Jan Möbius committed
146
# OpenMesh is a dependent project (in libs_required) so no finder is needed.
147 148 149 150
if (NOT USE_INTERNAL_OPENMESH)
  find_package (OpenMesh REQUIRED)
endif()

151 152
find_package (OpenVolumeMesh)
if (NOT OPENVOLUMEMESH_FOUND)
153
    message (WARNING "OpenVolumeMesh not found, proceeding without it!")
154
endif ()
155

156

157 158 159 160
# ========================================================================
# Configure the executables path for tests
# ========================================================================
if (APPLE)
161
  SET( OPENFLIPPER_EXECUTABLE "${CMAKE_BINARY_DIR}/Build/OpenFlipper.app/Contents/MacOS/${OPENFLIPPER_PRODUCT_STRING}" )
162
elseif( WIN32 )
163
  SET( OPENFLIPPER_EXECUTABLE "${CMAKE_BINARY_DIR}/Build/${OPENFLIPPER_PRODUCT_STRING}.exe" )
164
else()
165
  SET( OPENFLIPPER_EXECUTABLE "${CMAKE_BINARY_DIR}/Build/bin/${OPENFLIPPER_PRODUCT_STRING}" )
166
endif()
167 168 169
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 )
170

171 172
enable_testing()

173
# ========================================================================
Matthias Möller's avatar
Matthias Möller committed
174
# Build all additional libraries
175 176
# ========================================================================

Matthias Möller's avatar
Matthias Möller committed
177
# search all libs in the libs directory
178
# (required and optional libraries
179 180 181
file (
  GLOB _local_libs_in
  RELATIVE "${CMAKE_SOURCE_DIR}"
182
           "${CMAKE_SOURCE_DIR}/libs_required/*/CMakeLists.txt"
Jan Möbius's avatar
Jan Möbius committed
183
           "${CMAKE_SOURCE_DIR}/libs/*/CMakeLists.txt"
184
           "${CMAKE_SOURCE_DIR}/Package-*/libs/*/CMakeLists.txt"
185 186
)

Jan Möbius's avatar
Jan Möbius committed
187 188 189 190
set( REMAINING_LOCAL_LIBS "" )

# Special Comiso case:
# The library has to be configured first
191
foreach (_localLib ${_local_libs_in})
Jan Möbius's avatar
Jan Möbius committed
192 193
  if ( "${_localLib}" MATCHES .*CoMISo.* )
    get_filename_component (_local_lib_dir ${_localLib} PATH)
194 195 196 197 198 199 200
    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
201
  else()
202 203 204
    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
205 206 207 208 209 210
  endif()
endforeach ()


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

212
  get_filename_component (_local_lib_dir ${_localLib} PATH)
213 214 215

  # 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
216
  SET(REQUIRED FALSE)
217 218 219 220 221 222 223
  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
224

225 226 227 228 229 230
  # 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
231
  if ( LIB_${_local_lib_dir_upper}_BUILD OR REQUIRED)
232 233
    add_subdirectory (${CMAKE_SOURCE_DIR}/${_local_lib_dir})
  endif()
234 235
endforeach ()

Jan Möbius's avatar
Jan Möbius committed
236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254
# ========================================================================
# 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 )

255
# Add the documentation targets
Jan Möbius's avatar
Jan Möbius committed
256 257 258 259 260
add_subdirectory (OpenFlipper/Documentation/DeveloperTarget)
add_subdirectory (OpenFlipper/Documentation/DeveloperQtHelpTarget)
add_subdirectory (OpenFlipper/Documentation/UserTarget)
add_subdirectory (OpenFlipper/Documentation/UserQtHelpTarget)

261 262 263 264
# ========================================================================
# PolyLine extension special case
# ========================================================================

Isaak Lim's avatar
Isaak Lim committed
265 266 267
find_package (MeshIntegration)

if (MESH_INTEGRATION_FOUND)
268 269 270
  add_definitions( -DEXTENDED_POLY_LINE )
endif()

271 272 273 274 275 276 277
# ========================================================================
# 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()

278 279 280 281
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()

282 283 284 285 286 287 288 289 290 291 292 293 294
# ========================================================================
# 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 "")
295 296
acg_set (OPENFLIPPER_STATIC_PLUGINS "")
acg_set (OPENFLIPPER_STATIC_PLUGIN_FILES "")
297
acg_set (OPENFLIPPER_STATIC_PLUGIN_NAMES "")
298

299 300 301 302 303 304
foreach (package ${PREFOUND_PACKAGES})
find_package(${package})
endforeach ()

SET (LOADED_PACKAGES ${PREFOUND_PACKAGES})
LIST (APPEND LOADED_PACKAGES "Doxygen")
305 306
# add plugins
of_add_plugins ()
307 308
list (REMOVE_DUPLICATES LOADED_PACKAGES)
set (PREFOUND_PACKAGES "${LOADED_PACKAGES}" CACHE INTERNAL "List of packages that will get found at global scope so they don't get found over and over inside the individual packages.")
309

Jan Möbius's avatar
Jan Möbius committed
310 311 312
# ========================================================================
# Build core as we now know all dependencies
# ========================================================================
313

Jan Möbius's avatar
Jan Möbius committed
314
add_subdirectory (OpenFlipper/CoreApp)
315

316 317 318 319 320 321 322

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

if (WIN32 )

Matthias Möller's avatar
Matthias Möller committed
323
  # Plugins collected a list of required libdirs for getting
324 325
  # their DLLS on windows:
  get_property( WINDOWS_COPY_LIBDIRS GLOBAL PROPERTY WINDOWS_LIBRARY_DIR_LIST )
Matthias Möller's avatar
Matthias Möller committed
326

327 328 329 330
  if ( WINDOWS_COPY_LIBDIRS )
    list(REMOVE_DUPLICATES WINDOWS_COPY_LIBDIRS)
  endif()

331 332 333 334
  
  # workaround for VS2018 where the OpenMP vcomp90.dll seems to be missing from the path
  if ( CMAKE_GENERATOR MATCHES "^Visual Studio 9.*" )
    INCLUDE(InstallRequiredSystemLibraries)
335
    set ( OMP_PATH "${MSVC90_REDIST_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.VC90.OPENMP/;${MSVC90_REDIST_DIR}/Debug_NonRedist/${CMAKE_MSVC_ARCH}/Microsoft.VC90.DebugOpenMP/" )
336 337
  endif()

338 339 340 341 342 343 344 345
  # 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
346
  add_dependencies (fixbundle ${OPENFLIPPER_PRODUCT_STRING} OpenFlipperPluginLib ${OPENFLIPPER_PLUGINS})
Matthias Möller's avatar
Matthias Möller committed
347

348 349
endif(WIN32)

350
# ========================================================================
351
# Custom command to create a bundle and a package on mac
352
# ========================================================================
353

354 355 356 357 358 359 360
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()

361 362
  # 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
363
     "${CMAKE_BINARY_DIR}/fixbundle.cmake" @ONLY IMMEDIATE)
364 365

  # Fixbundle is only necessary, when we wan't a shippable package.
Matthias Möller's avatar
Matthias Möller committed
366
  # Otherwise the original rpaths are used
367
  if ( OPENFLIPPER_CALL_FIX_BUNDLE )
Matthias Möller's avatar
Matthias Möller committed
368 369
    # Call fixbundle every time
    add_custom_target (fixbundle ALL
370 371 372 373
      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
374
    add_custom_target (fixbundle
375 376 377 378
      COMMAND ${CMAKE_COMMAND} -P "${CMAKE_BINARY_DIR}/fixbundle.cmake"
    )
  endif()

379
  # let bundle generation depend on all targets
Jan Möbius's avatar
Jan Möbius committed
380
  add_dependencies (fixbundle ${OPENFLIPPER_PRODUCT_STRING} OpenFlipperPluginLib ${OPENFLIPPER_PLUGINS})
381 382 383 384

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

386
  # Extra target for building an OpenFlipper package on mac
387 388 389 390 391 392 393 394 395 396
  # 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()

397 398 399 400 401 402 403 404
# ========================================================================
# Output log information
# ========================================================================

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