Browse Source

ipk: add cpack ipk generation

* added similar cmake modules used in libmaa

Signed-off-by: Thomas Ingleby <thomas.c.ingleby@intel.com>
Thomas Ingleby 10 years ago
parent
commit
fa1753f4ef

+ 49
- 1
CMakeLists.txt View File

@@ -12,8 +12,35 @@ find_package (PkgConfig REQUIRED)
12 12
 pkg_check_modules (MAA REQUIRED maa>=0.2.6)
13 13
 message (INFO " found libmaa version: ${MAA_VERSION}")
14 14
 
15
+# Appends the cmake/modules path to MAKE_MODULE_PATH variable.
16
+set (CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH})
17
+
18
+# Make a version file containing the current version from git.
19
+include (GetGitRevisionDescription)
20
+git_describe (VERSION "--tags")
21
+if ("x_${VERSION}" STREQUAL "x_GIT-NOTFOUND")
22
+  message (WARNING " - Install git to compile a production libmaa!")
23
+  set (VERSION "v0.1.1-dirty")
24
+endif ()
25
+
26
+message (INFO " - UPM Version ${VERSION}")
27
+
28
+#parse the version information into pieces.
29
+string (REGEX REPLACE "^v([0-9]+)\\..*" "\\1" VERSION_MAJOR "${VERSION}")
30
+string (REGEX REPLACE "^v[0-9]+\\.([0-9]+).*" "\\1" VERSION_MINOR "${VERSION}")
31
+string (REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" VERSION_PATCH "${VERSION}")
32
+string (REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.[0-9]+\\-([0-9]+).*" "\\1" VERSION_COMMIT "${VERSION}")
33
+string (REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.[0-9]+-[0-9]+\\-(.*)" "\\1" VERSION_SHA1 "${VERSION}")
34
+
35
+set (upm_VERSION_MAJOR ${VERSION_MAJOR})
36
+set (upm_VERSION_MINOR ${VERSION_MINOR})
37
+set (upm_VERSION_PATCH ${VERSION_PATCH})
38
+set (upm_VERSION_STRING ${maa_VERSION_MAJOR}.${maa_VERSION_MINOR}.${maa_VERSION_PATCH})
39
+
15 40
 set (CMAKE_SWIG_FLAGS "")
16 41
 
42
+option (IPK "Generate IPK using CPack" OFF)
43
+
17 44
 # add a target to generate API documentation with Doxygen
18 45
 find_package (Doxygen)
19 46
 if (DOXYGEN_FOUND)
@@ -25,6 +52,27 @@ if (DOXYGEN_FOUND)
25 52
   )
26 53
 endif (DOXYGEN_FOUND)
27 54
 
28
-include(CPack)
55
+if (IPK)
56
+  include (TargetArch)
57
+  target_architecture (DETECTED_ARCH)
58
+  message( INFO " - Target arch is ${DETECTED_ARCH}")
59
+
60
+  set(CPACK_GENERATOR "DEB")
61
+  set(OPKG_ARCH ${DETECTED_ARCH})
62
+  set(CPACK_BINARY_DIR ${CMAKE_BINARY_DIR})
63
+  set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Intel IoT-Devkit") #required
64
+  set(CPACK_PACKAGE_VERSION ${upm_VERSION_MAJOR}.${upm_VERSION_MINOR}.${upm_VERSION_PATCH}.${VERSION_COMMIT})
65
+  set(CPACK_PACKAGE_NAME "libupm${upm_VERSION_MAJOR}")
66
+  set(CPACK_DEBIAN_PACKAGE_SECTION "libs")
67
+  set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE ${DETECTED_ARCH})
68
+  set(CPACK_SYSTEM_NAME ${DETECTED_ARCH})
69
+  set(CPACK_DEBIAN_PACKAGE_DEPENDS "libmaa0 (>= ${MAA_VERSION})")
70
+  set(CPACK_DEBIAN_PACKAGE_PROVIDES "libupm-dev, libupm-dbg, libupm-doc")
71
+  set(CPACK_DEBIAN_PACKAGE_REPLACES "libupm-dev, libupm-dbg, libupm-doc")
72
+  set(CPACK_DEBIAN_PACKAGE_CONFLICTS "libupm-dev, libupm-dbg, libupm-doc")
73
+  set(WDIR "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}")
74
+  include (CPack)
75
+endif()
76
+
29 77
 add_subdirectory (src)
30 78
 add_subdirectory (examples)

+ 222
- 0
cmake/modules/CPackDeb.cmake View File

@@ -0,0 +1,222 @@
1
+# - The builtin (binary) CPack Deb generator (Unix only)
2
+# CPackDeb may be used to create Deb package using CPack.
3
+# CPackDeb is a CPack generator thus it uses the CPACK_XXX variables
4
+# used by CPack : http://www.cmake.org/Wiki/CMake:CPackConfiguration
5
+#
6
+# However CPackRPM has specific features which are controlled by
7
+# the specifics CPACK_RPM_XXX variables.You'll find a detailed usage on 
8
+# the wiki: 
9
+#  http://www.cmake.org/Wiki/CMake:CPackPackageGenerators#DEB_.28UNIX_only.29
10
+# However as a handy reminder here comes the list of specific variables:
11
+#
12
+#  CPACK_DEBIAN_PACKAGE_NAME
13
+#     Mandatory : YES
14
+#     Default   : CPACK_PACKAGE_NAME (lower case)
15
+#     The debian package summary
16
+# CPACK_DEBIAN_PACKAGE_VERSION
17
+#     Mandatory : YES
18
+#     Default   : CPACK_PACKAGE_VERSION
19
+#     The debian package version
20
+# CPACK_DEBIAN_PACKAGE_ARCHITECTURE)
21
+#     Mandatory : YES
22
+#     Default   : Output of dpkg --print-architecture or i386
23
+#     The debian package architecture
24
+# CPACK_DEBIAN_PACKAGE_DEPENDS
25
+#     Mandatory : NO
26
+#     Default   : -
27
+#     May be used to set deb dependencies. 
28
+# CPACK_DEBIAN_PACKAGE_MAINTAINER
29
+#     Mandatory : YES
30
+#     Default   : CPACK_PACKAGE_CONTACT
31
+#     The debian package maintainer
32
+# CPACK_DEBIAN_PACKAGE_DESCRIPTION
33
+#     Mandatory : YES
34
+#     Default   : CPACK_PACKAGE_DESCRIPTION_SUMMARY
35
+#     The debian package description
36
+# CPACK_DEBIAN_PACKAGE_SECTION
37
+#     Mandatory : YES
38
+#     Default   : 'devel'
39
+#     The debian package section
40
+# CPACK_DEBIAN_PACKAGE_PRIORITY
41
+#     Mandatory : YES
42
+#     Default   : 'optional'
43
+#     The debian package priority
44
+
45
+#=============================================================================
46
+# Copyright 2007-2009 Kitware, Inc.
47
+# Copyright 2007-2009 Mathieu Malaterre <mathieu.malaterre@gmail.com>
48
+#
49
+# Distributed under the OSI-approved BSD License (the "License");
50
+# see accompanying file Copyright.txt for details.
51
+#
52
+# This software is distributed WITHOUT ANY WARRANTY; without even the
53
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
54
+# See the License for more information.
55
+#=============================================================================
56
+# (To distributed this file outside of CMake, substitute the full
57
+#  License text for the above reference.)
58
+
59
+# CPack script for creating Debian package
60
+# Author: Mathieu Malaterre
61
+#
62
+# http://wiki.debian.org/HowToPackageForDebian
63
+
64
+IF(CMAKE_BINARY_DIR)
65
+  MESSAGE(FATAL_ERROR "CPackDeb.cmake may only be used by CPack internally.")
66
+ENDIF(CMAKE_BINARY_DIR)
67
+
68
+IF(NOT UNIX)
69
+  MESSAGE(FATAL_ERROR "CPackDeb.cmake may only be used under UNIX.")
70
+ENDIF(NOT UNIX)
71
+
72
+# Let's define the control file found in debian package:
73
+
74
+# Binary package:
75
+# http://www.debian.org/doc/debian-policy/ch-controlfields.html#s-binarycontrolfiles
76
+
77
+# DEBIAN/control
78
+# debian policy enforce lower case for package name
79
+# Package: (mandatory)
80
+IF(NOT CPACK_DEBIAN_PACKAGE_NAME)
81
+  STRING(TOLOWER "${CPACK_PACKAGE_NAME}" CPACK_DEBIAN_PACKAGE_NAME)
82
+ENDIF(NOT CPACK_DEBIAN_PACKAGE_NAME)
83
+
84
+# Version: (mandatory)
85
+IF(NOT CPACK_DEBIAN_PACKAGE_VERSION)
86
+  IF(NOT CPACK_PACKAGE_VERSION)
87
+    MESSAGE(FATAL_ERROR "Debian package requires a package version")
88
+  ENDIF(NOT CPACK_PACKAGE_VERSION)
89
+  SET(CPACK_DEBIAN_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION})
90
+ENDIF(NOT CPACK_DEBIAN_PACKAGE_VERSION)
91
+
92
+# Architecture: (mandatory)
93
+IF(NOT CPACK_DEBIAN_PACKAGE_ARCHITECTURE)
94
+  # There is no such thing as i686 architecture on debian, you should use i386 instead
95
+  # $ dpkg --print-architecture
96
+  FIND_PROGRAM(DPKG_CMD dpkg)
97
+  IF(NOT DPKG_CMD)
98
+    MESSAGE(STATUS "Can not find dpkg in your path, default to i386.")
99
+    SET(CPACK_DEBIAN_PACKAGE_ARCHITECTURE i386)
100
+  ENDIF(NOT DPKG_CMD)
101
+  EXECUTE_PROCESS(COMMAND "${DPKG_CMD}" --print-architecture
102
+    OUTPUT_VARIABLE CPACK_DEBIAN_PACKAGE_ARCHITECTURE
103
+    OUTPUT_STRIP_TRAILING_WHITESPACE
104
+    )
105
+ENDIF(NOT CPACK_DEBIAN_PACKAGE_ARCHITECTURE)
106
+
107
+# have a look at GET_PROPERTY(result GLOBAL PROPERTY ENABLED_FEATURES),
108
+# this returns the successful FIND_PACKAGE() calls, maybe this can help
109
+# Depends:
110
+# You should set: DEBIAN_PACKAGE_DEPENDS
111
+# TODO: automate 'objdump -p | grep NEEDED'
112
+IF(NOT CPACK_DEBIAN_PACKAGE_DEPENDS)
113
+  MESSAGE(STATUS "CPACK_DEBIAN_PACKAGE_DEPENDS not set, the package will have no dependencies.")
114
+ENDIF(NOT CPACK_DEBIAN_PACKAGE_DEPENDS)
115
+
116
+# Maintainer: (mandatory)
117
+IF(NOT CPACK_DEBIAN_PACKAGE_MAINTAINER)
118
+  IF(NOT CPACK_PACKAGE_CONTACT)
119
+    MESSAGE(FATAL_ERROR "Debian package requires a maintainer for a package, set CPACK_PACKAGE_CONTACT or CPACK_DEBIAN_PACKAGE_MAINTAINER")
120
+  ENDIF(NOT CPACK_PACKAGE_CONTACT)
121
+  SET(CPACK_DEBIAN_PACKAGE_MAINTAINER ${CPACK_PACKAGE_CONTACT})
122
+ENDIF(NOT CPACK_DEBIAN_PACKAGE_MAINTAINER)
123
+
124
+# Description: (mandatory)
125
+IF(NOT CPACK_DEBIAN_PACKAGE_DESCRIPTION)
126
+  IF(NOT CPACK_PACKAGE_DESCRIPTION_SUMMARY)
127
+    MESSAGE(FATAL_ERROR "Debian package requires a summary for a package, set CPACK_PACKAGE_DESCRIPTION_SUMMARY or CPACK_DEBIAN_PACKAGE_DESCRIPTION")
128
+  ENDIF(NOT CPACK_PACKAGE_DESCRIPTION_SUMMARY)
129
+  SET(CPACK_DEBIAN_PACKAGE_DESCRIPTION ${CPACK_PACKAGE_DESCRIPTION_SUMMARY})
130
+ENDIF(NOT CPACK_DEBIAN_PACKAGE_DESCRIPTION)
131
+
132
+# Section: (recommended)
133
+IF(NOT CPACK_DEBIAN_PACKAGE_SECTION)
134
+  SET(CPACK_DEBIAN_PACKAGE_SECTION "devel")
135
+ENDIF(NOT CPACK_DEBIAN_PACKAGE_SECTION)
136
+
137
+# Priority: (recommended)
138
+IF(NOT CPACK_DEBIAN_PACKAGE_PRIORITY)
139
+  SET(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
140
+ENDIF(NOT CPACK_DEBIAN_PACKAGE_PRIORITY )
141
+
142
+# Recommends:
143
+# You should set: CPACK_DEBIAN_PACKAGE_RECOMMENDS
144
+
145
+# Suggests:
146
+# You should set: CPACK_DEBIAN_PACKAGE_SUGGESTS
147
+
148
+# CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA
149
+# This variable allow advanced user to add custom script to the control.tar.gz (inside the .deb archive)
150
+# Typical examples are: 
151
+# - conffiles
152
+# - postinst
153
+# - postrm
154
+# - prerm"
155
+# Usage:
156
+# SET(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA 
157
+#    "${CMAKE_CURRENT_SOURCE_DIR/prerm;${CMAKE_CURRENT_SOURCE_DIR}/postrm")
158
+
159
+
160
+# For debian source packages:
161
+# debian/control
162
+# http://www.debian.org/doc/debian-policy/ch-controlfields.html#s-sourcecontrolfiles
163
+
164
+# .dsc
165
+# http://www.debian.org/doc/debian-policy/ch-controlfields.html#s-debiansourcecontrolfiles
166
+
167
+# Builds-Depends:
168
+#IF(NOT CPACK_DEBIAN_PACKAGE_BUILDS_DEPENDS)
169
+#  SET(CPACK_DEBIAN_PACKAGE_BUILDS_DEPENDS
170
+#    "debhelper (>> 5.0.0), libncurses5-dev, tcl8.4"
171
+#  )
172
+#ENDIF(NOT CPACK_DEBIAN_PACKAGE_BUILDS_DEPENDS)
173
+
174
+# Description: (mandatory)
175
+#if(NOT CPACK_SECTION)
176
+#    message(FATAL_ERROR "opkg package requires a package section")
177
+#endif(NOT CPACK_SECTION)
178
+
179
+# Package for opkg
180
+FIND_PROGRAM(OPKG_CMD opkg-build)
181
+if( ${OPKG_CMD} STREQUAL "OPKG_CMD-NOTFOUND" )
182
+  message("CPack: opkg-build not found. Skipping packaging")
183
+else( ${OPKG_CMD} STREQUAL "OPKG_CMD-NOTFOUND" )
184
+  SET(CPACK_OPKG_ROOTDIR "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}")
185
+  FILE(MAKE_DIRECTORY ${CPACK_OPKG_ROOTDIR}/CONTROL)
186
+  set(CPACK_OPKG_CONTROL_FILE "${CPACK_OPKG_ROOTDIR}/CONTROL/control")
187
+  # Write controlfile
188
+  FILE(WRITE ${CPACK_OPKG_CONTROL_FILE}
189
+    "Package: ${CPACK_PACKAGE_NAME}
190
+Version: ${CPACK_PACKAGE_VERSION}
191
+Description: ${CPACK_PACKAGE_DESCRIPTION_SUMMARY}
192
+Architecture: ${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}
193
+Section: ${CPACK_DEBIAN_PACKAGE_SECTION}
194
+Priority: optional
195
+Maintainer: ${CPACK_DEBIAN_PACKAGE_MAINTAINER}
196
+Depends: ${CPACK_DEBIAN_PACKAGE_DEPENDS}
197
+Provides: ${CPACK_DEBIAN_PACKAGE_PROVIDES}
198
+Replaces: ${CPACK_DEBIAN_PACKAGE_REPLACES}
199
+Conflicts: ${CPACK_DEBIAN_PACKAGE_CONFLICTS}
200
+Source: https://github.com/intel-iot-devkit/upm
201
+#Essential: no
202
+")
203
+
204
+set(OPKG_FILE_NAME "${CPACK_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}")
205
+  execute_process(
206
+    COMMAND "${OPKG_CMD}" "-o" "0" "${CPACK_PACKAGE_FILE_NAME}" "."
207
+    RESULT_VARIABLE _result
208
+    OUTPUT_VARIABLE _res_output
209
+    ERROR_VARIABLE  _res_error
210
+    WORKING_DIRECTORY ${CPACK_TOPLEVEL_DIRECTORY}
211
+    )
212
+
213
+  if(${_result})
214
+    message("Result '${_result}'")
215
+    message("Output '${_res_output}'")
216
+    message("Error  '${_res_error}'")
217
+  else(${_result})
218
+    message("CPack: Package ${OPKG_FILE_NAME}.ipk generated.")
219
+    set(WDIR "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}")
220
+    file(RENAME ${CPACK_TOPLEVEL_DIRECTORY}/${OPKG_FILE_NAME}.ipk ${CPACK_BINARY_DIR}/${OPKG_FILE_NAME}.ipk)
221
+  endif(${_result})
222
+endif( ${OPKG_CMD} STREQUAL "OPKG_CMD-NOTFOUND" )

+ 130
- 0
cmake/modules/GetGitRevisionDescription.cmake View File

@@ -0,0 +1,130 @@
1
+# - Returns a version string from Git
2
+#
3
+# These functions force a re-configure on each git commit so that you can
4
+# trust the values of the variables in your build system.
5
+#
6
+#  get_git_head_revision(<refspecvar> <hashvar> [<additional arguments to git describe> ...])
7
+#
8
+# Returns the refspec and sha hash of the current head revision
9
+#
10
+#  git_describe(<var> [<additional arguments to git describe> ...])
11
+#
12
+# Returns the results of git describe on the source tree, and adjusting
13
+# the output so that it tests false if an error occurs.
14
+#
15
+#  git_get_exact_tag(<var> [<additional arguments to git describe> ...])
16
+#
17
+# Returns the results of git describe --exact-match on the source tree,
18
+# and adjusting the output so that it tests false if there was no exact
19
+# matching tag.
20
+#
21
+# Requires CMake 2.6 or newer (uses the 'function' command)
22
+#
23
+# Original Author:
24
+# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
25
+# http://academic.cleardefinition.com
26
+# Iowa State University HCI Graduate Program/VRAC
27
+#
28
+# Copyright Iowa State University 2009-2010.
29
+# Distributed under the Boost Software License, Version 1.0.
30
+# (See accompanying file LICENSE_1_0.txt or copy at
31
+# http://www.boost.org/LICENSE_1_0.txt)
32
+
33
+if(__get_git_revision_description)
34
+	return()
35
+endif()
36
+set(__get_git_revision_description YES)
37
+
38
+# We must run the following at "include" time, not at function call time,
39
+# to find the path to this module rather than the path to a calling list file
40
+get_filename_component(_gitdescmoddir ${CMAKE_CURRENT_LIST_FILE} PATH)
41
+
42
+function(get_git_head_revision _refspecvar _hashvar)
43
+	set(GIT_PARENT_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
44
+	set(GIT_DIR "${GIT_PARENT_DIR}/.git")
45
+	while(NOT EXISTS "${GIT_DIR}")	# .git dir not found, search parent directories
46
+		set(GIT_PREVIOUS_PARENT "${GIT_PARENT_DIR}")
47
+		get_filename_component(GIT_PARENT_DIR ${GIT_PARENT_DIR} PATH)
48
+		if(GIT_PARENT_DIR STREQUAL GIT_PREVIOUS_PARENT)
49
+			# We have reached the root directory, we are not in git
50
+			set(${_refspecvar} "GITDIR-NOTFOUND" PARENT_SCOPE)
51
+			set(${_hashvar} "GITDIR-NOTFOUND" PARENT_SCOPE)
52
+			return()
53
+		endif()
54
+		set(GIT_DIR "${GIT_PARENT_DIR}/.git")
55
+	endwhile()
56
+	# check if this is a submodule
57
+	if(NOT IS_DIRECTORY ${GIT_DIR})
58
+		file(READ ${GIT_DIR} submodule)
59
+		string(REGEX REPLACE "gitdir: (.*)\n$" "\\1" GIT_DIR_RELATIVE ${submodule})
60
+		get_filename_component(SUBMODULE_DIR ${GIT_DIR} PATH)
61
+		get_filename_component(GIT_DIR ${SUBMODULE_DIR}/${GIT_DIR_RELATIVE} ABSOLUTE)
62
+	endif()
63
+	set(GIT_DATA "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/git-data")
64
+	if(NOT EXISTS "${GIT_DATA}")
65
+		file(MAKE_DIRECTORY "${GIT_DATA}")
66
+	endif()
67
+
68
+	if(NOT EXISTS "${GIT_DIR}/HEAD")
69
+		return()
70
+	endif()
71
+	set(HEAD_FILE "${GIT_DATA}/HEAD")
72
+	configure_file("${GIT_DIR}/HEAD" "${HEAD_FILE}" COPYONLY)
73
+
74
+	configure_file("${_gitdescmoddir}/GetGitRevisionDescription.cmake.in"
75
+		"${GIT_DATA}/grabRef.cmake"
76
+		@ONLY)
77
+	include("${GIT_DATA}/grabRef.cmake")
78
+
79
+	set(${_refspecvar} "${HEAD_REF}" PARENT_SCOPE)
80
+	set(${_hashvar} "${HEAD_HASH}" PARENT_SCOPE)
81
+endfunction()
82
+
83
+function(git_describe _var)
84
+	if(NOT GIT_FOUND)
85
+		find_package(Git QUIET)
86
+	endif()
87
+	get_git_head_revision(refspec hash)
88
+	if(NOT GIT_FOUND)
89
+		set(${_var} "GIT-NOTFOUND" PARENT_SCOPE)
90
+		return()
91
+	endif()
92
+	if(NOT hash)
93
+		set(${_var} "HEAD-HASH-NOTFOUND" PARENT_SCOPE)
94
+		return()
95
+	endif()
96
+
97
+	# TODO sanitize
98
+	#if((${ARGN}" MATCHES "&&") OR
99
+	#	(ARGN MATCHES "||") OR
100
+	#	(ARGN MATCHES "\\;"))
101
+	#	message("Please report the following error to the project!")
102
+	#	message(FATAL_ERROR "Looks like someone's doing something nefarious with git_describe! Passed arguments ${ARGN}")
103
+	#endif()
104
+
105
+	#message(STATUS "Arguments to execute_process: ${ARGN}")
106
+
107
+	execute_process(COMMAND
108
+		"${GIT_EXECUTABLE}"
109
+		describe
110
+		${hash}
111
+		${ARGN}
112
+		WORKING_DIRECTORY
113
+		"${CMAKE_SOURCE_DIR}"
114
+		RESULT_VARIABLE
115
+		res
116
+		OUTPUT_VARIABLE
117
+		out
118
+		ERROR_QUIET
119
+		OUTPUT_STRIP_TRAILING_WHITESPACE)
120
+	if(NOT res EQUAL 0)
121
+		set(out "${out}-${res}-NOTFOUND")
122
+	endif()
123
+
124
+	set(${_var} "${out}" PARENT_SCOPE)
125
+endfunction()
126
+
127
+function(git_get_exact_tag _var)
128
+	git_describe(out --exact-match ${ARGN})
129
+	set(${_var} "${out}" PARENT_SCOPE)
130
+endfunction()

+ 38
- 0
cmake/modules/GetGitRevisionDescription.cmake.in View File

@@ -0,0 +1,38 @@
1
+# 
2
+# Internal file for GetGitRevisionDescription.cmake
3
+#
4
+# Requires CMake 2.6 or newer (uses the 'function' command)
5
+#
6
+# Original Author:
7
+# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
8
+# http://academic.cleardefinition.com
9
+# Iowa State University HCI Graduate Program/VRAC
10
+#
11
+# Copyright Iowa State University 2009-2010.
12
+# Distributed under the Boost Software License, Version 1.0.
13
+# (See accompanying file LICENSE_1_0.txt or copy at
14
+# http://www.boost.org/LICENSE_1_0.txt)
15
+
16
+set(HEAD_HASH)
17
+
18
+file(READ "@HEAD_FILE@" HEAD_CONTENTS LIMIT 1024)
19
+
20
+string(STRIP "${HEAD_CONTENTS}" HEAD_CONTENTS)
21
+if(HEAD_CONTENTS MATCHES "ref")
22
+	# named branch
23
+	string(REPLACE "ref: " "" HEAD_REF "${HEAD_CONTENTS}")
24
+	if(EXISTS "@GIT_DIR@/${HEAD_REF}")
25
+		configure_file("@GIT_DIR@/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY)
26
+	elseif(EXISTS "@GIT_DIR@/logs/${HEAD_REF}")
27
+		configure_file("@GIT_DIR@/logs/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY)
28
+		set(HEAD_HASH "${HEAD_REF}")
29
+	endif()
30
+else()
31
+	# detached HEAD
32
+	configure_file("@GIT_DIR@/HEAD" "@GIT_DATA@/head-ref" COPYONLY)
33
+endif()
34
+
35
+if(NOT HEAD_HASH)
36
+	file(READ "@GIT_DATA@/head-ref" HEAD_HASH LIMIT 1024)
37
+	string(STRIP "${HEAD_HASH}" HEAD_HASH)
38
+endif()

+ 23
- 0
cmake/modules/LICENSE_1_0.txt View File

@@ -0,0 +1,23 @@
1
+Boost Software License - Version 1.0 - August 17th, 2003
2
+
3
+Permission is hereby granted, free of charge, to any person or organization
4
+obtaining a copy of the software and accompanying documentation covered by
5
+this license (the "Software") to use, reproduce, display, distribute,
6
+execute, and transmit the Software, and to prepare derivative works of the
7
+Software, and to permit third-parties to whom the Software is furnished to
8
+do so, all subject to the following:
9
+
10
+The copyright notices in the Software and this entire statement, including
11
+the above license grant, this restriction and the following disclaimer,
12
+must be included in all copies of the Software, in whole or in part, and
13
+all derivative works of the Software, unless such copies or derivative
14
+works are solely in the form of machine-executable object code generated by
15
+a source language processor.
16
+
17
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
20
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
21
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
22
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23
+DEALINGS IN THE SOFTWARE.

+ 136
- 0
cmake/modules/TargetArch.cmake View File

@@ -0,0 +1,136 @@
1
+# Based on the Qt 5 processor detection code, so should be very accurate
2
+# https://qt.gitorious.org/qt/qtbase/blobs/master/src/corelib/global/qprocessordetection.h
3
+# Currently handles arm (v5, v6, v7), x86 (32/64), ia64, and ppc (32/64)
4
+
5
+# Regarding POWER/PowerPC, just as is noted in the Qt source,
6
+# "There are many more known variants/revisions that we do not handle/detect."
7
+
8
+set(archdetect_c_code "
9
+#if defined(__arm__) || defined(__TARGET_ARCH_ARM)
10
+    #if defined(__ARM_ARCH_7__) \\
11
+        || defined(__ARM_ARCH_7A__) \\
12
+        || defined(__ARM_ARCH_7R__) \\
13
+        || defined(__ARM_ARCH_7M__) \\
14
+        || (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM-0 >= 7)
15
+        #error cmake_ARCH armv7
16
+    #elif defined(__ARM_ARCH_6__) \\
17
+        || defined(__ARM_ARCH_6J__) \\
18
+        || defined(__ARM_ARCH_6T2__) \\
19
+        || defined(__ARM_ARCH_6Z__) \\
20
+        || defined(__ARM_ARCH_6K__) \\
21
+        || defined(__ARM_ARCH_6ZK__) \\
22
+        || defined(__ARM_ARCH_6M__) \\
23
+        || (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM-0 >= 6)
24
+        #error cmake_ARCH armv6
25
+    #elif defined(__ARM_ARCH_5TEJ__) \\
26
+        || (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM-0 >= 5)
27
+        #error cmake_ARCH armv5
28
+    #else
29
+        #error cmake_ARCH arm
30
+    #endif
31
+#elif defined(__i586) || defined(__i586__)
32
+    #error cmake_ARCH i586
33
+#elif defined(__i386) || defined(__i386__) || defined(_M_IX86)
34
+    #error cmake_ARCH i386
35
+#elif defined(__x86_64) || defined(__x86_64__) || defined(__amd64) || defined(_M_X64)
36
+    #error cmake_ARCH x86_64
37
+#elif defined(__ia64) || defined(__ia64__) || defined(_M_IA64)
38
+    #error cmake_ARCH ia64
39
+#elif defined(__ppc__) || defined(__ppc) || defined(__powerpc__) \\
40
+      || defined(_ARCH_COM) || defined(_ARCH_PWR) || defined(_ARCH_PPC)  \\
41
+      || defined(_M_MPPC) || defined(_M_PPC)
42
+    #if defined(__ppc64__) || defined(__powerpc64__) || defined(__64BIT__)
43
+        #error cmake_ARCH ppc64
44
+    #else
45
+        #error cmake_ARCH ppc
46
+    #endif
47
+#endif
48
+
49
+#error cmake_ARCH unknown
50
+")
51
+
52
+# Set ppc_support to TRUE before including this file or ppc and ppc64
53
+# will be treated as invalid architectures since they are no longer supported by Apple
54
+
55
+function(target_architecture output_var)
56
+    if(APPLE AND CMAKE_OSX_ARCHITECTURES)
57
+        # On OS X we use CMAKE_OSX_ARCHITECTURES *if* it was set
58
+        # First let's normalize the order of the values
59
+
60
+        # Note that it's not possible to compile PowerPC applications if you are using
61
+        # the OS X SDK version 10.6 or later - you'll need 10.4/10.5 for that, so we
62
+        # disable it by default
63
+        # See this page for more information:
64
+        # http://stackoverflow.com/questions/5333490/how-can-we-restore-ppc-ppc64-as-well-as-full-10-4-10-5-sdk-support-to-xcode-4
65
+
66
+        # Architecture defaults to i386 or ppc on OS X 10.5 and earlier, depending on the CPU type detected at runtime.
67
+        # On OS X 10.6+ the default is x86_64 if the CPU supports it, i386 otherwise.
68
+
69
+        foreach(osx_arch ${CMAKE_OSX_ARCHITECTURES})
70
+            if("${osx_arch}" STREQUAL "ppc" AND ppc_support)
71
+                set(osx_arch_ppc TRUE)
72
+            elseif("${osx_arch}" STREQUAL "i386")
73
+                set(osx_arch_i386 TRUE)
74
+            elseif("${osx_arch}" STREQUAL "x86_64")
75
+                set(osx_arch_x86_64 TRUE)
76
+            elseif("${osx_arch}" STREQUAL "ppc64" AND ppc_support)
77
+                set(osx_arch_ppc64 TRUE)
78
+            else()
79
+                message(FATAL_ERROR "Invalid OS X arch name: ${osx_arch}")
80
+            endif()
81
+        endforeach()
82
+
83
+        # Now add all the architectures in our normalized order
84
+        if(osx_arch_ppc)
85
+            list(APPEND ARCH ppc)
86
+        endif()
87
+
88
+        if(osx_arch_i386)
89
+            list(APPEND ARCH i386)
90
+        endif()
91
+
92
+        if(osx_arch_x86_64)
93
+            list(APPEND ARCH x86_64)
94
+        endif()
95
+
96
+        if(osx_arch_ppc64)
97
+            list(APPEND ARCH ppc64)
98
+        endif()
99
+    else()
100
+        file(WRITE "${CMAKE_BINARY_DIR}/arch.c" "${archdetect_c_code}")
101
+
102
+        enable_language(C)
103
+
104
+        # Detect the architecture in a rather creative way...
105
+        # This compiles a small C program which is a series of ifdefs that selects a
106
+        # particular #error preprocessor directive whose message string contains the
107
+        # target architecture. The program will always fail to compile (both because
108
+        # file is not a valid C program, and obviously because of the presence of the
109
+        # #error preprocessor directives... but by exploiting the preprocessor in this
110
+        # way, we can detect the correct target architecture even when cross-compiling,
111
+        # since the program itself never needs to be run (only the compiler/preprocessor)
112
+        try_run(
113
+            run_result_unused
114
+            compile_result_unused
115
+            "${CMAKE_BINARY_DIR}"
116
+            "${CMAKE_BINARY_DIR}/arch.c"
117
+            COMPILE_OUTPUT_VARIABLE ARCH
118
+            CMAKE_FLAGS CMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES}
119
+        )
120
+
121
+        # Parse the architecture name from the compiler output
122
+        string(REGEX MATCH "cmake_ARCH ([a-zA-Z0-9_]+)" ARCH "${ARCH}")
123
+
124
+        # Get rid of the value marker leaving just the architecture name
125
+        string(REPLACE "cmake_ARCH " "" ARCH "${ARCH}")
126
+
127
+        # If we are compiling with an unknown architecture this variable should
128
+        # already be set to "unknown" but in the case that it's empty (i.e. due
129
+        # to a typo in the code), then set it to unknown
130
+        if (NOT ARCH)
131
+            set(ARCH unknown)
132
+        endif()
133
+    endif()
134
+
135
+    set(${output_var} "${ARCH}" PARENT_SCOPE)
136
+endfunction()

+ 4
- 0
cmake/modules/version.c.in View File

@@ -0,0 +1,4 @@
1
+#include "version.h"
2
+
3
+const char* gVERSION = "@VERSION@";
4
+const char* gVERSION_SHORT = "@VERSION_SHORT@";