CamiTKExtensionPackaging.cmake 15.9 KB
Newer Older
1
2
3
4
5
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
#!
#! \addtogroup CamiTKMacros
#!
#! CamiTK cep packaging allows you to build a package from a CEP
#! If README and COPYRIGHT files exists at top source dir, then
#! they will be included in the source package
#!
#! Usage:
#! \code
#! camitk_cep_packaging(DESCRIPTION "CEP package description"
#!                      [NAME packageName]
#!                      [VENDOR vendorName]
#!                      [CONTACT contactName]
#!                      [APPLICATIONS appName1 appName2...]
#! )
#! \endcode
#!
#  \param DESCRIPTION                   Some comments on what is this CEP package about
#! \param NAME (optional)               Specify the package name (default is project name)
#! \param VENDOR (optional)             Specify the vendor name (default is TIMC-IMAG)
#! \param CONTACT (optional)            Specify the contact name (default is link to CamiTK website)
#! \param APPLICATIONS (optional)       If you want to package some applications

macro(camitk_cep_packaging)

#  CEP Packaging only works for stand-alone CEP
if (NOT CAMITK_MULTI_CEP)
    
parse_arguments(CAMITK_CEP_PACKAGING
        "NAME;VENDOR;CONTACT;APPLICATIONS;DESCRIPTION"  # possible lists
        ""  # possible option
        ${ARGN}
)
34

35
36
37
38
39
40
41
42
# package named
if (CAMITK_CEP_PACKAGING_NAME)
    set(PACKAGING_NAME ${CAMITK_CEP_PACKAGING_NAME})
else()
    # package name is project name
    set(PACKAGING_NAME ${CMAKE_PROJECT_NAME})
endif()
string(TOLOWER ${PACKAGING_NAME} CPACK_PACKAGE_NAME)
43
set(CPACK_PACKAGE_VERSION_MAJOR ${CAMITK_VER_MAJ})
44
set(CPACK_PACKAGE_VERSION_MINOR "0")
45
46
set(CPACK_PACKAGE_VERSION_PATCH ${CAMITK_VER_PACKAGE_PAT})
string(TOLOWER "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}-${CAMITK_VER_NICKNAME}-${LSB_DISTRIB}_${CPACK_PACKAGE_ARCHITECTURE}" CPACK_PACKAGE_FILE_NAME)
47

48
# contact information
49
50
51
52
53
54
55
56
57
58
if (CAMITK_CEP_PACKAGING_VENDOR)
    set(CPACK_PACKAGE_VENDOR ${CAMITK_CEP_PACKAGING_VENDOR})
else()
    set(CPACK_PACKAGE_VENDOR "UJF-Grenoble 1, CNRS, TIMC-IMAG UMR 5525")
endif()
if (CAMITK_CEP_PACKAGING_CONTACT)
    set(CPACK_PACKAGE_CONTACT ${CAMITK_CEP_PACKAGING_CONTACT})
else()
    set(CPACK_PACKAGE_CONTACT "http://camitk.imag.fr")
endif()
59

60
61
62
63
64
65
66
# resource files
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/README")
    set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README")
endif()
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/COPYING")
    set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING")
endif()
67

68
69
70
71
72
73
74
75
# applications / executable
if(CAMITK_CEP_PACKAGING_APPLICATIONS)    
    set(EXECUTABLES_TO_PACKAGE)
    foreach(APP_TO_PACKAGE ${CAMITK_CEP_PACKAGING_APPLICATIONS})
        # name and label are the same
        set(EXECUTABLES_TO_PACKAGE ${EXECUTABLES_TO_PACKAGE} ${APP_TO_PACKAGE} ${APP_TO_PACKAGE})
    endforeach()
    set(CPACK_PACKAGE_EXECUTABLES ${EXECUTABLES_TO_PACKAGE})
76
77
endif()

78
79
# package description
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY ${CAMITK_CEP_PACKAGING_DESCRIPTION})
80

81
# Files to ignore during generation of the package
82
83
set(CPACK_SOURCE_IGNORE_FILES
"~$"
84
85
"/CVS/"
"tags"
86
87
"/\\\\.svn/"
"/\\\\.git/"
88
"/kdev4$/"
89
"/build/"
90
91
92
93
"\\\\.kdevses$"
"\\\\.kdev4$"
"\\\\.kdevelop\\\\.pcs$"
".DS_Store"
94
95
96
${CPACK_SOURCE_IGNORE_FILES}
)

97
set(CPACK_SOURCE_GENERATOR "TGZ" "ZIP" )
98

