Install desktop files and pixmaps from CMake

This commit is contained in:
Dmitry Marakasov
2021-04-02 23:11:12 +03:00
committed by Simon Tatham
parent f6434e8496
commit b685eee478
3 changed files with 38 additions and 10 deletions

View File

@ -64,17 +64,30 @@ function(get_platform_puzzle_extra_source_files OUTVAR NAME)
endfunction() endfunction()
function(set_platform_puzzle_target_properties NAME TARGET) function(set_platform_puzzle_target_properties NAME TARGET)
set_target_properties(${TARGET} PROPERTIES get_target_property(official ${TARGET} official)
OUTPUT_NAME ${NAME_PREFIX}${NAME}) get_target_property(exename ${TARGET} exename)
get_target_property(displayname ${TARGET} displayname)
get_target_property(description ${TARGET} description)
set(binary_name ${NAME_PREFIX}${NAME})
if(CMAKE_VERSION VERSION_LESS 3.14) set_target_properties(${TARGET} PROPERTIES
# CMake 3.13 and earlier required an explicit install destination. OUTPUT_NAME ${binary_name})
install(TARGETS ${TARGET} RUNTIME DESTINATION bin)
else() if(${official})
# 3.14 and above selects a sensible default, which we should avoid if(CMAKE_VERSION VERSION_LESS 3.14)
# overriding here so that end users can override it using # CMake 3.13 and earlier required an explicit install destination.
# CMAKE_INSTALL_BINDIR. install(TARGETS ${TARGET} RUNTIME DESTINATION bin)
install(TARGETS ${TARGET}) 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() endif()
endfunction() endfunction()

View File

@ -80,6 +80,11 @@ function(puzzle NAME)
add_executable(${EXENAME} ${NAME}.c ${extra_files}) add_executable(${EXENAME} ${NAME}.c ${extra_files})
target_link_libraries(${EXENAME} target_link_libraries(${EXENAME}
common ${platform_gui_libs} ${platform_libs}) 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}) set_platform_puzzle_target_properties(${NAME} ${EXENAME})
endif() endif()
endfunction() endfunction()

10
puzzle.desktop.in Normal file
View File

@ -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