CamiTKPackaging.cmake 15.8 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#------------------
# CamiTK packaging
#------------------

# Do not forget to change the version variables in CamiTKBuild.cmake
#
# To make a source tar ball, just use the custom target camitk_package_source, e.g. "make camitk_package_source"
#
# To make an executable/installable, you will have to properly set a specific CAMITK_INSTALL_ROOT
#
# CAMITK_INSTALL_ROOT will be used as the root installation directory on the targeted plateform
# Usual values for unix are /usr or /usr/local
#
# Therefore, in order to produce a proper deb for system-wide install, you can run something like:
15
16
# sudo su
# cmake -DCAMITK_INSTALL_ROOT=/usr -DCMAKE_BUILD_TYPE=Release -DACTION_ITKSEGMENTATION=TRUE -DACTION_ITKFILTERS=TRUE -DAPPLICATION_WIZARD=TRUE -DCOMPONENT_DICOM=TRUE -DCOMPONENT_ITKIMAGE=TRUE -DCOMPONENT_MML=TRUE -DCOMPONENT_PHYSICALMODEL=TRUE -DMML_GENERATE_XSD_LIB=TRUE /home/promayon/Dev/CamiTK/camitk
17
18
# make camitk_package
#
19
20
21
22
# To build source package
# make camitk_package_source
# (it generates the correct CamiTKVersion.h)
#
23
24
25
26
27
28
29
30
# Once CAMITK_INSTALL_ROOT is properly defined, type "make camitk_package"
# 
# To check the content of a deb package:
# dpkg --contents package.deb
# To install the content of a deb in a subdirectory instead of system-wide:
# dpkg --vextract package.deb subdirectory
#
# To produce a window installer with NSIS from linux, you need to install the nsis package (on ubuntu, type "sudo apt-get install nsis")
ykeraval's avatar
ykeraval committed
31
# To install NSIS on Window you need to complete manually in the regedit : HKEY_LOCAL_MACHINE\SOFTWARE\NSIS ---->pathdir de NSIS
32
33
34
35
36
37
#
# To generate different components that can be opt out at install time, see
# http://www.itk.org/Wiki/CMake:Component_Install_With_CPack
#
# More generally see http://www.itk.org/Wiki/CMake:CPackConfiguration
#
38
39
40
41
# string(TOLOWER ${CAMITK_PROJECT_NAME} CPACK_PACKAGE_NAME)
# set(CPACK_PACKAGE_VERSION_MAJOR ${CAMITK_VER_MAJ})
# set(CPACK_PACKAGE_VERSION_MINOR ${CAMITK_VER_MIN})
# set(CPACK_PACKAGE_VERSION_PATCH ${CAMITK_VER_PACKAGE_PAT})
42
# use the nickname of the package version
43
44
45
46
# set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}-${CAMITK_VER_NICKNAME}")
# set(CPACK_PACKAGE_FILE_NAME "${CPACK_SOURCE_PACKAGE_FILE_NAME}")
# set(CPACK_PACKAGE_INSTALL_DIRECTORY "/") 

47
48
49
50
51
52
53
54
55
56
57
58
#
# There is a "bug"/packaging problem with CMake 2.8.7 and 2.8.8 on ubuntu 12.04
# The package that is produced is corrupted.
# The workaround (see http://cmake.3232098.n2.nabble.com/Creating-package-td7577614.html )
# mkdir tmp
# cp camitk-3.0.0-blue-ubuntu12.04_amd64.deb tmp
# cd tmp
# ar xv camitk-3.0.0-blue-ubuntu12.04_amd64.deb data.tar.gz
# tar xzvf data.tar.gz
# tar zcvf data.tgz ./usr
# mv data.tgz data.tar.gz
# ar rv camitk-3.0.0-blue-ubuntu12.04_amd64.deb data.tar.gz 
59

60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83



if (UNIX AND NOT WIN32)
  set(CPACK_GENERATOR "DEB") # "RPM")
else()
  set(CPACK_GENERATOR "NSIS")
endif()

set(CPACK_SOURCE_GENERATOR "TGZ" "ZIP" )

set(CPACK_SOURCE_IGNORE_FILES
"~$"
"/\\\\.svn/"
"/\\\\.git/"
"/kdev4$/"
"/build/"
${CPACK_SOURCE_IGNORE_FILES}
)

# ----------------
# Debian packages
# ----------------
if (UNIX AND NOT WIN32)
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
	
	message(STATUS "Packaging CamiTK for UNIX systems")
	# 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
