CMakeLists.txt 20.5 KB
Newer Older
1
# Force minimal cmake version
2
# Required 3.8 to use source_group TREE 
3
4
# Required 3.12 to use findPython3
cmake_minimum_required(VERSION 3.12.0 FATAL_ERROR)
5

Jan Möbius's avatar
Jan Möbius committed
6
7
8
file(SHA512 ${CMAKE_SOURCE_DIR}/CMakeLists.txt HASH_TOPLEVEL_CMAKEFILE)
file(SHA512 ${CMAKE_SOURCE_DIR}/OpenFlipper/cmake/CMakeLists.txt HASH_LATEST_CMAKEFILE)

9
if ( NOT ${HASH_TOPLEVEL_CMAKEFILE} STREQUAL ${HASH_LATEST_CMAKEFILE} )
Jan Möbius's avatar
Jan Möbius committed
10
11
12
  message(WARNING "WARNING! Possibly Outdated toplevel CMakeLists.txt. Please update the toplevel copy by the file OpenFlipper/cmake/CMakeLists.txt .")
endif()

13
14
15
16
17
# Convenience checks for problems
if(EXISTS ${CMAKE_SOURCE_DIR}/libs_required/OpenMesh)
  message(FATAL_ERROR "Directory libs_required/OpenMesh has been moved to OpenFlipper/libs_required/OpenMesh! Please remove the old directory if it's still there!")
endif()

18
# Set and enforce C++-11 flags
Jan Möbius's avatar
Jan Möbius committed
19
set( CMAKE_CXX_STANDARD_REQUIRED TRUE )
20
set( CMAKE_CXX_STANDARD 11 )
21

Jan Möbius's avatar
Jan Möbius committed
22
# ACG Environment default settings
23
24
# This is ugly but currently we need to work around the default installed on debian
if ( EXISTS /ACG/acgdev/gcc-x86_64/qt-5.12.2/5.12.2/gcc_64 )
Jan Möbius's avatar
Jan Möbius committed
25
  # Default to this install path for QT%_INSTALL_DIR
26
  set (QT5_INSTALL_PATH /ACG/acgdev/gcc-x86_64/qt-5.12.2/5.12.2/gcc_64/ CACHE PATH "Qt5 install path set for ACG environment using QT 5.12.2" )
Jan Möbius's avatar
Jan Möbius committed
27
28
endif()

29
30
31
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." )
Jan Möbius's avatar
Jan Möbius committed
32
endif()
33

34
35
if (NOT CMAKE_BUILD_TYPE)
  message(STATUS "No build type selected, default to Release")
36
  set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE)
37
38
endif()

Jan Möbius's avatar
Jan Möbius committed
39
40

IF ( APPLE )
41
42
43
44
45
     set(CMAKE_MACOSX_RPATH 0)

     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
46
47
48
endif()


49
50
project (OpenFlipper)

51
52
53
54
55
56
57
58
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
	if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "6.0" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "4.9" OR CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL "4.9")
		message(WARNING "Your version of GCC contains an optimizer bug. Please verify that you do not use -O3!")
		string(REPLACE "-O3" "-O2" CMAKE_CXX_FLAGS_RELEASE_NEW "${CMAKE_CXX_FLAGS_RELEASE}")
		set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE_NEW}" CACHE STRING "" FORCE)
	endif()
endif()

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

Jan Möbius's avatar
Jan Möbius committed
62
# Enable automoc, autouic and auto rcc
Jan Möbius's avatar
Jan Möbius committed
63
set(CMAKE_AUTOMOC ON)
Jan Möbius's avatar
Jan Möbius committed
64
set(CMAKE_AUTOUIC ON)
Jan Möbius's avatar
Jan Möbius committed
65
set(CMAKE_AUTORCC ON)
Jan Möbius's avatar
Jan Möbius committed
66

67
68
#This finder takes very long, so call it once here to avoid calling it multiple times in the subprojects
FIND_PACKAGE(Doxygen)
Jan Möbius's avatar
Jan Möbius committed
69
70


