aboutsummaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt49
1 files changed, 44 insertions, 5 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2263af0..4cbb01d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -176,6 +176,7 @@ add_custom_command (OUTPUT xC-proto.c
add_custom_target (xC-proto DEPENDS ${PROJECT_BINARY_DIR}/xC-proto.c)
# Build
+set (project_binaries xB xC xD)
foreach (name xB xC xD)
add_executable (${name} ${name}.c ${project_config})
target_link_libraries (${name} ${project_libraries})
@@ -187,12 +188,13 @@ add_dependencies (xC replies xC-proto)
target_link_libraries (xC ${xC_libraries})
if (WANT_XF)
- pkg_check_modules (x11 REQUIRED x11 xrender xft fontconfig)
- include_directories (${x11_INCLUDE_DIRS})
- link_directories (${x11_LIBRARY_DIRS})
+ list (APPEND project_binaries xF)
+ pkg_check_modules (x11 REQUIRED x11 xrender xft fontconfig libpng)
add_executable (xF xF.c ${project_config})
add_dependencies (xF xC-proto)
+ target_include_directories (xF PRIVATE ${x11_INCLUDE_DIRS})
+ target_link_directories (xF PRIVATE ${x11_LIBRARY_DIRS})
target_link_libraries (xF ${x11_LIBRARIES} ${project_libraries})
add_threads (xF)
endif ()
@@ -226,13 +228,50 @@ add_custom_target (clang-tidy
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
# Installation
-install (TARGETS xB xC xD DESTINATION ${CMAKE_INSTALL_BINDIR})
+install (TARGETS ${project_binaries} DESTINATION ${CMAKE_INSTALL_BINDIR})
install (FILES LICENSE DESTINATION ${CMAKE_INSTALL_DOCDIR})
install (DIRECTORY plugins/xB/
DESTINATION ${CMAKE_INSTALL_DATADIR}/xB/plugins USE_SOURCE_PERMISSIONS)
install (DIRECTORY plugins/xC/
DESTINATION ${CMAKE_INSTALL_DATADIR}/xC/plugins)
+# Rasterize and install SVG icons (CMake code adjusted from tdv)
+if (NOT ${CMAKE_VERSION} VERSION_LESS 3.18.0)
+ set (find_program_REQUIRE REQUIRED)
+endif ()
+
+function (icon_to_png name svg size output_dir output)
+ set (_dimensions ${size}x${size})
+ set (_png_path ${output_dir}/hicolor/${_dimensions}/apps)
+ set (_png ${_png_path}/${name}.png)
+ set (${output} ${_png} PARENT_SCOPE)
+
+ find_program (rsvg_convert_EXECUTABLE rsvg-convert ${find_program_REQUIRE})
+ add_custom_command (OUTPUT ${_png}
+ COMMAND ${CMAKE_COMMAND} -E make_directory ${_png_path}
+ COMMAND ${rsvg_convert_EXECUTABLE} --output=${_png}
+ --width=${size} --height=${size} ${svg}
+ DEPENDS ${svg}
+ COMMENT "Generating ${name} ${_dimensions} application icon" VERBATIM)
+endfunction ()
+
+if (WANT_XF)
+ set (icon_base ${PROJECT_BINARY_DIR}/icons)
+ set (icon_png_list)
+ foreach (icon_size 16 32 48)
+ icon_to_png (xF
+ ${PROJECT_SOURCE_DIR}/xF.svg ${icon_size} ${icon_base} icon_png)
+ list (APPEND icon_png_list ${icon_png})
+ endforeach ()
+
+ add_custom_target (icons ALL DEPENDS ${icon_png_list})
+
+ install (FILES xF.svg
+ DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/scalable/apps)
+ install (DIRECTORY ${icon_base}
+ DESTINATION ${CMAKE_INSTALL_DATADIR})
+endif ()
+
# Generate documentation from text markup
find_program (ASCIIDOCTOR_EXECUTABLE asciidoctor)
find_program (A2X_EXECUTABLE a2x)
@@ -241,7 +280,7 @@ if (NOT ASCIIDOCTOR_EXECUTABLE AND NOT A2X_EXECUTABLE)
"falling back to a substandard manual page generator")
endif ()
-foreach (page xB xC xD)
+foreach (page ${project_binaries})
set (page_output "${PROJECT_BINARY_DIR}/${page}.1")
list (APPEND project_MAN_PAGES "${page_output}")
if (ASCIIDOCTOR_EXECUTABLE)