CMakeLists.txt 16.6 KB
Newer Older
chraibi's avatar
chraibi committed
1
2
3
4
5
6
7
8
9
# To have CMake pick a Qt installation of your choice that won't be found
# automatically, set the CMAKE_PREFIX_PATH environment variable.
# For example: "export CMAKE_PREFIX_PATH=/usr/local/trolltech/qt4.3.5"
# Specify the path to qmake with  QT_QMAKE_EXECUTABLE
# 
# Available flags (-D):
#================
# 1. CMAKE_BUILD_TYPE=Release (default Debug)
# 2. DESIRED_QT_VERSION=5 (default 4)
10
# example: >> cmake  -DDESIRED_QT_VERSION=5  -DCMAKE_PREFIX_PATH=~/Qt/5.5/clang_64 ..
11
# Flags for VS: -G "Visual Studio ..." -DCMAKE_PREFIX_PATH=... -DCMAKE_C_FLAGS="-mwindows" 
chraibi's avatar
chraibi committed
12

13
cmake_minimum_required(VERSION 2.8.9)
chraibi's avatar
chraibi committed
14
15
16
IF (POLICY CMP0048) # in CMake 3.0.0+
  CMAKE_POLICY (SET CMP0048 OLD) # keep PROJECT() from clearing VERSION variables
ENDIF (POLICY CMP0048)
17
18
19
IF (POLICY CMP0043) # in CMake 3.0.0+
  CMAKE_POLICY (SET CMP0043 OLD) # keep PROJECT() from clearing VERSION variables
ENDIF (POLICY CMP0043)
20
IF (POLICY CMP0020)
Erik Andresen's avatar
Erik Andresen committed
21
CMAKE_POLICY (SET CMP0020 OLD) # keep old POLICY (2.8.10 and lower) The OLD behavior for this policy is not to link executables to
22
ENDIF (POLICY CMP0020)			#qtmain.lib automatically when they link to the QtCore IMPORTEDtarget 
Mohcine Chraibi's avatar
Mohcine Chraibi committed
23
project(JPSeditor)
24

Ulrich Kemloh's avatar
Ulrich Kemloh committed
25

chraibi's avatar
chraibi committed
26
27
28

set(README_FILE "${CMAKE_SOURCE_DIR}/README.md")
set(CMAKE_COLOR_MAKEFILE ON)
Mohcine Chraibi's avatar
Mohcine Chraibi committed
29
30
31
32
33
34
set(JPSEDITOR_MAJOR_VERSION 0)
set(JPSEDITOR_MINOR_VERSION 7)
set(JPSEDITOR_PATCH_VERSION 0)
set(JPSEDITOR_VERSION
  ${JPSEDITOR_MAJOR_VERSION}.${JPSEDITOR_MINOR_VERSION}.${JPSEDITOR_PATCH_VERSION})
message( STATUS "JPSEDITOR_VERSION: " ${JPSEDITOR_VERSION} )
chraibi's avatar
chraibi committed
35
36
37


# ------------------------- Begin Generic CMake Variable Logging ------------------
Ulrich Kemloh's avatar
Ulrich Kemloh committed
38
39
message(STATUS  "The system is: ${CMAKE_SYSTEM_NAME} - ${CMAKE_SYSTEM_VERSION} - ${CMAKE_SYSTEM_PROCESSOR}")
# the compiler used for C files 
chraibi's avatar
chraibi committed
40
message( STATUS "CMAKE_C_COMPILER: " ${CMAKE_C_COMPILER} )
Ulrich Kemloh's avatar
Ulrich Kemloh committed
41
42

# the compiler used for C++ files 
chraibi's avatar
chraibi committed
43
message( STATUS "CMAKE_CXX_COMPILER: " ${CMAKE_CXX_COMPILER} )
Ulrich Kemloh's avatar
Ulrich Kemloh committed
44
45
# ------------------------- End of Generic CMake Variable Logging ------------------