71
72
# Include some of our OpenFlipper cmake macros
include(OpenFlipper_common)
73

74
75
76
77
78
79
80
# 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})

81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98

# ========================================================================
# Python support
# ========================================================================

if (NOT DISABLE_OPENFLIPPER_PYTHON_SYSTEM)
  set(DISABLE_OPENFLIPPER_PYTHON_SYSTEM "FALSE" CACHE BOOL "Choose if OpenFlippers integrated Python system should be build" FORCE)
endif()

if (NOT DISABLE_OPENFLIPPER_PYTHON_SYSTEM)
  find_package(Python3 COMPONENTS Development)

  if (NOT TARGET pybind11::module OR NOT TARGET pybind11::embed)
      add_subdirectory(OpenFlipper/libs_required/pybind11)
  endif()
endif()


Jan Möbius's avatar
Jan Möbius committed
99
100
101
102
103
104
105
106
107
108
# ========================================================================
# QT Setup 
# ========================================================================

# Qt setup
include(ACGQt)

acg_qt5 ()

if (NOT QT5_FOUND)
Jan Möbius's avatar
Jan Möbius committed
109
  message(FATAL_ERROR "Could not find any QT Version. Please specify QT5_INSTALL_PATH (path to bin and include dir) to build with QT5. Note that this error is also shown if not all required qt modules were found, e.g. Qt5Script.")
Jan Möbius's avatar
Jan Möbius committed
110
111
endif()

112
113
114
115
116
117
118
119
# display warnings if a problematic qt version is used

if ( APPLE )
  if ( ${Qt5Core_VERSION_STRING} STREQUAL "5.8.0" OR ${Qt5Core_VERSION_STRING} STREQUAL "5.7.1" )
    message(WARNING "You are using a Qt Version that might cause problems on OSX regarding GLErrors. We recommend you to use another version. If you fix any GLErrors on these versions feel free to contribute to OpenFlipper.")
  endif()
endif()

120
if ( WIN32 )
121
122
  OPTION(USE_UNSUPPORTED_QT "Build OpenFlipper with an unsupported version of Qt e.g. if you fixed the moc issue on 5.8.0 yourself" OFF)
  if ( ${Qt5Core_VERSION_STRING} STREQUAL "5.8.0" )
123
124
125
126
127
128
129
130
    if(USE_UNSUPPORTED_QT)
      message(WARNING "You appear to be using Qt 5.8.0 on a Windows System.\n On Windows, this version of Qt causes a problem regarding moc generation.\n You are using this Qt Version on Windows at your own risk and without support." )
    else()
      message(FATAL_ERROR "You appear to be using Qt 5.8.0 on a Windows System.\n On Windows, this version of Qt causes a problem regarding moc generation.\n Please use another version of Qt, or set the USE_UNSUPPORTED_QT flag")
    endif()
  endif()
endif()

131
set (OF_MAX_QT_VERSION "5.12.2")
Jan Möbius's avatar
Jan Möbius committed
132
133
134
135
136
137
138
139
140
141
142
143
144
145

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.")
endif()

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

# include our cmake files
include (ACGCommon)
include (MSVCMacros)

acg_get_version (OpenFlipper)

146
# ========================================================================
147
# Branding 
148
149
# ========================================================================

150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
# 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)
179
180
endif()

181
182
183
184
185
186
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
187
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)." )
188
189
set( OPENFLIPPER_PRODUCT_NAME "OpenFlipper" CACHE String "Product name used in all visible places (e.g. about box)." )

190
191
192
193
if (BRANDING_HEADER)
add_definitions(-DBRANDING_HEADER)
endif ()

194
195
196
197
198
199
add_definitions(-DPRODUCT_STRING=${OPENFLIPPER_PRODUCT_STRING})
add_definitions(-DPRODUCT_NAME=${OPENFLIPPER_PRODUCT_NAME})

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

200
201
202
203
204
include (package)
include (ACGOutput)

acg_openmp ()

Jan Möbius's avatar
Jan Möbius committed
205
# check for OpenGL, GLEW as our required dependencies
206
207
208
209
210
find_package (OpenGL)
if (NOT OPENGL_FOUND)
  message (FATAL_ERROR "OpengGL not found!")
