Initial commit.
This commit is contained in:
88
cmake/AddEngine.cmake
Normal file
88
cmake/AddEngine.cmake
Normal file
@@ -0,0 +1,88 @@
|
||||
# Strawberry Music Player
|
||||
# Copyright 2013, Jonas Kvinge <jonas@strawbs.net>
|
||||
#
|
||||
# Strawberry is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Strawberry is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
macro(add_engine engine_lower engine_upper lib_list src_list inc_list enabled)
|
||||
|
||||
#message(STATUS "ADD ENGINE: ${engine_lower} ${engine_upper} ${lib_list} ${src_list} ${inc_list} ${enabled}")
|
||||
|
||||
#set(ENGINE_LIBRARIES "")
|
||||
|
||||
# recreate list
|
||||
set(lib_list ${lib_list})
|
||||
#list(GET lib_list 0 name)
|
||||
|
||||
# add a user selectable build option
|
||||
option(ENGINE_${engine_upper}_ENABLED "enable engine ${engine_upper}" ${enabled})
|
||||
|
||||
# check if engine is enabled and needed librares are available
|
||||
if(ENGINE_${engine_upper}_ENABLED)
|
||||
|
||||
# check for all needed libraries
|
||||
foreach(lib ${lib_list})
|
||||
#pkg_check_modules(${lib} ${lib})
|
||||
if (NOT ${lib}_FOUND MATCHES 1)
|
||||
set(ENGINE_${engine_upper}_LIB_MISSING TRUE)
|
||||
endif(NOT ${lib}_FOUND MATCHES 1)
|
||||
endforeach(lib ${lib_list})
|
||||
|
||||
if(ENGINE_${engine_upper}_LIB_MISSING)
|
||||
set(ENGINES_MISSING "${ENGINES_MISSING} ${engine_lower}")
|
||||
#set("HAVE_${engine_upper}" 0 CACHE INTERNAL ${engine_upper})
|
||||
set("HAVE_${engine_upper}" OFF)
|
||||
else(ENGINE_${engine_upper}_LIB_MISSING)
|
||||
# add define -DHAVE_<engine> so we can clutter the code with #ifdefs
|
||||
#set("HAVE_${engine_upper}" 1 CACHE INTERNAL ${engine_upper})
|
||||
set("HAVE_${engine_upper}" ON)
|
||||
# add sources and headers
|
||||
list(APPEND SOURCES ${src_list})
|
||||
list(APPEND HEADERS ${inc_list})
|
||||
# add libraries to link against
|
||||
foreach(lib ${lib_list})
|
||||
#set(ENGINE_LIBRARIES ${ENGINE_LIBRARIES} ${${lib}_LIBRARIES} CACHE INTERNAL libraries)
|
||||
set(ENGINE_LIBRARIES ${ENGINE_LIBRARIES} ${${lib}_LIBRARIES})
|
||||
endforeach(lib ${lib_list})
|
||||
# add to list of enabled engines
|
||||
set(ENGINES_ENABLED "${ENGINES_ENABLED} ${engine_lower}")
|
||||
endif(ENGINE_${engine_upper}_LIB_MISSING)
|
||||
else(ENGINE_${engine_upper}_ENABLED)
|
||||
set(ENGINES_DISABLED "${ENGINES_DISABLED} ${engine_lower}")
|
||||
#set("HAVE_${engine_upper}" 0 CACHE INTERNAL ${engine_upper})
|
||||
set("HAVE_${engine_upper}" OFF)
|
||||
endif(ENGINE_${engine_upper}_ENABLED)
|
||||
|
||||
endmacro(add_engine engine_lower engine_upper lib_list src_list inc_list enabled)
|
||||
|
||||
# print engines to be built
|
||||
macro(print_engines)
|
||||
|
||||
if(ENGINES_ENABLED)
|
||||
message(STATUS "Building engines:${ENGINES_ENABLED}")
|
||||
endif(ENGINES_ENABLED)
|
||||
if(ENGINES_DISABLED)
|
||||
message(STATUS "Disabled engines:${ENGINES_DISABLED}")
|
||||
endif(ENGINES_DISABLED)
|
||||
if(ENGINES_MISSING)
|
||||
message(STATUS "Missing engines:${ENGINES_MISSING}")
|
||||
endif(ENGINES_MISSING)
|
||||
|
||||
#message(STATUS "Engine libraries:${ENGINE_LIBRARIES}")
|
||||
|
||||
# need at least 1 engine
|
||||
if(NOT ENGINES_ENABLED)
|
||||
message(FATAL_ERROR "No engine enabled!")
|
||||
endif(NOT ENGINES_ENABLED)
|
||||
|
||||
endmacro(print_engines)
|
||||
9
cmake/C++11Compat.cmake
Normal file
9
cmake/C++11Compat.cmake
Normal file
@@ -0,0 +1,9 @@
|
||||
# Hacky stuff to make C++11 features work with old compilers.
|
||||
|
||||
if (CMAKE_COMPILER_IS_GNUCC)
|
||||
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion
|
||||
OUTPUT_VARIABLE GCC_VERSION)
|
||||
if (GCC_VERSION VERSION_LESS 4.7)
|
||||
add_definitions(-Doverride=)
|
||||
endif()
|
||||
endif()
|
||||
9
cmake/Deb.cmake
Normal file
9
cmake/Deb.cmake
Normal file
@@ -0,0 +1,9 @@
|
||||
set(DEB_ARCH amd64 CACHE STRING "Architecture of the deb file")
|
||||
set(DEB_DIST "unstable" CACHE STRING "Distribution to set in the .deb changelog")
|
||||
|
||||
add_custom_target(deb
|
||||
COMMAND dpkg-buildpackage -b -d -uc -us
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/../strawberry_${STRAWBERRY_VERSION_DEB}~${DEB_DIST}_${DEB_ARCH}.deb
|
||||
${CMAKE_BINARY_DIR}/strawberry_${STRAWBERRY_VERSION_DEB}~${DEB_DIST}_${DEB_ARCH}.deb
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
)
|
||||
133
cmake/FindFFTW3.cmake
Normal file
133
cmake/FindFFTW3.cmake
Normal file
@@ -0,0 +1,133 @@
|
||||
#
|
||||
# Try to find FFTW3 library
|
||||
# (see www.fftw.org)
|
||||
# Once run this will define:
|
||||
#
|
||||
# FFTW3_FOUND
|
||||
# FFTW3_INCLUDE_DIR
|
||||
# FFTW3_LIBRARIES
|
||||
# FFTW3_LINK_DIRECTORIES
|
||||
#
|
||||
# You may set one of these options before including this file:
|
||||
# FFTW3_USE_SSE2
|
||||
#
|
||||
# TODO: _F_ versions.
|
||||
#
|
||||
# Jan Woetzel 05/2004
|
||||
# www.mip.informatik.uni-kiel.de
|
||||
# --------------------------------
|
||||
|
||||
FIND_PATH(FFTW3_INCLUDE_DIR fftw3.h
|
||||
${FFTW3_DIR}/include
|
||||
${FFTW3_HOME}/include
|
||||
${FFTW3_DIR}
|
||||
${FFTW3_HOME}
|
||||
$ENV{FFTW3_DIR}/include
|
||||
$ENV{FFTW3_HOME}/include
|
||||
$ENV{FFTW3_DIR}
|
||||
$ENV{FFTW3_HOME}
|
||||
/usr/include
|
||||
/usr/local/include
|
||||
$ENV{SOURCE_DIR}/fftw3
|
||||
$ENV{SOURCE_DIR}/fftw3/include
|
||||
$ENV{SOURCE_DIR}/fftw
|
||||
$ENV{SOURCE_DIR}/fftw/include
|
||||
)
|
||||
#MESSAGE("DBG FFTW3_INCLUDE_DIR=${FFTW3_INCLUDE_DIR}")
|
||||
|
||||
|
||||
SET(FFTW3_POSSIBLE_LIBRARY_PATH
|
||||
${FFTW3_DIR}/lib
|
||||
${FFTW3_HOME}/lib
|
||||
${FFTW3_DIR}
|
||||
${FFTW3_HOME}
|
||||
$ENV{FFTW3_DIR}/lib
|
||||
$ENV{FFTW3_HOME}/lib
|
||||
$ENV{FFTW3_DIR}
|
||||
$ENV{FFTW3_HOME}
|
||||
/usr/lib
|
||||
/usr/local/lib
|
||||
$ENV{SOURCE_DIR}/fftw3
|
||||
$ENV{SOURCE_DIR}/fftw3/lib
|
||||
$ENV{SOURCE_DIR}/fftw
|
||||
$ENV{SOURCE_DIR}/fftw/lib
|
||||
)
|
||||
|
||||
|
||||
# the lib prefix is containe din filename onf W32, unfortuantely. JW
|
||||
# teh "general" lib:
|
||||
FIND_LIBRARY(FFTW3_FFTW_LIBRARY
|
||||
NAMES fftw3 libfftw libfftw3 libfftw3-3
|
||||
PATHS
|
||||
${FFTW3_POSSIBLE_LIBRARY_PATH}
|
||||
)
|
||||
#MESSAGE("DBG FFTW3_FFTW_LIBRARY=${FFTW3_FFTW_LIBRARY}")
|
||||
|
||||
FIND_LIBRARY(FFTW3_FFTWF_LIBRARY
|
||||
NAMES fftwf3 fftw3f fftwf libfftwf libfftwf3 libfftw3f-3
|
||||
PATHS
|
||||
${FFTW3_POSSIBLE_LIBRARY_PATH}
|
||||
)
|
||||
#MESSAGE("DBG FFTW3_FFTWF_LIBRARY=${FFTW3_FFTWF_LIBRARY}")
|
||||
|
||||
FIND_LIBRARY(FFTW3_FFTWL_LIBRARY
|
||||
NAMES fftwl3 fftw3l fftwl libfftwl libfftwl3 libfftw3l-3
|
||||
PATHS
|
||||
${FFTW3_POSSIBLE_LIBRARY_PATH}
|
||||
)
|
||||
#MESSAGE("DBG FFTW3_FFTWF_LIBRARY=${FFTW3_FFTWL_LIBRARY}")
|
||||
|
||||
|
||||
FIND_LIBRARY(FFTW3_FFTW_SSE2_LIBRARY
|
||||
NAMES fftw_sse2 fftw3_sse2 libfftw_sse2 libfftw3_sse2
|
||||
PATHS
|
||||
${FFTW3_POSSIBLE_LIBRARY_PATH}
|
||||
)
|
||||
#MESSAGE("DBG FFTW3_FFTW_SSE2_LIBRARY=${FFTW3_FFTW_SSE2_LIBRARY}")
|
||||
|
||||
FIND_LIBRARY(FFTW3_FFTWF_SSE_LIBRARY
|
||||
NAMES fftwf_sse fftwf3_sse libfftwf_sse libfftwf3_sse
|
||||
PATHS
|
||||
${FFTW3_POSSIBLE_LIBRARY_PATH}
|
||||
)
|
||||
#MESSAGE("DBG FFTW3_FFTWF_SSE_LIBRARY=${FFTW3_FFTWF_SSE_LIBRARY}")
|
||||
|
||||
|
||||
# --------------------------------
|
||||
# select one of the above
|
||||
# default:
|
||||
IF (FFTW3_FFTW_LIBRARY)
|
||||
SET(FFTW3_LIBRARIES ${FFTW3_FFTW_LIBRARY})
|
||||
ENDIF (FFTW3_FFTW_LIBRARY)
|
||||
# specialized:
|
||||
IF (FFTW3_USE_SSE2 AND FFTW3_FFTW_SSE2_LIBRARY)
|
||||
SET(FFTW3_LIBRARIES ${FFTW3_FFTW_SSE2_LIBRARY})
|
||||
ENDIF (FFTW3_USE_SSE2 AND FFTW3_FFTW_SSE2_LIBRARY)
|
||||
|
||||
# --------------------------------
|
||||
|
||||
IF(FFTW3_LIBRARIES)
|
||||
IF (FFTW3_INCLUDE_DIR)
|
||||
|
||||
# OK, found all we need
|
||||
SET(FFTW3_FOUND TRUE)
|
||||
GET_FILENAME_COMPONENT(FFTW3_LINK_DIRECTORIES ${FFTW3_LIBRARIES} PATH)
|
||||
|
||||
ELSE (FFTW3_INCLUDE_DIR)
|
||||
MESSAGE("FFTW3 include dir not found. Set FFTW3_DIR to find it.")
|
||||
ENDIF(FFTW3_INCLUDE_DIR)
|
||||
ELSE(FFTW3_LIBRARIES)
|
||||
MESSAGE("FFTW3 lib not found. Set FFTW3_DIR to find it.")
|
||||
ENDIF(FFTW3_LIBRARIES)
|
||||
|
||||
|
||||
MARK_AS_ADVANCED(
|
||||
FFTW3_INCLUDE_DIR
|
||||
FFTW3_LIBRARIES
|
||||
FFTW3_FFTW_LIBRARY
|
||||
FFTW3_FFTW_SSE2_LIBRARY
|
||||
FFTW3_FFTWF_LIBRARY
|
||||
FFTW3_FFTWF_SSE_LIBRARY
|
||||
FFTW3_FFTWL_LIBRARY
|
||||
FFTW3_LINK_DIRECTORIES
|
||||
)
|
||||
6
cmake/Format.cmake
Normal file
6
cmake/Format.cmake
Normal file
@@ -0,0 +1,6 @@
|
||||
add_custom_target(format-diff
|
||||
#COMMAND python ${CMAKE_SOURCE_DIR}/dist/format.py)
|
||||
COMMAND python2 ${CMAKE_SOURCE_DIR}/dist/format.py)
|
||||
add_custom_target(format
|
||||
#COMMAND python ${CMAKE_SOURCE_DIR}/dist/format.py -i)
|
||||
COMMAND python2 ${CMAKE_SOURCE_DIR}/dist/format.py -i)
|
||||
22
cmake/OptionalSource.cmake
Normal file
22
cmake/OptionalSource.cmake
Normal file
@@ -0,0 +1,22 @@
|
||||
macro(optional_source TOGGLE)
|
||||
parse_arguments(OPTIONAL_SOURCE
|
||||
"SOURCES;HEADERS;UI;INCLUDE_DIRECTORIES"
|
||||
""
|
||||
${ARGN}
|
||||
)
|
||||
|
||||
if(${TOGGLE})
|
||||
list(APPEND SOURCES ${OPTIONAL_SOURCE_SOURCES})
|
||||
list(APPEND HEADERS ${OPTIONAL_SOURCE_HEADERS})
|
||||
list(APPEND UI ${OPTIONAL_SOURCE_UI})
|
||||
include_directories(${OPTIONAL_SOURCE_INCLUDE_DIRECTORIES})
|
||||
else(${TOGGLE})
|
||||
list(APPEND OTHER_SOURCES ${OPTIONAL_SOURCE_SOURCES})
|
||||
list(APPEND OTHER_SOURCES ${OPTIONAL_SOURCE_HEADERS})
|
||||
|
||||
set(_uic_sources)
|
||||
qt5_wrap_ui(_uic_sources ${OPTIONAL_SOURCE_UI})
|
||||
list(APPEND OTHER_SOURCES ${_uic_sources})
|
||||
list(APPEND OTHER_UIC_SOURCES ${_uic_sources})
|
||||
endif(${TOGGLE})
|
||||
endmacro(optional_source)
|
||||
34
cmake/ParseArguments.cmake
Normal file
34
cmake/ParseArguments.cmake
Normal file
@@ -0,0 +1,34 @@
|
||||
# From http://www.cmake.org/Wiki/CMakeMacroParseArguments
|
||||
|
||||
cmake_minimum_required(VERSION 2.6)
|
||||
|
||||
MACRO(PARSE_ARGUMENTS prefix arg_names option_names)
|
||||
SET(DEFAULT_ARGS)
|
||||
FOREACH(arg_name ${arg_names})
|
||||
SET(${prefix}_${arg_name})
|
||||
ENDFOREACH(arg_name)
|
||||
FOREACH(option ${option_names})
|
||||
SET(${prefix}_${option} FALSE)
|
||||
ENDFOREACH(option)
|
||||
|
||||
SET(current_arg_name DEFAULT_ARGS)
|
||||
SET(current_arg_list)
|
||||
FOREACH(arg ${ARGN})
|
||||
SET(larg_names ${arg_names})
|
||||
LIST(FIND larg_names "${arg}" is_arg_name)
|
||||
IF (is_arg_name GREATER -1)
|
||||
SET(${prefix}_${current_arg_name} ${current_arg_list})
|
||||
SET(current_arg_name ${arg})
|
||||
SET(current_arg_list)
|
||||
ELSE (is_arg_name GREATER -1)
|
||||
SET(loption_names ${option_names})
|
||||
LIST(FIND loption_names "${arg}" is_option)
|
||||
IF (is_option GREATER -1)
|
||||
SET(${prefix}_${arg} TRUE)
|
||||
ELSE (is_option GREATER -1)
|
||||
SET(current_arg_list ${current_arg_list} ${arg})
|
||||
ENDIF (is_option GREATER -1)
|
||||
ENDIF (is_arg_name GREATER -1)
|
||||
ENDFOREACH(arg)
|
||||
SET(${prefix}_${current_arg_name} ${current_arg_list})
|
||||
ENDMACRO(PARSE_ARGUMENTS)
|
||||
19
cmake/Rpm.cmake
Normal file
19
cmake/Rpm.cmake
Normal file
@@ -0,0 +1,19 @@
|
||||
set(RPMBUILD_DIR ~/rpmbuild CACHE STRING "Rpmbuild directory, for the rpm target")
|
||||
set(MOCK_COMMAND mock CACHE STRING "Command to use for running mock")
|
||||
set(MOCK_CHROOT fedora-13-x86_64 CACHE STRING "Chroot to use when building an rpm with mock")
|
||||
set(RPM_DISTRO fc13 CACHE STRING "Suffix of the rpm file")
|
||||
set(RPM_ARCH x86_64 CACHE STRING "Architecture of the rpm file")
|
||||
|
||||
add_custom_target(rpm
|
||||
COMMAND ${CMAKE_SOURCE_DIR}/dist/maketarball.sh
|
||||
COMMAND ${CMAKE_COMMAND} -E copy strawberry-${STRAWBERRY_VERSION_SPARKLE}.tar.gz ${RPMBUILD_DIR}/SOURCES/
|
||||
COMMAND rpmbuild -bs ${CMAKE_SOURCE_DIR}/dist/strawberry.spec
|
||||
COMMAND ${MOCK_COMMAND}
|
||||
--verbose
|
||||
--root=${MOCK_CHROOT}
|
||||
--resultdir=${CMAKE_BINARY_DIR}/mock_result/
|
||||
${RPMBUILD_DIR}/SRPMS/strawberry-${STRAWBERRY_VERSION_RPM_V}-${STRAWBERRY_VERSION_RPM_R}.${RPM_DISTRO}.src.rpm
|
||||
COMMAND ${CMAKE_COMMAND} -E copy
|
||||
${CMAKE_BINARY_DIR}/mock_result/strawberry-${STRAWBERRY_VERSION_RPM_V}-${STRAWBERRY_VERSION_RPM_R}.${RPM_DISTRO}.${RPM_ARCH}.rpm
|
||||
${CMAKE_BINARY_DIR}/strawberry-${STRAWBERRY_VERSION_RPM_V}-${STRAWBERRY_VERSION_RPM_R}.${RPM_DISTRO}.${RPM_ARCH}.rpm
|
||||
)
|
||||
89
cmake/Summary.cmake
Normal file
89
cmake/Summary.cmake
Normal file
@@ -0,0 +1,89 @@
|
||||
cmake_policy(SET CMP0012 NEW)
|
||||
|
||||
set(summary_willbuild "")
|
||||
set(summary_willnotbuild "")
|
||||
|
||||
macro(summary_add name test)
|
||||
if (${test})
|
||||
list(APPEND summary_willbuild ${name})
|
||||
else (${test})
|
||||
list(APPEND summary_willnotbuild "${name}")
|
||||
endif (${test})
|
||||
endmacro(summary_add)
|
||||
|
||||
macro(summary_show_part variable title)
|
||||
list(LENGTH ${variable} _len)
|
||||
if (_len)
|
||||
message("")
|
||||
message(${title})
|
||||
foreach (_item ${${variable}})
|
||||
message(" ${_item}")
|
||||
endforeach (_item)
|
||||
endif (_len)
|
||||
endmacro(summary_show_part)
|
||||
|
||||
macro(summary_show)
|
||||
list(SORT summary_willbuild)
|
||||
list(SORT summary_willnotbuild)
|
||||
message("")
|
||||
message("Building strawberry version: ${STRAWBERRY_VERSION_DISPLAY}")
|
||||
summary_show_part(summary_willbuild "The following components will be built:")
|
||||
summary_show_part(summary_willnotbuild "The following components WILL NOT be built:")
|
||||
message("")
|
||||
endmacro(summary_show)
|
||||
|
||||
function(optional_component name default description)
|
||||
set(option_variable "ENABLE_${name}")
|
||||
set(have_variable "HAVE_${name}")
|
||||
set(${have_variable} OFF)
|
||||
|
||||
# Create the option
|
||||
option(${option_variable} "${description}" ${default})
|
||||
|
||||
# Was the option set?
|
||||
if(NOT ${option_variable})
|
||||
set(summary_willnotbuild "${summary_willnotbuild};${description} (disabled in CMake config)" PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
|
||||
# Check each of the dependencies
|
||||
set(next_arg_is_dep_name FALSE)
|
||||
set(testing_deps TRUE)
|
||||
set(current_dep_name)
|
||||
set(missing_deps)
|
||||
|
||||
foreach(arg ${ARGN})
|
||||
if(${next_arg_is_dep_name})
|
||||
set(current_dep_name "${arg}")
|
||||
set(next_arg_is_dep_name FALSE)
|
||||
elseif(arg STREQUAL "DEPENDS")
|
||||
set(next_arg_is_dep_name TRUE)
|
||||
set(testing_deps TRUE)
|
||||
elseif(${testing_deps})
|
||||
string(REPLACE " " ";" arglist "${arg}")
|
||||
if(${arglist})
|
||||
# We have to do this instead of if(NOT ${arg}) so that tests may contain
|
||||
# "NOT" themselves.
|
||||
else()
|
||||
list(APPEND missing_deps "${current_dep_name}")
|
||||
set(testing_deps FALSE)
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if(missing_deps)
|
||||
foreach(dep ${missing_deps})
|
||||
if(deplist_text)
|
||||
set(deplist_text "${deplist_text}, ${dep}")
|
||||
else()
|
||||
set(deplist_text "${dep}")
|
||||
endif()
|
||||
endforeach()
|
||||
set(text "${description} (missing ${deplist_text})")
|
||||
|
||||
set(summary_willnotbuild "${summary_willnotbuild};${text}" PARENT_SCOPE)
|
||||
else()
|
||||
set(${have_variable} ON PARENT_SCOPE)
|
||||
set(summary_willbuild "${summary_willbuild};${description}" PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
169
cmake/Version.cmake
Normal file
169
cmake/Version.cmake
Normal file
@@ -0,0 +1,169 @@
|
||||
# Change this file when releasing a new version.
|
||||
|
||||
# Version numbers.
|
||||
set(STRAWBERRY_VERSION_MAJOR 0)
|
||||
set(STRAWBERRY_VERSION_MINOR 1)
|
||||
set(STRAWBERRY_VERSION_PATCH 1)
|
||||
#set(STRAWBERRY_VERSION_PRERELEASE rc1)
|
||||
|
||||
# This should be set to OFF in a release branch
|
||||
set(INCLUDE_GIT_REVISION ON)
|
||||
|
||||
# Rules about version number comparison on different platforms:
|
||||
# Debian:
|
||||
# Two stages are repeated until there are no more characters to compare:
|
||||
# one block of consecutive digits (\d+) is compared numerically, then one
|
||||
# block of consecutive NON-digits (\D+) is compared lexigraphically,
|
||||
# with the exception that ~ sorts before everything else.
|
||||
#
|
||||
# The "upstream version" and "debian revision" are separated by the last
|
||||
# dash in the version number.
|
||||
#
|
||||
# Algorithm is in "man deb-version", test comparisons with
|
||||
# dpkg --compare-versions.
|
||||
#
|
||||
# These are in sorted order:
|
||||
# 1.0~rc1
|
||||
# 1.0~rc2
|
||||
# 1.0
|
||||
# 1.0-1-g044287b
|
||||
# 1.0-506-g044287b
|
||||
# 1.0.1
|
||||
# 1.0.2
|
||||
# 1.0.a
|
||||
#
|
||||
# Rpm:
|
||||
# The string is split on non-alphanumeric characters. Numeric sections are
|
||||
# compared numerically and non-numeric sections are compared lexigraphically.
|
||||
# If one sections is numeric and the other sections is non-numeric, the
|
||||
# numeric sections is always NEWER.
|
||||
#
|
||||
# The "version" and "release" fields are compared with the same algorithm -
|
||||
# if the versions are equal the releases are compared to determine which
|
||||
# package is newer.
|
||||
#
|
||||
# Algorithm is described in:
|
||||
# http://fedoraproject.org/wiki/Packaging:NamingGuidelines#Package_Versioning
|
||||
# Test comparisons with:
|
||||
# import rpm
|
||||
# rpm.labelCompare((epoch, version, release), (epoch, version, release))
|
||||
#
|
||||
# These are in sorted order:
|
||||
# 1.0-0.rc1
|
||||
# 1.0-0.rc2
|
||||
# 1.0-1
|
||||
# 1.0-2.506-g044287b
|
||||
# 1.0.1-1
|
||||
# 1.0.2-1
|
||||
#
|
||||
# Sparkle (mac) and QtSparkle (windows):
|
||||
# The strings are split into sections of characters that are all of the same
|
||||
# "type" - where a "type" is period, digit, or other. Sections are then
|
||||
# compared against each other - digits are compared numerically and other
|
||||
# are compared lexigraphically. When two sections are of different types,
|
||||
# the numeric section is always NEWER.
|
||||
#
|
||||
# If the common parts of both strings are equal, but one string has more
|
||||
# sections, the type of the first extra section is used to determine which
|
||||
# version is newer.
|
||||
# If the extra section is a string, the shorter result is NEWER, otherwise
|
||||
# the shorter section is OLDER. That means that 1.0 is NEWER than 1.0rc1,
|
||||
# but 1.0 is OLDER than 1.0.1.
|
||||
#
|
||||
# See compareversions.cpp in QtSparkle.
|
||||
|
||||
# Version numbers in Strawberry:
|
||||
# Deb:
|
||||
# With git: $tagname-$commitcount-g$sha1
|
||||
# Without git: $major.$minor.$patch[~$prerelease]
|
||||
#
|
||||
# Rpm: Version Release
|
||||
# Prerelease: $major.$minor.$patch 0.$prerelease
|
||||
# Without git: $major.$minor.$patch 1
|
||||
# With git: $tagname 2.$commitcount.g$sha1
|
||||
#
|
||||
# QtSparkle (Windows):
|
||||
# With git: $tagname-$commitcount-g$sha1
|
||||
# Without git: $major.$minor.$patch[$prerelease]
|
||||
#
|
||||
# Mac info.plist: CFBundleVersion
|
||||
# Prerelease: 4096.$major.$minor.$patch.0
|
||||
# Without git: 4096.$major.$minor.$patch.1
|
||||
# With git: 4096.$tagname.2.$commitcount
|
||||
# The 4096. prefix is because the previous versioning scheme used svn revision
|
||||
# numbers, which got up to 3000+.
|
||||
|
||||
|
||||
set(majorminorpatch "${STRAWBERRY_VERSION_MAJOR}.${STRAWBERRY_VERSION_MINOR}.${STRAWBERRY_VERSION_PATCH}")
|
||||
|
||||
set(STRAWBERRY_VERSION_DISPLAY "${majorminorpatch}")
|
||||
set(STRAWBERRY_VERSION_DEB "${majorminorpatch}")
|
||||
set(STRAWBERRY_VERSION_RPM_V "${majorminorpatch}")
|
||||
set(STRAWBERRY_VERSION_RPM_R "1")
|
||||
set(STRAWBERRY_VERSION_SPARKLE "${majorminorpatch}")
|
||||
set(STRAWBERRY_VERSION_PLIST "4096.${majorminorpatch}")
|
||||
|
||||
if(${STRAWBERRY_VERSION_PATCH} EQUAL "0")
|
||||
set(STRAWBERRY_VERSION_DISPLAY "${STRAWBERRY_VERSION_MAJOR}.${STRAWBERRY_VERSION_MINOR}")
|
||||
endif(${STRAWBERRY_VERSION_PATCH} EQUAL "0")
|
||||
|
||||
# Add prerelease
|
||||
if(STRAWBERRY_VERSION_PRERELEASE)
|
||||
set(STRAWBERRY_VERSION_DISPLAY "${STRAWBERRY_VERSION_DISPLAY} ${STRAWBERRY_VERSION_PRERELEASE}")
|
||||
set(STRAWBERRY_VERSION_DEB "${STRAWBERRY_VERSION_DEB}~${STRAWBERRY_VERSION_PRERELEASE}")
|
||||
set(STRAWBERRY_VERSION_RPM_R "0.${STRAWBERRY_VERSION_PRERELEASE}")
|
||||
set(STRAWBERRY_VERSION_SPARKLE "${STRAWBERRY_VERSION_SPARKLE}${STRAWBERRY_VERSION_PRERELEASE}")
|
||||
set(STRAWBERRY_VERSION_PLIST "${STRAWBERRY_VERSION_PLIST}.0")
|
||||
else(STRAWBERRY_VERSION_PRERELEASE)
|
||||
set(STRAWBERRY_VERSION_PLIST "${STRAWBERRY_VERSION_PLIST}.1")
|
||||
endif(STRAWBERRY_VERSION_PRERELEASE)
|
||||
|
||||
# Add git revision
|
||||
if(FORCE_GIT_REVISION)
|
||||
set(GIT_REV ${FORCE_GIT_REVISION})
|
||||
set(GIT_INFO_RESULT 0)
|
||||
else(FORCE_GIT_REVISION)
|
||||
find_program(GIT_EXECUTABLE git)
|
||||
|
||||
if(NOT GIT_EXECUTABLE-NOTFOUND)
|
||||
execute_process(COMMAND ${GIT_EXECUTABLE} describe
|
||||
RESULT_VARIABLE GIT_INFO_RESULT
|
||||
OUTPUT_VARIABLE GIT_REV
|
||||
ERROR_QUIET
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(${GIT_INFO_RESULT} EQUAL 0)
|
||||
string(REGEX REPLACE "^(.+)-([0-9]+)-(g[a-f0-9]+)$" "\\1;\\2;\\3"
|
||||
GIT_PARTS ${GIT_REV})
|
||||
|
||||
if(NOT GIT_PARTS)
|
||||
message(FATAL_ERROR "Failed to parse git revision string '${GIT_REV}'")
|
||||
endif(NOT GIT_PARTS)
|
||||
|
||||
list(LENGTH GIT_PARTS GIT_PARTS_LENGTH)
|
||||
if(GIT_PARTS_LENGTH EQUAL 3)
|
||||
list(GET GIT_PARTS 0 GIT_TAGNAME)
|
||||
list(GET GIT_PARTS 1 GIT_COMMITCOUNT)
|
||||
list(GET GIT_PARTS 2 GIT_SHA1)
|
||||
set(HAS_GET_REVISION ON)
|
||||
endif(GIT_PARTS_LENGTH EQUAL 3)
|
||||
endif(${GIT_INFO_RESULT} EQUAL 0)
|
||||
|
||||
if(INCLUDE_GIT_REVISION AND HAS_GET_REVISION)
|
||||
set(STRAWBERRY_VERSION_DISPLAY "${GIT_REV}")
|
||||
set(STRAWBERRY_VERSION_DEB "${GIT_REV}")
|
||||
set(STRAWBERRY_VERSION_RPM_V "${GIT_TAGNAME}")
|
||||
set(STRAWBERRY_VERSION_RPM_R "2.${GIT_COMMITCOUNT}.${GIT_SHA1}")
|
||||
set(STRAWBERRY_VERSION_SPARKLE "${GIT_REV}")
|
||||
set(STRAWBERRY_VERSION_PLIST "4096.${GIT_TAGNAME}.2.${GIT_COMMITCOUNT}")
|
||||
endif(INCLUDE_GIT_REVISION AND HAS_GET_REVISION)
|
||||
|
||||
if(0)
|
||||
message(STATUS "Display: ${STRAWBERRY_VERSION_DISPLAY}")
|
||||
message(STATUS "Deb: ${STRAWBERRY_VERSION_DEB}")
|
||||
message(STATUS "Rpm: ${STRAWBERRY_VERSION_RPM_V}-${STRAWBERRY_VERSION_RPM_R}")
|
||||
message(STATUS "Sparkle: ${STRAWBERRY_VERSION_SPARKLE}")
|
||||
message(STATUS "Plist: ${STRAWBERRY_VERSION_PLIST}")
|
||||
endif(0)
|
||||
Reference in New Issue
Block a user