chraibi's avatar
chraibi committed
46
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
Ulrich Kemloh's avatar
Ulrich Kemloh committed
47

chraibi's avatar
chraibi committed
48
49
# put in cmake cmake scripts if any
# message(STATUS "CMAKE_MODULE_PATH" ${CMAKE_MODULE_PATH})
Ulrich Kemloh's avatar
Ulrich Kemloh committed
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65


#------------------ set important directories --------------------
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin")
set(EXECUTABLE_OUTPUT_PATH "${CMAKE_SOURCE_DIR}/bin")
# Debug messages
message( STATUS "CMAKE_BINARY_DIR: " ${CMAKE_BINARY_DIR} )
message( STATUS "CMAKE_SOURCE_DIR: " ${CMAKE_SOURCE_DIR} )
message( STATUS "CMAKE_CURRENT_SOURCE_DIR: " ${CMAKE_CURRENT_SOURCE_DIR} )
message( STATUS "CMAKE_RUNTIME_OUTPUT_DIRECTORY: " ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} )
message( STATUS "EXECUTABLE_OUTPUT_PATH: " ${EXECUTABLE_OUTPUT_PATH} )
message( STATUS "CMAKE_VERBOSE_MAKEFILE: " ${CMAKE_VERBOSE_MAKEFILE} )


# we need this to be able to include headers produced by uic in our code
# (CMAKE_BINARY_DIR holds a path to the build directory, while INCLUDE_DIRECTORIES() works just like INCLUDEPATH from qmake)
chraibi's avatar
chraibi committed
66
67
include_directories( ${CMAKE_BINARY_DIR} )
include_directories( ${CMAKE_CURRENT_BINARY_DIR} )
Ulrich Kemloh's avatar
Ulrich Kemloh committed
68

69

chraibi's avatar
chraibi committed
70
if(APPLE AND CMAKE_INSTALL_PREFIX MATCHES "/usr/local")
Mohcine Chraibi's avatar
Mohcine Chraibi committed
71
	set(CMAKE_INSTALL_PREFIX "/Applications")
chraibi's avatar
chraibi committed
72
73
endif()
message(STATUS "${PROJECT_NAME} will be installed to ${CMAKE_INSTALL_PREFIX}")
74
75