endif ()

211
212
213
# 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")

214
215
216
217
218
219
# 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
220
221
find_package(ACG)

Jan Möbius's avatar
Jan Möbius committed
222
# OpenMesh is a dependent project (in libs_required) so no finder is needed.
223
224
225
226
if (NOT USE_INTERNAL_OPENMESH)
  find_package (OpenMesh REQUIRED)
endif()

227
228
229
230
# ========================================================================
# Configure the executables path for tests
# ========================================================================
if (APPLE)
231
  SET( OPENFLIPPER_EXECUTABLE "${CMAKE_BINARY_DIR}/Build/${OPENFLIPPER_PRODUCT_STRING}.app/Contents/MacOS/${OPENFLIPPER_PRODUCT_STRING}" )
232
elseif( WIN32 )
233
  SET( OPENFLIPPER_EXECUTABLE "${CMAKE_BINARY_DIR}/Build/${OPENFLIPPER_PRODUCT_STRING}.exe" )
234
else()
235
  SET( OPENFLIPPER_EXECUTABLE "${CMAKE_BINARY_DIR}/Build/bin/${OPENFLIPPER_PRODUCT_STRING}" )
236
endif()
237
238
239
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 )
240

241
242
enable_testing()

243
# ========================================================================
Matthias Möller's avatar
Matthias Möller committed
244
# Build all additional libraries
245
246
# ========================================================================

Jan Möbius's avatar
Jan Möbius committed
247
add_subdirectory (OpenFlipper/libs_required/glew-cmake)
248
249
250
add_subdirectory (OpenFlipper/libs_required/OpenMesh)
add_subdirectory (OpenFlipper/libs_required/ACG)

Matthias Möller's avatar
Matthias Möller committed
251
# search all libs in the libs directory
Jan Möbius's avatar
Jan Möbius committed
252
253
# in Packages, types, ...
# (required and optional libraries )
254
255
256
file (
  GLOB _local_libs_in
  RELATIVE "${CMAKE_SOURCE_DIR}"
257
           "${CMAKE_SOURCE_DIR}/libs_required/*/CMakeLists.txt"
Jan Möbius's avatar
Jan Möbius committed
258
           "${CMAKE_SOURCE_DIR}/libs/*/CMakeLists.txt"
Jan Möbius's avatar
Jan Möbius committed
259
           "${CMAKE_SOURCE_DIR}/Type-*/libs/*/CMakeLists.txt"
260
           "${CMAKE_SOURCE_DIR}/Package-*/libs/*/CMakeLists.txt"
261
262
)

Jan Möbius's avatar
Jan Möbius committed
263
264
265
266
set( REMAINING_LOCAL_LIBS "" )

# Special Comiso case:
# The library has to be configured first
267
foreach (_localLib ${_local_libs_in})
Jan Möbius's avatar
Jan Möbius committed
268
269
  if ( "${_localLib}" MATCHES .*CoMISo.* )
    get_filename_component (_local_lib_dir ${_localLib} PATH)
270
271
272
273
274
275
276
    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
277
  else()
278
279
280
    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
281
282
283
284
285
286
  endif()
endforeach ()


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

288
  get_filename_component (_local_lib_dir ${_localLib} PATH)
289
290
291

  # 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
292
  SET(REQUIRED FALSE)
293
294
295
296
297
298
299
  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
300

301
302
303
304
305
306
  # 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
307
  if ( LIB_${_local_lib_dir_upper}_BUILD OR REQUIRED)
308
309
    add_subdirectory (${CMAKE_SOURCE_DIR}/${_local_lib_dir})
  endif()
310
311
endforeach ()

312
313
314
# Group the external libraries in a folder libs_required
GROUP_PROJECT(OpenMeshTools libs_required)
GROUP_PROJECT(OpenMeshCore libs_required)
315
GROUP_PROJECT(ACG libs_required)
Jan Möbius's avatar
Jan Möbius committed
316
317

