2012-12-26 13:56:12 +00:00
|
|
|
cmake_minimum_required(VERSION 2.8)
|
|
|
|
|
2016-04-03 03:18:46 +00:00
|
|
|
set(COLOBOT_ICON_FILE ${CMAKE_CURRENT_SOURCE_DIR}/colobot.svg)
|
2013-10-30 16:18:53 +00:00
|
|
|
|
|
|
|
# Render SVG icon in various sizes
|
|
|
|
find_program(RSVG_CONVERT rsvg-convert)
|
2016-04-03 03:30:23 +00:00
|
|
|
if(NOT RSVG_CONVERT)
|
2016-04-03 10:25:41 +00:00
|
|
|
message(WARNING "rsvg-convert not found; desktop icons will not be generated")
|
2016-04-03 03:30:23 +00:00
|
|
|
endif()
|
|
|
|
|
2016-04-03 03:18:46 +00:00
|
|
|
find_program(XMLSTARLET xmlstarlet)
|
2016-04-03 03:30:23 +00:00
|
|
|
if(NOT XMLSTARLET)
|
|
|
|
message(WARNING "xmlstarlet not found; desktop icons will not be generated")
|
|
|
|
endif()
|
|
|
|
|
2016-04-03 03:18:46 +00:00
|
|
|
if(RSVG_CONVERT AND XMLSTARLET AND (PLATFORM_GNU OR PLATFORM_MACOSX))
|
|
|
|
add_custom_target(png-icons ALL DEPENDS ${COLOBOT_ICON_FILE})
|
|
|
|
|
|
|
|
foreach(PNG_SIZE 512 256 128 48 32 16)
|
|
|
|
# Using xmlstarlet to edit SVG file is a workaround for rsvg-convert bug (see: https://bugzilla.gnome.org/show_bug.cgi?id=762115)
|
2013-10-30 16:18:53 +00:00
|
|
|
add_custom_command(
|
2016-04-03 03:18:46 +00:00
|
|
|
OUTPUT ${PNG_SIZE}/colobot.png
|
|
|
|
COMMAND mkdir -p ${PNG_SIZE}
|
|
|
|
COMMAND ${XMLSTARLET} ed -u /*/@width -v ${PNG_SIZE} -u /*/@height -v ${PNG_SIZE} ${COLOBOT_ICON_FILE} > ${PNG_SIZE}/colobot.svg
|
|
|
|
COMMAND ${RSVG_CONVERT} ${PNG_SIZE}/colobot.svg -o ${PNG_SIZE}/colobot.png
|
2013-10-30 16:18:53 +00:00
|
|
|
)
|
2016-04-03 03:18:46 +00:00
|
|
|
add_custom_target(png-icon-${PNG_SIZE} ALL DEPENDS ${PNG_SIZE}/colobot.png)
|
|
|
|
add_dependencies(png-icons png-icon-${PNG_SIZE})
|
2013-10-30 16:18:53 +00:00
|
|
|
|
2013-11-27 17:53:28 +00:00
|
|
|
if(PLATFORM_GNU)
|
2013-10-30 16:18:53 +00:00
|
|
|
install(
|
2016-04-03 03:18:46 +00:00
|
|
|
FILES ${CMAKE_CURRENT_BINARY_DIR}/${PNG_SIZE}/colobot.png
|
|
|
|
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/${PNG_SIZE}x${PNG_SIZE}/apps/
|
2013-10-30 16:18:53 +00:00
|
|
|
)
|
|
|
|
endif()
|
|
|
|
# Prepare the ICNS icon generation
|
2016-04-03 03:18:46 +00:00
|
|
|
list(APPEND ICNS_SRCS "${PNG_SIZE}/colobot.png")
|
2013-10-30 16:18:53 +00:00
|
|
|
endforeach()
|
2016-04-03 03:18:46 +00:00
|
|
|
|
2013-10-30 16:18:53 +00:00
|
|
|
# Pack icon for Mac OS
|
2016-04-03 03:30:23 +00:00
|
|
|
if(PLATFORM_MACOSX)
|
|
|
|
find_program(PNG2ICNS png2icns)
|
|
|
|
if(NOT PNG2ICNS)
|
|
|
|
message(WARNING "png2icns not found; icns file will not be generated")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(PNG2ICNS)
|
|
|
|
add_custom_command(OUTPUT Colobot.icns
|
|
|
|
COMMAND ${PNG2ICNS} Colobot.icns ${ICNS_SRCS}
|
|
|
|
DEPENDS png-icons
|
|
|
|
)
|
|
|
|
add_custom_target(icns-icon ALL DEPENDS Colobot.icns)
|
|
|
|
endif()
|
2013-10-30 16:18:53 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
endif()
|
|
|
|
|
2013-11-27 17:53:28 +00:00
|
|
|
if(PLATFORM_GNU)
|
2013-10-30 08:06:06 +00:00
|
|
|
# Install Desktop Entry file
|
|
|
|
set(COLOBOT_DESKTOP_FILE colobot.desktop)
|
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${COLOBOT_DESKTOP_FILE}
|
|
|
|
COMMAND ./create_desktop_file.sh > ${CMAKE_CURRENT_BINARY_DIR}/${COLOBOT_DESKTOP_FILE}
|
|
|
|
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
|
|
|
COMMENT "Build ${COLOBOT_DESKTOP_FILE}"
|
|
|
|
)
|
|
|
|
add_custom_target(desktopfile ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${COLOBOT_DESKTOP_FILE})
|
|
|
|
install(
|
|
|
|
FILES ${CMAKE_CURRENT_BINARY_DIR}/${COLOBOT_DESKTOP_FILE}
|
|
|
|
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/applications/
|
|
|
|
)
|
|
|
|
|
2018-10-03 22:43:09 +00:00
|
|
|
# Install appdata
|
|
|
|
install(
|
|
|
|
FILES ${CMAKE_CURRENT_BINARY_DIR}/info.colobot.Colobot.appdata.xml
|
|
|
|
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/metainfo/
|
|
|
|
)
|
|
|
|
|
2013-10-30 08:06:06 +00:00
|
|
|
# Install Icon
|
|
|
|
install(
|
2016-04-03 03:18:46 +00:00
|
|
|
FILES ${COLOBOT_ICON_FILE}
|
2013-10-30 08:06:06 +00:00
|
|
|
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/scalable/apps/
|
|
|
|
)
|
|
|
|
|
2013-10-30 15:38:58 +00:00
|
|
|
# Translate translatable material
|
|
|
|
find_program(PO4A po4a)
|
2016-04-03 03:30:23 +00:00
|
|
|
if(NOT PO4A)
|
|
|
|
message(WARNING "po4a not found; desktop and manpage files will not be translated")
|
|
|
|
endif()
|
|
|
|
|
2013-10-30 15:38:58 +00:00
|
|
|
if(PO4A)
|
|
|
|
add_custom_target(desktop_po4a
|
|
|
|
COMMAND ${PO4A} po4a.cfg
|
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
|
|
|
)
|
|
|
|
add_dependencies(desktopfile desktop_po4a)
|
|
|
|
endif()
|
|
|
|
|
2013-10-30 08:06:06 +00:00
|
|
|
# Create manpage from pod-formatted file
|
|
|
|
find_program(POD2MAN pod2man)
|
2016-04-03 03:30:23 +00:00
|
|
|
if(NOT POD2MAN)
|
|
|
|
message(WARNING "pod2man not found; manpage will not be generated")
|
|
|
|
endif()
|
|
|
|
|
2013-10-30 08:06:06 +00:00
|
|
|
if(POD2MAN)
|
|
|
|
set(COLOBOT_MANPAGE_SECTION 6)
|
|
|
|
|
2013-10-30 15:38:58 +00:00
|
|
|
macro(podman)
|
2013-10-30 08:06:06 +00:00
|
|
|
cmake_parse_arguments(PM "" "PODFILE;LOCALE;" "" ${ARGN})
|
|
|
|
if(PM_LOCALE)
|
|
|
|
# This copes with the fact that english has no "/LANG" in the paths and filenames.
|
|
|
|
set(SLASHLOCALE /${PM_LOCALE})
|
|
|
|
endif()
|
|
|
|
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}${SLASHLOCALE})
|
|
|
|
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}${SLASHLOCALE}/colobot.${COLOBOT_MANPAGE_SECTION}
|
|
|
|
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${PM_PODFILE}
|
|
|
|
COMMAND ${POD2MAN} ARGS --section=${COLOBOT_MANPAGE_SECTION}
|
|
|
|
--center="Colobot" --stderr --utf8
|
|
|
|
--release="${COLOBOT_VERSION_FULL}"
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/${PM_PODFILE}
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}${SLASHLOCALE}/colobot.${COLOBOT_MANPAGE_SECTION}
|
|
|
|
COMMENT "Create ${SLASHLOCALE}/colobot.${COLOBOT_MANPAGE_SECTION} manpage"
|
|
|
|
)
|
|
|
|
add_custom_target(man${PM_LOCALE} ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}${SLASHLOCALE}/colobot.${COLOBOT_MANPAGE_SECTION})
|
|
|
|
|
|
|
|
install(
|
|
|
|
FILES ${CMAKE_CURRENT_BINARY_DIR}${SLASHLOCALE}/colobot.${COLOBOT_MANPAGE_SECTION}
|
|
|
|
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/man${SLASHLOCALE}/man${COLOBOT_MANPAGE_SECTION}/ )
|
|
|
|
|
|
|
|
add_dependencies(man man${PM_LOCALE})
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
# Create the english manpage
|
|
|
|
podman(PODFILE colobot.pod)
|
|
|
|
|
2013-10-30 15:38:58 +00:00
|
|
|
if(PO4A)
|
|
|
|
# Translate the manpage to other languages
|
2013-10-30 16:05:29 +00:00
|
|
|
add_dependencies(man desktop_po4a)
|
2013-10-30 08:06:06 +00:00
|
|
|
file(GLOB LINGUAS_PO RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/po/ ${CMAKE_CURRENT_SOURCE_DIR}/po/*.po)
|
|
|
|
string(REGEX REPLACE ".po$" "" LINGUAS ${LINGUAS_PO})
|
|
|
|
foreach(LOCALE ${LINGUAS})
|
|
|
|
podman(PODFILE lang/${LOCALE}/colobot.pod LOCALE ${LOCALE})
|
2013-10-30 16:05:29 +00:00
|
|
|
add_dependencies(man${PM_LOCALE} desktop_po4a)
|
2013-10-30 08:06:06 +00:00
|
|
|
endforeach()
|
|
|
|
endif()
|
|
|
|
endif()
|
2013-11-27 17:53:28 +00:00
|
|
|
endif(PLATFORM_GNU)
|
2013-10-30 08:06:06 +00:00
|
|
|
|
2013-10-30 16:08:12 +00:00
|
|
|
if(PLATFORM_MACOSX)
|
|
|
|
configure_file(Info.plist.cmake ${CMAKE_CURRENT_BINARY_DIR}/Info.plist)
|
|
|
|
endif(PLATFORM_MACOSX)
|
|
|
|
|
2013-10-30 15:38:58 +00:00
|
|
|
if(PLATFORM_WINDOWS)
|
2018-05-16 09:55:06 +00:00
|
|
|
if(COLOBOT_VERSION_REVISION MATCHES "([0-9]+)\\.([0-9]+)")
|
|
|
|
string(REGEX REPLACE "([0-9]+)\\.([0-9]+)" "\\1,\\2" COLOBOT_VERSION_REVISION_COMMA "${COLOBOT_VERSION_REVISION}")
|
|
|
|
set(COLOBOT_VERSION_4COMMAS "${COLOBOT_VERSION_MAJOR},${COLOBOT_VERSION_MINOR},${COLOBOT_VERSION_REVISION_COMMA}")
|
|
|
|
else()
|
|
|
|
set(COLOBOT_VERSION_4COMMAS "${COLOBOT_VERSION_MAJOR},${COLOBOT_VERSION_MINOR},${COLOBOT_VERSION_REVISION},0")
|
|
|
|
endif()
|
2013-10-30 08:06:06 +00:00
|
|
|
configure_file(colobot.rc.cmake ${CMAKE_CURRENT_BINARY_DIR}/colobot.rc)
|
2013-10-30 15:38:58 +00:00
|
|
|
endif(PLATFORM_WINDOWS)
|
2013-11-08 15:52:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
##
|
|
|
|
# Packaging
|
|
|
|
##
|
2014-10-25 17:44:08 +00:00
|
|
|
set(CPACK_BUNDLE_NAME "Colobot: Gold Edition")
|
2013-11-08 15:52:42 +00:00
|
|
|
set(CPACK_PACKAGE_FILE_NAME "colobot-${COLOBOT_VERSION_FULL}")
|
|
|
|
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/../README.md")
|
2014-10-25 17:44:08 +00:00
|
|
|
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Colobot: Gold Edition")
|
2014-11-01 18:57:23 +00:00
|
|
|
set(CPACK_PACKAGE_VENDOR "TerranovaTeam")
|
2013-11-08 15:52:42 +00:00
|
|
|
|
|
|
|
set(CPACK_PACKAGE_VERSION_MAJOR ${COLOBOT_VERSION_MAJOR})
|
|
|
|
set(CPACK_PACKAGE_VERSION_MINOR ${COLOBOT_VERSION_MINOR})
|
|
|
|
set(CPACK_PACKAGE_VERSION_PATCH ${COLOBOT_VERSION_REVISION})
|
|
|
|
|
|
|
|
if(PLATFORM_WINDOWS)
|
|
|
|
set(CPACK_STRIP_FILES TRUE)
|
|
|
|
|
|
|
|
# Don't version the install directory, and allow overwriting
|
|
|
|
set(CPACK_PACKAGE_INSTALL_DIRECTORY "Colobot")
|
2014-10-25 17:44:08 +00:00
|
|
|
set(CPACK_NSIS_DEFINES "SetOverwrite on\nBrandingText \\\"Colobot: Gold Edition (${COLOBOT_VERSION_FULL})\\\"")
|
2013-11-08 15:52:42 +00:00
|
|
|
# Install the executable directly in Program Files/Colobot/
|
|
|
|
set(CPACK_NSIS_EXECUTABLES_DIRECTORY ".")
|
2014-10-25 17:44:08 +00:00
|
|
|
set(CPACK_PACKAGE_EXECUTABLES "colobot" "Colobot: Gold Edition")
|
2013-11-08 15:52:42 +00:00
|
|
|
|
|
|
|
# Branding
|
|
|
|
## Installation and uninstallation icons
|
|
|
|
set(CPACK_NSIS_MUI_ICON ${CMAKE_CURRENT_SOURCE_DIR}/colobot.ico)
|
|
|
|
set(CPACK_NSIS_MUI_UNIICON ${CMAKE_CURRENT_SOURCE_DIR}/colobot.ico)
|
|
|
|
## Header and Left banner images
|
|
|
|
set(CPACK_PACKAGE_ICON "")
|
|
|
|
set(CPACK_NSIS_INSTALLER_ICON_CODE "!define MUI_HEADERIMAGE_BITMAP \\\"${CMAKE_CURRENT_SOURCE_DIR}/colobot_nsis.bmp\\\"
|
|
|
|
!define MUI_WELCOMEFINISHPAGE_BITMAP \\\"${CMAKE_CURRENT_SOURCE_DIR}/colobot_nsis_left.bmp\\\"")
|
|
|
|
|
|
|
|
## Allow to directly run Colobot at the end of the installation
|
|
|
|
set(CPACK_NSIS_MUI_FINISHPAGE_RUN "colobot.exe")
|
|
|
|
|
|
|
|
## TODO: Find a way to have no license prompt. Until that, display the GPL-3
|
|
|
|
set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/../LICENSE.txt)
|
|
|
|
|
|
|
|
elseif(PLATFORM_MACOSX)
|
2014-11-04 02:21:03 +00:00
|
|
|
set(CPACK_BUNDLE_NAME "Colobot")
|
2013-11-08 15:52:42 +00:00
|
|
|
set(CPACK_GENERATOR "Bundle")
|
|
|
|
set(CPACK_BUNDLE_ICON ${CMAKE_CURRENT_BINARY_DIR}/Colobot.icns)
|
|
|
|
set(CPACK_PACKAGE_ICON ${CMAKE_CURRENT_BINARY_DIR}/Colobot.icns)
|
|
|
|
set(CPACK_BUNDLE_PLIST ${CMAKE_CURRENT_BINARY_DIR}/Info.plist)
|
|
|
|
|
|
|
|
set(CPACK_BINARY_DRAGNDROP ON)
|
|
|
|
|
|
|
|
install(CODE "
|
|
|
|
include(BundleUtilities)
|
|
|
|
message(STATUS \"fixup_bundle(\${CMAKE_INSTALL_PREFIX}/${COLOBOT_INSTALL_BIN_DIR}/colobot/\")
|
|
|
|
fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/${COLOBOT_INSTALL_BIN_DIR}/colobot\" \"\" \"\")
|
|
|
|
")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
include(CPack)
|