chraibi's avatar
chraibi committed
76
#--------------------
77
if (NOT MSVC)
chraibi's avatar
chraibi committed
78
79
80
81
82
83
84
85
86
87
88
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
if(COMPILER_SUPPORTS_CXX11)
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
elseif(COMPILER_SUPPORTS_CXX0X)
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
else()
  message(AUTHOR_WARNING "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
endif()
message(STATUS "Checking for C++11 compiler - available")
89
endif()
chraibi's avatar
chraibi committed
90
91
92
#---------------------

set( SRCS
Ulrich Kemloh's avatar
Ulrich Kemloh committed
93
94
95
    src/mainWindow.cpp
    src/main.cpp 
    src/GraphicView.cpp
96
    src/graphicscene.cpp
Ulrich Kemloh's avatar
Ulrich Kemloh committed
97
98
99
100
101
102
103
    src/roomwidget.cpp
    src/rooms.cpp
    src/datamanager.cpp  
    src/jpscrossing.cpp  
    src/jpsLineItem.cpp  
    src/jpsexit.cpp
    src/jpsobstacle.cpp 
104
105
106
107
108
109
    src/jpslandmark.cpp
    src/jpswaypoint.cpp
    src/widgetlandmark.cpp
    src/widgetsettings.cpp
    src/jpsyahpointer.cpp
    src/jpsconnection.cpp
Erik Andresen's avatar
Erik Andresen committed
110
	src/jpsregion.cpp
111
112
    dxflib/src/dl_writer_ascii.cpp
    dxflib/src/dl_dxf.cpp
113
114
115
    src/UndoFramework/action.cpp
    src/UndoFramework/actionstack.cpp
    src/UndoFramework/lineaction.cpp
Ulrich Kemloh's avatar
Ulrich Kemloh committed
116
117
  )  
# all header files that should be treated with moc
chraibi's avatar
chraibi committed
118
set( HDR
Ulrich Kemloh's avatar
Ulrich Kemloh committed
119
120
    src/mainWindow.h 
    src/GraphicView.h
121
    src/graphicscene.h
Ulrich Kemloh's avatar
Ulrich Kemloh committed
122
123
124
125
126
127
    src/roomwidget.h
    src/rooms.h
    src/datamanager.h  
    src/jpscrossing.h  
    src/jpsLineItem.h  
    src/jpsexit.h     
128
    src/jpsobstacle.h
129
130
131
132
133
134
    src/jpslandmark.h
    src/jpswaypoint.h
    src/widgetlandmark.h
    src/widgetsettings.h
    src/jpsyahpointer.h
    src/jpsconnection.h
Erik Andresen's avatar
Erik Andresen committed
135
	src/jpsregion.h
136
137
138
139
140
141
142
143
144
145
146
    dxflib/src/dl_writer_ascii.h
    dxflib/src/dl_writer.h
    dxflib/src/dl_global.h
    dxflib/src/dl_extrusion.h
    dxflib/src/dl_exception.h
    dxflib/src/dl_entities.h
    dxflib/src/dl_dxf.h
    dxflib/src/dl_creationinterface.h
    dxflib/src/dl_creationadapter.h
    dxflib/src/dl_codes.h
    dxflib/src/dl_attributes.h
147
148
149
    src/UndoFramework/action.h
    src/UndoFramework/actionstack.h
    src/UndoFramework/lineaction.h
150
 
Ulrich Kemloh's avatar
Ulrich Kemloh committed
151
152
153
  )

# *.ui files
chraibi's avatar
chraibi committed
154
set( UIS
Ulrich Kemloh's avatar
Ulrich Kemloh committed
155
156
    forms/mainwindow.ui
    forms/roomwidget.ui
157
158
    forms/widgetlandmark.ui
    forms/widgetsettings.ui
Ulrich Kemloh's avatar
Ulrich Kemloh committed
159
160
161
  )

# and finally a resource file
chraibi's avatar
chraibi committed
162
set( RCS
Ulrich Kemloh's avatar
Ulrich Kemloh committed
163
164
165
166
167
168
169
170
171
    forms/Ressource.qrc
  )


set(CMAKE_INCLUDE_CURRENT_DIR ON)

# Instruct CMake to run moc automatically when needed.
set(CMAKE_AUTOMOC ON)

Mohcine Chraibi's avatar
Mohcine Chraibi committed
172
173
174
175
IF (WIN32)
    SET (QT_USE_QTMAIN TRUE)
ENDIF (WIN32)

Ulrich Kemloh's avatar
Ulrich Kemloh committed
176
#--------------- here comes QT. Version problem (4 or 5?)
chraibi's avatar
chraibi committed
177
178
179
180
181
# cmake does not provide findqt5-modules

message(STATUS "QT_Qmake_executable " ${QT_QMAKE_EXECUTABLE})
if($QT_QMAKE_EXECUTABLE STREQUAL "")
  FIND_PROGRAM(QT_QMAKE_EXECUTABLE NAMES qmake)
182
  if (NOT QT_QMAKE_EXECUTABLE)
chraibi's avatar
chraibi committed
183
184
185
    message(WARNING "QT not found - abort.")
  endif()
endif()
Ulrich Kemloh's avatar
Ulrich Kemloh committed
186

chraibi's avatar
chraibi committed
187
#
Ulrich Kemloh's avatar
Ulrich Kemloh committed
188

chraibi's avatar
chraibi committed
189
# default qt version is 4
Ulrich Kemloh's avatar
Ulrich Kemloh committed
190
if("${DESIRED_QT_VERSION}" STREQUAL "")
chraibi's avatar
chraibi committed
191
  set(DESIRED_QT_VERSION "4")
Ulrich Kemloh's avatar
Ulrich Kemloh committed
192
193
endif()

chraibi's avatar
chraibi committed
194
195
196
# qt version > 5 or qt version < 3 are not supported
if( ${DESIRED_QT_VERSION} VERSION_GREATER 5 OR ${DESIRED_QT_VERSION} VERSION_LESS 3)
  message(FATAL_ERROR "QT version " ${DESIRED_QT_VERSION} " not supported. Try 4 or 5")
Ulrich Kemloh's avatar
Ulrich Kemloh committed
197
198
endif()

chraibi's avatar
chraibi committed
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
# find packages according to qt version
if("${DESIRED_QT_VERSION}" STREQUAL "5")
  find_package(Qt5Widgets REQUIRED)
# - these find_packages are not necessary? -----------
  FIND_PACKAGE(Qt5Core REQUIRED)
  FIND_PACKAGE(Qt5Gui REQUIRED)
  FIND_PACKAGE(Qt5Network REQUIRED)
  FIND_PACKAGE(Qt5Xml REQUIRED)
#-----------------------------------------------------
  set(QT5_INSTALLED TRUE)
  MESSAGE(STATUS "Found Qt version: ${Qt5Core_VERSION_STRING}")
elseif("${DESIRED_QT_VERSION}" STREQUAL "4")
 
  #   QT4_INSTALLED is set to TRUE if qt4 is found and
  #   QT3_INSTALLED is set to TRUE if qt3 is found.
  FIND_PACKAGE(Qt COMPONENTS QtXml QT_USE_QTNETWORK QtXmlPatterns REQUIRED)
215
  set(QT4_INSTALLED TRUE)
chraibi's avatar
chraibi committed
216
217
218
219
220
endif()




Ulrich Kemloh's avatar
Ulrich Kemloh committed
221
message(STATUS "DESIRED_QT_VERSION " ${DESIRED_QT_VERSION})
chraibi's avatar
chraibi committed
222
223
224
225
226
227
228
229
230
231
232
233
234
if(QT5_INSTALLED)
  message(STATUS "QT5_INSTALLED: " ${QT5_INSTALLED})
elseif(QT4_INSTALLED )
  message(STATUS "QT4_INSTALLED: " ${QT4_INSTALLED})
elseif(QT3_INSTALLED)
  message(STATUS "QT3_INSTALLED: " ${QT3_INSTALLED})
else()
  message(SEND_ERROR "No supported Qt found.")
endif()
# Disable automatic conversion from QString to ASCII 8-bit strings (char *)
# (Keeps code compatible with Qt/Mac/64bit)
if(APPLE)
  ADD_DEFINITIONS(-DQT_NO_CAST_TO_ASCII)
Mohcine Chraibi's avatar
Mohcine Chraibi committed
235
236
  # include the icns file in the target
  SET(SRCS ${SRCS} ${CMAKE_CURRENT_SOURCE_DIR}/icons/jupedsim.icns)
chraibi's avatar
chraibi committed
237
238
239
240
241
endif()

# this command will generate rules that will run rcc on all files from RCS
# in result RC_SRCS variable will contain paths to files produced by rcc
if(${QT4_INSTALLED})
Ulrich Kemloh's avatar
Ulrich Kemloh committed
242
243
  message(STATUS "Working with Qt4")
  # and finally this will run moc:
chraibi's avatar
chraibi committed
244
  QT4_WRAP_CPP( MOC_HDRS ${MOC_HDRS} )
Ulrich Kemloh's avatar
Ulrich Kemloh committed
245
  # this will run uic on .ui files:
chraibi's avatar
chraibi committed
246
  QT4_WRAP_UI( UI_HDRS ${UIS} )
Mohcine Chraibi's avatar
Mohcine Chraibi committed
247
  QT4_ADD_RESOURCES( RCS ${RCS} )
Ulrich Kemloh's avatar
Ulrich Kemloh committed
248
  include( ${QT_USE_FILE} )
Mohcine Chraibi's avatar
Mohcine Chraibi committed
249
  ADD_EXECUTABLE( JPSeditor MACOSX_BUNDLE WIN32
chraibi's avatar
chraibi committed
250
251
252
  ${SRCS}
  ${MOC_HDRS}
  ${UI_HDRS} 
Mohcine Chraibi's avatar
Mohcine Chraibi committed
253
  ${RCS}
chraibi's avatar
chraibi committed
254
  )
Mohcine Chraibi's avatar
Mohcine Chraibi committed
255
  TARGET_LINK_LIBRARIES( JPSeditor ${QT_LIBRARIES})
chraibi's avatar
chraibi committed
256
257
258
259
260
261
elseif( ${QT5_INSTALLED})
  message(STATUS "Working with Qt5")
  # http://www.kdab.com/using-cmake-with-qt-5/
  set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}" ) 
  
  qt5_wrap_ui( UI_HDRS ${UIS} )