if( DOXYGEN_FOUND )
318
GROUP_PROJECT(doc-install Documentation)
Jan Möbius's avatar
Jan Möbius committed
319
endif()
320

Jan Möbius's avatar
Jan Möbius committed
321
322
323
324
325
# ========================================================================
# Core Library Components (Except the Core application)
# ========================================================================
add_subdirectory (OpenFlipper/PluginLib)

Jan Möbius's avatar
Jan Möbius committed
326
327
328
329
330
331
332
333
334
335
336
337
338
339
# ========================================================================
# Build DataTypes
# ========================================================================

# Search for all available data types
file (
  GLOB _data_types
  RELATIVE "${CMAKE_SOURCE_DIR}"
           "${CMAKE_SOURCE_DIR}/Type-*/ObjectTypes/*"
           "${CMAKE_SOURCE_DIR}/Package-*/Type-*/ObjectTypes/*"
)

# add all found libs to the build
foreach (DATATYPE_DIR ${_data_types})
340
341
  if (EXISTS ${CMAKE_SOURCE_DIR}/${DATATYPE_DIR}/CMakeLists.txt)
    add_subdirectory(${DATATYPE_DIR})
Jan Möbius's avatar
Jan Möbius committed
342

343
344
345
346
    # Extract Name of type from directory
    string(REGEX MATCH "[^/\\]*$" TYPENAME ${DATATYPE_DIR})
    string(TOUPPER ${TYPENAME} TYPENAME )
    list(APPEND TYPE_LIST ${TYPENAME})
Jan Möbius's avatar
Jan Möbius committed
347

348
349
    # Binary is only for the ui files generated there. Maybe a better solution can be found!
    set(${TYPENAME}_INCLUDE ${CMAKE_SOURCE_DIR}/${DATATYPE_DIR}/../../ ${CMAKE_BINARY_DIR}/${DATATYPE_DIR}/ )
350
 endif()
Jan Möbius's avatar
Jan Möbius committed
351
352
353
354
355
356
357
358
359
360
361
362
363
364
endforeach()

# info header for Available data types
acg_color_message ("\n${_escape}[40;37m************************************************************${_escape}[0m")
acg_color_message ("${_escape}[40;37m* Available OpenFlipper Types:                             *${_escape}[0m")
acg_color_message ("${_escape}[40;37m************************************************************${_escape}[0m")
acg_color_message (" ")

foreach (DATATYPE ${TYPE_LIST})
  acg_color_message ("${DATATYPE}")
endforeach()

acg_color_message (" ")

Jan Möbius's avatar
Jan Möbius committed
365
366
367
# ========================================================================
# Tests
# ========================================================================
Jan Möbius's avatar
Jan Möbius committed
368
add_subdirectory (OpenFlipper/tests)
Jan Möbius's avatar
Jan Möbius committed
369
370
371
372
373
374
375
376
377

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

378
# Add the documentation targets
Jan Möbius's avatar
Jan Möbius committed
379
380
381
382
383
add_subdirectory (OpenFlipper/Documentation/DeveloperTarget)
add_subdirectory (OpenFlipper/Documentation/DeveloperQtHelpTarget)
add_subdirectory (OpenFlipper/Documentation/UserTarget)
add_subdirectory (OpenFlipper/Documentation/UserQtHelpTarget)

384
385
386
387
# ========================================================================
# PolyLine extension special case
# ========================================================================

Isaak Lim's avatar
Isaak Lim committed
388
389
390
find_package (MeshIntegration)

if (MESH_INTEGRATION_FOUND)
391
392
393
  add_definitions( -DEXTENDED_POLY_LINE )
endif()

394
395
396
397
398
399
400
# ========================================================================
# 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()

401
402
403
404
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()

405
406
407
408
409
410
411
412
413
414
415
416
417
# ========================================================================
# 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 "")
418
419
acg_set (OPENFLIPPER_STATIC_PLUGINS "")
acg_set (OPENFLIPPER_STATIC_PLUGIN_FILES "")
420
acg_set (OPENFLIPPER_STATIC_PLUGIN_NAMES "")
421

