aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt21
-rw-r--r--src/CMakeLists.txt8
-rw-r--r--src/version.h.in19
3 files changed, 39 insertions, 9 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 88d461c..1b9e25d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,13 +1,17 @@
cmake_minimum_required(VERSION 3.1.0)
project(smolbote)
+include(FeatureSummary)
+
# Options
+option(MercurialRepo "Get version information from .hg" ON)
option(CompilerWarnings "Compiler warnings" ON)
option(QtDeprecatedWarnings "Qt deprecated warnings" ON)
option(UseLibCpp "Use libc++ over stdlibc++ (requires clang)" OFF)
# Libraries
-find_package(Qt5 5.11 COMPONENTS Core Widgets Concurrent WebEngineWidgets REQUIRED)
+find_package(Qt5 COMPONENTS Core Widgets Concurrent REQUIRED)
+find_package(Qt5 5.11 COMPONENTS WebEngineWidgets REQUIRED)
find_package(Boost COMPONENTS program_options REQUIRED)
# Global C++ settings
@@ -32,6 +36,19 @@ if (UseLibCpp)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++")
endif (UseLibCpp)
+# detect version and commit from mercurial
+if (MercurialRepo AND EXISTS "${PROJECT_SOURCE_DIR}/.hg")
+ execute_process(COMMAND hg log -r '.' --template={latesttag} WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} OUTPUT_VARIABLE VcsVersion OUTPUT_STRIP_TRAILING_WHITESPACE)
+ execute_process(COMMAND hg identify --id WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} OUTPUT_VARIABLE VcsCommit OUTPUT_STRIP_TRAILING_WHITESPACE)
+ execute_process(COMMAND hg identify --num WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} OUTPUT_VARIABLE VcsRevision OUTPUT_STRIP_TRAILING_WHITESPACE)
+ execute_process(COMMAND hg identify --branch WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} OUTPUT_VARIABLE VcsBranch OUTPUT_STRIP_TRAILING_WHITESPACE)
+endif()
+
+# configure a header file to pass version information
+# if repo is missing or option is turned off, version.h.in can be configured
+# with static values
+configure_file("${PROJECT_SOURCE_DIR}/src/version.h.in" "${PROJECT_BINARY_DIR}/src/version.h")
+
add_subdirectory(lib/bookmarks)
add_subdirectory(lib/downloads)
add_subdirectory(lib/configuration)
@@ -43,3 +60,5 @@ add_subdirectory(src)
# configuration program
add_subdirectory(config)
+
+feature_summary(WHAT ALL)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 6f231b4..03f6c17 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -6,14 +6,6 @@ set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)
-# configure a header file to pass version information
-# if you don't have git, or are building this off the source tarball, define versions in version.h.in
-execute_process(COMMAND hg log -r '.' --template={latesttag} WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} OUTPUT_VARIABLE VcsVersion OUTPUT_STRIP_TRAILING_WHITESPACE)
-execute_process(COMMAND hg identify --id WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} OUTPUT_VARIABLE VcsCommit OUTPUT_STRIP_TRAILING_WHITESPACE)
-execute_process(COMMAND hg identify --num WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} OUTPUT_VARIABLE VcsRevision OUTPUT_STRIP_TRAILING_WHITESPACE)
-execute_process(COMMAND hg identify --branch WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} OUTPUT_VARIABLE VcsBranch OUTPUT_STRIP_TRAILING_WHITESPACE)
-configure_file(version.h.in "${PROJECT_BINARY_DIR}/src/version.h")
-
add_executable(poi
# main
main.cpp
diff --git a/src/version.h.in b/src/version.h.in
index 2e6ecf2..a5c3204 100644
--- a/src/version.h.in
+++ b/src/version.h.in
@@ -1,6 +1,10 @@
#ifndef VERSION_H
#define VERSION_H
+// VcsVersion gets defined by the CMakeLists if project-src/.hg exists
+#cmakedefine VcsVersion
+
+#ifdef VcsVersion
// Version: 1.2.3
#define SMOLBOTE_VERSION "@VcsVersion@"
@@ -13,4 +17,19 @@
// Branch: default
#define SMOLBOTE_BRANCH "@VcsBranch@"
+#else
+// Version: 1.2.3
+#define SMOLBOTE_VERSION "0.3.0"
+
+// Describe: 1.2.3-r123-0123456789ab
+#define SMOLBOTE_DESCRIBE "0.3.0-release"
+
+// Commit
+#define SMOLBOTE_COMMIT "package"
+
+// Branch: default
+#define SMOLBOTE_BRANCH "release"
+
+#endif
+
#endif //VERSION_H