37356a2c5a7eb916d13e59ab24bf81ed18bda032
[platform/upstream/libjpeg-turbo.git] / cmakescripts / BuildPackages.cmake
1 # This file is included from the top-level CMakeLists.txt.  We just store it
2 # here to avoid cluttering up that file.
3
4 set(PKGNAME ${CMAKE_PROJECT_NAME} CACHE STRING
5   "Distribution package name (default: ${CMAKE_PROJECT_NAME})")
6 set(PKGVENDOR "The ${CMAKE_PROJECT_NAME} Project" CACHE STRING
7   "Vendor name to be included in distribution package descriptions (default: The ${CMAKE_PROJECT_NAME} Project)")
8 set(PKGURL "http://www.${CMAKE_PROJECT_NAME}.org" CACHE STRING
9   "URL of project web site to be included in distribution package descriptions (default: http://www.${CMAKE_PROJECT_NAME}.org)")
10 set(PKGEMAIL "information@${CMAKE_PROJECT_NAME}.org" CACHE STRING
11   "E-mail of project maintainer to be included in distribution package descriptions (default: information@${CMAKE_PROJECT_NAME}.org")
12 set(PKGID "com.${CMAKE_PROJECT_NAME}.${PKGNAME}" CACHE STRING
13   "Globally unique package identifier (reverse DNS notation) (default: com.${CMAKE_PROJECT_NAME}.${PKGNAME})")
14
15
16 ###############################################################################
17 # Linux RPM and DEB
18 ###############################################################################
19
20 if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
21
22 set(RPMARCH ${CMAKE_SYSTEM_PROCESSOR})
23 if(CPU_TYPE STREQUAL "x86_64")
24   set(DEBARCH amd64)
25 elseif(CPU_TYPE STREQUAL "arm64")
26   set(DEBARCH ${CPU_TYPE})
27 elseif(CPU_TYPE STREQUAL "arm")
28   check_c_source_compiles("
29     #if __ARM_PCS_VFP != 1
30     #error \"float ABI != hard\"
31     #endif
32     int main(void) { return 0; }" HAVE_HARD_FLOAT)
33   if(HAVE_HARD_FLOAT)
34     set(RPMARCH armv7hl)
35     set(DEBARCH armhf)
36   else()
37     set(RPMARCH armel)
38     set(DEBARCH armel)
39   endif()
40 elseif(CMAKE_SYSTEM_PROCESSOR_LC STREQUAL "ppc64le")
41   set(DEBARCH ppc64el)
42 elseif(CPU_TYPE STREQUAL "powerpc" AND BITS EQUAL 32)
43   set(RPMARCH ppc)
44   set(DEBARCH ppc)
45 else()
46   set(DEBARCH ${CMAKE_SYSTEM_PROCESSOR})
47 endif()
48 message(STATUS "RPM architecture = ${RPMARCH}, DEB architecture = ${DEBARCH}")
49
50 # Re-set CMAKE_POSITION_INDEPENDENT_CODE so that the RPM spec file works
51 # properly
52 boolean_number(CMAKE_POSITION_INDEPENDENT_CODE)
53
54 configure_file(release/makerpm.in pkgscripts/makerpm)
55 configure_file(release/rpm.spec.in pkgscripts/rpm.spec @ONLY)
56
57 add_custom_target(rpm pkgscripts/makerpm
58   SOURCES pkgscripts/makerpm)
59
60 configure_file(release/makesrpm.in pkgscripts/makesrpm)
61
62 add_custom_target(srpm pkgscripts/makesrpm
63   SOURCES pkgscripts/makesrpm
64   DEPENDS dist)
65
66 configure_file(release/makedpkg.in pkgscripts/makedpkg)
67 configure_file(release/deb-control.in pkgscripts/deb-control)
68
69 add_custom_target(deb pkgscripts/makedpkg
70   SOURCES pkgscripts/makedpkg)
71
72 endif() # Linux
73
74
75 ###############################################################################
76 # Windows installer (NullSoft Installer)
77 ###############################################################################
78
79 if(WIN32)
80
81 if(MSVC)
82   set(INST_PLATFORM "Visual C++")
83   set(INST_ID vc)
84   set(INST_NAME ${CMAKE_PROJECT_NAME}-${VERSION}-${INST_ID})
85   set(INST_REG_NAME ${CMAKE_PROJECT_NAME})
86 elseif(MINGW)
87   set(INST_PLATFORM GCC)
88   set(INST_ID gcc)
89   set(INST_NAME ${CMAKE_PROJECT_NAME}-${VERSION}-${INST_ID})
90   set(INST_REG_NAME ${CMAKE_PROJECT_NAME}-${INST_ID})
91   set(INST_DEFS -DGCC)
92 endif()
93
94 if(BITS EQUAL 64)
95   set(INST_PLATFORM "${INST_PLATFORM} 64-bit")
96   set(INST_NAME ${INST_NAME}64)
97   set(INST_REG_NAME ${INST_REG_NAME}64)
98   set(INST_DEFS ${INST_DEFS} -DWIN64)
99 endif()
100
101 if(WITH_JAVA)
102   set(INST_DEFS ${INST_DEFS} -DJAVA)
103 endif()
104
105 if(MSVC_IDE)
106   set(INST_DEFS ${INST_DEFS} "-DBUILDDIR=${CMAKE_CFG_INTDIR}\\")
107 else()
108   set(INST_DEFS ${INST_DEFS} "-DBUILDDIR=")
109 endif()
110
111 string(REGEX REPLACE "/" "\\\\" INST_DIR ${CMAKE_INSTALL_PREFIX})
112
113 configure_file(release/installer.nsi.in installer.nsi @ONLY)
114 # TODO: It would be nice to eventually switch to CPack and eliminate this mess,
115 # but not today.
116 configure_file(win/projectTargets.cmake.in
117   win/${CMAKE_PROJECT_NAME}Targets.cmake @ONLY)
118 configure_file(win/${INST_ID}/projectTargets-release.cmake.in
119   win/${CMAKE_PROJECT_NAME}Targets-release.cmake @ONLY)
120
121 if(WITH_JAVA)
122   set(JAVA_DEPEND turbojpeg-java)
123 endif()
124 add_custom_target(installer
125   makensis -nocd ${INST_DEFS} installer.nsi
126   DEPENDS jpeg jpeg-static turbojpeg turbojpeg-static rdjpgcom wrjpgcom
127     cjpeg djpeg jpegtran tjbench ${JAVA_DEPEND}
128   SOURCES installer.nsi)
129
130 endif() # WIN32
131
132
133 ###############################################################################
134 # Mac DMG
135 ###############################################################################
136
137 if(APPLE)
138
139 set(ARMV8_BUILD "" CACHE PATH
140   "Directory containing Armv8 iOS or macOS build to include in universal binaries")
141
142 set(MACOS_APP_CERT_NAME "" CACHE STRING
143   "Name of the Developer ID Application certificate (in the macOS keychain) that should be used to sign the libjpeg-turbo DMG.  Leave this blank to generate an unsigned DMG.")
144 set(MACOS_INST_CERT_NAME "" CACHE STRING
145   "Name of the Developer ID Installer certificate (in the macOS keychain) that should be used to sign the libjpeg-turbo installer package.  Leave this blank to generate an unsigned package.")
146
147 configure_file(release/makemacpkg.in pkgscripts/makemacpkg)
148 configure_file(release/Distribution.xml.in pkgscripts/Distribution.xml)
149 configure_file(release/Welcome.rtf.in pkgscripts/Welcome.rtf)
150 configure_file(release/uninstall.in pkgscripts/uninstall)
151
152 add_custom_target(dmg pkgscripts/makemacpkg
153   SOURCES pkgscripts/makemacpkg)
154
155 endif() # APPLE
156
157
158 ###############################################################################
159 # Generic
160 ###############################################################################
161
162 add_custom_target(dist
163   COMMAND git archive --prefix=${CMAKE_PROJECT_NAME}-${VERSION}/ HEAD |
164     gzip > ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}-${VERSION}.tar.gz
165     WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
166
167 configure_file(release/maketarball.in pkgscripts/maketarball)
168
169 add_custom_target(tarball pkgscripts/maketarball
170   SOURCES pkgscripts/maketarball)
171
172 configure_file(release/libjpeg.pc.in pkgscripts/libjpeg.pc @ONLY)
173
174 configure_file(release/libturbojpeg.pc.in pkgscripts/libturbojpeg.pc @ONLY)
175
176 include(CMakePackageConfigHelpers)
177 write_basic_package_version_file(
178   pkgscripts/${CMAKE_PROJECT_NAME}ConfigVersion.cmake
179   VERSION ${VERSION} COMPATIBILITY AnyNewerVersion)
180
181 configure_package_config_file(release/Config.cmake.in
182   pkgscripts/${CMAKE_PROJECT_NAME}Config.cmake
183   INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${CMAKE_PROJECT_NAME})