Merge branch 'appimagetool/master' into expose_list_and_extract_files_functions
[appimagekit/gsi.git] / CMakeLists.txt
blob6fd3780248f6f3efba55d866d1c8a4dc878b1f26
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 if("$ENV{TRAVIS_BUILD_NUMBER}" STREQUAL "")
40     set(BUILD_NUMBER "<local dev build>")
41 else()
42     set(BUILD_NUMBER "$ENV{TRAVIS_BUILD_NUMBER}")
43 endif()
45 # get current date
46 execute_process(
47     COMMAND env LC_ALL=C date -u "+%Y-%m-%d %H:%M:%S %Z"
48     OUTPUT_VARIABLE DATE
49     OUTPUT_STRIP_TRAILING_WHITESPACE
52 # C and C++ versions
53 set(CMAKE_C_STANDARD 99)
54 set(CMAKE_CXX_STANDARD 98)
55 set(CMAKE_C_STANDARD_REQUIRED ON)
56 set(CMAKE_CXX_STANDARD_REQUIRED ON)
57 set(CMAKE_POSITION_INDEPENDENT_CODE ON)
59 # write version information for CPack to files
60 file(WRITE ${PROJECT_BINARY_DIR}/GIT_COMMIT "${GIT_COMMIT}")
63 ##########################
64 # configure dependencies #
65 ##########################
67 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake)
69 # first of all, make sure required programs are available
70 function(check_program name)
71     string(TOUPPER ${name} name_upper)
72     find_program(${name_upper} ${name})
74     message(STATUS "Checking for program ${name}")
76     if(NOT ${name_upper})
77         message(FATAL_ERROR "Could not find required program ${name}.")
78     endif()
80     mark_as_advanced(${name_upper})
81 endfunction()
83 check_program(aclocal)
84 check_program(autoheader)
85 check_program(automake)
86 check_program(autoreconf)
87 check_program(libtoolize)
88 check_program(patch)
89 check_program(sed)
90 check_program(wget)
91 check_program(xxd)
92 check_program(desktop-file-validate)
93 # TODO: add checks for remaining commands
96 # configure dependencies
97 include(cmake/dependencies.cmake)
100 # include directories globally
101 include_directories(${GLIB_INCLUDE_DIRS})
102 include_directories(${CAIRO_INCLUDE_DIRS})
103 include_directories(${ZLIB_INCLUDE_DIRS})
104 include_directories(${xz_INCLUDE_DIR})
105 include_directories(${inotify-tools_INCLUDE_DIR})
106 include_directories(${squashfuse_INCLUDE_DIR})
107 include_directories(${libarchive_INCLUDE_DIR})
110 ################
111 # Source files #
112 ################
114 # sanitizer support
115 set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/sanitizers-cmake/cmake" ${CMAKE_MODULE_PATH})
117 add_subdirectory(src)
119 ################################
120 #           packaging          #
121 ################################
122 set(APPIMAGEKIT_PACKAGE_DEBS FALSE CACHE BOOL "")
124 if(APPIMAGEKIT_PACKAGE_DEBS)
125     include(cmake/cpack_debs.cmake)
126 endif()
128 ################################
129 # unit and functionality tests #
130 ################################
132 add_subdirectory(tests)