-
-
Notifications
You must be signed in to change notification settings - Fork 987
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(cmake): split CMakeLists into modules
- Loading branch information
1 parent
a3eec98
commit ed7f440
Showing
3 changed files
with
69 additions
and
68 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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# todo - set version to 0.0.0 once confident in automated versioning | ||
project(Sunshine VERSION 0.20.0 | ||
DESCRIPTION "Sunshine is a self-hosted game stream host for Moonlight." | ||
HOMEPAGE_URL "https://app.lizardbyte.dev") | ||
|
||
set(PROJECT_LONG_DESCRIPTION "Offering low latency, cloud gaming server capabilities with support for AMD, Intel, \ | ||
and Nvidia GPUs for hardware encoding. Software encoding is also available. You can connect to Sunshine from any \ | ||
Moonlight client on a variety of devices. A web UI is provided to allow configuration, and client pairing, from \ | ||
your favorite web browser. Pair from the local server or any mobile device.") |
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,58 @@ | ||
# Check if env vars are defined before attempting to access them, variables will be defined even if blank | ||
if((DEFINED ENV{BRANCH}) AND (DEFINED ENV{BUILD_VERSION}) AND (DEFINED ENV{COMMIT})) # cmake-lint: disable=W0106 | ||
if(($ENV{BRANCH} STREQUAL "master") AND (NOT $ENV{BUILD_VERSION} STREQUAL "")) | ||
# If BRANCH is "master" and BUILD_VERSION is not empty, then we are building a master branch | ||
MESSAGE("Got from CI master branch and version $ENV{BUILD_VERSION}") | ||
set(PROJECT_VERSION $ENV{BUILD_VERSION}) | ||
elseif((DEFINED ENV{BRANCH}) AND (DEFINED ENV{COMMIT})) | ||
# If BRANCH is set but not BUILD_VERSION we are building nightly, we gather only the commit hash | ||
MESSAGE("Got from CI $ENV{BRANCH} branch and commit $ENV{COMMIT}") | ||
set(PROJECT_VERSION ${PROJECT_VERSION}.$ENV{COMMIT}) | ||
endif() | ||
# Generate Sunshine Version based of the git tag | ||
# https://github.com/nocnokneo/cmake-git-versioning-example/blob/master/LICENSE | ||
else() | ||
find_package(Git) | ||
if(GIT_EXECUTABLE) | ||
MESSAGE("${CMAKE_CURRENT_SOURCE_DIR}") | ||
get_filename_component(SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR} DIRECTORY) | ||
#Get current Branch | ||
execute_process( | ||
COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD | ||
#WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} | ||
OUTPUT_VARIABLE GIT_DESCRIBE_BRANCH | ||
RESULT_VARIABLE GIT_DESCRIBE_ERROR_CODE | ||
OUTPUT_STRIP_TRAILING_WHITESPACE | ||
) | ||
# Gather current commit | ||
execute_process( | ||
COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD | ||
#WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} | ||
OUTPUT_VARIABLE GIT_DESCRIBE_VERSION | ||
RESULT_VARIABLE GIT_DESCRIBE_ERROR_CODE | ||
OUTPUT_STRIP_TRAILING_WHITESPACE | ||
) | ||
# Check if Dirty | ||
execute_process( | ||
COMMAND ${GIT_EXECUTABLE} diff --quiet --exit-code | ||
#WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} | ||
RESULT_VARIABLE GIT_IS_DIRTY | ||
OUTPUT_STRIP_TRAILING_WHITESPACE | ||
) | ||
if(NOT GIT_DESCRIBE_ERROR_CODE) | ||
MESSAGE("Sunshine Branch: ${GIT_DESCRIBE_BRANCH}") | ||
if(NOT GIT_DESCRIBE_BRANCH STREQUAL "master") | ||
set(PROJECT_VERSION ${PROJECT_VERSION}.${GIT_DESCRIBE_VERSION}) | ||
MESSAGE("Sunshine Version: ${GIT_DESCRIBE_VERSION}") | ||
endif() | ||
if(GIT_IS_DIRTY) | ||
set(PROJECT_VERSION ${PROJECT_VERSION}.dirty) | ||
MESSAGE("Git tree is dirty!") | ||
endif() | ||
else() | ||
MESSAGE(ERROR ": Got git error while fetching tags: ${GIT_DESCRIBE_ERROR_CODE}") | ||
endif() | ||
else() | ||
MESSAGE(WARNING ": Git not found, cannot find git version") | ||
endif() | ||
endif() |