From: =?utf-8?q?Christian_G=C3=B6ttsche?= <cgzones@googlemail.com>
Date: Mon, 11 May 2020 15:25:24 +0200
Subject: install with cmake

Install the build cursors with cmake.

Also fail if required commands can not be found.
---
 cursors.cmake | 11 ++++++++++-
 setup.cmake   | 34 +++++++++++++++++++++++++++-------
 2 files changed, 37 insertions(+), 8 deletions(-)

diff --git a/cursors.cmake b/cursors.cmake
index 835f78c..cb61f7e 100644
--- a/cursors.cmake
+++ b/cursors.cmake
@@ -116,5 +116,14 @@ macro(add_theme color theme dpi)
                                       oxy-${theme}/index.theme
                        WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
                       )
-    add_custom_target(package-${theme} ALL DEPENDS ${CMAKE_BINARY_DIR}/packages/oxy-${theme}.tar.bz2)
+    add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/packages/oxy-${theme}.theme
+                       DEPENDS ${CMAKE_BINARY_DIR}/oxy-${theme}/index.theme
+                       COMMAND ${GREP} -v Inherits ${CMAKE_BINARY_DIR}/oxy-${theme}/index.theme > ${CMAKE_BINARY_DIR}/packages/oxy-${theme}.theme
+                       COMMAND ${ECHO} "Inherits = oxy-${theme}" >> ${CMAKE_BINARY_DIR}/packages/oxy-${theme}.theme
+                      )
+    add_custom_target(package-${theme} ALL DEPENDS ${CMAKE_BINARY_DIR}/packages/oxy-${theme}.tar.bz2 ${CMAKE_BINARY_DIR}/packages/oxy-${theme}.theme)
+    # install
+    install(DIRECTORY ${CMAKE_BINARY_DIR}/oxy-${theme}/cursors/ DESTINATION share/icons/oxy-${theme}/cursors)
+    install(FILES ${CMAKE_BINARY_DIR}/oxy-${theme}/index.theme DESTINATION share/icons/oxy-${theme})
+    install(FILES ${CMAKE_BINARY_DIR}/packages/oxy-${theme}.theme DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/X11/cursors)
 endmacro(add_theme)
diff --git a/setup.cmake b/setup.cmake
index aedb777..e7e8e31 100644
--- a/setup.cmake
+++ b/setup.cmake
@@ -1,13 +1,33 @@
 find_program(TAR tar)
-# TODO abort if tar not found (or does not understand cjf?)
+if(NOT TAR)
+    message(FATAL_ERROR "tar not found!")
+endif(NOT TAR)
+
+find_program(GREP grep)
+if(NOT GREP)
+    message(FATAL_ERROR "grep not found!")
+endif(NOT GREP)
+
+find_program(ECHO echo)
+if(NOT ECHO)
+    message(FATAL_ERROR "echo not found!")
+endif(NOT ECHO)
+
 if(NOT WIN32)
-find_program(INKSCAPE inkscape)
-# TODO abort if inkscape not found
+    find_program(INKSCAPE inkscape)
+    if(NOT INKSCAPE)
+        message(FATAL_ERROR "inkscape not found!")
+    endif(NOT INKSCAPE)
 
-find_program(XCURSORGEN xcursorgen)
-# TODO abort if xcursorgen not found
+    find_program(XCURSORGEN xcursorgen)
+    if(NOT XCURSORGEN)
+        message(FATAL_ERROR "xcursorgen not found!")
+    endif(NOT XCURSORGEN)
 else(NOT WIN32)
-find_program(INKSCAPE inkscape "$ENV{PROGRAMFILES}/Inkscape" "$ENV{INKSCAPE_DIR}")
+    find_program(INKSCAPE inkscape "$ENV{PROGRAMFILES}/Inkscape" "$ENV{INKSCAPE_DIR}")
+    if(NOT INKSCAPE)
+        message(FATAL_ERROR "inkscape not found!")
+    endif(NOT INKSCAPE)
 endif(NOT WIN32)
 
 # For a given cursor, this macro defines a variable ${cursor}_inputs that contains
@@ -29,4 +49,4 @@ foreach(config ${CONFIGS})
     string(REGEX REPLACE "[.]in" "" cursor ${cursor})
     list(APPEND CURSORS ${cursor})
     set_dependencies(${cursor})
-endforeach(config)
\ No newline at end of file
+endforeach(config)
