2017-02-10 23:03:33 +01:00
|
|
|
|
|
|
|
cmake_minimum_required (VERSION 3.2)
|
|
|
|
|
2017-02-25 17:01:04 +01:00
|
|
|
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
|
|
|
|
|
2017-02-10 23:03:33 +01:00
|
|
|
include (${CMAKE_ROOT}/Modules/ExternalProject.cmake)
|
|
|
|
|
2017-02-22 22:57:31 +01:00
|
|
|
include_directories (${CMAKE_INSTALL_PREFIX}/include)
|
|
|
|
link_directories (${CMAKE_INSTALL_PREFIX}/lib)
|
|
|
|
|
2017-02-10 23:03:33 +01:00
|
|
|
project (planetblupi)
|
|
|
|
set (PB_VERSION_MAJOR 2)
|
|
|
|
set (PB_VERSION_MINOR 0)
|
|
|
|
set (PB_VERSION_PATCH 0)
|
|
|
|
|
2017-02-28 22:39:26 +01:00
|
|
|
configure_file (
|
|
|
|
"${PROJECT_SOURCE_DIR}/src/config.h.in"
|
|
|
|
"${PROJECT_BINARY_DIR}/include/config.h"
|
|
|
|
)
|
|
|
|
|
|
|
|
include_directories ("${PROJECT_BINARY_DIR}/include")
|
|
|
|
|
2017-02-26 10:46:11 +01:00
|
|
|
file (GLOB_RECURSE sources src/*.cxx src/*.h)
|
2017-02-15 22:02:59 +01:00
|
|
|
file (GLOB_RECURSE po resources/po/*.po)
|
2017-02-26 00:04:23 +01:00
|
|
|
|
2017-02-23 19:35:00 +01:00
|
|
|
if (MINGW)
|
2017-02-26 10:46:11 +01:00
|
|
|
file (GLOB_RECURSE rc resources/win32/*.rc)
|
2017-02-23 19:35:00 +01:00
|
|
|
list (APPEND sources ${rc})
|
|
|
|
endif (MINGW)
|
2017-02-10 23:03:33 +01:00
|
|
|
|
2017-02-26 00:04:23 +01:00
|
|
|
if (APPIMAGE_APPRUN_PROGRAM AND APPIMAGE_ASSISTANT_PROGRAM)
|
|
|
|
set (USE_APPIMAGE ON)
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
|
|
|
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=c++11 -L${CMAKE_INSTALL_PREFIX}/lib")
|
|
|
|
endif ()
|
|
|
|
|
2017-02-18 23:43:19 +01:00
|
|
|
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
|
|
|
set (CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++")
|
|
|
|
endif ()
|
|
|
|
|
2017-03-02 18:55:41 +01:00
|
|
|
if (USE_APPIMAGE AND "${CMAKE_BUILD_TYPE}" STREQUAL "Release")
|
2017-02-26 00:04:55 +01:00
|
|
|
set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -s")
|
|
|
|
set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -s")
|
|
|
|
endif ()
|
|
|
|
|
2017-02-18 17:58:52 +01:00
|
|
|
add_executable (planetblupi ${sources})
|
2017-02-10 23:03:33 +01:00
|
|
|
|
2017-02-18 17:58:52 +01:00
|
|
|
file (COPY resources/data DESTINATION share/planetblupi)
|
|
|
|
file (COPY resources/image DESTINATION share/planetblupi)
|
|
|
|
file (COPY resources/movie DESTINATION share/planetblupi)
|
|
|
|
file (COPY resources/sound DESTINATION share/planetblupi)
|
|
|
|
file (COPY resources/music DESTINATION share/planetblupi)
|
2017-02-26 22:21:19 +01:00
|
|
|
file (COPY resources/icon/planetblupi.png DESTINATION share/planetblupi)
|
2017-02-10 23:03:33 +01:00
|
|
|
|
2017-02-23 19:35:00 +01:00
|
|
|
# Windows stuff
|
|
|
|
|
|
|
|
if (MINGW)
|
|
|
|
set (CMAKE_RC_COMPILER_INIT windres)
|
|
|
|
enable_language (RC)
|
|
|
|
set (CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> <FLAGS> -O coff <DEFINES> -i <SOURCE> -o <OBJECT>")
|
|
|
|
endif (MINGW)
|
|
|
|
|
2017-02-10 23:03:33 +01:00
|
|
|
# Dependencies
|
|
|
|
|
2017-03-21 19:45:56 +01:00
|
|
|
set (CMAKE_INCLUDE_PATH ${CMAKE_INSTALL_PREFIX}/include)
|
|
|
|
set (CMAKE_LIBRARY_PATH ${CMAKE_INSTALL_PREFIX}/lib)
|
2017-02-10 23:03:33 +01:00
|
|
|
find_package (Intl REQUIRED)
|
2017-03-21 19:52:33 +01:00
|
|
|
find_package (Iconv REQUIRED)
|
2017-02-10 23:03:33 +01:00
|
|
|
|
|
|
|
find_package (PkgConfig REQUIRED)
|
2017-02-22 22:57:31 +01:00
|
|
|
pkg_search_module (SDL2 REQUIRED sdl2)
|
2017-02-10 23:03:33 +01:00
|
|
|
pkg_search_module (SDL2_MIXER REQUIRED SDL2_mixer)
|
2017-02-12 22:06:08 +01:00
|
|
|
pkg_search_module (SDL2_IMAGE REQUIRED SDL2_image)
|
2017-02-22 22:57:31 +01:00
|
|
|
# Static dependencies for SDL_kitchensink
|
|
|
|
pkg_search_module (PNG REQUIRED libpng)
|
|
|
|
pkg_search_module (AVCODEC REQUIRED libavcodec)
|
|
|
|
pkg_search_module (AVFORMAT REQUIRED libavformat)
|
|
|
|
pkg_search_module (AVUTIL REQUIRED libavutil)
|
|
|
|
pkg_search_module (SWSCALE REQUIRED libswscale)
|
|
|
|
pkg_search_module (SWRESAMPLE REQUIRED libswresample)
|
2017-02-10 23:03:33 +01:00
|
|
|
|
|
|
|
##################
|
|
|
|
## SDL_kitchensink
|
2017-02-14 23:47:24 +01:00
|
|
|
##################
|
2017-02-14 18:17:45 +01:00
|
|
|
|
2017-02-22 22:57:31 +01:00
|
|
|
add_library (SDL_kitchensink STATIC IMPORTED)
|
|
|
|
set_property (TARGET SDL_kitchensink PROPERTY IMPORTED_LOCATION ${CMAKE_INSTALL_PREFIX}/lib/libSDL_kitchensink_static.a)
|
2017-02-14 18:17:45 +01:00
|
|
|
|
2017-02-14 23:47:24 +01:00
|
|
|
###########################
|
|
|
|
## Main binary dependencies
|
|
|
|
###########################
|
2017-02-10 23:03:33 +01:00
|
|
|
|
|
|
|
target_link_libraries (planetblupi PUBLIC
|
|
|
|
${Intl_LIBRARIES}
|
2017-03-21 19:52:33 +01:00
|
|
|
${Iconv_LIBRARIES}
|
2017-02-22 22:57:31 +01:00
|
|
|
${SDL2_STATIC_LIBRARIES}
|
|
|
|
${SDL2_MIXER_STATIC_LIBRARIES}
|
|
|
|
${SDL2_IMAGE_STATIC_LIBRARIES}
|
2017-02-14 18:17:45 +01:00
|
|
|
SDL_kitchensink
|
2017-02-22 22:57:31 +01:00
|
|
|
${PNG_STATIC_LIBRARIES}
|
|
|
|
${AVCODEC_STATIC_LIBRARIES}
|
|
|
|
${AVFORMAT_STATIC_LIBRARIES}
|
|
|
|
${AVUTIL_STATIC_LIBRARIES}
|
|
|
|
${SWSCALE_STATIC_LIBRARIES}
|
|
|
|
${SWRESAMPLE_STATIC_LIBRARIES}
|
2017-02-10 23:03:33 +01:00
|
|
|
)
|
2017-02-13 23:05:49 +01:00
|
|
|
|
2017-02-14 23:47:24 +01:00
|
|
|
##########
|
2017-02-13 23:05:49 +01:00
|
|
|
## GetText
|
2017-02-14 23:47:24 +01:00
|
|
|
##########
|
2017-02-13 23:05:49 +01:00
|
|
|
|
|
|
|
find_package (Gettext)
|
|
|
|
|
2017-02-15 22:02:59 +01:00
|
|
|
set (_potFile ${CMAKE_CURRENT_SOURCE_DIR}/resources/po/${PROJECT_NAME}.pot)
|
2017-02-13 23:05:49 +01:00
|
|
|
|
|
|
|
add_custom_command (OUTPUT ${_potFile}
|
2017-02-15 22:21:59 +01:00
|
|
|
COMMAND xgettext --keyword=translate -o ${_potFile} ${sources}
|
2017-07-09 00:18:07 +02:00
|
|
|
DEPENDS ${sources}
|
2017-02-14 23:08:21 +01:00
|
|
|
COMMENT "Extract translatable messages to ${_potFile}"
|
2017-02-13 23:05:49 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
add_custom_target (pot_file ALL ${_all}
|
2017-02-14 23:08:21 +01:00
|
|
|
DEPENDS ${_potFile}
|
2017-02-13 23:05:49 +01:00
|
|
|
)
|
|
|
|
|
2017-02-14 23:08:21 +01:00
|
|
|
gettext_create_translations (${_potFile} ALL ${po})
|
2017-02-14 23:47:12 +01:00
|
|
|
|
|
|
|
## Put mo files to appropriate directory
|
2017-02-15 23:11:23 +01:00
|
|
|
foreach (file ${_gmoFiles})
|
|
|
|
get_filename_component (_lang ${file} NAME_WE)
|
2017-02-21 22:35:48 +01:00
|
|
|
set (_out "share/locale/${_lang}/LC_MESSAGES")
|
2017-02-15 23:11:23 +01:00
|
|
|
|
|
|
|
add_custom_command (OUTPUT ${_out}/planetblupi.mo
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy ${file} ${_out}/planetblupi.mo
|
|
|
|
DEPENDS ${file}
|
|
|
|
)
|
|
|
|
|
|
|
|
add_custom_target ("po-${_lang}" ALL ${_all}
|
|
|
|
DEPENDS ${_out}/planetblupi.mo
|
|
|
|
)
|
2017-07-09 00:18:07 +02:00
|
|
|
|
|
|
|
add_dependencies (planetblupi "po-${_lang}")
|
2017-02-15 23:11:23 +01:00
|
|
|
endforeach (file)
|
2017-02-22 22:57:43 +01:00
|
|
|
|
|
|
|
# Installation
|
|
|
|
|
|
|
|
install (TARGETS planetblupi
|
|
|
|
RUNTIME DESTINATION bin
|
|
|
|
)
|
|
|
|
|
|
|
|
install (DIRECTORY resources/data DESTINATION share/planetblupi)
|
|
|
|
install (DIRECTORY resources/image DESTINATION share/planetblupi)
|
|
|
|
install (DIRECTORY resources/movie DESTINATION share/planetblupi)
|
|
|
|
install (DIRECTORY resources/sound DESTINATION share/planetblupi)
|
|
|
|
install (DIRECTORY resources/music DESTINATION share/planetblupi)
|
2017-02-26 17:46:49 +01:00
|
|
|
install (FILES resources/icon/planetblupi.png DESTINATION share/planetblupi)
|
2017-02-25 17:01:04 +01:00
|
|
|
|
|
|
|
#########
|
|
|
|
## Deploy
|
|
|
|
#########
|
|
|
|
|
2017-07-28 15:29:25 +02:00
|
|
|
if ("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
|
|
|
|
if (USE_APPIMAGE)
|
|
|
|
include (LinuxAppImageBuild)
|
|
|
|
set (CMAKE_PACKAGED_OUTPUT_PREFIX ${CMAKE_INSTALL_PREFIX})
|
|
|
|
APPIMAGE_PACKAGE (planetblupi "planetblupi" "${CMAKE_CURRENT_SOURCE_DIR}/resources/linux" "${CMAKE_BINARY_DIR}/share" "" "")
|
|
|
|
elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
|
|
|
|
set (CPACK_GENERATOR NSIS64)
|
|
|
|
set (CPACK_PACKAGE_NAME "planetblupi")
|
|
|
|
set (CPACK_PACKAGE_VENDOR "blupi.org")
|
|
|
|
set (CPACK_PACKAGE_DESCRIPTION_SUMMARY "PlanetBlupi")
|
|
|
|
set (CPACK_PACKAGE_VERSION_MAJOR ${PB_VERSION_MAJOR})
|
|
|
|
set (CPACK_PACKAGE_VERSION_MINOR ${PB_VERSION_MINOR})
|
|
|
|
set (CPACK_PACKAGE_VERSION_PATCH ${PB_VERSION_PATCH})
|
|
|
|
set (CPACK_PACKAGE_INSTALL_DIRECTORY "planetblupi")
|
|
|
|
set (CPACK_NSIS_MODIFY_PATH ON)
|
|
|
|
|
|
|
|
include (CPack)
|
|
|
|
endif ()
|
2017-02-25 17:01:04 +01:00
|
|
|
endif ()
|