Skip to content

Commit

Permalink
cmake: add static version back
Browse files Browse the repository at this point in the history
  • Loading branch information
tsl0922 committed Mar 30, 2024
1 parent 89fb69b commit 62f44f8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/release.yml
Expand Up @@ -12,6 +12,15 @@ jobs:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Check version bump
run: |
TAG=$(git describe --tags --match "[0-9]*.[0-9]*.[0-9]*" --abbrev=8)
VERSION=$(grep project CMakeLists.txt| awk '{print $3}')
if [ "$TAG" != "$VERSION" ]; then
echo "=== Version in CMakeLists.txt and git tag does not match!"
echo "=== Git Tag: $TAG, Version: $VERSION"
exit 1
fi
- uses: actions/download-artifact@v4
- run: |
mkdir build
Expand Down
17 changes: 10 additions & 7 deletions CMakeLists.txt
Expand Up @@ -2,15 +2,18 @@ cmake_minimum_required(VERSION 3.12.0)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")

include(GetGitVersion)
project(ttyd VERSION 1.7.6 LANGUAGES C)

set(TTYD_VERSION "${PROJECT_VERSION}")

include(GetGitVersion)
get_git_version(GIT_VERSION SEM_VER)
get_git_head(GIT_COMMIT)

project(ttyd VERSION "${SEM_VER}" LANGUAGES C)

if(NOT "{GIT_COMMIT}" STREQUAL "")
set(PROJECT_VERSION "${PROJECT_VERSION}-${GIT_COMMIT}")
if("${SEM_VER}" VERSION_GREATER "${TTYD_VERSION}")
set(TTYD_VERSION "${SEM_VER}")
endif()
if(NOT "${GIT_COMMIT}" STREQUAL "")
set(TTYD_VERSION "${TTYD_VERSION}-${GIT_COMMIT}")
endif()

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_GNU_SOURCE")
Expand Down Expand Up @@ -81,7 +84,7 @@ add_executable(${PROJECT_NAME} ${SOURCE_FILES})
target_include_directories(${PROJECT_NAME} PUBLIC ${INCLUDE_DIRS})
target_link_libraries(${PROJECT_NAME} ${LINK_LIBS})
target_compile_definitions(${PROJECT_NAME} PUBLIC
TTYD_VERSION="${PROJECT_VERSION}"
TTYD_VERSION="${TTYD_VERSION}"
$<$<PLATFORM_ID:Windows>:_WIN32_WINNT=0xa00 WINVER=0xa00>
)

Expand Down

0 comments on commit 62f44f8

Please sign in to comment.