101
102
103
104
105
106
107
108
109
110
111
112
	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()

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
	


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

# 		make_directory(${CMAKE_BINARY_DIR}/packaging/debian)
# 		set(GTK_UPDATE_ICON_CACHE "gtk-update-icon-cache -f -t ${THEME_DIRECTORY}")
# 		configure_file( ${CMAKE_SOURCE_DIR}/cmake/debian/postinst.in ${CMAKE_BINARY_DIR}/packaging/debian/postinst )
# 		configure_file( ${CMAKE_SOURCE_DIR}/cmake/debian/prerm.in ${CMAKE_BINARY_DIR}/packaging/debian/prerm )
# 
# 		set(CPACK_GENERATOR "DEB")
# 		set(CPACK_DEBIAN_PACKAGE_PRIORITY "extra")
# 		set(CPACK_DEBIAN_PACKAGE_SECTION "photos")
# 		set(CPACK_DEBIAN_PACKAGE_RECOMMENDS "")
# 		set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_BINARY_DIR}/packaging/debian/postinst;${CMAKE_BINARY_DIR}/packaging/debian/prerm;" )

		# 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("${CPACK_PACKAGE_ARCHITECTURE}" MATCHES "i[3-6]86")
		if("${CPACK_PACKAGE_ARCHITECTURE}" MATCHES "x86_64")
			set(CPACK_PACKAGE_ARCHITECTURE amd64)
		endif("${CPACK_PACKAGE_ARCHITECTURE}" MATCHES "x86_64")
		# Set the dependencies based on the distrib version

		# Installation path
		# Set the install location to "/usr"
		set(CAMITK_INSTALL_ROOT "/usr")
		set(CPACK_PACKAGING_INSTALL_PREFIX "/usr")
		set(CPACK_PACKAGE_DEFAULT_LOCATION "/usr")
144
		set(CPACK_SET_DESTDIR TRUE)
145
146
147
148
149
150
151
152
153
154
155

		# Package information
		set(CPACK_PACKAGE_DESCRIPTION_SUMMARY ${CPACK_PACKAGE_DESCRIPTION_SUMMARY})
		set(CPACK_DEBIAN_PACKAGE_DESCRIPTION ${CPACK_PACKAGE_DESCRIPTION})

		# For building on a different system
		# set(LSB_DISTRIB Ubuntu11.10)

		# Dependencies depending on the Operating System.
		# Ubuntu
		if("${LSB_DISTRIB}" MATCHES "Ubuntu11.10")
saubatn's avatar
saubatn committed
156
			set(CPACK_DEBIAN_PACKAGE_DEPENDS "libqt4-dev, libinsighttoolkit3.20, libxml2, libvtk5.6-qt4, libxerces-c3.1 ")
157
		endif("${LSB_DISTRIB}" MATCHES "Ubuntu11.10")
158
		# For Ubuntu11.04
159
		if("${LSB_DISTRIB}" MATCHES "Ubuntu12.04")
saubatn's avatar
saubatn committed
160
			set(CPACK_DEBIAN_PACKAGE_DEPENDS "libqt4-dev, libinsighttoolkit3.20, libxml2, libvtk5.8-qt4, libxerces-c3.1 ")
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
		endif("${LSB_DISTRIB}" MATCHES "Ubuntu12.04")

		# Debian
# 		if("${LSB_DISTRIB}" MATCHES "Debian5.*")
# 			set(CPACK_DEBIAN_PACKAGE_DEPENDS "libgtk2.0-0, libsqlite3-0, libglade2-0, libgegl-0.0-0, libcairo2, libexiv2-5, liblcms1, libjpeg62, libpng12-0, liblensfun0, liblensfun-data")
# 
# 		endif("${LSB_DISTRIB}" MATCHES "Debian5.*")
# 		if("${LSB_DISTRIB}" MATCHES "Debiantesting")
# 			set(CPACK_DEBIAN_PACKAGE_DEPENDS "libgtk2.0-0, libsqlite3-0, libglade2-0, libgegl-0.0-0, libcairo2, libexiv2-5, liblcms1, libjpeg62, libpng12-0, liblensfun0, liblensfun-data")
# 		endif("${LSB_DISTRIB}" MATCHES "Debiantesting")

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