Mohcine Chraibi's avatar
Mohcine Chraibi committed
262
263
  qt5_add_resources( RCS ${RCS} )
  #qt5_use_package(JPSeditor Widgets)
chraibi's avatar
chraibi committed
264

Mohcine Chraibi's avatar
Mohcine Chraibi committed
265
  ADD_EXECUTABLE( JPSeditor MACOSX_BUNDLE WIN32
chraibi's avatar
chraibi committed
266
267
268
  ${SRCS}
  ${MOC_HDRS}
  ${UI_HDRS} 
Mohcine Chraibi's avatar
Mohcine Chraibi committed
269
  ${RCS}
chraibi's avatar
chraibi committed
270
  )
Mohcine Chraibi's avatar
Mohcine Chraibi committed
271
272
 qt5_use_modules(JPSeditor Widgets)
 target_link_libraries(JPSeditor ${Qt5Widgets_LIBRARIES})
chraibi's avatar
chraibi committed
273
else()
Mohcine Chraibi's avatar
Mohcine Chraibi committed
274
  message(FATAL_ERROR "QT NOT BE FOUND - ABORT")
Ulrich Kemloh's avatar
Ulrich Kemloh committed
275
276
endif() 

277
278
279
280
281
282
IF(APPLE)
  SET(MACOSX_BUNDLE_ICON_FILE jupedsim.icns)
  SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_SOURCE_DIR}/icons/jupedsim.icns PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