422
423
424
425
426
427
foreach (package ${PREFOUND_PACKAGES})
find_package(${package})
endforeach ()

SET (LOADED_PACKAGES ${PREFOUND_PACKAGES})
LIST (APPEND LOADED_PACKAGES "Doxygen")
428
429
# add plugins
of_add_plugins ()
430
431
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.")
432

Jan Möbius's avatar
Jan Möbius committed
433
434
435
# ========================================================================
# Build core as we now know all dependencies
# ========================================================================
436

Jan Möbius's avatar
Jan Möbius committed
437
add_subdirectory (OpenFlipper/CoreApp)
438
439

set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT ${OPENFLIPPER_PRODUCT_STRING} )
440
GROUP_PROJECT(${OPENFLIPPER_PRODUCT_STRING} ${OPENFLIPPER_PRODUCT_STRING})
441

442

443

444
445
446
447
448
449
# ========================================================================
# Bundle generation
# ========================================================================

if (WIN32 )

Matthias Möller's avatar
Matthias Möller committed
450
  # Plugins collected a list of required libdirs for getting
451
452
  # their DLLS on windows:
  get_property( WINDOWS_COPY_LIBDIRS GLOBAL PROPERTY WINDOWS_LIBRARY_DIR_LIST )
Matthias Möller's avatar
Matthias Möller committed
453

454
455
456
457
  if ( WINDOWS_COPY_LIBDIRS )
    list(REMOVE_DUPLICATES WINDOWS_COPY_LIBDIRS)
  endif()

458
459
460
461
  
  # workaround for VS2018 where the OpenMP vcomp90.dll seems to be missing from the path
  if ( CMAKE_GENERATOR MATCHES "^Visual Studio 9.*" )
    INCLUDE(InstallRequiredSystemLibraries)
462
    set ( OMP_PATH "${MSVC90_REDIST_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.VC90.OPENMP/;${MSVC90_REDIST_DIR}/Debug_NonRedist/${CMAKE_MSVC_ARCH}/Microsoft.VC90.DebugOpenMP/" )
463
464
  endif()

465
466
467
468
469
470
471
472
  # 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
473
  add_dependencies (fixbundle ${OPENFLIPPER_PRODUCT_STRING} OpenFlipperPluginLib ${OPENFLIPPER_PLUGINS})
Matthias Möller's avatar
Matthias Möller committed
474

475
476
endif(WIN32)

477
# ========================================================================
478
# Custom command to create a bundle and a package on mac
479
# ========================================================================
480

481
482
483
484
485
486
487
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()

488
489
  # 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
490
     "${CMAKE_BINARY_DIR}/fixbundle.cmake" @ONLY IMMEDIATE)
491
492

  # Fixbundle is only necessary, when we wan't a shippable package.
Matthias Möller's avatar
Matthias Möller committed
493
  # Otherwise the original rpaths are used
494
  if ( OPENFLIPPER_CALL_FIX_BUNDLE )
Matthias Möller's avatar
Matthias Möller committed
495
496
    # Call fixbundle every time
    add_custom_target (fixbundle ALL
497
498
499
500
      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
501
    add_custom_target (fixbundle
502
503
504
505
      COMMAND ${CMAKE_COMMAND} -P "${CMAKE_BINARY_DIR}/fixbundle.cmake"
    )
  endif()

506
  # let bundle generation depend on all targets
Jan Möbius's avatar
Jan Möbius committed
507
  add_dependencies (fixbundle ${OPENFLIPPER_PRODUCT_STRING} OpenFlipperPluginLib ${OPENFLIPPER_PLUGINS})
508
509

  # install bundle
510
  install (DIRECTORY ${CMAKE_BINARY_DIR}/Build/${OPENFLIPPER_PRODUCT_STRING}.app DESTINATION .
511
           USE_SOURCE_PERMISSIONS)
512

513
  # Extra target for building an OpenFlipper package on mac
514
515
516
517
518
519
520
521
522
523
  # 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()

524
525
526
527
528
529
530
531
# ========================================================================
# Output log information
# ========================================================================

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