summaryrefslogtreecommitdiffstats
path: root/CMakeLists.txt
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--CMakeLists.txt44
1 files changed, 19 insertions, 25 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 27366f1..1eab7c7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,28 +1,19 @@
-cmake_minimum_required(VERSION 2.8.12)
-
-if(${CMAKE_VERSION} VERSION_LESS "3.12.0")
- project(ttyd C)
- set(PROJECT_VERSION_MAJOR "1")
- set(PROJECT_VERSION_MINOR "7")
- set(PROJECT_VERSION_PATCH "4")
- set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
-else()
- cmake_policy(SET CMP0048 NEW)
- project(ttyd VERSION 1.7.4 LANGUAGES C)
-endif()
+cmake_minimum_required(VERSION 3.12.0)
-find_package(Git)
-if(GIT_FOUND)
- execute_process(
- COMMAND ${GIT_EXECUTABLE} --git-dir ${CMAKE_CURRENT_SOURCE_DIR}/.git rev-parse --short HEAD
- RESULT_VARIABLE GIT_RET
- OUTPUT_VARIABLE GIT_COMMIT
- OUTPUT_STRIP_TRAILING_WHITESPACE
- ERROR_QUIET
- )
- if("${GIT_RET}" STREQUAL "0")
- set(PROJECT_VERSION "${PROJECT_VERSION}-${GIT_COMMIT}")
- endif()
+list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
+
+project(ttyd VERSION 1.7.7 LANGUAGES C)
+
+set(TTYD_VERSION "${PROJECT_VERSION}")
+
+include(GetGitVersion)
+get_git_version(GIT_VERSION SEM_VER)
+get_git_head(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")
@@ -92,7 +83,10 @@ endif()
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} PRIVATE TTYD_VERSION="${PROJECT_VERSION}")
+target_compile_definitions(${PROJECT_NAME} PUBLIC
+ TTYD_VERSION="${TTYD_VERSION}"
+ $<$<PLATFORM_ID:Windows>:_WIN32_WINNT=0xa00 WINVER=0xa00>
+)
include(GNUInstallDirs)