99
100
101
# ----------------------------------
# Unix packages (Ubuntu and Debian)
# ----------------------------------
102
if (UNIX AND NOT WIN32)
103

104
        message(STATUS "Packaging ${CPACK_PACKAGE_NAME} for UNIX systems")
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
        # Try to find architecture
        execute_process(COMMAND uname -m OUTPUT_VARIABLE CPACK_PACKAGE_ARCHITECTURE)
        string(STRIP "${CPACK_PACKAGE_ARCHITECTURE}" CPACK_PACKAGE_ARCHITECTURE)
        # Try to find distro name and distro-specific arch
        execute_process(COMMAND lsb_release -is OUTPUT_VARIABLE LSB_ID)
        execute_process(COMMAND lsb_release -rs OUTPUT_VARIABLE LSB_RELEASE)
        string(STRIP "${LSB_ID}" LSB_ID)
        string(STRIP "${LSB_RELEASE}" LSB_RELEASE)
        set(LSB_DISTRIB "${LSB_ID}${LSB_RELEASE}")
        if(NOT LSB_DISTRIB)
                set(LSB_DISTRIB "unix")
        endif(NOT LSB_DISTRIB)
        message(STATUS "Packager architecture : ${LSB_DISTRIB}")

        #Find DPKG
        find_program(DPKG
                NAMES dpkg-deb
                PATHS "/usr/bin" #Add paths here
        )
        if ( DPKG )
                get_filename_component(DPKG_PATH ${DPKG} ABSOLUTE)
                message(STATUS "Packaging deb using ${DPKG_PATH}: OK")
                set(DPKG_FOUND "YES")
        else()
                set(DPKG_FOUND "NO")
        endif()

        # For Debian-based distribs we want to create DEB packages.
        if("${LSB_DISTRIB}" MATCHES "Ubuntu|Debian")

                # We need to alter the architecture names as per distro rules
                if("${CPACK_PACKAGE_ARCHITECTURE}" MATCHES "i[3-6]86")
                        set(CPACK_PACKAGE_ARCHITECTURE i386)
                endif()
                if("${CPACK_PACKAGE_ARCHITECTURE}" MATCHES "x86_64")
                        set(CPACK_PACKAGE_ARCHITECTURE amd64)
                endif()
                # Set the dependencies based on the distrib version

                # Installation path
                # Set the install location to "/usr"
                # set(CAMITK_INSTALL_ROOT "/usr") # Set the CamiTK install root path in your CMake command line / GUI.
                set(CPACK_PACKAGING_INSTALL_PREFIX "/usr")
                set(CPACK_PACKAGE_DEFAULT_LOCATION "/usr")
                set(CPACK_SET_DESTDIR TRUE)

                # Dependencies depending on the Operating System.
                # Ubuntu11.10
                if("${LSB_DISTRIB}" MATCHES "Ubuntu11.10")
                        set(CPACK_DEBIAN_PACKAGE_DEPENDS "libqt4-dev, libinsighttoolkit3.20, libxml2, libvtk5.6-qt4, libxerces-c3.1 ")
                endif()
                # For Ubuntu12.04
                if("${LSB_DISTRIB}" MATCHES "Ubuntu12.04")
158
                        set(LSB_DISTRIB "Ubuntu12.xx")
159
160
                        set(CPACK_DEBIAN_PACKAGE_DEPENDS "libqt4-dev, libinsighttoolkit3.20, libxml2, libvtk5.8-qt4, libxerces-c3.1 ")
                endif()
161
162
163
164
                if("${LSB_DISTRIB}" MATCHES "Ubuntu12.04.1")
                    set(LSB_DISTRIB "Ubuntu12.xx")
                    set(CPACK_DEBIAN_PACKAGE_DEPENDS "libqt4-dev, libinsighttoolkit3.20, libxml2, libvtk5.8-qt4, libxerces-c3.1 ")
                endif()
165
166
                # For Ubuntu12.10
                if("${LSB_DISTRIB}" MATCHES "Ubuntu12.10")
167
168
                    set(LSB_DISTRIB "Ubuntu12.xx")
                    set(CPACK_DEBIAN_PACKAGE_DEPENDS "libqt4-dev, libinsighttoolkit3.20, libxml2, libvtk5.8-qt4, libxerces-c3.1 ")
169
                endif()
170
171
                
                # TODO Debian dependencies (see CamiTKPackaging.cmake)
