CamiTKExtensionPackaging.cmake 4.27 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
34
35
36
37
38
39
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
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
#----------------------------
# CamiTK extension packaging
#---------------------------

# See also CamiTKPackaging.cmake 

string(TOLOWER ${EXTENSION_NAME} CPACK_PACKAGE_NAME)
set(CPACK_PACKAGE_VERSION_MAJOR ${CAMITK_VER_MAJ})
set(CPACK_PACKAGE_VERSION_MINOR ${CAMITK_VER_MIN})

# use the nickname of the package version
set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}")
set(CPACK_PACKAGE_FILE_NAME "${CPACK_SOURCE_PACKAGE_FILE_NAME}")
set(CPACK_PACKAGE_INSTALL_DIRECTORY "/")

set(CPACK_PACKAGE_VENDOR "UJF-Grenoble 1, CNRS, TIMC-IMAG UMR 5525")
set(CPACK_PACKAGE_CONTACT "http://camitk.imag.fr")
set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING")
#set(CPACK_PACKAGE_EXECUTABLES "imp" "CamiTK/imp")

set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${EXTENSION_NAME} extension for CamiTK (Computer Assisted Medical Intervention Took Kit)")
SET(CPACK_PACKAGE_DESCRIPTION "${CPACK_PACKAGE_NAME}\n ${CPACK_PACKAGE_DESCRIPTION_SUMMARY}")

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
"~$"
"kdev4$"
"/\\\\.svn/"
"/\\\\.git/"
"/\\\\.kdev4/"
"/build/"
${CPACK_SOURCE_IGNORE_FILES}
)

# ----------------
# Debian packages
# ----------------
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()

if(DPKG_FOUND AND NOT WIN32)
    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
    set(CPACK_DEBIAN_PACKAGE_DEPENDS "libqt4-gui ( >= 4.6 ), libqt4-xml ( >= 4.6 )") # Specify other dependencies here
endif()

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


# -----------------------
# NSIS Windows installer
# -----------------------
find_program(MAKENSIS
  NAMES makensis
  PATHS "/usr/bin"
)

if(MAKENSIS)
  # NSIS Windows installer
  if(WIN32 AND NOT UNIX)
    message(STATUS "Packaging nsis using ${MAKENSIS}: OK")
    set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS 
      ${QT_BINARY_DIR}/QtCore4.dll 
      ${QT_BINARY_DIR}/QtGui4.dll
      ${QT_BINARY_DIR}/QtSvg4.dll
      ${QT_BINARY_DIR}/QtXml4.dll
    )

    set(CPACK_NSIS_DISPLAY_NAME "${EXTENSION_NAME}")
    set(CPACK_NSIS_MODIFY_PATH ON)
    set(CPACK_PACKAGE_INSTALL_DIRECTORY ${EXTENSION_NAME})
    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})
  endif()
else()
    message(STATUS "Can not find makensis: nsis packaging is not possible")
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)