ref: b685eee47899dfc9fdb065567b029f9c9061ec68
parent: f6434e84964d840160eeff518bc812392c13160f
author: Dmitry Marakasov <amdmi3@amdmi3.ru>
date: Fri Apr 2 19:11:12 EDT 2021
Install desktop files and pixmaps from CMake
--- a/cmake/platforms/unix.cmake
+++ b/cmake/platforms/unix.cmake
@@ -64,17 +64,30 @@
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()
--- a/cmake/setup.cmake
+++ b/cmake/setup.cmake
@@ -80,6 +80,11 @@
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()
--- /dev/null
+++ b/puzzle.desktop.in
@@ -1,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