summaryrefslogtreecommitdiffstats
path: root/CMakeLists.txt
blob: 08b0138be19e2c63d4e1b9cddd029e4c78ef8cfa (plain) (blame)
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
cmake_minimum_required(VERSION 3.10)

# include CMake macros
set (CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(version)

# define root CMake project
project(xloop
        DESCRIPTION "xloop Kernel modules and utility"
        HOMEPAGE_URL "https://git.openslx.org/openslx-ng/xloop.git/"
        LANGUAGES C)

# define project specific settings
set(BLK_DEV_XLOOP_MIN_COUNT 8
               CACHE STRING "Number of xloop devices to pre-create at init time")
set(XLOOP_MAJOR 120
   CACHE STRING "Major number for xloop devices")

# print configured settings
message(STATUS "Number of xloop devices to pre-create at init time is " ${BLK_DEV_XLOOP_MIN_COUNT})
message(STATUS "Major number for xloop devices is " ${XLOOP_MAJOR})

# set supported build configurations
set(CMAKE_CONFIGURATION_TYPES Debug Release)

# set compilation in debug mode as default configuration
if(NOT CMAKE_BUILD_TYPE)
    set(CMAKE_BUILD_TYPE Debug)
    message(STATUS "Build type is not set. Defaulting to ${CMAKE_BUILD_TYPE} build!")
endif()

# get versions to define project version
get_kernel_version(LINUX_KERNEL_VERSION)
get_repository_version(REPOSITORY_VERSION)
set(VERSION ${LINUX_KERNEL_VERSION}-${REPOSITORY_VERSION})

# define packaging if Release build is enabled
if(${CMAKE_BUILD_TYPE} MATCHES Release)
    set(CPACK_GENERATOR "DEB;TGZ")
    set(CPACK_SOURCE_GENERATOR "TGZ;ZIP")
    set(CPACK_PACKAGE_NAME ${CMAKE_PROJECT_NAME})
    set(CPACK_MONOLITHIC_INSTALL True)
    set(CPACK_IGNORE_FILES ".git*")
    set(CPACK_PACKAGE_VERSION ${VERSION})
    set(CPACK_PACKAGE_SECTION admin)
    set(CPACK_PACKAGE_VENDOR "University of Freiburg")
    set(CPACK_PACKAGE_CONTACT "Christian Rößler <christian.roessler@rz.uni-freiburg.de>")
    set(CPACK_PACKAGE_CHECKSUM SHA256)
    set(CPACK_PACKAGE_FILE_NAME ${CPACK_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}_${CMAKE_SYSTEM_PROCESSOR})
    set(CPACK_STRIP_FILES True)
    set(CPACK_SET_DESTDIR True)
    set(CMAKE_INSTALL_PREFIX /usr)
    # set DEB generator specific packaging options
    set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6")
    file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/package/deb/postinst "depmod -a\n")
    file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/package/deb/postrm "depmod -a\n")
    set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA ${CMAKE_CURRENT_BINARY_DIR}/package/deb/postinst
                                           ${CMAKE_CURRENT_BINARY_DIR}/package/deb/postrm)
    # include CPack functionality
    include(CPack)
endif()

# add subprojects
add_subdirectory(kernel)
add_subdirectory(utils)

# print version information
message(STATUS "Configured ${CMAKE_PROJECT_NAME} in version ${VERSION}")