2017-02-10 23:03:33 +01:00
|
|
|
|
|
|
|
cmake_minimum_required (VERSION 3.2)
|
|
|
|
|
|
|
|
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-22 22:57:31 +01:00
|
|
|
# set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
|
|
|
# set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
|
|
|
# set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
2017-02-10 23:03:33 +01:00
|
|
|
|
2017-02-11 18:58:12 +01:00
|
|
|
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
2017-02-23 18:39:50 +01:00
|
|
|
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=c++11 -L${CMAKE_INSTALL_PREFIX}/lib")
|
2017-02-11 18:58:12 +01:00
|
|
|
endif ()
|
|
|
|
|
2017-02-10 23:03:33 +01:00
|
|
|
file (GLOB_RECURSE sources src/*.cpp src/*.h)
|
2017-02-15 22:02:59 +01:00
|
|
|
file (GLOB_RECURSE po resources/po/*.po)
|
2017-02-10 23:03:33 +01:00
|
|
|
|
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-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-10 23:03:33 +01:00
|
|
|
|
|
|
|
# Dependencies
|
|
|
|
|
|
|
|
find_package (Intl REQUIRED)
|
|
|
|
|
|
|
|
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 (ASS REQUIRED libass)
|
|
|
|
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-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
|
|
|
# ${ASS_STATIC_LIBRARIES}
|
|
|
|
${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-02-18 12:17:58 +01: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
|
|
|
|
)
|
|
|
|
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)
|