Use git revision as the version when VERSION is not set and when -g is passed
[appimagekit/gsi.git] / CMakeLists.txt
blob219f4b75e51798ba4db2d2e2062f893eaa956d27
1 cmake_minimum_required(VERSION 3.2)
3 project(AppImageKit)
5 include(ExternalProject)
7 # enable testing globally
8 include(CTest)
10 # support for ccache
11 # call CMake with -DUSE_CCACHE=ON to make use of it
12 set(USE_CCACHE OFF CACHE BOOL "")
13 if(USE_CCACHE)
14     find_program(CCACHE ccache)
15     if(CCACHE)
16         message(STATUS "Using ccache")
17         set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${CCACHE})
18         set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ${CCACHE})
19     else()
20         message(WARNING "USE_CCACHE set, but could not find ccache")
21     endif()
22 endif()
25 #####################
26 # build information #
27 #####################
29 # determine Git commit ID
30 execute_process(
31     COMMAND git rev-parse --short HEAD
32     WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
33     OUTPUT_VARIABLE GIT_COMMIT
34     OUTPUT_STRIP_TRAILING_WHITESPACE
37 # set version and build number
38 set(VERSION 1-alpha)
39 mark_as_advanced(VERSION)
40 if("$ENV{TRAVIS_BUILD_NUMBER}" STREQUAL "")
41     set(BUILD_NUMBER "<local dev build>")
42 else()
43     set(BUILD_NUMBER "$ENV{TRAVIS_BUILD_NUMBER}")
44 endif()
45 mark_as_advanced(BUILD_NUMBER)
47 # get current date
48 execute_process(
49     COMMAND env LC_ALL=C date -u "+%Y-%m-%d %H:%M:%S %Z"
50     OUTPUT_VARIABLE DATE
51     OUTPUT_STRIP_TRAILING_WHITESPACE
54 # C and C++ versions
55 set(CMAKE_C_STANDARD 99)
56 set(CMAKE_CXX_STANDARD 98)
57 set(CMAKE_C_STANDARD_REQUIRED ON)
58 set(CMAKE_CXX_STANDARD_REQUIRED ON)
59 set(CMAKE_POSITION_INDEPENDENT_CODE ON)
62 ##########################
63 # configure dependencies #
64 ##########################
66 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake)
68 # configure dependencies
69 add_subdirectory(lib)
71 include(lib/libappimage/cmake/tools.cmake)
72 include(cmake/dependencies.cmake)
75 ################
76 # Source files #
77 ################
79 # sanitizer support
80 set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/sanitizers-cmake/cmake" ${CMAKE_MODULE_PATH})
82 add_subdirectory(src)
84 ################################
85 #           packaging          #
86 ################################
87 set(APPIMAGEKIT_PACKAGE_DEBS FALSE CACHE BOOL "")
89 if(APPIMAGEKIT_PACKAGE_DEBS)
90     include(cmake/cpack_debs.cmake)
91 endif()