endif("${LSB_DISTRIB}" MATCHES "Ubuntu|Debian")

		# package name
		string(TOLOWER ${CAMITK_PROJECT_NAME} CPACK_PACKAGE_NAME)
		set(CPACK_PACKAGE_VERSION_MAJOR ${CAMITK_VER_MAJ})
		set(CPACK_PACKAGE_VERSION_MINOR ${CAMITK_VER_MIN})
		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)

		# contact information
		set(CPACK_PACKAGE_VENDOR "UJF-Grenoble 1, CNRS, TIMC-IMAG UMR 5525")
		set(CPACK_PACKAGE_CONTACT "http://camitk.imag.fr")	
188
		set(CPACK_DEBIAN_PACKAGE_MAINTAINER "CamiTK Developers <camitk-developers@lists.forge.imag.fr>")
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231

		# resource files
		set(CPACK_RESOURCE_FILE_README "${CAMITK_SOURCE_DIR}/README")
		set(CPACK_RESOURCE_FILE_LICENSE "${CAMITK_SOURCE_DIR}/COPYING")

		# executable
		set(CPACK_PACKAGE_EXECUTABLES "imp" "CamiTK/imp")

		#set(CPACK_INSTALL_CMAKE_PROJECTS "???"
		# information description
		set(CPACK_PACKAGE_DESCRIPTION_FILE "${CAMITK_SOURCE_DIR}/README")
		set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Computer Assisted Medical Intervention Took Kit.
		CamiTK is a C++ framework that helps researchers and clinicians to easily and rapidly collaborate in order to prototype CAMI applications, that feature medical images, surgical navigation and biomechanical simulations.")

		SET(CPACK_PACKAGE_DESCRIPTION "${CPACK_PACKAGE_NAME}\n ${CPACK_PACKAGE_DESCRIPTION_SUMMARY}")



# 	if(DPKG_FOUND)
#                 set(CPACK_PACKAGING_INSTALL_PREFIX "/usr")
#                 set(CPACK_PACKAGE_DEFAULT_LOCATION "/usr")
# 		set(CPACK_DEBIAN_PACKAGE_DESCRIPTION ${CPACK_PACKAGE_DESCRIPTION})
# 		set(CPACK_PACKAGE_DESCRIPTION_SUMMARY ${CPACK_PACKAGE_DESCRIPTION_SUMMARY})
# 		set(CPACK_SET_DESTDIR TRUE)
# 		#set(CPACK_INSTALLED_DIRECTORIES "${CAMITK_INSTALL_ROOT}/include" "usr/include")
# 		set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE i386) # Change to your architecture here, there is no such thing as i686 in deb!
# 		# TODO update list of dependencies
# 		message(STATUS "Variable LSB_DISTRIB = ${LSB_DISTRIB} ")
# 		# For Ubuntu10.04
# 		if("${LSB_DISTRIB}" MATCHES "Ubuntu10.04")
# 			set(CPACK_DEBIAN_PACKAGE_DEPENDS "libinsighttoolkit3.16  ( >= 3.16.0-1 ), libxml2, libvtk5.2-qt4")
# 		endif("${LSB_DISTRIB}" MATCHES "Ubuntu10.04")
# 		# For Ubuntu10.10
# 		if("${LSB_DISTRIB}" MATCHES "Ubuntu10.10")
# 			set(CPACK_DEBIAN_PACKAGE_DEPENDS "libinsighttoolkit3.18, libxml2, libvtk5.4-qt4")
# 		endif("${LSB_DISTRIB}" MATCHES "Ubuntu10.10")
# 		# For Ubuntu11.04
# 		if("${LSB_DISTRIB}" MATCHES "Ubuntu11.04")
# 			set(CPACK_DEBIAN_PACKAGE_DEPENDS "libinsighttoolkit3.18, libxml2, libvtk5.4-qt4 ")
# 		endif("${LSB_DISTRIB}" MATCHES "Ubuntu11.04")
# 		# For Ubuntu11.04
# 		
# 	endif() 
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

	# -------------
	# RPM packages
	# -------------
	# TODO test rpm packaging
	find_program(RPMBUILD
		NAMES rpmbuild
		PATHS "/usr/bin"
	)

	if ( RPMBUILD )
		get_filename_component(RPMBUILD_PATH ${RPMBUILD} ABSOLUTE)
		message(STATUS "Packaging rpm using ${RPMBUILD_PATH}: OK")
		set(RPMBUILD_FOUND "YES")
	else () 
		SET(RPMBUILD_FOUND "NO")
	endif()

	if(RPMBUILD_FOUND AND NOT WIN32)
		set(CPACK_SET_DESTDIR TRUE)
	endif(RPMBUILD_FOUND AND NOT WIN32)