172
173
174
175
176
177
178
179

                if(NOT CPACK_DEBIAN_PACKAGE_DEPENDS)
                        message("Packaging for ${LSB_DISTRIB} not supported yet.\nPlease set deps in cmake/darktable-packaging.cmake before packaging.")
                endif()

        endif()

        # package name
180
        string(TOLOWER "${CPACK_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}-${LSB_DISTRIB}_${CPACK_PACKAGE_ARCHITECTURE}" CPACK_PACKAGE_FILE_NAME)
181

182
endif()
183
184
185



186
187
188
189
if(WIN32 AND NOT UNIX)
        # -----------------------
        # NSIS Windows installer
        # -----------------------
190

191
192
193
194
        # Update package name for windows release
        set(LSB_DISTRIB "win32")
        set(CPACK_PACKAGE_ARCHITECTURE i386)
        string(TOLOWER "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}-${CAMITK_VER_NICKNAME}-${LSB_DISTRIB}" CPACK_PACKAGE_FILE_NAME)
195

196
197
198
199
200
201
202
        # Try to find Makensis on Linux distribution
        find_program(MAKENSIS
          NAMES makensis
          PATHS "/usr/bin"
        )

        if(MAKENSIS)
203
204
205
206
            set(ITK_ROOT_DIR "C:/dev/ITK/3.20.1")

            # MinGW compiler
            if ("${CMAKE_GENERATOR}" MATCHES "MinGW Makefiles")
