From 6fa8ca7f3824ab63cd7708bbc5b0c5d1a9e651ed Mon Sep 17 00:00:00 2001
From: TURX <turx2003@gmail.com>
Date: Thu, 16 Jan 2020 03:20:54 +0800
Subject: [PATCH] haiku support

---
 CMakeLists.txt            | 2 +-
 cmake/productVersion.h.in | 1 +
 cmake/version.cmake       | 4 +++-
 src/app/main.cpp          | 4 ++++
 4 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index aaf04cf..911d59f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -230,7 +230,7 @@ target_include_directories(${LIB_UTILITY_PROJECT_NAME} SYSTEM
 
 target_link_libraries(${LIB_UTILITY_PROJECT_NAME} ${Boost_LIBRARIES} Qt5::Widgets Qt5::Network)
 
-if (UNIX AND NOT APPLE)
+if (UNIX AND NOT APPLE AND NOT HAIKU)
 	find_package(Threads REQUIRED)
 	target_link_libraries(${LIB_UTILITY_PROJECT_NAME} ${CMAKE_DL_LIBS} rt ${CMAKE_THREAD_LIBS_INIT})
 endif()
diff --git a/cmake/productVersion.h.in b/cmake/productVersion.h.in
index 8705cb6..f445999 100644
--- a/cmake/productVersion.h.in
+++ b/cmake/productVersion.h.in
@@ -8,5 +8,6 @@
 #define VERSION_YEAR @VERSION_YEAR@
 #define VERSION_MINOR @VERSION_MINOR@
 #define VERSION_COMMIT @VERSION_COMMIT@
+#define VERSION_STRING "@VERSION_STRING@"
 
 #endif // SOURCETRAIL_VERSION_H
diff --git a/cmake/version.cmake b/cmake/version.cmake
index 5e8cf0a..c52f96f 100644
--- a/cmake/version.cmake
+++ b/cmake/version.cmake
@@ -44,7 +44,9 @@ else(EXISTS "${CMAKE_SOURCE_DIR}/.git")
 
 endif(EXISTS "${CMAKE_SOURCE_DIR}/.git")
 
-set(VERSION_STRING "${VERSION_YEAR}.${VERSION_MINOR}.${VERSION_COMMIT}")
+if ("${VERSION_STRING}" STREQUAL "" OR "${VERSION_STRING}" STREQUAL "..")
+    set(VERSION_STRING "${VERSION_YEAR}.${VERSION_MINOR}.${VERSION_COMMIT}")
+endif()
 
 message(STATUS "Version: ${VERSION_STRING}")
 
diff --git a/src/app/main.cpp b/src/app/main.cpp
index a6f9679..983dc38 100644
--- a/src/app/main.cpp
+++ b/src/app/main.cpp
@@ -109,12 +109,16 @@ int main(int argc, char *argv[])
 		QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling, true);
 	}
 
+#if !defined(Q_OS_HAIKU)
 	Version version(
 		VERSION_YEAR,
 		VERSION_MINOR,
 		VERSION_COMMIT,
 		GIT_COMMIT_HASH
 	);
+#else
+	Version version = Version::fromString(VERSION_STRING);
+#endif
 	QApplication::setApplicationVersion(version.toDisplayString().c_str());
 
 	MessageStatus(
-- 
2.20.1