endif()

if(WIN32 AND NOT UNIX)
	# -----------------------
	# NSIS Windows installer
	# -----------------------
	find_program(MAKENSIS
	  NAMES makensis
	  PATHS "/usr/bin"
	)
ykeraval's avatar
ykeraval committed
263

264
	if(MAKENSIS)
promayon's avatar
promayon committed
265
266
267
		# NSIS Windows installer
		message(STATUS "Packaging nsis using ${MAKENSIS}: OK")

promayon's avatar
promayon committed
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
		# 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_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_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/vtkmesh.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/vtkQtChart.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				  
		# )
promayon's avatar
promayon committed
308
		
promayon's avatar
promayon committed
309
310
311
312
313
314
		##ITK is required
		# FIND_PACKAGE(ITK)
		# if (${ITK_FOUND})
			# message(pass ${VTK_LIBRARY_DIRS})
			# set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS} ${ITK_DIR}/bin/Release/ITKCommon.dll)
		# endif ()
promayon's avatar
promayon committed
315
		
ykeraval's avatar
ykeraval committed
316
317
	    # There is a bug in NSI that does not handle full unix paths properly. Make
		# sure there is at least one set of four (4) backslashes.
promayon's avatar
promayon committed
318
319
320
321
322
323
324
325
		set(CAMITK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/core/icons\\\\appIcon.ico")
		set(CPACK_PACKAGE_ICON ${CAMITK_PACKAGE_ICON})
		set(CPACK_NSIS_MUI_ICON ${CAMITK_PACKAGE_ICON})
		set(CPACK_NSIS_MUI_UNIICON ${CAMITK_PACKAGE_ICON})
		set(CPACK_NSIS_DISPLAY_NAME "CamiTK ${CAMITK_VER_MAJ}.${CAMITK_VER_MIN}.${CAMITK_VER_PACKAGE_PAT}")
		set(CPACK_NSIS_MODIFY_PATH ON)
		set(CPACK_NSIS_INSTALLED_ICON_NAME ${CAMITK_PROJECT_NAME})
		set(CPACK_PACKAGE_INSTALL_DIRECTORY ${CAMITK_PROJECT_NAME})
326
327
328
		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})
ykeraval's avatar
ykeraval committed
329
330
331
332
		set(CPACK_NSIS_MODIFY_PATH ON)
		include(InstallRequiredSystemLibraries)
	else()
	    message(STATUS "Can not find makensis: nsis packaging is not possible")
333
	endif()
ykeraval's avatar
ykeraval committed
334

335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
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()


# -------------------------------------
# System and dependencies requirements
# -------------------------------------
include(InstallRequiredSystemLibraries)

# and here we go...
include(CPack)


# ----------------------------------
# CamiTK specific packaging targets
# ----------------------------------

# create specific target for package source
add_custom_target(camitk_package_source
    COMMAND ${CMAKE_COMMAND}
        -E copy ${CAMITK_BINARY_DIR}/CamiTKPackageVersion.h
                ${CAMITK_SOURCE_DIR}/core/CamiTKVersion.h
    COMMAND ${CMAKE_COMMAND}
        --build ${CMAKE_BINARY_DIR}
        --target package_source
    COMMAND ${CMAKE_COMMAND}
        -E remove ${CAMITK_SOURCE_DIR}/core/CamiTKVersion.h
)

# create specific target for binary package
add_custom_target(camitk_package
    COMMAND ${CMAKE_COMMAND}
        -E copy ${CAMITK_BINARY_DIR}/core/CamiTKVersion.h
                ${CAMITK_BINARY_DIR}/core/CamiTKVersion.h-backup
    COMMAND ${CMAKE_COMMAND}
        -E copy ${CAMITK_BINARY_DIR}/CamiTKPackageVersion.h
                ${CAMITK_BINARY_DIR}/core/CamiTKVersion.h
    COMMAND ${CMAKE_COMMAND}
        --build ${CMAKE_BINARY_DIR}
        --target package
    COMMAND ${CMAKE_COMMAND}
        -E copy ${CAMITK_BINARY_DIR}/core/CamiTKVersion.h-backup
                ${CAMITK_BINARY_DIR}/core/CamiTKVersion.h
    COMMAND ${CMAKE_COMMAND}
        --build ${CMAKE_BINARY_DIR}
)