207
208
209
210
211
212
                # NSIS Windows installer
                message(STATUS "Packaging nsis using ${MAKENSIS}")

                set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS
                  ##TODO use GetPrerequisites.cmake (i.e. find a better way to list dependencies)
                  ##get_prerequisites() is not well enough documented to justify the time investement - EP May 2011
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
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
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
         ${QT_BINARY_DIR}/QtCore4.dll
         ${QT_BINARY_DIR}/QtGui4.dll
         ${QT_BINARY_DIR}/QtSvg4.dll
         ${QT_BINARY_DIR}/QtXml4.dll
         ${QT_BINARY_DIR}/QtNetwork4.dll
         ${QT_BINARY_DIR}/QtSql4.dll
         ${QT_BINARY_DIR}/QtWebKit4.dll
         # VTK dependencies
         ${VTK_LIBRARY_DIRS}/libQVTK.dll
         ${VTK_LIBRARY_DIRS}/libvtkCommon.dll
         ${VTK_LIBRARY_DIRS}/libvtksys.dll
         ${VTK_LIBRARY_DIRS}/libvtkFiltering.dll
         ${VTK_LIBRARY_DIRS}/libvtkGraphics.dll
         ${VTK_LIBRARY_DIRS}/libvtkHybrid.dll
         ${VTK_LIBRARY_DIRS}/libvtkIO.dll
         ${VTK_LIBRARY_DIRS}/libvtkImaging.dll
         ${VTK_LIBRARY_DIRS}/libvtkRendering.dll
         ${VTK_LIBRARY_DIRS}/libvtkVolumeRendering.dll
         ${VTK_LIBRARY_DIRS}/libvtkverdict.dll
         ${VTK_LIBRARY_DIRS}/libvtkDICOMParser.dll
         ${VTK_LIBRARY_DIRS}/libvtkNetCDF.dll
         ${VTK_LIBRARY_DIRS}/libvtkNetCDF_cxx.dll
         ${VTK_LIBRARY_DIRS}/libvtkexpat.dll
         ${VTK_LIBRARY_DIRS}/libvtkjpeg.dll
         ${VTK_LIBRARY_DIRS}/libvtkmetaio.dll
         ${VTK_LIBRARY_DIRS}/libvtkpng.dll
         ${VTK_LIBRARY_DIRS}/libvtktiff.dll
         ${VTK_LIBRARY_DIRS}/libvtkzlib.dll
         ${VTK_LIBRARY_DIRS}/libvtkInfovis.dll
         ${VTK_LIBRARY_DIRS}/libvtkfreetype.dll
         ${VTK_LIBRARY_DIRS}/libvtkftgl.dll
         ${VTK_LIBRARY_DIRS}/libvtkalglib.dll
         ${VTK_LIBRARY_DIRS}/libvtklibxml2.dll
         ${VTK_LIBRARY_DIRS}/libvtkViews.dll
         ${VTK_LIBRARY_DIRS}/libvtkexoIIc.dll
         ${VTK_LIBRARY_DIRS}/libvtkWidgets.dll
         ${VTK_LIBRARY_DIRS}/vtkhdf5.dll
         ${VTK_LIBRARY_DIRS}/vtkhdf5_hl.dll
         ${VTK_LIBRARY_DIRS}/libLSDyna.dll
         # Xerces-c dependency
         # ${XERCESC_ROOT_DIR}/bin/xerces-c_3_1.dll
         # Libxml2 dependencies
         # ${LIBXML2_INCLUDE_DIR}/../bin/iconv.dll
         C:/dev/libxml2/2.8/bin/libxml2-2.dll
         # ${LIBXML2_INCLUDE_DIR}/../bin/zlib1.dll
         # ITK dependency
         ${ITK_ROOT_DIR}/bin/libITKCommon.dll
         ${ITK_ROOT_DIR}/bin/libITKBasicFilters.dll
         ${ITK_ROOT_DIR}/lib/InsightToolkit/libitksys.dll
         ${ITK_ROOT_DIR}/bin/libitkvnl.dll
         ${ITK_ROOT_DIR}/bin/libitkvnl_algo.dll
         ${ITK_ROOT_DIR}/bin/libITKIO.dll
         ${ITK_ROOT_DIR}/bin/libitkv3p_lsqr.dll
         ${ITK_ROOT_DIR}/bin/libitkv3p_netlib.dll
         ${ITK_ROOT_DIR}/bin/libITKDICOMParser.dll
         ${ITK_ROOT_DIR}/bin/libITKEXPAT.dll
         ${ITK_ROOT_DIR}/bin/libitkgdcm.dll
         ${ITK_ROOT_DIR}/bin/libitkjpeg8.dll
         ${ITK_ROOT_DIR}/bin/libITKMetaIO.dll
         ${ITK_ROOT_DIR}/bin/libITKniftiio.dll
         ${ITK_ROOT_DIR}/bin/libITKNrrdIO.dll
         ${ITK_ROOT_DIR}/bin/libitkpng.dll
         ${ITK_ROOT_DIR}/bin/libitktiff.dll
         ${ITK_ROOT_DIR}/bin/libitkzlib.dll
         ${ITK_ROOT_DIR}/bin/libitkjpeg12.dll
         ${ITK_ROOT_DIR}/bin/libitkjpeg16.dll
         ${ITK_ROOT_DIR}/bin/libitkopenjpeg.dll
         ${ITK_ROOT_DIR}/bin/libITKznz.dll
         # MinGW Dependencies
         C:/dev/MinGW/bin/libgcc_s_dw2-1.dll
         C:/dev/MinGW/bin/libstdc++-6.dll
         C:/dev/MinGW/bin/mingwm10.dll
         )

      endif()

      # MSVC compiler
      if ("${CMAKE_GENERATOR}" MATCHES "Visual Studio 9 2008")

         message(STATUS "Packaging nsis using ${MAKENSIS} with MSVC compiler")

         set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS
         ##TODO use GetPrerequisites.cmake (i.e. find a better way to list dependencies)
         ##get_prerequisites() is not well enough documented to justify the time investement - EP May 2011
                 # Qt dependencies
         ${QT_BINARY_DIR}/QtCore4.dll
         ${QT_BINARY_DIR}/QtGui4.dll
         ${QT_BINARY_DIR}/QtSvg4.dll
         ${QT_BINARY_DIR}/QtXml4.dll
         ${QT_BINARY_DIR}/QtNetwork4.dll
         ${QT_BINARY_DIR}/QtSql4.dll
         ${QT_BINARY_DIR}/QtWebKit4.dll
         # VTK dependencies
         ${VTK_LIBRARY_DIRS}/Release/QVTK.dll
         ${VTK_LIBRARY_DIRS}/Release/vtkCommon.dll
         ${VTK_LIBRARY_DIRS}/Release/vtksys.dll
         ${VTK_LIBRARY_DIRS}/Release/vtkFiltering.dll
         ${VTK_LIBRARY_DIRS}/Release/vtkGraphics.dll
         ${VTK_LIBRARY_DIRS}/Release/vtkHybrid.dll
         ${VTK_LIBRARY_DIRS}/Release/vtkIO.dll
         ${VTK_LIBRARY_DIRS}/Release/vtkImaging.dll
         ${VTK_LIBRARY_DIRS}/Release/vtkRendering.dll
         ${VTK_LIBRARY_DIRS}/Release/vtkVolumeRendering.dll
         ${VTK_LIBRARY_DIRS}/Release/vtkverdict.dll
         ${VTK_LIBRARY_DIRS}/Release/vtkDICOMParser.dll
         ${VTK_LIBRARY_DIRS}/Release/vtkNetCDF.dll
         ${VTK_LIBRARY_DIRS}/Release/vtkNetCDF_cxx.dll
         ${VTK_LIBRARY_DIRS}/Release/vtkexpat.dll
         ${VTK_LIBRARY_DIRS}/Release/vtkjpeg.dll
         ${VTK_LIBRARY_DIRS}/Release/vtkmetaio.dll
         ${VTK_LIBRARY_DIRS}/Release/vtkpng.dll
         ${VTK_LIBRARY_DIRS}/Release/vtktiff.dll
         ${VTK_LIBRARY_DIRS}/Release/vtkzlib.dll
         ${VTK_LIBRARY_DIRS}/Release/vtkInfovis.dll
         ${VTK_LIBRARY_DIRS}/Release/vtkfreetype.dll
         ${VTK_LIBRARY_DIRS}/Release/vtkftgl.dll
         ${VTK_LIBRARY_DIRS}/Release/vtkalglib.dll
         ${VTK_LIBRARY_DIRS}/Release/vtklibxml2.dll
         ${VTK_LIBRARY_DIRS}/Release/vtkViews.dll
         ${VTK_LIBRARY_DIRS}/Release/vtkexoIIc.dll
         ${VTK_LIBRARY_DIRS}/Release/vtkWidgets.dll
         ${VTK_LIBRARY_DIRS}/Release/vtkhdf5.dll
         ${VTK_LIBRARY_DIRS}/Release/vtkhdf5_hl.dll
         ${VTK_LIBRARY_DIRS}/Release/LSDyna.dll
         # Xerces-c dependency
         ${XERCESC_ROOT_DIR}/bin/xerces-c_3_1.dll
         # Libxml2 dependencies
         ${LIBXML2_INCLUDE_DIR}/../bin/iconv.dll
         ${LIBXML2_INCLUDE_DIR}/../bin/libxml2.dll
         ${LIBXML2_INCLUDE_DIR}/../bin/zlib1.dll
         # ITK dependency
         ${ITK_ROOT_DIR}/bin/ITKCommon.dll
         )

      endif()

    # Application icon
    set(CAMITK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}\\\\core\\\\resources\\\\appIcon.ico") #set here the current icon for CamiTK apps
    set(CPACK_PACKAGE_ICON ${CAMITK_PACKAGE_ICON}) #icon for the top bar NSIS installer
    set(CPACK_NSIS_MUI_ICON ${CAMITK_PACKAGE_ICON}) #icon for the generated install program (the .exe to run to install CamiTK).
    set(CPACK_NSIS_MUI_UNIICON ${CAMITK_PACKAGE_ICON}) #icon for the generated uninstall program (the .exe to run to uninstall CamiTK).

