Browse Source

chore(cmake): Added git definitions

Diadlo 4 years ago
parent
commit
ba872e02af
3 changed files with 58 additions and 8 deletions
  1. 1 1
      .gitignore
  2. 16 3
      CMakeLists.txt
  3. 41 4
      cmake/Dependencies.cmake

+ 1 - 1
.gitignore

@@ -40,7 +40,7 @@ _testmain.go
 /qtox.app
 
 # Qt
-*.pro.user*
+*.user
 moc_*
 ui_*
 qrc_*

+ 16 - 3
CMakeLists.txt

@@ -22,6 +22,7 @@ execute_process(
   COMMAND brew --prefix qt5
   OUTPUT_VARIABLE QT_PREFIX_PATH
   OUTPUT_STRIP_TRAILING_WHITESPACE)
+
 if(NOT QT_PREFIX_PATH)
   set(QT_PREFIX_PATH
     /usr/src/mxe/usr/x86_64-w64-mingw32.shared/qt5
@@ -115,11 +116,23 @@ qt5_add_translation(${PROJECT_NAME}_QM_FILES
   translations/zh.ts
 )
 
-qt5_add_resources(${PROJECT_NAME}_RESOURCES
+qt5_add_resources(
+  ${PROJECT_NAME}_RESOURCES
   res.qrc
-  smileys/smileys.qrc
   ${CMAKE_CURRENT_BINARY_DIR}/translations.qrc
-  DEPENDS ${${PROJECT_NAME}_QM_FILES})
+  DEPENDS ${${PROJECT_NAME}_QM_FILES}
+)
+
+if(NOT ${SMILEYS})
+    set(SMILEYS, "")
+endif()
+
+if(NOT ${SMILEYS} MATCHES "NO")
+  qt5_add_resources(smileys/emojione.qrc)
+  if(NOT ${SMILEYS} MATCHES "MIN")
+    qt5_add_resources(smileys/smileys.qrc)
+  endif()
+endif()
 
 file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/translations.qrc.in"
 "<!DOCTYPE RCC>

+ 41 - 4
cmake/Dependencies.cmake

@@ -111,9 +111,46 @@ if(WIN32)
   search_dependency(STRMIIDS          LIBRARY strmiids)
 endif()
 
+execute_process(
+  COMMAND git describe --tags
+  WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+  OUTPUT_VARIABLE GIT_DESCRIBE
+  ERROR_QUIET
+  OUTPUT_STRIP_TRAILING_WHITESPACE
+)
+
+if(NOT GIT_DESCRIBE)
+  set(GIT_DESCRIBE "Nightly")
+endif()
+
+add_definitions(
+  -DGIT_DESCRIBE="${GIT_DESCRIBE}"
+)
+
+# GIT_VERSION
+execute_process(
+  COMMAND git rev-parse HEAD
+  WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+  OUTPUT_VARIABLE GIT_VERSION
+  ERROR_QUIET
+  OUTPUT_STRIP_TRAILING_WHITESPACE
+)
+
+if(NOT GIT_VERSION)
+  set(GIT_VERSION "build without git")
+endif()
+
+add_definitions(
+  -DGIT_VERSION="${GIT_VERSION}"
+)
+
+execute_process(
+  COMMAND date +%s
+  OUTPUT_VARIABLE TIMESTAMP
+)
+
 add_definitions(
+  -DTIMESTAMP=${TIMESTAMP}
+  -DLOG_TO_FILE=1
   -DQTOX_PLATFORM_EXT=1
-  -DGIT_COMMIT="N/A"
-  -DGIT_DESCRIBE="N/A"
-  -DGIT_VERSION="N/A"
-  -DTIMESTAMP="N/A")
+)