-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #85 from stephengtuggy/0.8.x_last_minute_cmake_stuff
Last minute CMake stuff on 0.8.x
- Loading branch information
Showing
3 changed files
with
128 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,8 +21,33 @@ | |
# along with vsUTCS. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
|
||
CMAKE_MINIMUM_REQUIRED(VERSION 3.5) | ||
PROJECT(vsUTCS) | ||
CMAKE_MINIMUM_REQUIRED(VERSION 3.5 FATAL_ERROR) | ||
|
||
SET(vsUTCS_VERSION_MAJOR "0") | ||
SET(vsUTCS_VERSION_MINOR "8") | ||
SET(vsUTCS_VERSION_PATCH "0") | ||
# Auto-populate with the git hash of the build | ||
IF (DEFINED ENV{GITHUB_SHA} AND NOT "$ENV{GITHUB_SHA}" STREQUAL "") | ||
SET (vsUTCS_VERSION_TWEAK "$ENV{GITHUB_SHA}") | ||
ELSE () | ||
EXECUTE_PROCESS( | ||
COMMAND git rev-parse --short HEAD | ||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} | ||
OUTPUT_VARIABLE vsUTCS_VERSION_TWEAK | ||
OUTPUT_STRIP_TRAILING_WHITESPACE | ||
) | ||
ENDIF () | ||
|
||
PROJECT(vsUTCS | ||
VERSION | ||
"${vsUTCS_VERSION_MAJOR}.${vsUTCS_VERSION_MINOR}.${vsUTCS_VERSION_PATCH}" #.${vsUTCS_VERSION_TWEAK} # CMake only allows numeric version components, unfortunately. | ||
) | ||
|
||
# Let cmake find our in-tree modules | ||
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${vsUTCS_SOURCE_DIR}) | ||
|
||
# Detect available Linux Distros that can be built for | ||
FIND_PACKAGE(LinuxDistro REQUIRED) | ||
|
||
SET(CPACK_IGNORE_FILES | ||
build/ | ||
|
@@ -138,17 +163,17 @@ SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "3D space combat and trading game") | |
SET(CPACK_PACKAGE_VENDOR "Vega Strike") | ||
SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/documentation/readme.txt") | ||
SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/vega-license.txt") | ||
SET(CPACK_PACKAGE_VERSION_MAJOR "0") | ||
SET(CPACK_PACKAGE_VERSION_MINOR "8") | ||
SET(CPACK_PACKAGE_VERSION_PATCH "0") | ||
SET(CPACK_PACKAGE_VERSION_MAJOR "${vsUTCS_VERSION_MAJOR}") | ||
SET(CPACK_PACKAGE_VERSION_MINOR "${vsUTCS_VERSION_MINOR}") | ||
SET(CPACK_PACKAGE_VERSION_PATCH "${vsUTCS_VERSION_PATCH}") | ||
SET(CPACK_PACKAGE_INSTALL_DIRECTORY "vsUTCS-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}") | ||
SET(CPACK_CONTACT "[email protected]") | ||
|
||
# Source package filename | ||
IF (DEFINED ENV{TAG_NAME}) | ||
SET(vsUTCS_PACKAGE_VERSION_STR "$ENV{TAG_NAME}") | ||
ELSE (DEFINED ENV{TAG_NAME}) | ||
SET(vsUTCS_PACKAGE_VERSION_STR "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}") | ||
SET(vsUTCS_PACKAGE_VERSION_STR "${vsUTCS_VERSION_MAJOR}.${vsUTCS_VERSION_MINOR}.${vsUTCS_VERSION_PATCH}-0.${vsUTCS_VERSION_TWEAK}") | ||
ENDIF (DEFINED ENV{TAG_NAME}) | ||
SET(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}_${vsUTCS_PACKAGE_VERSION_STR}-Source") | ||
SET(CPACK_SOURCE_GENERATOR "TXZ") | ||
|
@@ -180,73 +205,24 @@ ELSEIF (CMAKE_SYSTEM_NAME STREQUAL Linux) | |
MESSAGE("-- Configuring Packaging for Linux") | ||
SET(CPACK_GENERATOR "TXZ") | ||
|
||
# Gather info about Linux distro and release (if applicable). | ||
IF (CMAKE_SYSTEM_NAME STREQUAL Linux) | ||
EXECUTE_PROCESS( | ||
COMMAND sh -c "cat /etc/os-release | grep ^ID= | sed 's/^ID=//' | tr -d '\"\n'" | ||
OUTPUT_VARIABLE LINUX_ID) | ||
EXECUTE_PROCESS( | ||
COMMAND sh -c "cat /etc/os-release | grep ^VERSION_CODENAME= | sed 's/^VERSION_CODENAME=//' | tr -d '\"\n'" | ||
OUTPUT_VARIABLE LINUX_CODENAME) | ||
EXECUTE_PROCESS( | ||
COMMAND sh -c "cat /etc/os-release | grep ^VERSION_ID= | sed 's/^VERSION_ID=//' | tr -d '\"\n'" | ||
OUTPUT_VARIABLE LINUX_VERSION_ID) | ||
ENDIF (CMAKE_SYSTEM_NAME STREQUAL Linux) | ||
|
||
# SET(LSB_EXISTS FALSE) | ||
# SET(LSB_LINUX_DISTRIBUTION "Unknown") | ||
# SET(LSB_LINUX_DISTRIBUTION_CODENAME "Unknown") | ||
|
||
# # Lookup the LSB Data - this is known for Ubuntu, but also used by other distros too. | ||
# # and may help with distro-sub-selection | ||
# FIND_PROGRAM(LSB_RELEASE_EXEC lsb_release) | ||
# IF (LSB_RELEASE_EXEC) | ||
# EXECUTE_PROCESS(COMMAND ${LSB_RELEASE_EXEC} --codename --short | ||
# OUTPUT_VARIABLE LSB_LINUX_DISTRIBUTION_CODENAME | ||
# OUTPUT_STRIP_TRAILING_WHITESPACE) | ||
# EXECUTE_PROCESS(COMMAND ${LSB_RELEASE_EXEC} --id --short | ||
# OUTPUT_VARIABLE LSB_LINUX_DISTRIBUTION | ||
# OUTPUT_STRIP_TRAILING_WHITESPACE) | ||
# SET(LSB_EXISTS TRUE) | ||
# MESSAGE("Found Linux Distribution Release Name: ${LSB_LINUX_DISTRIBUTION_CODENAME}") | ||
# ENDIF (LSB_RELEASE_EXEC) | ||
|
||
# "DEB" | ||
FIND_PROGRAM(HAS_APT NAMES apt-get apt) | ||
IF (HAS_APT) | ||
IF (VS_CAN_BUILD_DEB) | ||
MESSAGE("-- Configuring Debian Packaging") | ||
# See https://cmake.org/cmake/help/v3.3/module/CPackDeb.html | ||
SET(CPACK_DEBIAN_PACKAGE_NAME "vsUTCS") | ||
SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "[email protected]") | ||
SET(CPACK_DEBIAN_COMPRESSION_TYPE "bzip2") | ||
SET(CPACK_DEBIAN_PACKAGE_DEPENDS "vega-strike") | ||
|
||
# Debian Version: /etc/debian_version - <name>/<junk> | ||
# IF (NOT LSB_EXISTS) | ||
# SET(USE_DEBIAN_VERSION TRUE) | ||
# FILE(READ "/etc/debian_version" DEBIAN_VERSION_DATA) | ||
# STRING(REGEX MATCH "^(.+)\/.*$" DEBIAN_VERSION_DATA DEBIAN_RELEASE_VERSION) | ||
# ELSE (NOT LSB_EXISTS) | ||
# SET(USE_DEBIAN_VERSION FALSE) | ||
# SET(DEBIAN_RELEASE_VERSION "Debian Derivative Release Version ${LSB_LINUX_DISTRIBUTION_CODENAME}") | ||
# ENDIF (NOT LSB_EXISTS) | ||
|
||
# IF (USE_DEBIAN_VERSION) | ||
# SET(CPACK_PACKAGE_FILE_NAME "${CPACK_DEBIAN_PACKAGE_NAME}_${vsUTCS_PACKAGE_VERSION_STR}-debian-${DEBIAN_RELEASE_VERSION}_x86_64") | ||
# ELSE (USE_DEBIAN_VERSION) | ||
# SET(CPACK_PACKAGE_FILE_NAME "${CPACK_DEBIAN_PACKAGE_NAME}_${vsUTCS_PACKAGE_VERSION_STR}-${LSB_LINUX_DISTRIBUTION}-${LSB_LINUX_DISTRIBUTION_CODENAME}_x86_64") | ||
# ENDIF (USE_DEBIAN_VERSION) | ||
|
||
SET(CPACK_PACKAGE_FILE_NAME "${CPACK_DEBIAN_PACKAGE_NAME}_${vsUTCS_PACKAGE_VERSION_STR}") | ||
|
||
SET(CPACK_DEBIAN_PACKAGE_SECTION "Amusements/Games") | ||
SET(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://www.vega-strike.org") | ||
SET(CPACK_GENERATOR "DEB") | ||
ENDIF (HAS_APT) | ||
ENDIF () | ||
|
||
# "RPM" | ||
FIND_PROGRAM(HAS_RPMBUILD rpmbuild) | ||
IF (HAS_RPMBUILD) | ||
IF (VS_CAN_BUILD_RPM) | ||
MESSAGE("-- Configuring RPM Packaging") | ||
# See https://cmake.org/cmake/help/v3.3/module/CPackRPM.html | ||
SET(CPACK_RPM_PACKAGE_LICENSE "GPLv3") # See ../LICENSE | ||
|
@@ -263,7 +239,7 @@ ELSEIF (CMAKE_SYSTEM_NAME STREQUAL Linux) | |
|
||
SET(CPACK_PACKAGE_FILE_NAME "${CPACK_RPM_PACKAGE_NAME}_${vsUTCS_PACKAGE_VERSION_STR}-${LINUX_ID}-${vsUTCS_LINUX_VERSION_STR}") | ||
SET(CPACK_GENERATOR "RPM") | ||
ENDIF (HAS_RPMBUILD) | ||
ENDIF () | ||
ELSE (WIN32 AND NOT UNIX) | ||
MESSAGE("-- Configuring Packaging for Unknown Platforms - \"${CMAKE_SYSTEM_NAME}\"") | ||
# Unknown Platform --> Just do compressed tarball | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
# - FindLinuxDistro.cmake | ||
# This module detects the Linux Distro and package build tooling, and provides | ||
# some variables for the primary CMake script to utilize to decide what to build. | ||
# | ||
# ======================== | ||
# Example Usage: | ||
# | ||
# FIND_PACKAGE(LinuxDistro, REQUIRED) | ||
# | ||
# Output Variables: | ||
# LINUX_ETC_OS_RELEASE_EXISTS | ||
# Does /etc/os-release exist? | ||
# | ||
# LINUX_ID | ||
# Linux Distro Name (semi-authoritative) | ||
# Only valid if LINUX_ETC_OS_RELEASE_EXISTS is TRUE | ||
# | ||
# LINUX_CODENAME | ||
# Linux Distro Code Name (semi-authoritative) | ||
# Only valid if LINUX_ETC_OS_RELEASE_EXISTS is TRUE | ||
# | ||
# LINUX_VERSION_ID | ||
# Linux Distro Version (semi-authoritative) | ||
# Only valid if LINUX_ETC_OS_RELEASE_EXISTS is TRUE | ||
# | ||
# LSB_EXISTS | ||
# Is the distro an LSB Compliant Distro? | ||
# | ||
# LSB_LINUX_DISTRIBUTION | ||
# Using LSB Tooling, what is the host distro family? (authoritative) | ||
# Only valid if LSB_EXISTS is TRUE | ||
# | ||
# LSB_LINUX_DISTRIBUTION_CODENAME | ||
# Using LSB Tooling, what is the host distro code name? (authoritative) | ||
# Only valid if LSB_EXISTS is TRUE | ||
# | ||
# VS_CAN_BUILD_DEB | ||
# Does the host have tooling installed to build Debian (DEB) Packages? | ||
# | ||
# VS_CAN_BUILD_RPM | ||
# Does the host have the tooling installed to build RPM Packages? | ||
# | ||
|
||
IF (CMAKE_SYSTEM_NAME STREQUAL Linux) | ||
|
||
SET(LINUX_ETC_OS_RELEASE_EXISTS FALSE) | ||
SET(LINUX_ID "Unknown") | ||
SET(LINUX_CODENAME "Unknown") | ||
SET(LINUX_VERSION_ID "Unknown") | ||
IF (EXISTS "/etc/os-release") | ||
SET(LINUX_ETC_OS_RELEASE_EXISTS TRUE) | ||
# Gather info about Linux distro and release (if applicable) for later use down below. | ||
EXECUTE_PROCESS( | ||
COMMAND sh -c "cat /etc/os-release | grep ^ID= | sed 's/^ID=//' | tr -d '\"\n'" | ||
OUTPUT_VARIABLE LINUX_ID) | ||
EXECUTE_PROCESS( | ||
COMMAND sh -c "cat /etc/os-release | grep ^VERSION_CODENAME= | sed 's/^VERSION_CODENAME=//' | tr -d '\"\n'" | ||
OUTPUT_VARIABLE LINUX_CODENAME) | ||
EXECUTE_PROCESS( | ||
COMMAND sh -c "cat /etc/os-release | grep ^VERSION_ID= | sed 's/^VERSION_ID=//' | tr -d '\"\n'" | ||
OUTPUT_VARIABLE LINUX_VERSION_ID) | ||
ENDIF (EXISTS "/etc/os-release") | ||
|
||
# lsb_release -i --> but then it'll find `Ubuntu` instead of Debian so will have to map more | ||
|
||
# we can probably more reliably detect via checking for different packager commands | ||
# `lsb_release` doesn't always work correctly, so it's easier to read the underlying file | ||
# if it exists. It doesn't always exist. Debian doesn't use it, but Ubuntu does. | ||
SET(LSB_EXISTS FALSE) | ||
SET(LSB_LINUX_DISTRIBUTION "Unknown") | ||
SET(LSB_LINUX_DISTRIBUTION_CODENAME "Unknown") | ||
|
||
# Lookup the LSB Data - this is known for Ubuntu, but also used by other distros too. | ||
# and may help with distro-sub-selection | ||
FIND_PROGRAM(LSB_RELEASE_EXEC lsb_release) | ||
IF (LSB_RELEASE_EXEC) | ||
EXECUTE_PROCESS(COMMAND ${LSB_RELEASE_EXEC} --codename --short | ||
OUTPUT_VARIABLE LSB_LINUX_DISTRIBUTION_CODENAME | ||
OUTPUT_STRIP_TRAILING_WHITESPACE) | ||
EXECUTE_PROCESS(COMMAND ${LSB_RELEASE_EXEC} --id --short | ||
OUTPUT_VARIABLE LSB_LINUX_DISTRIBUTION | ||
OUTPUT_STRIP_TRAILING_WHITESPACE) | ||
SET(LSB_EXISTS TRUE) | ||
MESSAGE("Found Linux Distribution Release Name: ${LSB_LINUX_DISTRIBUTION_CODENAME}") | ||
ENDIF (LSB_RELEASE_EXEC) | ||
|
||
# Definitively detect Debian Package Build tools | ||
FIND_PROGRAM(VS_CAN_BUILD_DEB NAMES dpkg-buildpackage) | ||
|
||
# Definitively detect RPM Package Build Tools | ||
FIND_PROGRAM(VS_CAN_BUILD_RPM rpmbuild) | ||
|
||
ENDIF (CMAKE_SYSTEM_NAME STREQUAL Linux) |