chiark / gitweb /
Install desktop files and pixmaps from CMake
authorDmitry Marakasov <amdmi3@amdmi3.ru>
Fri, 2 Apr 2021 20:11:12 +0000 (23:11 +0300)
committerSimon Tatham <anakin@pobox.com>
Sat, 3 Apr 2021 09:35:14 +0000 (10:35 +0100)
cmake/platforms/unix.cmake
cmake/setup.cmake
puzzle.desktop.in [new file with mode: 0644]

index 3398b9d4eb1dc2b7eda8eb8557a16b7401095c58..6cbcbe44764730ba2a5f0b422cf2e60317d31033 100644 (file)
@@ -64,17 +64,30 @@ function(get_platform_puzzle_extra_source_files OUTVAR NAME)
 endfunction()
 
 function(set_platform_puzzle_target_properties NAME TARGET)
+  get_target_property(official ${TARGET} official)
+  get_target_property(exename ${TARGET} exename)
+  get_target_property(displayname ${TARGET} displayname)
+  get_target_property(description ${TARGET} description)
+  set(binary_name ${NAME_PREFIX}${NAME})
+
   set_target_properties(${TARGET} PROPERTIES
-    OUTPUT_NAME ${NAME_PREFIX}${NAME})
+    OUTPUT_NAME ${binary_name})
 
-  if(CMAKE_VERSION VERSION_LESS 3.14)
-    # CMake 3.13 and earlier required an explicit install destination.
-    install(TARGETS ${TARGET} RUNTIME DESTINATION bin)
-  else()
-    # 3.14 and above selects a sensible default, which we should avoid
-    # overriding here so that end users can override it using
-    # CMAKE_INSTALL_BINDIR.
-    install(TARGETS ${TARGET})
+  if(${official})
+    if(CMAKE_VERSION VERSION_LESS 3.14)
+      # CMake 3.13 and earlier required an explicit install destination.
+      install(TARGETS ${TARGET} RUNTIME DESTINATION bin)
+    else()
+      # 3.14 and above selects a sensible default, which we should avoid
+      # overriding here so that end users can override it using
+      # CMAKE_INSTALL_BINDIR.
+      install(TARGETS ${TARGET})
+    endif()
+    configure_file(${CMAKE_SOURCE_DIR}/puzzle.desktop.in ${binary_name}.desktop)
+    install(FILES ${CMAKE_CURRENT_BINARY_DIR}/icons/${NAME}-48d24.png
+      DESTINATION share/pixmaps OPTIONAL RENAME ${binary_name}-48d24.png)
+    install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${binary_name}.desktop
+      DESTINATION share/applications)
   endif()
 endfunction()
 
index 8afa4551fc64e9550ace3a275b7ed22a547cdcf0..d9c766336621ac209c0d80ebce5cff38114e6c88 100644 (file)
@@ -80,6 +80,11 @@ function(puzzle NAME)
     add_executable(${EXENAME} ${NAME}.c ${extra_files})
     target_link_libraries(${EXENAME}
       common ${platform_gui_libs} ${platform_libs})
+    set_property(TARGET ${EXENAME} PROPERTY exename ${EXENAME})
+    set_property(TARGET ${EXENAME} PROPERTY displayname ${OPT_DISPLAYNAME})
+    set_property(TARGET ${EXENAME} PROPERTY description ${OPT_DESCRIPTION})
+    set_property(TARGET ${EXENAME} PROPERTY objective ${OPT_OBJECTIVE})
+    set_property(TARGET ${EXENAME} PROPERTY official ${official})
     set_platform_puzzle_target_properties(${NAME} ${EXENAME})
   endif()
 endfunction()
diff --git a/puzzle.desktop.in b/puzzle.desktop.in
new file mode 100644 (file)
index 0000000..fe7e490
--- /dev/null
@@ -0,0 +1,10 @@
+[Desktop Entry]
+Version=1.0
+Type=Application
+Name=${displayname}
+Comment=${description}
+Exec=${binary_name}
+Icon=${binary_name}-48d24
+StartupNotify=false
+Categories=Game;LogicGame;
+Terminal=false