355
356

                # Installer name
357
358
                set(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_NAME} ${CAMITK_VER_MAJ}.${CAMITK_VER_MIN}.${CAMITK_VER_PACKAGE_PAT}")
                set(CPACK_NSIS_INSTALLED_ICON_NAME ${CPACK_PACKAGE_NAME})
359
360
361
362




363
                set(CPACK_PACKAGE_INSTALL_DIRECTORY ${CPACK_PACKAGE_NAME})
364
365
366
367
368
369
370
                set(CPACK_NSIS_HELP_LINK "http:\\\\\\\\camitk.imag.fr")
                set(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\camitk.imag.fr")
                set(CPACK_NSIS_CONTACT ${CPACK_PACKAGE_CONTACT})
                include(InstallRequiredSystemLibraries)
        else()
            message(STATUS "Can not find makensis: nsis packaging is not possible")
        endif()
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388

endif()

# ---------------
# Mac App Bundle
# ---------------
if(APPLE)
    # TODO test this!
    set(CPACK_GENERATOR "PackageMaker")
    # Libraries are bundled directly
    set(CPACK_COMPONENT_LIBRARIES_HIDDEN TRUE)
    # Bundle Properties
    set(MACOSX_BUNDLE_BUNDLE_NAME ${CPACK_PACKAGE_NAME})
    set(MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION})
    set(MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION})
    set(MACOSX_BUNDLE_LONG_VERSION_STRING "Version ${PROJECT_VERSION}")
endif()

389

390
391
392
393
394
# -------------------------------------
# System and dependencies requirements
# -------------------------------------
include(InstallRequiredSystemLibraries)

395

396
397
398
# and here we go...
include(CPack)

399
400
endif() # Standalone CEP
endmacro()