forked from polycube-network/polycube
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
44 lines (33 loc) · 1.25 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
cmake_minimum_required (VERSION 3.2)
project(polycube)
set (CMAKE_CXX_STANDARD 11)
include(cmake/GetGitRevisionDescription.cmake)
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/nlohmann_json")
# TODO: remove --tags in following commands once we
# have the first annotated tag version
# if this commit matches a tag, use that for the version, otherwise
# append a '+' to it and get the commit info.
git_get_exact_tag(EXTACT_GIT_TAG --abbrev=0 --tags)
if (EXTACT_GIT_TAG)
set(VERSION ${EXTACT_GIT_TAG})
else ()
git_describe(GIT_TAG --abbrev=0 --tags)
get_git_head_revision(GIT_REFSPEC GIT_SHA1 --tags)
string(SUBSTRING "${GIT_SHA1}" 0 8 GIT_SHA1_SHORT)
# get branch
if (GIT_REFSPEC)
string(REPLACE "/" ";" GIT_REFSPEC_LIST ${GIT_REFSPEC})
list(GET GIT_REFSPEC_LIST -1 GIT_BRANCH)
else ()
set(GIT_BRANCH "NOT_FOUND")
endif()
# check if tree is dirty
git_describe(GIT_TAG_DIRTY --abbrev=0 --tags --dirty=magic0x6457)
if (GIT_TAG_DIRTY MATCHES ^.*magic0x6457)
set(IS_DIRTY "-dirty")
endif ()
set(VERSION "${GIT_TAG}+ [git: (branch/commit): ${GIT_BRANCH}/${GIT_SHA1_SHORT}${IS_DIRTY}]")
endif ()
message(STATUS "Version is ${VERSION}")
add_subdirectory(src)