ENDIF(APPLE)


Mohcine Chraibi's avatar
Mohcine Chraibi committed
283
SET_TARGET_PROPERTIES( JPSeditor PROPERTIES MACOSX_BUNDLE TRUE)
Ulrich Kemloh's avatar
Ulrich Kemloh committed
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
#----------------------------------------------------------------------
# enable as many warnings as possible
set(warning_flags "-Wall -Wextra")
# issue all the warnings demanded by strict iso c and iso c++
set(warning_flags "${warning_flags} -pedantic")
#---------------------------- compiler -------------------------------
# Initialize CXXFLAGS.
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
  set(CMAKE_CXX_FLAGS                "${CMAKE_CXX_FLAGS} ${warning_flags}")
  set(CMAKE_CXX_FLAGS_DEBUG          "${CMAKE_CXX_FLAGS_DEBUG} ${warning_flags} -O0 -g -Wunused-variable -Wunused-parameter -Wunused-function -Wshadow -Wunused")
  #    set(CMAKE_CXX_FLAGS_RELEASE        "${CMAKE_CXX_FLAGS_RELEASE} -O3 -DNDEBUG")
endif()



if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
  message(STATUS "Using Clang " ${CMAKE_CXX_COMPILER_VERSION})
endif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
if(CMAKE_COMPILER_IS_GNUCXX)
  message( STATUS "Using g++ " ${CMAKE_CXX_COMPILER_VERSION})
