Codefix: Documentation comment in IndustryDirectoryWindow (#13059)
[openttd-github.git] / media / CMakeLists.txt
blob17b10b5ec872123dd34e6aa338d30b35877a7a6d
1 add_subdirectory(baseset)
3 add_library(media
4         INTERFACE
6 add_library(openttd::media ALIAS media)
8 if(NOT UNIX OR APPLE)
9     return()
10 endif()
12 set(MEDIA_PNG_SOURCE_FILES
13         ${CMAKE_CURRENT_SOURCE_DIR}/openttd.16.png
14         ${CMAKE_CURRENT_SOURCE_DIR}/openttd.32.png
15         ${CMAKE_CURRENT_SOURCE_DIR}/openttd.48.png
16         ${CMAKE_CURRENT_SOURCE_DIR}/openttd.64.png
17         ${CMAKE_CURRENT_SOURCE_DIR}/openttd.128.png
18         ${CMAKE_CURRENT_SOURCE_DIR}/openttd.256.png
21 # Walk over all the png files, and generate a command to copy them
22 foreach(MEDIA_PNG_SOURCE_FILE IN LISTS MEDIA_PNG_SOURCE_FILES)
23         get_filename_component(MEDIA_PNG_FILE_NAME "${MEDIA_PNG_SOURCE_FILE}" NAME)
24         string(REGEX REPLACE "[^.]+.([0-9]*).*" "${CMAKE_CURRENT_BINARY_DIR}/icons/hicolor/\\1x\\1/apps/${BINARY_NAME}.png" MEDIA_PNG_BINARY_FILE "${MEDIA_PNG_FILE_NAME}")
26         add_custom_command(OUTPUT ${MEDIA_PNG_BINARY_FILE}
27             COMMAND ${CMAKE_COMMAND} -E copy
28                     ${MEDIA_PNG_SOURCE_FILE}
29                     ${MEDIA_PNG_BINARY_FILE}
30             MAIN_DEPENDENCY ${MEDIA_PNG_SOURCE_FILE}
31             WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
32             COMMENT "Copying ${MEDIA_PNG_FILE_NAME} file"
33         )
35         list(APPEND MEDIA_BINARY_FILES ${MEDIA_PNG_BINARY_FILE})
36 endforeach()
38 set(MEDIA_XPM_SOURCE_FILES
39         ${CMAKE_CURRENT_SOURCE_DIR}/openttd.32.xpm
40         ${CMAKE_CURRENT_SOURCE_DIR}/openttd.64.xpm
43 # Walk over all the xpm files, and generate a command to copy them
44 foreach(MEDIA_XPM_SOURCE_FILE IN LISTS MEDIA_XPM_SOURCE_FILES)
45         get_filename_component(MEDIA_XPM_FILE_NAME "${MEDIA_XPM_SOURCE_FILE}" NAME)
46         get_filename_component(MEDIA_XPM_FILE_EXT "${MEDIA_XPM_FILE_NAME}" EXT)
47         set(MEDIA_XPM_BINARY_FILE "${CMAKE_CURRENT_BINARY_DIR}/pixmaps/${BINARY_NAME}${MEDIA_XPM_FILE_EXT}")
49         add_custom_command(OUTPUT ${MEDIA_XPM_BINARY_FILE}
50             COMMAND ${CMAKE_COMMAND} -E copy
51                     ${MEDIA_XPM_SOURCE_FILE}
52                     ${MEDIA_XPM_BINARY_FILE}
53             MAIN_DEPENDENCY ${MEDIA_XPM_SOURCE_FILE}
54             WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
55             COMMENT "Copying ${MEDIA_XPM_FILE_NAME} file"
56         )
58         list(APPEND MEDIA_BINARY_FILES ${MEDIA_XPM_BINARY_FILE})
59 endforeach()
61 # Create a new target which copies media files
62 add_custom_target(media_files
63         DEPENDS
64         ${MEDIA_BINARY_FILES}
67 add_dependencies(media
68         media_files
71 get_target_property(LANG_SOURCE_FILES language_files LANG_SOURCE_FILES)
73 set(DESKTOP_BINARY_NAME ${BINARY_NAME}.desktop)
75 add_custom_command_timestamp(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${DESKTOP_BINARY_NAME}
76         COMMAND ${CMAKE_COMMAND}
77                 -DDESKTOP_SOURCE_FILE=${CMAKE_CURRENT_SOURCE_DIR}/openttd.desktop
78                 -DDESKTOP_BINARY_FILE=${CMAKE_CURRENT_BINARY_DIR}/${DESKTOP_BINARY_NAME}
79                 -DBINARY_NAME=${BINARY_NAME}
80                 -P ${CMAKE_SOURCE_DIR}/cmake/scripts/Desktop.cmake
81                 --
82                 ${LANG_SOURCE_FILES}
83         MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/openttd.desktop
84         DEPENDS ${LANG_SOURCE_FILES}
85                 ${CMAKE_SOURCE_DIR}/cmake/scripts/Desktop.cmake
86         WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
87         COMMENT "Generating desktop file"
90 # Create a new target which generates desktop file
91 add_custom_target_timestamp(desktop_file
92         DEPENDS
93         ${CMAKE_CURRENT_BINARY_DIR}/${DESKTOP_BINARY_NAME}
96 add_dependencies(media
97         desktop_file