CMakeLists: add installation target

This commit is contained in:
Anna “CyberTailor”
2022-02-21 11:40:33 +05:00
parent ed63ef1a28
commit 109026211c
2 changed files with 24 additions and 11 deletions
+19
View File
@@ -2,6 +2,8 @@ cmake_minimum_required(VERSION 3.1.0) # Threads::Threads
project(fastfetch LANGUAGES C)
include(GNUInstallDirs)
OPTION(ENABLE_LIBPCI "Enable libpci" ON)
OPTION(ENABLE_VULKAN "Enable vulkan" ON)
OPTION(ENABLE_WAYLAND "Enable wayland-client" ON)
@@ -61,6 +63,8 @@ find_package(Threads REQUIRED)
find_package(PkgConfig REQUIRED)
# Init CMake targets.
add_library(libfastfetch STATIC
src/util/FFstrbuf.c
src/util/FFlist.c
@@ -267,6 +271,8 @@ target_link_libraries(flashfetch
PRIVATE libfastfetch
)
# Testing.
add_executable(fastfetch-test-performance
tests/performance.c
)
@@ -280,3 +286,16 @@ add_executable(fastfetch-test-strbuf
target_link_libraries(fastfetch-test-strbuf
PRIVATE libfastfetch
)
# Installation.
install(TARGETS fastfetch DESTINATION ${CMAKE_INSTALL_BINDIR})
install(FILES completions/bash
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/bash-completion/completions
RENAME ${CMAKE_PROJECT_NAME}
)
install(DIRECTORY presets
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${CMAKE_PROJECT_NAME}
)
+5 -11
View File
@@ -6,9 +6,9 @@ rm -rf ./build ./fastfetch fastfetch.deb
echo "building fastfetch"
mkdir build
cd build || exit
cmake ../../..
cmake --build . --target fastfetch "-j$(nproc)"
cd build || exit 1
cmake ../../.. || exit 1
cmake --build . --target fastfetch "-j$(nproc)" || exit 1
echo "generating package contents"
# deb versions must start with a number, hence the 1 added before the rXXX
@@ -16,18 +16,12 @@ version="0:1$(./fastfetch --version | cut -d ' ' -f2)-0"
echo "Using package version: $version"
cd ..
cmake --install build --prefix fastfetch/usr || exit 1
mkdir -p fastfetch/DEBIAN
sed "s/<VERSION>/$version/g" control-template > fastfetch/DEBIAN/control
mkdir -p fastfetch/usr/bin
cp build/fastfetch fastfetch/usr/bin/
mkdir -p fastfetch/usr/share/bash-completion/completions
cp ../../completions/bash fastfetch/usr/share/bash-completion/completions/fastfetch
mkdir -p fastfetch/usr/share/fastfetch/
cp -r ../../presets fastfetch/usr/share/fastfetch/
echo "building package"
dpkg-deb --build fastfetch
dpkg-deb --build fastfetch || exit 1
echo "package built."
echo "cleaning up"
rm -rf build fastfetch