summaryrefslogtreecommitdiffstats
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorManuel Bentele2020-09-10 13:30:47 +0200
committerManuel Bentele2020-09-16 07:37:56 +0200
commit1dd2c3999236595a5f6cebdf35dfe7536ff5c34d (patch)
tree75b42c0631cb78ae9b0ce2a817399f8095bc6b07 /CMakeLists.txt
parentFixed major number of xloop device and device names in xlosetup (diff)
downloadxloop-1dd2c3999236595a5f6cebdf35dfe7536ff5c34d.tar.gz
xloop-1dd2c3999236595a5f6cebdf35dfe7536ff5c34d.tar.xz
xloop-1dd2c3999236595a5f6cebdf35dfe7536ff5c34d.zip
Generate util-linux configuration to build xlosetup
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt51
1 files changed, 36 insertions, 15 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 76439db..08b0138 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,7 +1,14 @@
cmake_minimum_required(VERSION 3.10)
-# set the project name
-project(xloop)
+# 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
@@ -13,35 +20,49 @@ set(XLOOP_MAJOR 120
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")
+ set(CMAKE_BUILD_TYPE Debug)
+ message(STATUS "Build type is not set. Defaulting to ${CMAKE_BUILD_TYPE} build!")
endif()
-# define packaging
-if(NOT CMAKE_BUILD_TYPE MATCHES Debug)
- set(CPACK_GENERATOR "DEB")
- set(CPACK_SOURCE_GENERATOR "TGZ")
- set(CPACK_IGNORE_FILES "*.gitignore")
- set(CPACK_PACKAGE_NAME "xloop")
- set(CPACK_PACKAGE_DESCRIPTION "xloop Kernel modules and utility")
- set(CPACK_PACKAGE_VERSION_MAJOR 0)
- set(CPACK_PACKAGE_VERSION_MINOR 1)
+# 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_HOMEPAGE_URL "https://git.openslx.org/openslx-ng/xloop.git/")
set(CPACK_PACKAGE_CHECKSUM SHA256)
- set(CPACK_STRIP_FILES TRUE)
- set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT)
+ 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}")