endif(CMAKE_COMPILER_IS_GNUCXX)

if(CMAKE_BUILD_TYPE MATCHES Debug)
  set(CMAKE_CXX_LDFLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fprofile-arcs -ftest-coverage")
  message(STATUS "Debug flags: "  ${CMAKE_CXX_FLAGS} " " ${CMAKE_CXX_FLAGS_DEBUG} )
else(CMAKE_BUILD_TYPE MATCHES Debug)
chraibi's avatar
chraibi committed
310
  set(CMAKE_BUILD_TYPE Release)
Ulrich Kemloh's avatar
Ulrich Kemloh committed
311
312
313
314
315
316
317
  message(STATUS "Release flags: " ${CMAKE_CXX_FLAGS} " ,  " ${CMAKE_CXX_FLAGS_RELEASE} )
endif(CMAKE_BUILD_TYPE MATCHES Debug)

# PGI ++ Flags
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "PGI")
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --c++11 -Minform=inform")	
endif()
chraibi's avatar
chraibi committed
318
message(STATUS "Building ${PROJECT_NAME} in ${CMAKE_BUILD_TYPE} mode")
319
320
321
322
323
#--------------------------------------------------------------------------------
# Now the installation stuff below
#--------------------------------------------------------------------------------
SET(plugin_dest_dir bin)
SET(qtconf_dest_dir bin)
Mohcine Chraibi's avatar
Mohcine Chraibi committed
324
SET(APPS "\${CMAKE_INSTALL_PREFIX}/bin/JPSeditor")
325
IF(APPLE)
Mohcine Chraibi's avatar
Mohcine Chraibi committed
326
327
328
  SET(plugin_dest_dir JPSeditor.app/Contents/MacOS)
  SET(qtconf_dest_dir JPSeditor.app/Contents/Resources)
  SET(APPS "\${CMAKE_INSTALL_PREFIX}/JPSeditor.app")  
329
330
331
ENDIF(APPLE)

IF(WIN32)
Mohcine Chraibi's avatar
Mohcine Chraibi committed
332
  SET(APPS "\${CMAKE_INSTALL_PREFIX}/bin/JPSeditor.exe")
333
334
ENDIF(WIN32)

Mohcine Chraibi's avatar
Mohcine Chraibi committed
335
INSTALL(TARGETS JPSeditor
Mohcine Chraibi's avatar
Mohcine Chraibi committed
336
  BUNDLE DESTINATION . COMPONENT Runtime
337
  RUNTIME DESTINATION bin COMPONENT Runtime
Mohcine Chraibi's avatar
Mohcine Chraibi committed
338
  # PERMISSIONS OWNER_EXECUTE 600
339
340
341
342
343
  )

#--------------------------------------------------------------------------------
# Install needed Qt plugins by copying directories from the qt installation
# One can cull what gets copied by using 'REGEX "..." EXCLUDE'
chraibi's avatar
chraibi committed
344
# todo should we check qt version here?
Mohcine Chraibi's avatar
Mohcine Chraibi committed
345
346
347
348
349
350
INSTALL(DIRECTORY "${QT_PLUGINS_DIR}/imageformats" DESTINATION ${plugin_dest_dir}/plugins
  # DIRECTORY_PERMISSIONS
  # OWNER_WRITE OWNER_READ  OWNER_EXECUTE
  # GROUP_WRITE GROUP_READ  GROUP_EXECUTE
  # WORLD_WRITE WORLD_READ WORLD_EXECUTE
  COMPONENT Runtime)
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365

