summaryrefslogtreecommitdiffstats
path: root/src/utils
diff options
context:
space:
mode:
authorManuel Bentele2020-10-23 18:13:15 +0200
committerManuel Bentele2020-10-23 18:13:15 +0200
commit588368dd2a46ddec70741c6cc87a79a0b26ee383 (patch)
tree69265caba9b1fb0ee126c142538b75fd49bbe8ee /src/utils
parentMove the source code of all xloop components to the common 'src' directory (diff)
downloadxloop-588368dd2a46ddec70741c6cc87a79a0b26ee383.tar.gz
xloop-588368dd2a46ddec70741c6cc87a79a0b26ee383.tar.xz
xloop-588368dd2a46ddec70741c6cc87a79a0b26ee383.zip
Add automatic generation of version and build type headers for compilation
This change replaces the static version and build type header file generation by CMake with dynamic CMake targets to generate the version file whenever a Make target is executed. Thus, there is no need anymore to reconfigure and rerun CMake after the repository version or build configuration has changed.
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/CMakeLists.txt8
-rw-r--r--src/utils/config.h (renamed from src/utils/config.h.in)19
-rw-r--r--src/utils/lib/CMakeLists.txt1
-rw-r--r--src/utils/libsmartcols/CMakeLists.txt4
-rw-r--r--src/utils/sys-utils/CMakeLists.txt3
5 files changed, 15 insertions, 20 deletions
diff --git a/src/utils/CMakeLists.txt b/src/utils/CMakeLists.txt
index cfc5548..f3ea912 100644
--- a/src/utils/CMakeLists.txt
+++ b/src/utils/CMakeLists.txt
@@ -4,15 +4,11 @@ cmake_minimum_required(VERSION 3.10)
project(xloop-utils)
# include global headers
-include_directories(${CMAKE_CURRENT_SOURCE_DIR})
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
-
-# prepare date for configuring config.h
-string(TIMESTAMP DATE "%d-%b-%Y")
+include_directories(${PROJECT_INCLUDE_GEN_DIR})
# configure configuration config.h and add it to each source file
-configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)
-add_compile_options(-include ${CMAKE_CURRENT_BINARY_DIR}/config.h)
+add_compile_options(-include ${CMAKE_CURRENT_SOURCE_DIR}/config.h)
# add xloop specific compile options
add_definitions(-DCONFIG_BLK_DEV_XLOOP_MIN_COUNT=${BLK_DEV_XLOOP_MIN_COUNT} -DXLOOP_MAJOR=${XLOOP_MAJOR})
diff --git a/src/utils/config.h.in b/src/utils/config.h
index 40b8d34..781ddc7 100644
--- a/src/utils/config.h.in
+++ b/src/utils/config.h
@@ -1,6 +1,8 @@
/* config.h. Generated from config.h.in by configure. */
/* config.h.in. Generated from configure.ac by autoheader. */
+#include <xloop/version.h>
+
/* Define if building universal (internal helper macro) */
/* #undef AC_APPLE_UNIVERSAL_BUILD */
@@ -693,20 +695,17 @@
/* Define to 1 if you have the `__secure_getenv' function. */
/* #undef HAVE___SECURE_GETENV */
-/* libblkid date string */
-#define LIBBLKID_DATE "@DATE@"
-
/* libblkid version string */
-#define LIBBLKID_VERSION "@VERSION@"
+#define LIBBLKID_VERSION XLOOP_VERSION
/* libfdisk version string */
-#define LIBFDISK_VERSION "@VERSION@"
+#define LIBFDISK_VERSION XLOOP_VERSION
/* libmount version string */
-#define LIBMOUNT_VERSION "@VERSION@"
+#define LIBMOUNT_VERSION XLOOP_VERSION
/* libsmartcols version string */
-#define LIBSMARTCOLS_VERSION "@VERSION@"
+#define LIBSMARTCOLS_VERSION XLOOP_VERSION
/* Should login chown /dev/vcsN? */
/* #undef LOGIN_CHOWN_VCS */
@@ -736,7 +735,7 @@
#define PACKAGE_NAME "util-linux"
/* Define to the full name and version of this package. */
-#define PACKAGE_STRING "util-linux @VERSION@"
+#define PACKAGE_STRING ("util-linux " XLOOP_VERSION)
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "util-linux"
@@ -745,7 +744,7 @@
#define PACKAGE_URL "http://www.kernel.org/pub/linux/utils/util-linux/"
/* Define to the version of this package. */
-#define PACKAGE_VERSION "@VERSION@"
+#define PACKAGE_VERSION XLOOP_VERSION
/* Should pg ring the bell on invalid keys? */
#define PG_BELL 1
@@ -848,7 +847,7 @@
/* #undef USE_VENDORDIR */
/* Version number of package */
-#define VERSION "@VERSION@"
+#define VERSION XLOOP_VERSION
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
significant byte first (like Motorola and SPARC, unlike Intel). */
diff --git a/src/utils/lib/CMakeLists.txt b/src/utils/lib/CMakeLists.txt
index e5fa459..22eafb3 100644
--- a/src/utils/lib/CMakeLists.txt
+++ b/src/utils/lib/CMakeLists.txt
@@ -42,3 +42,4 @@ add_library(libcommon STATIC ${CMAKE_CURRENT_SOURCE_DIR}/blkdev.c
${CMAKE_CURRENT_SOURCE_DIR}/timer.c
${CMAKE_CURRENT_SOURCE_DIR}/timeutils.c
${CMAKE_CURRENT_SOURCE_DIR}/ttyutils.c)
+target_link_libraries(libcommon xloop-version)
diff --git a/src/utils/libsmartcols/CMakeLists.txt b/src/utils/libsmartcols/CMakeLists.txt
index c8deb72..dccb5e2 100644
--- a/src/utils/libsmartcols/CMakeLists.txt
+++ b/src/utils/libsmartcols/CMakeLists.txt
@@ -18,5 +18,5 @@ add_library(libsmartcols STATIC ${CMAKE_CURRENT_SOURCE_DIR}/src/buffer.c
${CMAKE_CURRENT_SOURCE_DIR}/src/table.c
${CMAKE_CURRENT_SOURCE_DIR}/src/version.c
${CMAKE_CURRENT_SOURCE_DIR}/src/walk.c)
-target_include_directories(libsmartcols PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_SOURCE_DIR}/../lib)
-target_link_libraries(libsmartcols LINK_PUBLIC libcommon)
+target_include_directories(libsmartcols PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src)
+target_link_libraries(libsmartcols LINK_PUBLIC libcommon xloop-version)
diff --git a/src/utils/sys-utils/CMakeLists.txt b/src/utils/sys-utils/CMakeLists.txt
index 01295d9..e05b5cf 100644
--- a/src/utils/sys-utils/CMakeLists.txt
+++ b/src/utils/sys-utils/CMakeLists.txt
@@ -5,8 +5,7 @@ project(xloop-utils-sys-utils)
# add xlosetup executable
add_executable(xlosetup ${CMAKE_CURRENT_SOURCE_DIR}/xlosetup.c)
-target_link_libraries(xlosetup LINK_PUBLIC libcommon libsmartcols)
-target_include_directories(xlosetup PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../lib ${CMAKE_CURRENT_SOURCE_DIR}/../libsmartcols)
+target_link_libraries(xlosetup libcommon libsmartcols xloop-version)
install(TARGETS xlosetup DESTINATION bin
COMPONENT main)