Skip to content

Commit 254f42f

Browse files
committed
build: add icon prefix + improve uninstall targets
1 parent f4a0aad commit 254f42f

File tree

3 files changed

+49
-22
lines changed

3 files changed

+49
-22
lines changed

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ add_dependencies(${TARGET_NAME} locale)
9999
set(MANPREFIX "${CMAKE_INSTALL_PREFIX}/share/man" CACHE PATH "Man page installation directory")
100100
set(APPPREFIX "${CMAKE_INSTALL_PREFIX}/share/applications" CACHE PATH "Application desktop file directory")
101101
set(LOCALEDIR "${CMAKE_INSTALL_PREFIX}/share/locale" CACHE PATH "Locale files directory")
102+
set(ICONPREFIX "${CMAKE_INSTALL_PREFIX}/share/pixmaps" CACHE PATH "Icon installation directory")
102103

103104
# Install executable
104105
install(TARGETS ${TARGET_NAME}
@@ -125,6 +126,10 @@ install(DIRECTORY ${CMAKE_SOURCE_DIR}/examples/
125126
DESTINATION share/customfetch/examples
126127
COMPONENT runtime)
127128

129+
install(DIRECTORY ${CMAKE_SOURCE_DIR}/assets/icons/
130+
DESTINATION share/pixmaps/customfetch
131+
COMPONENT runtime)
132+
128133
install(DIRECTORY ${CMAKE_SOURCE_DIR}/locale/
129134
DESTINATION share/locale
130135
COMPONENT runtime)

Makefile

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ PREFIX ?= /usr
44
MANPREFIX ?= $(PREFIX)/share/man
55
APPPREFIX ?= $(PREFIX)/share/applications
66
LOCALEDIR ?= $(PREFIX)/share/locale
7+
ICONPREFIX ?= $(PREFIX)/share/pixmaps
78
VARS ?= -DENABLE_NLS=1
89

910
DEBUG ?= 1
@@ -109,7 +110,7 @@ usr-dist: $(TARGET) locale
109110
rm -rf usr/
110111

111112
clean:
112-
rm -rf $(BUILDDIR)/$(TARGET) $(BUILDDIR)/libcustomfetch.a $(OBJ)
113+
rm -rf $(BUILDDIR)/$(TARGET) $(BUILDDIR)/lib$(NAME).a $(OBJ)
113114

114115
distclean:
115116
rm -rf $(BUILDDIR) ./tests/$(BUILDDIR) $(OBJ)
@@ -126,8 +127,9 @@ install-common: locale
126127
sed -e "s/@VERSION@/$(VERSION)/g" -e "s/@BRANCH@/$(BRANCH)/g" < $(NAME).1 > $(DESTDIR)$(MANPREFIX)/man1/$(NAME).1
127128
chmod 644 $(DESTDIR)$(MANPREFIX)/man1/$(NAME).1
128129
install LICENSE -Dm 644 $(DESTDIR)$(PREFIX)/share/licenses/$(NAME)/LICENSE
129-
cd assets/ && find ascii/ -type f -exec install -Dm 644 "{}" "$(DESTDIR)$(PREFIX)/share/customfetch/{}" \;
130-
find examples/ -type f -exec install -Dm 644 "{}" "$(DESTDIR)$(PREFIX)/share/customfetch/{}" \;
130+
cd assets/ && find ascii/ -type f -exec install -Dm 644 "{}" "$(DESTDIR)$(PREFIX)/share/$(NAME)/{}" \;
131+
cd assets/icons && find . -type f -exec install -Dm 644 "{}" "$(DESTDIR)$(ICONPREFIX)/$(NAME)/{}" \;
132+
find examples/ -type f -exec install -Dm 644 "{}" "$(DESTDIR)$(PREFIX)/share/$(NAME)/{}" \;
131133
find locale/ -type f -exec install -Dm 644 "{}" "$(DESTDIR)$(PREFIX)/share/{}" \;
132134
ifeq ($(GUI_APP), 1)
133135
mkdir -p $(DESTDIR)$(APPPREFIX)
@@ -138,13 +140,16 @@ uninstall:
138140
rm -f $(DESTDIR)$(PREFIX)/bin/$(TARGET) $(DESTDIR)$(PREFIX)/bin/cufetch
139141
rm -f $(DESTDIR)$(MANPREFIX)/man1/$(NAME).1
140142
rm -f $(DESTDIR)$(APPPREFIX)/$(NAME).desktop
141-
rm -rf $(DESTDIR)$(PREFIX)/share/customfetch/
143+
rm -rf $(DESTDIR)$(PREFIX)/share/licenses/$(NAME)/
144+
rm -rf $(DESTDIR)$(PREFIX)/share/$(NAME)/
145+
rm -rf $(DESTDIR)$(ICONPREFIX)/$(NAME)/
146+
find $(DESTDIR)$(LOCALEDIR) -type f -path "$(DESTDIR)$(LOCALEDIR)/*/LC_MESSAGES/$(NAME).mo" -exec rm -f {} \;
142147

143148
remove: uninstall
144149
delete: uninstall
145150

146151
updatever:
147152
sed -i "s#$(OLDVERSION)#$(VERSION)#g" $(wildcard .github/workflows/*.yml) compile_flags.txt
148-
sed -i "s#Project-Id-Version: customfetch $(OLDVERSION)#Project-Id-Version: customfetch $(VERSION)#g" po/*
153+
sed -i "s#Project-Id-Version: $(NAME) $(OLDVERSION)#Project-Id-Version: $(NAME) $(VERSION)#g" po/*
149154

150155
.PHONY: $(TARGET) updatever remove uninstall delete dist distclean fmt toml install all locale

cmake_uninstall.cmake.in

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,37 @@
1-
if(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
2-
message(FATAL_ERROR "Cannot find install manifest: @CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
1+
message(STATUS "Removing special files")
2+
file(REMOVE "${CMAKE_INSTALL_PREFIX}/bin/cufetch") # Symlink
3+
if(EXISTS "${CMAKE_INSTALL_PREFIX}/bin/customfetch-gui")
4+
file(REMOVE "${CMAKE_INSTALL_PREFIX}/bin/customfetch-gui") # GUI executable
35
endif()
46

5-
file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
6-
string(REGEX REPLACE "\n" ";" files "${files}")
7-
foreach(file ${files})
8-
message(STATUS "Uninstalling $ENV{DESTDIR}${file}")
9-
if(EXISTS "$ENV{DESTDIR}${file}")
10-
exec_program(
11-
"@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
12-
OUTPUT_VARIABLE rm_out
13-
RETURN_VALUE rm_retval)
14-
if(NOT "${rm_retval}" STREQUAL 0)
15-
message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}")
7+
if(EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
8+
message(STATUS "Processing install manifest")
9+
file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
10+
string(REGEX REPLACE "\n" ";" files "${files}")
11+
12+
foreach(file ${files})
13+
if(EXISTS "${file}" OR IS_SYMLINK "${file}")
14+
message(STATUS "Removing: ${file}")
15+
file(REMOVE "${file}")
16+
17+
# Remove empty parent directories
18+
get_filename_component(dir "${file}" DIRECTORY)
19+
while(NOT dir STREQUAL "${CMAKE_INSTALL_PREFIX}")
20+
file(GLOB contents "${dir}/*")
21+
if(NOT contents)
22+
message(STATUS "Removing empty directory: ${dir}")
23+
file(REMOVE_RECURSE "${dir}")
24+
get_filename_component(dir "${dir}" DIRECTORY)
25+
else()
26+
break()
27+
endif()
28+
endwhile()
29+
else()
30+
message(STATUS "File not found (may be already removed): ${file}")
1631
endif()
17-
else()
18-
message(STATUS "File $ENV{DESTDIR}${file} does not exist.")
19-
endif()
20-
endforeach()
32+
endforeach()
33+
else()
34+
message(WARNING "Install manifest not found - some files may remain")
35+
endif()
36+
37+
message(STATUS "Uninstallation complete")

0 commit comments

Comments
 (0)