#--------------------------------------------------------------------------------
# install a qt.conf file
# this inserts some cmake code into the install script to write the file
INSTALL(CODE "
    file(WRITE \"\${CMAKE_INSTALL_PREFIX}/${qtconf_dest_dir}/qt.conf\" \"\")
    " COMPONENT Runtime)


#--------------------------------------------------------------------------------
# Use BundleUtilities to get all other dependencies for the application to work.
# It takes a bundle or executable along with possible plugins and inspects it
# for dependencies.  If they are not system dependencies, they are copied.

# directories to look for dependencies
chraibi's avatar
chraibi committed
366
367
368
369
370
371

if( ${QT5_INSTALLED})
  SET(DIRS ${QT_LIBRARIES})
elseif( ${QT5_INSTALLED})
  SET(DIRS ${QT_LIBRARY_DIRS})
endif()
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391

# Now the work of copying dependencies into the bundle/package
# The quotes are escaped and variables to use at install time have their $ escaped
# An alternative is the do a configure_file() on a script and use install(SCRIPT  ...).
# Note that the image plugins depend on QtSvg and QtXml, and it got those copied
# over.
INSTALL(CODE "
    file(GLOB_RECURSE QTPLUGINS
      \"\${CMAKE_INSTALL_PREFIX}/${plugin_dest_dir}/plugins/*${CMAKE_SHARED_LIBRARY_SUFFIX}\")
    include(BundleUtilities)
    fixup_bundle(\"${APPS}\" \"\${QTPLUGINS}\" \"${DIRS}\")
    " COMPONENT Runtime)




#================================================ APPLE Stuff ======================

IF(APPLE)
  # set how it shows up in the Info.plist file
chraibi's avatar
chraibi committed
392
  SET(MACOSX_EDIT_ICON jupedsim.icns)
Mohcine Chraibi's avatar
Mohcine Chraibi committed
393
  set_target_properties(JPSeditor PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Resources/Info.plist.in)
394
  SET(MACOSX_BUNDLE_COPYRIGHT "Copyright (c) 2015 Forschungszentrum Juelich. All rights reserved.")
Mohcine Chraibi's avatar
Mohcine Chraibi committed
395
396
397
398
  SET(MACOSX_BUNDLE_BUNDLE_NAME "JPSeditor")
  SET(MACOSX_BUNDLE_BUNDLE_VERSION "${JPSEDITOR_VERSION}")
  SET(MACOSX_BUNDLE_LONG_VERSION_STRING "version ${JPSEDITOR_VERSION}")
  SET(MACOSX_BUNDLE_SHORT_VERSION_STRING "${JPSEDITOR_VERSION}")
chraibi's avatar
chraibi committed
399
400
  SET(MACOSX_EDIT_COPYRIGHT "Copyright (c) 2015 Forschungszentrum Juelich. All rights reserved.")
  SET(MACOSX_BUNDLE_EDIT_IDENTIFIER "www.jupedsim.org")
401
402
403
404
405
406
407
  # set where in the bundle to put the icns file

ENDIF(APPLE)

# To Create a package, one can run "cpack -G DragNDrop CPackConfig.cmake" on Mac OS X
# where CPackConfig.cmake is created by including CPack
# And then there's ways to customize this as well
chraibi's avatar
chraibi committed
408
# https://github.com/mikemcquaid/Fabula
409
set(CPACK_BINARY_DRAGNDROP ON)
chraibi's avatar
chraibi committed
410
set(CPACK_GENERATOR "TBZ2")
Mohcine Chraibi's avatar
Mohcine Chraibi committed
411
412
413
414
415
set(CPACK_PACKAGE_VERSION_MAJOR "${JPSEDITOR_VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${JPSEDITOR_VERSION_MINOR}")
set(CPACK_PACKAGE_VERSION_PATCH "${JPSEDITOR_version_patch}")
set(CPACK_PACKAGE_VERSION "${JPSEDITOR_VERSION}")
set(CPACK_PACKAGE_VENDOR "${JPSEDITOR_VENDOR}")
chraibi's avatar
chraibi committed
416
417
418
419
420
set(CPACK_RESOURCE_FILE_README "${README_FILE}")
if(WIN32) # todo test this for windows
    set(CPACK_GENERATOR "NSIS")
    set(CPACK_PACKAGE_EXECUTABLES "${PROJECT_NAME}" "${PROJECT_NAME}")
    set(CPACK_PACKAGE_INSTALL_DIRECTORY "${PROJECT_NAME}")
Mohcine Chraibi's avatar
Mohcine Chraibi committed
421
    set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME} ${JPSEDITOR_VERSION}")
chraibi's avatar
chraibi committed
422
423
424
425
426
427
428
429
    set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/${LICENSE_FILE}")
    set(CPACK_NSIS_EXECUTABLES_DIRECTORY "${BIN_INSTALL_DIR}")
    #set(CPACK_NSIS_MUI_ICON "${PROJECT_ICONS_DIRECTORY}/NSIS.ico")
    #set(CPACK_PACKAGE_ICON "${PROJECT_ICONS_DIRECTORY}\\\\NSISHeader.bmp")
    set(CPACK_NSIS_INSTALLED_ICON_NAME "${PROJECT_NAME}${CMAKE_EXECUTABLE_SUFFIX}")
#    set(CPACK_NSIS_MENU_LINKS "${LICENSE_FILE}" "License" "${README_FILE}" "Readme")
 #   set(CPACK_NSIS_MUI_FINISHPAGE_RUN "${CPACK_NSIS_INSTALLED_ICON_NAME}")
elseif(APPLE) # todo test this for apple
Mohcine Chraibi's avatar
Mohcine Chraibi committed
430
     set(CMAKE_INSTALL_PREFIX "/Applications/")
chraibi's avatar
chraibi committed
431
432
433
434
     set(CPACK_GENERATOR "DragNDrop")
     set(CPACK_DMG_FORMAT "UDBZ")
     set(CPACK_DMG_VOLUME_NAME "${PROJECT_NAME}")
     set(CPACK_SYSTEM_NAME "OSX")
Mohcine Chraibi's avatar
Mohcine Chraibi committed
435
     set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${JPSEDITOR_VERSION}")
chraibi's avatar
chraibi committed
436
437
438
439
440
441
442
443
     #set(CPACK_PACKAGE_ICON "${ICONS_DIR}/DMG.icns")
     #set(CPACK_DMG_DS_STORE "${ICONS_DIR}/DMGDSStore")
     #set(CPACK_DMG_BACKGROUND_IMAGE "${ICONS_DIR}/DMGBackground.png")
   elseif(UNIX)
     # tested with success in 
     # Linux dhcppc5 3.2.0-4-686-pae #1 SMP Debian 3.2.68-1+deb7u2 i686 GNU/Linux
    set(CPACK_SYSTEM_NAME "${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}")
endif()
444
445
446
include(CPack)


Mohcine Chraibi's avatar
Mohcine Chraibi committed
447
message (STATUS "bin ins" ${BIN_INSTALL_DIR})
chraibi's avatar
chraibi committed
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
set(CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION "${BIN_INSTALL_DIR}")
include(InstallRequiredSystemLibraries)

if(APPLE)
    set(EXECUTABLE "${PROJECT_NAME}.app")
elseif(WIN32)
    set(EXECUTABLE "${PROJECT_NAME}${CMAKE_EXECUTABLE_SUFFIX}")
else()
    set(EXECUTABLE "${BIN_INSTALL_DIR}/${PROJECT_NAME}${CMAKE_EXECUTABLE_SUFFIX}")
endif()

if(APPLE OR WIN32)
  if(${QT4_INSTALLED})
    include(DeployQt4)
    install_qt4_executable("${EXECUTABLE}" "qsqlite")
Erik Andresen's avatar
Erik Andresen committed
463

GrgrLmml's avatar
GrgrLmml committed
464
  elseif(${QT5_INSTALLED})
chraibi's avatar
chraibi committed
465
466
467
468
469
    include(DeployQt5)
    install_qt5_executable("${EXECUTABLE}" "qsqlite")
  endif()
endif()