1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428
|
cmake_minimum_required (VERSION 3.2)
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
set (CMAKE_CXX_STANDARD 11)
include (GNUInstallDirs)
include (${CMAKE_ROOT}/Modules/ExternalProject.cmake)
include ("${CMAKE_SOURCE_DIR}/cmake/Ronn2Man.cmake")
include_directories (${CMAKE_INSTALL_PREFIX}/include)
link_directories (${CMAKE_INSTALL_PREFIX}/lib)
project (planetblupi)
set (PB_VERSION_MAJOR 1)
set (PB_VERSION_MINOR 14)
set (PB_VERSION_PATCH 2)
set (PB_VERSION_EXTRA "")
set (PB_PRODUCT_NAME "Planet Blupi")
set (PB_PACKAGE_NAME "planetblupi")
set (PB_EXEC "planetblupi")
set (PB_ICON_REF "blupi")
set (PB_DESCRIPTION "Planet Blupi - A delirious spell-binding game")
option (PB_HTTP_VERSION_CHECK "Run a version check over HTTP (with CURL)" OFF)
configure_file (
"${PROJECT_SOURCE_DIR}/src/config.h.in"
"${PROJECT_BINARY_DIR}/include/config.h"
)
include_directories ("${PROJECT_BINARY_DIR}/include")
if (BUILD_JS)
file (GLOB sources src/*.cxx src/*.h src/json/* src/platform/*_js.*)
else ()
file (GLOB sources src/*.cxx src/*.h src/json/* src/platform/*_sdl.*)
endif ()
file (GLOB_RECURSE po resources/po/*.po)
if (APPIMAGE_APPRUN_PROGRAM AND APPIMAGE_ASSISTANT_PROGRAM)
set (USE_APPIMAGE ON)
endif ()
if (NOT USE_APPIMAGE)
configure_file (
"${PROJECT_SOURCE_DIR}/resources/linux/application.desktop.in"
"${CMAKE_CURRENT_BINARY_DIR}/${PB_PACKAGE_NAME}.desktop"
@ONLY
)
endif ()
set (planetblupi_OUTPUT planetblupi)
if (NOT DEFINED BUILD_LINUX)
set (BUILD_LINUX UNIX AND NOT APPLE)
endif ()
if (BUILD_JS)
set (CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} ${EMSCRIPTEN_FLAGS})
set (CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS} "--preload-file share")
set (planetblupi_OUTPUT planetblupi.html)
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 ()
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND "${STATIC_BUILD}")
set (CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS} "-static-libgcc -static-libstdc++")
endif ()
if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3 -DDEBUG")
endif ()
if ("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -s")
set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -s")
endif ()
# These copies are necessary with our stuff for AppImage because it's not
# supported by CPack.
if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
file (COPY resources/data DESTINATION share/planetblupi)
else ()
file (
COPY resources/data DESTINATION share/planetblupi
PATTERN "world2*.blp" EXCLUDE
PATTERN "world*.dev.blp" EXCLUDE
)
endif ()
file (COPY resources/image DESTINATION share/planetblupi)
if (NOT BUILD_JS)
file (COPY resources/movie DESTINATION share/planetblupi)
endif ()
file (COPY resources/sound DESTINATION share/planetblupi)
file (COPY resources/music DESTINATION share/planetblupi)
file (COPY LICENSE.all DESTINATION share/doc/planetblupi)
file (COPY COPYING DESTINATION share/doc/planetblupi)
file (RENAME "${CMAKE_BINARY_DIR}/share/doc/planetblupi/LICENSE.all"
"${CMAKE_BINARY_DIR}/share/doc/planetblupi/copyright")
if (BUILD_LINUX)
file (COPY resources/icon/hicolor DESTINATION share/icons)
file (
COPY resources/linux/${PB_PACKAGE_NAME}.appdata.xml
DESTINATION share/metainfo
)
endif ()
# Windows stuff
if (MINGW)
file (COPY resources/icon/blupi.ico DESTINATION "${CMAKE_BINARY_DIR}")
configure_file (
"${CMAKE_CURRENT_SOURCE_DIR}/resources/win32/planetblupi.rc.in"
"${CMAKE_BINARY_DIR}/planetblupi.rc"
@ONLY
)
list (APPEND sources "${CMAKE_BINARY_DIR}/planetblupi.rc")
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>")
# Remove cmd window when executing planetblupi
set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -mwindows")
endif (MINGW)
# Dependencies
if ("${STATIC_BUILD}")
set (CMAKE_INCLUDE_PATH ${CMAKE_INSTALL_PREFIX}/include)
set (CMAKE_LIBRARY_PATH ${CMAKE_INSTALL_PREFIX}/lib)
endif ()
find_package (Intl REQUIRED)
include_directories (${Intl_INCLUDE_DIRS})
find_package (Iconv REQUIRED)
include_directories (${Iconv_INCLUDE_DIRS})
find_package (Argagg REQUIRED)
include_directories (${Argagg_INCLUDE_DIRS})
find_package (SDLKitchensink REQUIRED)
include_directories (${SDLKitchensink_INCLUDE_DIRS})
find_package (PkgConfig REQUIRED)
if (NOT BUILD_JS)
pkg_search_module (SDL2 REQUIRED sdl2)
include_directories (${SDL2_INCLUDE_DIRS})
set (planetblupi_DEPS ${planetblupi_DEPS} ${SDL2_STATIC_LIBRARIES})
pkg_search_module (SDL2_IMAGE REQUIRED SDL2_image)
include_directories (${SDL2_IMAGE_INCLUDE_DIRS})
set (planetblupi_DEPS ${planetblupi_DEPS} ${SDL2_IMAGE_STATIC_LIBRARIES})
pkg_search_module (SDL2_MIXER REQUIRED SDL2_mixer)
include_directories (${SDL2_MIXER_INCLUDE_DIRS})
set (planetblupi_DEPS ${planetblupi_DEPS} ${SDL2_MIXER_STATIC_LIBRARIES})
endif ()
if (${PB_HTTP_VERSION_CHECK})
pkg_search_module (CURL REQUIRED libcurl)
add_definitions (-DUSE_CURL)
endif ()
if ("${STATIC_BUILD}")
# Static dependencies for SDL_kitchensink
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)
if (NOT BUILD_JS)
pkg_search_module (PNG REQUIRED libpng)
set (planetblupi_DEPS ${planetblupi_DEPS} ${PNG_STATIC_LIBRARIES})
# Static dependencies for SDL_mixer
pkg_search_module (VORBIS REQUIRED vorbisfile)
set (planetblupi_DEPS ${planetblupi_DEPS} ${VORBIS_STATIC_LIBRARIES})
if (BUILD_LINUX)
pkg_search_module (ALSA REQUIRED alsa)
pkg_search_module (PULSE REQUIRED libpulse)
endif ()
set (planetblupi_DEPS ${planetblupi_DEPS}
${Intl_LIBRARIES}
${Iconv_LIBRARIES}
)
endif ()
if (${PB_HTTP_VERSION_CHECK})
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DCURL_STATICLIB")
endif ()
endif ()
###########################
## Main binary dependencies
###########################
add_executable (${planetblupi_OUTPUT} ${sources})
if ("${STATIC_BUILD}")
set (planetblupi_DEPS ${planetblupi_DEPS}
${SDLKitchensink_STATIC_LIBRARIES}
${AVCODEC_STATIC_LIBRARIES}
${AVFORMAT_STATIC_LIBRARIES}
${AVUTIL_STATIC_LIBRARIES}
${SWSCALE_STATIC_LIBRARIES}
${SWRESAMPLE_STATIC_LIBRARIES}
)
if (${PB_HTTP_VERSION_CHECK})
list (APPEND planetblupi_DEPS
${CURL_STATIC_LIBRARIES}
)
endif ()
if (BUILD_LINUX)
list (APPEND planetblupi_DEPS
${ALSA_STATIC_LIBRARIES}
${PULSE_STATIC_LIBRARIES}
)
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L${CMAKE_INSTALL_PREFIX}/lib/pulseaudio")
endif ()
else ()
set (planetblupi_DEPS
${SDL2_LIBRARIES}
${SDL2_MIXER_LIBRARIES}
${SDL2_IMAGE_LIBRARIES}
${CURL_LIBRARIES}
${SDLKitchensink_LIBRARIES}
pthread
)
if (${PB_HTTP_VERSION_CHECK})
list (APPEND planetblupi_DEPS
${CURL_LIBRARIES}
)
endif ()
endif ()
target_link_libraries (${planetblupi_OUTPUT} PUBLIC ${planetblupi_DEPS})
##########
## GetText
##########
find_package (Gettext)
set (_potFile ${CMAKE_CURRENT_SOURCE_DIR}/resources/po/${PROJECT_NAME}.pot)
add_custom_command (OUTPUT ${_potFile}
COMMAND xgettext --no-location --keyword=translate -o ${_potFile} ${sources}
DEPENDS ${sources}
COMMENT "Extract translatable messages to ${_potFile}"
)
add_custom_target (pot_file ALL ${_all}
DEPENDS ${_potFile}
)
gettext_create_translations (${_potFile} ALL ${po})
## Put mo files to appropriate directory
foreach (file ${_gmoFiles})
get_filename_component (_lang ${file} NAME_WE)
set (_out "share/locale/${_lang}/LC_MESSAGES")
add_custom_command (OUTPUT ${_out}/planetblupi.mo
COMMAND ${CMAKE_COMMAND} -E copy ${file} ${_out}/planetblupi.mo
DEPENDS translations ${file}
)
add_custom_target ("po-${_lang}" ALL ${_all}
DEPENDS ${_out}/planetblupi.mo
)
add_dependencies (${planetblupi_OUTPUT} "po-${_lang}")
endforeach (file)
#########
# manpage
#########
add_manpage_target ()
manpage(${PROJECT_NAME} 6)
##############
# Installation
##############
if (NOT BUILD_JS)
install (TARGETS ${planetblupi_OUTPUT}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
install (
DIRECTORY resources/data DESTINATION share/planetblupi
PATTERN "world2*.blp" EXCLUDE
PATTERN "world*.dev.blp" EXCLUDE
)
install (
DIRECTORY resources/data DESTINATION share/planetblupi
CONFIGURATIONS Debug
PATTERN "world2*.blp"
PATTERN "world*.dev.blp"
)
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)
install (FILES LICENSE.all DESTINATION share/doc/planetblupi RENAME copyright)
install (FILES COPYING DESTINATION share/doc/planetblupi)
if (BUILD_LINUX)
install (DIRECTORY resources/icon/hicolor DESTINATION share/icons)
install (
FILES resources/linux/${PB_PACKAGE_NAME}.appdata.xml
DESTINATION share/metainfo
)
endif ()
if (NOT USE_APPIMAGE)
install (
FILES ${CMAKE_CURRENT_BINARY_DIR}/${PB_PACKAGE_NAME}.desktop
DESTINATION share/applications
)
endif ()
# Copy libwinpthread-1.dll which seems not be linkable statically
if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows" AND MINGW)
execute_process (COMMAND cygpath.exe --windows $ENV{MINGW_PREFIX} OUTPUT_VARIABLE MINGW_PATH)
string (REGEX REPLACE "[ \t\n\r]+$" "" MINGW_PATH "${MINGW_PATH}")
string (REGEX REPLACE "[\\]" "\\\\\\\\" MINGW_PATH "${MINGW_PATH}")
install (FILES "${MINGW_PATH}\\\\bin\\\\libwinpthread-1.dll" DESTINATION bin)
endif ()
endif ()
#########
## Deploy
#########
if ("${CMAKE_BUILD_TYPE}" STREQUAL "Release" AND "${STATIC_BUILD}")
# set (CPACK_STRIP_FILES TRUE)
set (CPACK_PACKAGE_NAME ${PB_PACKAGE_NAME})
set (CPACK_PACKAGE_VENDOR "blupi.org")
set (CPACK_PACKAGE_DESCRIPTION_SUMMARY ${PB_DESCRIPTION})
set (CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
# set (CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README-user.md")
set (CPACK_PACKAGE_FILE_NAME ${PB_PACKAGE_NAME})
set (CPACK_PACKAGE_VERSION "${PB_VERSION_MAJOR}.${PB_VERSION_MINOR}.${PB_VERSION_PATCH}${PB_VERSION_EXTRA}")
set (CPACK_PACKAGE_INSTALL_DIRECTORY ${PB_PRODUCT_NAME})
set (CPACK_PACKAGE_EXECUTABLES "planetblupi;Planet Blupi")
if (USE_APPIMAGE)
include (LinuxAppImageBuild)
set (CMAKE_PACKAGED_OUTPUT_PREFIX ${CMAKE_INSTALL_PREFIX})
APPIMAGE_PACKAGE (planetblupi ${PB_PACKAGE_NAME} ${PB_PRODUCT_NAME} "${CMAKE_CURRENT_SOURCE_DIR}/resources/linux" "${CMAKE_BINARY_DIR}/share" "" "" ${PB_ICON_REF} SIGN_APP)
elseif (MINGW)
set (INSTALLER_FILE_NAME "${PB_PACKAGE_NAME}-${PB_VERSION_MAJOR}.${PB_VERSION_MINOR}.${PB_VERSION_PATCH}${PB_VERSION_EXTRA}")
set (CPACK_PACKAGE_FILE_NAME "${INSTALLER_FILE_NAME}")
set (CPACK_GENERATOR "NSIS64")
set (CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}\\\\resources\\\\nsis\\\\installer.bmp")
set (CPACK_NSIS_COMPRESSOR "/SOLID lzma")
set (CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\planetblupi.exe")
set (CPACK_NSIS_URL_INFO_ABOUT "http://www.blupi.org")
set (CPACK_NSIS_MUI_FINISHPAGE_RUN "planetblupi")
if (SIGN_APP)
set (CPACK_NSIS_SIGN_UNINSTALLER "sign -a -fd sha1 -t http://time.certum.pl -v")
endif ()
include (CPack)
find_program (SIGNTOOL_EXECUTABLE signtool)
if (SIGN_APP AND SIGNTOOL_EXECUTABLE)
add_custom_command (TARGET planetblupi
POST_BUILD
COMMAND ${SIGNTOOL_EXECUTABLE}
sign -a -fd sha1 -t http://time.certum.pl -v
"${CMAKE_BINARY_DIR}/planetblupi.exe")
endif ()
add_custom_command (TARGET planetblupi
POST_BUILD
COMMAND make package)
if (SIGN_APP AND SIGNTOOL_EXECUTABLE)
add_custom_command (TARGET planetblupi
POST_BUILD
COMMAND ${SIGNTOOL_EXECUTABLE}
sign -a -fd sha1 -t http://time.certum.pl
"${CMAKE_BINARY_DIR}/${INSTALLER_FILE_NAME}.exe")
endif ()
elseif (APPLE)
set (CPACK_GENERATOR "Bundle")
set (CPACK_BUNDLE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/resources/darwin/icon.icns")
set (CPACK_BUNDLE_NAME ${PB_PRODUCT_NAME})
set (CPACK_BUNDLE_PLIST "${CMAKE_BINARY_DIR}/Info.plist")
set (CPACK_BUNDLE_STARTUP_COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/resources/darwin/Planet Blupi")
if (SIGN_APP)
set (CPACK_BUNDLE_APPLE_CERT_APP "Developer ID Application: Mathieu Schroeter")
endif ()
set (CPACK_PACKAGE_FILE_NAME "planetblupi-${PB_VERSION_MAJOR}.${PB_VERSION_MINOR}.${PB_VERSION_PATCH}${PB_VERSION_EXTRA}")
set (CPACK_DMG_BACKGROUND_IMAGE "${CMAKE_CURRENT_SOURCE_DIR}/resources/darwin/background.tiff")
set (CPACK_DMG_DS_STORE_SETUP_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/resources/darwin/dmgsetup.scpt")
set (BUNDLE_VERSION "${PB_VERSION_MAJOR}.${PB_VERSION_MINOR}.${PB_VERSION_PATCH}${PB_VERSION_EXTRA}")
set (BUNDLE_IDENTIFIER "org.blupi.planet")
set (BUNDLE_ICON_REF "Planet Blupi")
configure_file (
"${CMAKE_CURRENT_SOURCE_DIR}/resources/darwin/Info.plist.in"
"${CMAKE_BINARY_DIR}/Info.plist"
@ONLY
)
include (CPack)
add_custom_command (TARGET planetblupi
POST_BUILD
COMMAND make package)
endif ()
endif ()
|