]> git.lyx.org Git - lyx.git/blob - development/cmake/LyxPackaging.cmake
Autotools: optimize with -Og when debugging
[lyx.git] / development / cmake / LyxPackaging.cmake
1
2 # CPack packaging
3 #
4 # http://cmake.org/cmake/help/cmake-2-8-docs.html#module:CPack
5
6 if(LYX_BUNDLE)
7         if(APPLE)
8                 set(CPACK_GENERATOR DragNDrop)
9                 set(CPACK_DMG_BACKGROUND_IMAGE "${TOP_CMAKE_PATH}/../MacOSX/dmg-background.png")
10                 set(CPACK_DMG_DS_STORE "${CMAKE_BINARY_DIR}/ds_store/.DS_Store")
11         elseif(UNIX)
12                 set(CPACK_GENERATOR STGZ)
13         elseif(WIN32)
14                 set(CPACK_GENERATOR ZIP)
15         endif()
16 endif()
17
18 # Overwrite package name dependent on platform
19 # (Ignores the top project)
20 if(APPLE)
21         # true on all systems whre __APPLE__ is defined in header files
22         set(CPACK_PACKAGE_NAME "LyX${LYX_MAJOR_VERSION}${LYX_MINOR_VERSION}")
23 elseif(UNIX)
24         # True also for cygwin
25         set(CPACK_PACKAGE_NAME "lyx${LYX_MAJOR_VERSION}${LYX_MINOR_VERSION}")
26 else()
27         set(CPACK_PACKAGE_NAME "LyX${LYX_MAJOR_VERSION}${LYX_MINOR_VERSION}")
28 endif()
29
30 set(CPACK_PACKAGE_VERSION_MAJOR "${LYX_MAJOR_VERSION}")
31 set(CPACK_PACKAGE_VERSION_MINOR "${LYX_MINOR_VERSION}")
32 FILE(STRINGS "${TOP_CMAKE_PATH}/LyX_summary.txt" CPACK_PACKAGE_DESCRIPTION_SUMMARY)
33
34
35 set(CPACK_PACKAGE_INSTALL_DIRECTORY "CMake ${LYX_INSTALL_SUFFIX}")
36
37 if (APPLE)
38         # We don't need absolute paths
39         set(CPACK_SET_DESTDIR "OFF")
40 elseif(WIN32)
41     set(CPACK_GENERATOR ZIP)
42     set(CPACK_BINARY_ZIP 1)
43     if(MINGW)
44         set(runtime)
45         if(LYX_XMINGW)
46             execute_process(COMMAND ${CMAKE_CXX_COMPILER} -print-libgcc-file-name OUTPUT_VARIABLE GCC_LIBGCC OUTPUT_STRIP_TRAILING_WHITESPACE)
47         else()
48             set(GCC_LIBGCC ${CMAKE_CXX_COMPILER})
49         endif()
50
51         # RKH
52         # get_filename_component(MINGW_RUNTIME_PATH ${GCC_LIBGCC} PATH)
53         set(MINGW_RUNTIME_PATH "/usr/i686-w64-mingw32/sys-root/mingw/bin")
54         macro(add_runtime_dll _DLL)
55             file(GLOB GCC_RUNTIME ${MINGW_RUNTIME_PATH}/${_DLL})
56             list(APPEND runtime ${GCC_RUNTIME})
57         endmacro()
58         add_runtime_dll(iconv.dll)
59         add_runtime_dll(libgcc*.dll)
60         add_runtime_dll(libstd*.dll)
61         add_runtime_dll(libwin*.dll)
62         add_runtime_dll(libbz2-1.dll)
63         add_runtime_dll(libfreetype-6.dll)
64         add_runtime_dll(libglib-2.0-0.dll)
65         add_runtime_dll(libgraphite2.dll)
66         add_runtime_dll(libharfbuzz-0.dll)
67         add_runtime_dll(libicudt6*.dll)
68         add_runtime_dll(libicuin6*.dll)
69         add_runtime_dll(libicuuc6*.dll)
70         add_runtime_dll(libintl-8.dll)
71         add_runtime_dll(libjpeg-62.dll)
72         add_runtime_dll(libpcre-1.dll)
73         add_runtime_dll(libpcre2-16-0.dll)
74         add_runtime_dll(libpng16-16.dll)
75         add_runtime_dll(libtiff-5.dll)
76         add_runtime_dll(libwebp-7.dll)
77         add_runtime_dll(libwebpdemux-2.dll)
78         add_runtime_dll(zlib1.dll)
79
80         if(NOT runtime)
81             message(FATAL_ERROR "No mingw runtime found in ${MINGW_RUNTIME_PATH}")
82         endif()
83
84         if(LYX_USE_QT MATCHES "QT5")
85             get_target_property(qmakebin Qt5::qmake IMPORTED_LOCATION)
86             # RKH
87             # get_filename_component(QT_BINARY_DIR ${qmakebin} PATH)
88             set(QT_BINARY_DIR "/usr/i686-w64-mingw32/sys-root/mingw/bin")
89             install(FILES
90                 ${runtime}
91                 ${QT_BINARY_DIR}/Qt5Core.dll
92                 ${QT_BINARY_DIR}/Qt5Network.dll
93                 ${QT_BINARY_DIR}/Qt5Gui.dll
94                 ${QT_BINARY_DIR}/Qt5Widgets.dll
95                 ${QT_BINARY_DIR}/Qt5Concurrent.dll
96                 ${QT_BINARY_DIR}/Qt5OpenGL.dll
97                 ${QT_BINARY_DIR}/Qt5PrintSupport.dll
98                 ${QT_BINARY_DIR}/Qt5Svg.dll
99                 ${QT_BINARY_DIR}/Qt5WinExtras.dll
100                 DESTINATION bin)
101             install(FILES
102                 ${QT_BINARY_DIR}/../lib/qt5/plugins/platforms/qminimal.dll
103                 ${QT_BINARY_DIR}/../lib/qt5/plugins/platforms/qwindows.dll
104                 DESTINATION bin/platforms)
105             install(FILES
106                 ${QT_BINARY_DIR}/../lib/qt5/plugins/printsupport/windowsprintersupport.dll
107                 DESTINATION bin/printsupport)
108             install(FILES
109                 ${QT_BINARY_DIR}/../lib/qt5/plugins/imageformats/qgif.dll
110                 ${QT_BINARY_DIR}/../lib/qt5/plugins/imageformats/qicns.dll
111                 ${QT_BINARY_DIR}/../lib/qt5/plugins/imageformats/qico.dll
112                 ${QT_BINARY_DIR}/../lib/qt5/plugins/imageformats/qjpeg.dll
113                 ${QT_BINARY_DIR}/../lib/qt5/plugins/imageformats/qsvg.dll
114                 ${QT_BINARY_DIR}/../lib/qt5/plugins/imageformats/qtga.dll
115                 ${QT_BINARY_DIR}/../lib/qt5/plugins/imageformats/qtiff.dll
116                 ${QT_BINARY_DIR}/../lib/qt5/plugins/imageformats/qwbmp.dll
117                 ${QT_BINARY_DIR}/../lib/qt5/plugins/imageformats/qwebp.dll
118                 DESTINATION bin/imageformats)
119             install(FILES
120                 ${QT_BINARY_DIR}/../lib/qt5/plugins/styles/qwindowsvistastyle.dll
121                 DESTINATION bin/styles)
122             install(FILES
123                 ${QT_BINARY_DIR}/../lib/qt5/plugins/iconengines/qsvgicon.dll
124                 DESTINATION bin/iconengines)
125         else()
126             install(FILES
127                 ${runtime}
128                 ${QT_BINARY_DIR}/QtCore4.dll
129                 ${QT_BINARY_DIR}/QtGui4.dll
130                 ${QT_BINARY_DIR}/QtNetwork4.dll
131                 ${QT_PLUGINS_DIR}/imageformats/qgif4.dll
132                 ${QT_PLUGINS_DIR}/imageformats/qico4.dll
133                 ${QT_PLUGINS_DIR}/imageformats/qmng4.dll
134                 ${QT_PLUGINS_DIR}/imageformats/qsvg4.dll
135                 ${QT_PLUGINS_DIR}/imageformats/qtga4.dll
136                 ${QT_PLUGINS_DIR}/imageformats/qtiff4.dll
137                 DESTINATION bin)
138         endif()
139     endif()
140 else()
141         # needed by rpm
142         set(CPACK_SET_DESTDIR "ON")
143 endif()
144
145 FILE(READ "${TOP_CMAKE_PATH}/LyX_license.txt" CPACK_RPM_PACKAGE_LICENSE)
146 set(CPACK_RPM_PACKAGE_GROUP "Applications/Publishing")
147 set(CPACK_RPM_PACKAGE_VENDOR "The LyX team")
148 #
149 # the next ones are needed by deb
150 set(CPACK_PACKAGE_CONTACT "${PACKAGE_BUGREPORT}")
151 set(CPACK_SOURCE_PACKAGE_FILE_NAME "${LYX_PROJECT}-${LYX_INSTALL_SUFFIX}")
152
153 # We depend on python scripting
154 # Currently no need to specify versions for pythonx since they are only
155 # available in newest distributions.
156 set(CPACK_DEBIAN_PACKAGE_DEPENDS "python (>= 2.7) | python3 | python2")
157 set(CPACK_DEBIAN_PACKAGE_SECTION "universe/editors")
158
159 # use dpkg-shlibdeps to generate additional info for package dependency list.
160 set(CPACK_DEBIAN_PACKAGE_RELEASE ${LYX_PACKAGE_RELEASE})
161 set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
162 set(CPACK_DEBIAN_PACKAGE_DEBUG ON)
163
164 #
165 # for the next ones, cpack insists on data with values in some file
166 set(CPACK_PACKAGE_DESCRIPTION_FILE "${TOP_CMAKE_PATH}/LyX_description.txt")
167 set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/COPYING")
168
169 # Use the revision number saved in ${LYX_PACKAGE_RELEASE}
170 # as the release in rpm-package-build.
171 # This way we maycan omit the otherwise needed "--force" parameter when
172 # installing from that rpm package.
173 set(CPACK_RPM_PACKAGE_RELEASE ${LYX_PACKAGE_RELEASE})
174 set(CPACK_PACKAGE_VERSION_PATCH ${LYX_REVISION_VERSION})
175
176 # we do not have a readme or welcome data,
177 # so we do not provide infofiles for
178 # CPACK_RESOURCE_FILE_README and CPACK_RESOURCE_FILE_WELCOME
179
180 # sources
181 set(CPACK_SOURCE_INSTALLED_DIRECTORIES "${TOP_SRC_DIR};/") # http://www.mail-archive.com/cmake@cmake.org/msg33720.html
182
183
184 set(CPACK_STRIP_FILES 1)
185
186 # Finaly give some hints about files not to be included in source package
187 SET(CPACK_SOURCE_IGNORE_FILES
188 "/CVS/"
189 "/\\\\.svn/"
190 "/\\\\.bzr/"
191 "/\\\\.hg/"
192 "/\\\\.git/"
193 "/\\\\.project$"
194 "/\\\\.cproject$"
195 "/\\\\.history$"
196 "/\\\\.gitignore$"
197 "/\\\\.gitattributes$"
198 "\\\\.#"
199 "\\\\.swp$"
200 "\\\\.my$"
201 "\\\\.pyc$"
202 "\\\\.patch$"
203 "~$"
204 "/#"
205 "/_CPack_Packages/"
206 "/CMakeCache.txt$"
207 "/CPackSourceConfig\\\\.cmake$"
208 "/configCompiler\\\\.h$"
209 "/install_manifest\\\\.txt$"
210 "/cmake_install\\\\.cmake$"
211 "/POTFILES"
212 "\\\\.tar\\\\.gz$"
213 "\\\\.tar\\\\.bz2$"
214 "\\\\.tar\\\\.Z$"
215 "\\\\.deb$"
216 "\\\\.rpm$"
217 "\\\\.rej$"
218 "\\\\.orig$"
219 "/core$"
220 "/CMakeFiles/"
221 "/Makefile\\\\.in$"
222 "/Makefile$"
223 "/autom4te\\\\.cache/"
224 "/\\\\.deps/"
225 "/build/"
226 "/attic/"
227 "/HTML/"
228 "/lyx-2\\\\."
229 "/expectedTestFailures$"
230 "/MergedManuals.lyx$"
231 )
232
233 if(LYX_CPACK)
234         include(CPack)
235 endif()
236
237
238 #Now it is possible to create some packages
239 # cd <BuildDir>
240 # make package
241 #############################################################################################
242 # So, e.g. for variables
243 #    CMAKE_PROJECT_NAME                     : lyx
244 #    CPACK_PACKAGE_VERSION_MAJOR            : 2
245 #    CPACK_PACKAGE_VERSION_MINOR            : 0
246 #    CPACK_PACKAGE_VERSION_PATCH            : 1
247 #    CMAKE_SYSTEM_NAME                      : Linux
248 #    CPACK_BINARY_DEB:BOOL                  : ON
249 #
250 # the package name builds as "lyx-2.0.1-Linux.deb"
251 #
252 ############################## rpm ################################### deb ##################
253 # create    # cpack -G RPM --config CPackConfig.cmake   # cpack -G DEB --config CPackConfig.cmake
254 # creates =># lyx-2.0.1-Linux.rpm                       # lyx-2.0.1-Linux.deb
255 # list      # rpm -qlp lyx-2.0.1-Linux.rpm              # dpkg-deb -c lyx-2.0.1-Linux.deb
256 # install   # rpm -U lyx-2.0.1-Linux.rpm                # dpkg -i lyx-2.0.1-Linux.deb
257 #
258