]> prime8.dev >> repos - ttyd.git/commitdiff
Add git commit id to version string
authorShuanglei Tao <tsl0922@gmail.com>
Tue, 4 Sep 2018 14:44:52 +0000 (22:44 +0800)
committerShuanglei Tao <tsl0922@gmail.com>
Tue, 4 Sep 2018 14:54:29 +0000 (22:54 +0800)
CMakeLists.txt
README.md

index 50e2f6b1fd11734c51c889ad65b70b72c760a135..43bd4ba510e600c2181e60824a29e8e424b6df49 100644 (file)
@@ -1,7 +1,22 @@
 cmake_minimum_required(VERSION 2.8)
-cmake_policy(SET CMP0048 NEW)
 
-project(ttyd VERSION "1.4.0")
+project(ttyd)
+set(PROJECT_VERSION "1.4.0")
+
+find_package(Git)
+if(GIT_FOUND)
+    execute_process(
+            COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD
+            WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
+            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()
+endif()
 
 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_GNU_SOURCE")
 if(CMAKE_VERSION VERSION_LESS "3.1")
@@ -55,7 +70,11 @@ add_custom_command(OUTPUT html.h
 list(APPEND SOURCE_FILES html.h)
 
 set(INCLUDE_DIRS ${OPENSSL_INCLUDE_DIR} ${LIBWEBSOCKETS_INCLUDE_DIR} ${JSON-C_INCLUDE_DIR})
-set(LINK_LIBS util pthread ${OPENSSL_LIBRARIES} ${LIBWEBSOCKETS_LIBRARIES} ${JSON-C_LIBRARY})
+set(LINK_LIBS pthread ${OPENSSL_LIBRARIES} ${LIBWEBSOCKETS_LIBRARIES} ${JSON-C_LIBRARY})
+
+if(NOT APPLE)
+    list(APPEND LINK_LIBS util)
+endif()
 
 if(WIN32)
     list(APPEND LINK_LIBS shell32)
@@ -70,17 +89,3 @@ include(GNUInstallDirs)
 
 install(TARGETS ${PROJECT_NAME} DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT prog)
 install(FILES man/ttyd.1 DESTINATION "${CMAKE_INSTALL_MANDIR}/man1" COMPONENT doc)
-
-set(CPACK_PACKAGE_NAME "${PROJECT_NAME}")
-set(CPACK_PACKAGE_VERSION "${PROJECT_VERSION}")
-set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${PROJECT_NAME} - Share your terminal over the web")
-set(CPACK_PACKAGE_CONTACT "Shuanglei Tao <tsl0922@gmail.com>")
-set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}_${CMAKE_SYSTEM_PROCESSOR}")
-
-set(CPACK_GENERATOR "DEB")
-SET(CPACK_DEBIAN_ARCHITECTURE ${CMAKE_SYSTEM_PROCESSOR})
-set(CPACK_DEBIAN_PACKAGE_SECTION "shells")
-set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://tsl0922.github.io/ttyd")
-set(CPACK_DEBIAN_PACKAGE_DEPENDS "libjson-c2, libwebsockets7, libssl1.0.0, libc6 (>= 2.14)")
-
-include(CPack)
index 55ff85a6575592a03357775fa016593bbcd75e90..e91ff32e11726a6badb4695927a0d8b8415bf767 100644 (file)
--- a/README.md
+++ b/README.md
@@ -45,8 +45,6 @@ brew install ttyd
     make && make install
     ```
 
-    [CMake][19] of at least 3.0 is required. If you get the error message `Policy "CMP0048" is not known to this version of CMake`, that means you have an old CMake.
-    
     You may also need to compile/install [libwebsockets][2] from source if the `libwebsockets-dev` package is outdated.
 
 ## Install on Windows