CMakeLists.txt 48 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219
  1. #
  2. # SuperTux - root build script
  3. # Copyright (C) 2006 Christoph Sommer <christoph.sommer@2006.expires.deltadevelopment.de>
  4. #
  5. # This program is free software; you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation; either version 2 of the License, or
  8. # (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program; if not, write to the Free Software
  17. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  18. #
  19. #
  20. # INSTRUCTIONS:
  21. # -------------
  22. #
  23. # Create a directory build/ and change to it. Run
  24. #
  25. # cmake ..
  26. #
  27. # This creates a set of Makefiles to build the project. Run
  28. #
  29. # make
  30. #
  31. ## Project name to use as command prefix.
  32. project(SUPERTUX)
  33. ### CMake configuration
  34. cmake_minimum_required(VERSION 3.1)
  35. if(COMMAND cmake_policy)
  36. cmake_policy(SET CMP0003 NEW)
  37. cmake_policy(SET CMP0008 NEW)
  38. cmake_policy(SET CMP0023 NEW)
  39. endif(COMMAND cmake_policy)
  40. set(CMAKE_CXX_STANDARD 14)
  41. set(CMAKE_CXX_STANDARD_REQUIRED ON)
  42. set(CMAKE_CXX_EXTENSIONS OFF)
  43. set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/mk/cmake)
  44. include(ConfigureFiles)
  45. include(ExternalProject)
  46. include(CheckCXXCompilerFlag)
  47. ## For autopackage
  48. set(APPDATADIR "${CMAKE_INSTALL_PREFIX}/share/games/supertux2")
  49. set(BUILD_DATA_DIR "${CMAKE_CURRENT_SOURCE_DIR}/data")
  50. set(BUILD_CONFIG_DATA_DIR "${CMAKE_BINARY_DIR}/data")
  51. ## Check endianess
  52. include(TestBigEndian)
  53. test_big_endian(WORDS_BIGENDIAN)
  54. ## Add definitions
  55. if(CMAKE_BUILD_TYPE MATCHES "Release|RelWithDebInfo")
  56. add_definitions(-DRELEASE)
  57. elseif(CMAKE_BUILD_TYPE MATCHES Debug)
  58. add_definitions(-DDEBUG)
  59. endif()
  60. set(SUPERTUX_SYSTEM_NAME ${CMAKE_SYSTEM_NAME})
  61. set(VCPKG_BUILD OFF CACHE BOOL "Use dependencies installed via vcpkg (not dependency package)")
  62. set(VCPKG_APPLOCAL_DEPS ${VCPKG_BUILD} BOOL)
  63. ## These variables enable MSVC to find libraries located in "dependencies{32|64}"
  64. if(WIN32)
  65. if(NOT VCPKG_BUILD)
  66. ## Store path of dependecy folder
  67. set(DEPENDENCY_FOLDER "${PROJECT_SOURCE_DIR}/dependencies")
  68. endif()
  69. ## To test if the host (not the build) is x64:
  70. ## "$ENV{PROCESSOR_ARCHITEW6432}" STREQUAL "AMD64"
  71. if(${CMAKE_SIZEOF_VOID_P} EQUAL 8)
  72. set(WIN64 ON)
  73. if(NOT VCPKG_BUILD)
  74. set(DEPENDENCY_FOLDER "${DEPENDENCY_FOLDER}64")
  75. endif()
  76. else(${CMAKE_SIZEOF_VOID_P} EQUAL 8)
  77. set(WIN64 OFF)
  78. if(NOT VCPKG_BUILD)
  79. set(DEPENDENCY_FOLDER "${DEPENDENCY_FOLDER}32")
  80. endif()
  81. endif(${CMAKE_SIZEOF_VOID_P} EQUAL 8)
  82. if(WIN64)
  83. set(SUPERTUX_SYSTEM_NAME win64)
  84. else(WIN64)
  85. set(SUPERTUX_SYSTEM_NAME win32)
  86. endif(WIN64)
  87. if(NOT VCPKG_BUILD)
  88. set(ENV{PATH} "$ENV{PATH};${DEPENDENCY_FOLDER}/include")
  89. set(ENV{LIB} "${DEPENDENCY_FOLDER}/lib")
  90. set(ENV{OPENALDIR} "${DEPENDENCY_FOLDER}")
  91. endif()
  92. ## Enable multi-processor compilation (faster)
  93. if(MSVC)
  94. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
  95. endif(MSVC)
  96. ## And shut up about unsafe stuff
  97. add_definitions(-D_CRT_SECURE_NO_WARNINGS)
  98. ## Add an icon
  99. configure_file("${CMAKE_CURRENT_SOURCE_DIR}/mk/msvc/icon_rc.template" "${PROJECT_BINARY_DIR}/tmp/icon.rc")
  100. ## Find all used libraries
  101. if(NOT VCPKG_BUILD)
  102. file(GLOB DLLS "${DEPENDENCY_FOLDER}/dll/*")
  103. endif()
  104. endif(WIN32)
  105. # Detect mobile builds
  106. option(UBUNTU_TOUCH "Compile the project for an Ubuntu Touch target" OFF)
  107. # Mobile builds
  108. if (UBUNTU_TOUCH)
  109. option(ENABLE_TOUCHSCREEN_SUPPORT "Enable on-screen controls and event detection for touchscreen devices" ON)
  110. else()
  111. option(ENABLE_TOUCHSCREEN_SUPPORT "Enable on-screen controls and event detection for touchscreen devices" OFF)
  112. endif()
  113. ## Add lots of dependencies to compiler switches
  114. set(Boost_ADDITIONAL_VERSIONS "1.41" "1.41.0")
  115. if(WIN32)
  116. option(ENABLE_BOOST_STATIC_LIBS "Use boost static libraries" ON)
  117. else(WIN32)
  118. option(ENABLE_BOOST_STATIC_LIBS "Use boost static libraries" OFF)
  119. endif(WIN32)
  120. if(ENABLE_BOOST_STATIC_LIBS)
  121. set(Boost_USE_STATIC_LIBS TRUE)
  122. else(ENABLE_BOOST_STATIC_LIBS)
  123. set(Boost_USE_STATIC_LIBS FALSE)
  124. endif(ENABLE_BOOST_STATIC_LIBS)
  125. find_package(Boost REQUIRED COMPONENTS filesystem system date_time locale)
  126. include_directories(SYSTEM ${Boost_INCLUDE_DIR})
  127. link_directories(${Boost_LIBRARY_DIRS})
  128. find_package(PNG REQUIRED)
  129. if(WIN32)
  130. if(VCPKG_BUILD)
  131. find_package(SDL2 CONFIG REQUIRED)
  132. find_path(SDL2_INCLUDE_DIRS SDL2/SDL.h)
  133. find_path(SDL2IMAGE_INCLUDE_DIRS SDL2/SDL_image.h)
  134. set(SDL2_INCLUDE_DIRS ${SDL2_INCLUDE_DIRS}/SDL2)
  135. set(SDL2IMAGE_INCLUDE_DIRS ${SDL2IMAGE_INCLUDE_DIRS}/SDL2)
  136. find_library(SDL2_LIBRARIES SDL2)
  137. find_library(SDL2IMAGE_LIBRARIES SDL2_image)
  138. find_library(SDL2MAIN_LIBRARIES SDL2main)
  139. message(STATUS "SDL2_INCLUDE_DIR is ${SDL2_INCLUDE_DIRS}")
  140. else(VCPKG_BUILD)
  141. find_path(SDL2_INCLUDE_DIRS NAMES SDL.h PATHS "${DEPENDENCY_FOLDER}/include/SDL2")
  142. find_path(SDL2IMAGE_INCLUDE_DIRS NAMES SDL_image.h PATHS "${DEPENDENCY_FOLDER}/include/SDL2_image")
  143. find_library(SDL2_LIBRARIES NAMES SDL2 PATHS "${DEPENDENCY_FOLDER}/lib")
  144. find_library(SDL2IMAGE_LIBRARIES NAMES SDL2_image PATHS "${DEPENDENCY_FOLDER}/lib")
  145. find_library(SDL2MAIN_LIBRARIES NAMES SDL2main PATHS "${DEPENDENCY_FOLDER}/lib")
  146. find_path(PHYSFS_INCLUDE_DIR NAMES physfs.h PATHS "${DEPENDENCY_FOLDER}/include/physfs")
  147. endif(VCPKG_BUILD)
  148. else(WIN32)
  149. if (CMAKE_SIZEOF_VOID_P EQUAL 4)
  150. # 32-bit
  151. find_library(SDL2_LIBRARIES SDL2)
  152. find_library(SDL2IMAGE_LIBRARIES SDL2_image)
  153. find_path(SDL2_INCLUDE_DIRS SDL2/SDL.h)
  154. find_path(SDL2IMAGE_INCLUDE_DIRS SDL2/SDL_image.h)
  155. set(SDL2_INCLUDE_DIRS ${SDL2_INCLUDE_DIRS}/SDL2)
  156. set(SDL2IMAGE_INCLUDE_DIRS ${SDL2IMAGE_INCLUDE_DIRS}/SDL2)
  157. message(STATUS "SDL LIBS: ${SDL2_LIBRARIES}")
  158. message(STATUS "SDL INCL: ${SDL2_INCLUDE_DIRS}")
  159. else()
  160. # 64-bit
  161. include(FindPkgConfig)
  162. pkg_search_module(SDL2 REQUIRED sdl2>=2.0.1)
  163. pkg_search_module(SDL2IMAGE REQUIRED SDL2_image>=2.0.0)
  164. endif()
  165. endif(WIN32)
  166. set(HAVE_SDL TRUE)
  167. option(IS_SUPERTUX_RELEASE "Build as official SuperTux release" OFF)
  168. option(BUILD_TESTS "Build test cases" OFF)
  169. option(ENABLE_OPENGL "Enable OpenGL support" ON)
  170. option(ENABLE_OPENGLES2 "Enable OpenGLES2 support" OFF)
  171. option(GLBINDING_ENABLED "Use glbinding instead of GLEW" OFF)
  172. option(GLBINDING_DEBUG_OUTPUT "Enable glbinding debug output for each called OpenGL function" OFF)
  173. if(ENABLE_OPENGL)
  174. if(ENABLE_OPENGLES2)
  175. pkg_check_modules(GLESV2 REQUIRED glesv2)
  176. set(HAVE_OPENGL TRUE)
  177. set(OPENGL_INCLUDE_DIR ${GLESV2_INCLUDE_DIRS})
  178. set(OPENGL_LIBRARY ${GLESV2_LIBRARIES})
  179. add_definitions(-DUSE_OPENGLES2)
  180. else()
  181. set(OpenGL_GL_PREFERENCE "LEGACY")
  182. find_package(OpenGL)
  183. if(OPENGL_FOUND)
  184. include_directories(SYSTEM ${OPENGL_INCLUDE_DIR})
  185. set(HAVE_OPENGL TRUE)
  186. endif(OPENGL_FOUND)
  187. if(GLBINDING_ENABLED)
  188. find_package(GLBINDING REQUIRED)
  189. if(GLBINDING_FOUND)
  190. include_directories(SYSTEM ${GLBINDING_INCLUDES})
  191. add_definitions(-DUSE_GLBINDING)
  192. IF (GLBINDING_DEBUG_OUTPUT)
  193. add_definitions(-DUSE_GLBINDING_DEBUG_OUTPUT)
  194. endif()
  195. endif()
  196. else()
  197. find_package(GLEW REQUIRED)
  198. if(GLEW_FOUND)
  199. include_directories(SYSTEM ${GLEW_INCLUDE_DIR})
  200. endif(GLEW_FOUND)
  201. endif()
  202. endif()
  203. endif(ENABLE_OPENGL)
  204. if(VCPKG_BUILD)
  205. find_package(OpenAL CONFIG REQUIRED)
  206. else()
  207. find_package(OpenAL REQUIRED)
  208. endif()
  209. include_directories(SYSTEM ${OPENAL_INCLUDE_DIR})
  210. find_package(OggVorbis REQUIRED)
  211. include_directories(SYSTEM ${VORBIS_INCLUDE_DIR})
  212. include(CheckSymbolExists)
  213. find_package(PhysFS)
  214. if(PHYSFS_LIBRARY)
  215. set(CMAKE_REQUIRED_LIBRARIES ${PHYSFS_LIBRARY})
  216. check_symbol_exists("PHYSFS_getPrefDir" "${PHYSFS_INCLUDE_DIR}/physfs.h" HAVE_PHYSFS_GETPREFDIR)
  217. endif()
  218. if(HAVE_PHYSFS_GETPREFDIR)
  219. set(USE_SYSTEM_PHYSFS ON CACHE BOOL "Use preinstalled physfs (must support getPrefDir)")
  220. else(HAVE_PHYSFS_GETPREFDIR)
  221. set(USE_SYSTEM_PHYSFS OFF CACHE BOOL "Use preinstalled physfs (must support getPrefDir)")
  222. endif(HAVE_PHYSFS_GETPREFDIR)
  223. if(NOT USE_SYSTEM_PHYSFS)
  224. if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/external/physfs/CMakeLists.txt)
  225. message(FATAL_ERROR "physfs submodule is not checked out or ${CMAKE_CURRENT_SOURCE_DIR}/external/physfs/CMakeLists.txt is missing")
  226. endif()
  227. if(WIN32)
  228. set(PHYSFS_BUILD_SHARED TRUE)
  229. set(PHYSFS_BUILD_STATIC FALSE)
  230. else(WIN32)
  231. set(PHYSFS_BUILD_SHARED FALSE)
  232. set(PHYSFS_BUILD_STATIC TRUE)
  233. endif()
  234. set(PHYSFS_PREFIX ${CMAKE_BINARY_DIR}/physfs/)
  235. ExternalProject_Add(physfs
  236. SOURCE_DIR "${CMAKE_SOURCE_DIR}/external/physfs/"
  237. BUILD_BYPRODUCTS
  238. "${PHYSFS_PREFIX}/bin/${CMAKE_SHARED_LIBRARY_PREFIX}physfs${CMAKE_SHARED_LIBRARY_SUFFIX}"
  239. "${PHYSFS_PREFIX}/lib${LIB_SUFFIX}/physfs${CMAKE_LINK_LIBRARY_SUFFIX}"
  240. "${PHYSFS_PREFIX}/lib${LIB_SUFFIX}/${CMAKE_STATIC_LIBRARY_PREFIX}physfs${CMAKE_STATIC_LIBRARY_SUFFIX}"
  241. CMAKE_ARGS
  242. -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
  243. -DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
  244. -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
  245. -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
  246. -DCMAKE_INSTALL_PREFIX=${PHYSFS_PREFIX}
  247. -DLIB_SUFFIX=${LIB_SUFFIX}
  248. -DPHYSFS_BUILD_SHARED=${PHYSFS_BUILD_SHARED}
  249. -DPHYSFS_BUILD_STATIC=${PHYSFS_BUILD_STATIC}
  250. -DPHYSFS_BUILD_TEST=FALSE)
  251. if(WIN32)
  252. add_library(physfs_lib SHARED IMPORTED)
  253. set_target_properties(physfs_lib PROPERTIES IMPORTED_LOCATION "${PHYSFS_PREFIX}/bin/${CMAKE_SHARED_LIBRARY_PREFIX}physfs${CMAKE_SHARED_LIBRARY_SUFFIX}")
  254. set_target_properties(physfs_lib PROPERTIES IMPORTED_IMPLIB "${PHYSFS_PREFIX}/lib${LIB_SUFFIX}/physfs${CMAKE_LINK_LIBRARY_SUFFIX}")
  255. else()
  256. add_library(physfs_lib STATIC IMPORTED)
  257. set_target_properties(physfs_lib PROPERTIES IMPORTED_LOCATION "${PHYSFS_PREFIX}/lib${LIB_SUFFIX}/${CMAKE_STATIC_LIBRARY_PREFIX}physfs${CMAKE_STATIC_LIBRARY_SUFFIX}")
  258. endif()
  259. set(PHYSFS_INCLUDE_DIR "${PHYSFS_PREFIX}/include/")
  260. endif()
  261. include_directories(BEFORE SYSTEM ${PHYSFS_INCLUDE_DIR})
  262. ## The curl headers are in the standard include path in dependencies
  263. ## so it's not required to add them here
  264. find_package(CURL REQUIRED)
  265. if(WIN32 AND VCPKG_BUILD)
  266. list(LENGTH CURL_LIBRARY CURL_LIBRARY_LENGTH)
  267. if (CURL_LIBRARY_LENGTH EQUAL 1)
  268. set(CURL_LIBRARY_DEBUG_LIB ${CURL_LIBRARY})
  269. set(CURL_LIBRARY_RELEASE_LIB ${CURL_LIBRARY_DEBUG_LIB}/../../../lib/libcurl.lib)
  270. get_filename_component(CURL_LIBRARY_RELEASE_LIB ${CURL_LIBRARY_RELEASE_LIB} REALPATH)
  271. unset(CURL_LIBRARY CACHE)
  272. unset(CURL_LIBRARY)
  273. unset(CURL_LIBRARIES CACHE)
  274. unset(CURL_LIBRARIES)
  275. set(CURL_LIBRARY "debug;${CURL_LIBRARY_DEBUG_LIB};optimized;${CURL_LIBRARY_RELEASE_LIB}")
  276. set(CURL_LIBRARIES ${CURL_LIBRARY})
  277. endif()
  278. endif()
  279. if(CURL_FOUND)
  280. include_directories(SYSTEM ${CURL_INCLUDE_DIR})
  281. set(HAVE_LIBCURL TRUE)
  282. endif(CURL_FOUND)
  283. #find_package(ICONV REQUIRED)
  284. #include_directories(SYSTEM ${ICONV_INCLUDE_DIR})
  285. #link_libraries(${ICONV_LIBRARY})
  286. if(EXISTS "${CMAKE_SOURCE_DIR}/.git")
  287. ## Find revision of WC
  288. mark_as_advanced(GIT_EXECUTABLE)
  289. find_program(GIT_EXECUTABLE git)
  290. if(NOT GIT_EXECUTABLE EQUAL "GIT_EXECUTABLE-NOTFOUND")
  291. include(GetGitRevisionDescription)
  292. git_describe(VERSION_STRING_GIT "--tags" "--match" "?[0-9]*.[0-9]*.[0-9]*")
  293. string(REPLACE "v" "" VERSION_LIST ${VERSION_STRING_GIT})
  294. string(REGEX REPLACE "[^\\-]+\\-([0-9]+)\\-.*" "\\1" VERSION_NUMBER_GIT "${VERSION_LIST}")
  295. string(REGEX REPLACE "(-|_|\\.)" ";" VERSION_LIST ";${VERSION_LIST}")
  296. endif()
  297. endif(EXISTS "${CMAKE_SOURCE_DIR}/.git")
  298. get_filename_component(BASEDIR ${CMAKE_SOURCE_DIR} NAME)
  299. if("${VERSION_LIST}" STREQUAL "")
  300. if(${BASEDIR} MATCHES "supertux2-[0-9\\.]*")
  301. string(REGEX REPLACE "(\\.|_|-)" ";" VERSION_LIST ${BASEDIR})
  302. endif()
  303. endif()
  304. file(GLOB ORIG_TGZ ../*.orig.tar.gz)
  305. if("${VERSION_LIST}" STREQUAL "" AND (NOT "${ORIG_TGZ}" STREQUAL ""))
  306. get_filename_component(BASEDIR ${ORIG_TGZ} NAME)
  307. string(REGEX REPLACE "(\\.|_|-)" ";" VERSION_LIST ${BASEDIR})
  308. endif()
  309. list(LENGTH VERSION_LIST VERSION_LIST_SIZE)
  310. if(${VERSION_LIST_SIZE} GREATER 0)
  311. list(GET VERSION_LIST 1 MAJOR_VERSION_GIT)
  312. list(GET VERSION_LIST 2 MINOR_VERSION_GIT)
  313. list(GET VERSION_LIST 3 PATCH_VERSION_GIT)
  314. if("${VERSION_STRING_GIT}" STREQUAL "")
  315. set(VERSION_STRING_GIT "${MAJOR_VERSION_GIT}.${MINOR_VERSION_GIT}.${PATCH_VERSION_GIT}")
  316. endif()
  317. configure_file("${CMAKE_SOURCE_DIR}/version.cmake.in" "${CMAKE_SOURCE_DIR}/version.cmake")
  318. endif()
  319. if(NOT EXISTS "${CMAKE_SOURCE_DIR}/version.cmake")
  320. message( SEND_ERROR "Cound not find GIT or valid version.cmake. Version information will be invalid." )
  321. endif(NOT EXISTS "${CMAKE_SOURCE_DIR}/version.cmake")
  322. include("${CMAKE_SOURCE_DIR}/version.cmake")
  323. set(SUPERTUX_VERSION ${SUPERTUX_VERSION_STRING})
  324. configure_file(version.h.in ${CMAKE_BINARY_DIR}/version.h )
  325. set_source_files_properties(${CMAKE_BINARY_DIR}/version.h
  326. PROPERTIES GENERATED true)
  327. set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/src/supertux/main.cpp
  328. PROPERTIES OBJECT_DEPENDS "${CMAKE_BINARY_DIR}/version.h")
  329. set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/src/supertux/title_screen.cpp
  330. PROPERTIES OBJECT_DEPENDS "${CMAKE_BINARY_DIR}/version.h")
  331. set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/src/addon/addon_manager.cpp
  332. PROPERTIES OBJECT_DEPENDS "${CMAKE_BINARY_DIR}/version.h")
  333. ## Configure doxygen
  334. # Adapted from https://tty1.net/blog/2014/cmake-doxygen_en.html
  335. # add a target to generate API documentation with Doxygen
  336. find_package(Doxygen)
  337. option(BUILD_DOCUMENTATION "Build API documentation using Doxygen" ${DOXYGEN_FOUND})
  338. if(BUILD_DOCUMENTATION)
  339. if(NOT DOXYGEN_FOUND)
  340. message(FATAL_ERROR "Doxygen is needed to build the documentation.")
  341. endif()
  342. set(doxyfile_in ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in)
  343. set(doxyfile ${CMAKE_CURRENT_BINARY_DIR}/docs/Doxyfile)
  344. configure_file(${doxyfile_in} ${doxyfile} @ONLY)
  345. add_custom_target(doc
  346. COMMAND ${DOXYGEN_EXECUTABLE} ${doxyfile}
  347. WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
  348. COMMENT "Generating API documentation with Doxygen"
  349. VERBATIM)
  350. endif()
  351. ## Check platform-dependent build options
  352. include(ConfigureChecks)
  353. # Include altivec wrapper on ppc
  354. if(CMAKE_SYSTEM_PROCESSOR MATCHES "^ppc.*")
  355. include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/ppc)
  356. endif()
  357. ## Also build external/squirrel
  358. if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/external/squirrel/CMakeLists.txt)
  359. message(FATAL_ERROR "squirrel submodule is not checked out or ${CMAKE_CURRENT_SOURCE_DIR}/external/squirrel/CMakeLists.txt is missing")
  360. endif()
  361. set(SQUIRREL_PREFIX ${CMAKE_BINARY_DIR}/squirrel/ex)
  362. ExternalProject_Add(squirrel
  363. SOURCE_DIR "${CMAKE_SOURCE_DIR}/external/squirrel/"
  364. BUILD_BYPRODUCTS
  365. "${SQUIRREL_PREFIX}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}sqstdlib_static${CMAKE_STATIC_LIBRARY_SUFFIX}"
  366. "${SQUIRREL_PREFIX}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}squirrel_static${CMAKE_STATIC_LIBRARY_SUFFIX}"
  367. CMAKE_ARGS
  368. -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
  369. -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
  370. -DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
  371. -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
  372. -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
  373. -DCMAKE_INSTALL_PREFIX=${SQUIRREL_PREFIX}
  374. -DINSTALL_INC_DIR=include
  375. -DCMAKE_POSITION_INDEPENDENT_CODE=ON)
  376. if(WIN32)
  377. add_library(squirrel_lib SHARED IMPORTED)
  378. set_target_properties(squirrel_lib PROPERTIES IMPORTED_LOCATION "${SQUIRREL_PREFIX}/bin/${CMAKE_SHARED_LIBRARY_PREFIX}squirrel${CMAKE_SHARED_LIBRARY_SUFFIX}")
  379. set_target_properties(squirrel_lib PROPERTIES IMPORTED_IMPLIB "${SQUIRREL_PREFIX}/lib/squirrel${CMAKE_LINK_LIBRARY_SUFFIX}")
  380. add_library(sqstdlib_lib SHARED IMPORTED)
  381. set_target_properties(sqstdlib_lib PROPERTIES IMPORTED_LOCATION "${SQUIRREL_PREFIX}/bin/${CMAKE_SHARED_LIBRARY_PREFIX}sqstdlib${CMAKE_SHARED_LIBRARY_SUFFIX}")
  382. set_target_properties(sqstdlib_lib PROPERTIES IMPORTED_IMPLIB "${SQUIRREL_PREFIX}/lib/sqstdlib${CMAKE_LINK_LIBRARY_SUFFIX}")
  383. #For debug run purposes
  384. configure_file("${CMAKE_CURRENT_SOURCE_DIR}/mk/msvc/run_supertux.bat.in" "${PROJECT_BINARY_DIR}/run_supertux.bat")
  385. else()
  386. add_library(squirrel_lib STATIC IMPORTED)
  387. set_target_properties(squirrel_lib PROPERTIES IMPORTED_LOCATION "${SQUIRREL_PREFIX}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}squirrel_static${CMAKE_STATIC_LIBRARY_SUFFIX}")
  388. add_library(sqstdlib_lib STATIC IMPORTED)
  389. set_target_properties(sqstdlib_lib PROPERTIES IMPORTED_LOCATION "${SQUIRREL_PREFIX}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}sqstdlib_static${CMAKE_STATIC_LIBRARY_SUFFIX}")
  390. endif()
  391. include_directories(SYSTEM ${SQUIRREL_PREFIX}/include)
  392. ## Also build external/tinygettext
  393. if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/external/tinygettext/CMakeLists.txt)
  394. message(FATAL_ERROR "tinygettext submodule is not checked out or ${CMAKE_CURRENT_SOURCE_DIR}/external/tinygettext/CMakeLists.txt is missing")
  395. endif()
  396. # Include altivec wrapper on ppc
  397. if(CMAKE_SYSTEM_PROCESSOR MATCHES "^ppc.*")
  398. set(TINYGETTEXT_CXX_FLAGS "-isystem ${CMAKE_CURRENT_SOURCE_DIR}/src/ppc ${CMAKE_CXX_FLAGS}")
  399. else()
  400. set(TINYGETTEXT_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
  401. endif()
  402. set(TINYGETTEXT_PREFIX ${CMAKE_BINARY_DIR}/tinygettext/)
  403. ExternalProject_Add(tinygettext
  404. SOURCE_DIR "${CMAKE_SOURCE_DIR}/external/tinygettext/"
  405. BUILD_BYPRODUCTS "${TINYGETTEXT_PREFIX}/lib${LIB_SUFFIX}/${CMAKE_STATIC_LIBRARY_PREFIX}tinygettext${CMAKE_STATIC_LIBRARY_SUFFIX}"
  406. CMAKE_ARGS
  407. -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
  408. -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
  409. -DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
  410. -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
  411. -DCMAKE_CXX_FLAGS=${TINYGETTEXT_CXX_FLAGS}
  412. -DBUILD_SHARED_LIBS=OFF
  413. -DHAVE_SDL=ON
  414. -DVCPKG_BUILD=${VCPKG_BUILD}
  415. -DCMAKE_INSTALL_PREFIX=${TINYGETTEXT_PREFIX}
  416. -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
  417. -DSDL2_LIBRARIES=${SDL2_LIBRARIES}
  418. -DSDL2_INCLUDE_DIRS=${SDL2_INCLUDE_DIRS}
  419. -DLIB_SUFFIX=${LIB_SUFFIX})
  420. add_library(tinygettext_lib STATIC IMPORTED)
  421. set_target_properties(tinygettext_lib PROPERTIES IMPORTED_LOCATION "${TINYGETTEXT_PREFIX}/lib${LIB_SUFFIX}/${CMAKE_STATIC_LIBRARY_PREFIX}tinygettext${CMAKE_STATIC_LIBRARY_SUFFIX}")
  422. include_directories(SYSTEM ${TINYGETTEXT_PREFIX}/include)
  423. ## external/SDL_ttf with patches
  424. find_package(Freetype REQUIRED)
  425. find_package(RAQM)
  426. set(SDL_TTF_PREFIX ${CMAKE_BINARY_DIR}/SDL_ttf/)
  427. ExternalProject_Add(SDL_ttf
  428. SOURCE_DIR "${CMAKE_SOURCE_DIR}/external/SDL_ttf/"
  429. BUILD_BYPRODUCTS "${SDL_TTF_PREFIX}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}SDL2_ttf${CMAKE_STATIC_LIBRARY_SUFFIX}"
  430. CMAKE_ARGS
  431. -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
  432. -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
  433. -DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
  434. -DCMAKE_INSTALL_PREFIX=${SDL_TTF_PREFIX}
  435. -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
  436. -DWITH_RAQM=${RAQM_FOUND}
  437. -DRAQM_LIBRARIES=${RAQM_LIBRARY}
  438. -DRAQM_INCLUDE_DIR=${RAQM_INCLUDE_DIR}
  439. -DBUILD_SHARED_LIBS=OFF)
  440. add_library(SDL_ttf_lib STATIC IMPORTED)
  441. set_target_properties(SDL_ttf_lib PROPERTIES IMPORTED_LOCATION "${SDL_TTF_PREFIX}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}SDL2_ttf${CMAKE_STATIC_LIBRARY_SUFFIX}")
  442. link_directories(${SDL_TTF_PREFIX}/lib)
  443. include_directories(SYSTEM ${SDL_TTF_PREFIX}/include/SDL2)
  444. if(RAQM_FOUND)
  445. find_package(FriBidi REQUIRED)
  446. find_package(HarfBuzz REQUIRED)
  447. set_target_properties(SDL_ttf_lib PROPERTIES INTERFACE_LINK_LIBRARIES "${RAQM_LIBRARIES}")
  448. endif()
  449. ## Some additional include paths
  450. include_directories(${CMAKE_BINARY_DIR}/)
  451. include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/)
  452. include_directories(SYSTEM ${CMAKE_CURRENT_SOURCE_DIR}/external/findlocale/)
  453. include_directories(SYSTEM ${CMAKE_CURRENT_SOURCE_DIR}/external/obstack/)
  454. include_directories(SYSTEM ${CMAKE_CURRENT_SOURCE_DIR}/external/sexp-cpp/include/)
  455. include_directories(SYSTEM ${CMAKE_CURRENT_SOURCE_DIR}/external/SDL_SavePNG/)
  456. # Discord SDK
  457. # Before removing messages, please check with the community if no one minds that the Discord SDK gets bundled with ST.
  458. # Some privay-concerned users or free software package managers might need an option to compile ST without the Discord integration.
  459. option(ENABLE_DISCORD "Compile the Discord integration" OFF)
  460. if(ENABLE_DISCORD)
  461. message(STATUS "Discord WILL be compiled. To disable Discord, pass -DENABLE_DISCORD=Off")
  462. include_directories(SYSTEM ${CMAKE_CURRENT_SOURCE_DIR}/external/discord-sdk/include)
  463. set(BUILD_EXAMPLES OFF)
  464. add_subdirectory(external/discord-sdk)
  465. else(ENABLE_DISCORD)
  466. message(STATUS "## WARNING : Discord integration will NOT be compiled. To enable Discord, pass -DENABLE_DISCORD=On")
  467. endif(ENABLE_DISCORD)
  468. if(WIN32)
  469. add_definitions(-D_USE_MATH_DEFINES -DNOMINMAX)
  470. add_definitions(-DWIN32)
  471. endif(WIN32)
  472. ## Lint
  473. if(CMAKE_VERSION VERSION_GREATER 3.6)
  474. if (USE_CLANG_TIDY)
  475. find_program(
  476. CLANG_TIDY_EXE
  477. NAMES "clang-tidy"
  478. DOC "Path to clang-tidy executable"
  479. )
  480. if(NOT CLANG_TIDY_EXE)
  481. message(FATAL_ERROR "clang-tidy not found.")
  482. else()
  483. message(STATUS "clang-tidy found: ${CLANG_TIDY_EXE}")
  484. set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_EXE}")
  485. endif()
  486. endif()
  487. endif()
  488. ## Build list of sources for supertux binary
  489. file(GLOB SUPERTUX_SOURCES_C RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} external/obstack/*.c external/findlocale/findlocale.c)
  490. file(GLOB SUPERTUX_SOURCES_CXX RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} src/*/*.cpp src/supertux/menu/*.cpp src/video/sdl/*.cpp src/video/null/*.cpp)
  491. file(GLOB SUPERTUX_RESOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "${PROJECT_BINARY_DIR}/tmp/*.rc")
  492. if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/external/sexp-cpp/CMakeLists.txt)
  493. message(FATAL_ERROR "sexp-cpp submodule is not checked out or ${CMAKE_CURRENT_SOURCE_DIR}/external/sexp-cpp/CMakeLists.txt is missing")
  494. endif()
  495. file(GLOB SEXP_SOURCES_CXX RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} external/sexp-cpp/src/*.cpp)
  496. add_library(sexp STATIC ${SEXP_SOURCES_CXX})
  497. target_compile_definitions(sexp PRIVATE -DSEXP_USE_LOCALE)
  498. file(GLOB SAVEPNG_SOURCES_CXX RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} external/SDL_SavePNG/savepng.c)
  499. add_library(savepng STATIC ${SAVEPNG_SOURCES_CXX})
  500. target_include_directories(savepng SYSTEM PUBLIC ${SDL2_INCLUDE_DIRS} ${PNG_INCLUDE_DIRS})
  501. target_link_libraries(savepng PUBLIC ${PNG_LIBRARIES})
  502. if(HAVE_OPENGL)
  503. file(GLOB SUPERTUX_OPENGL_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} src/video/gl/*.cpp)
  504. set(SUPERTUX_SOURCES_CXX ${SUPERTUX_SOURCES_CXX} ${SUPERTUX_OPENGL_SOURCES})
  505. endif(HAVE_OPENGL)
  506. ## Sort source lists to have deterministic linking order
  507. list(SORT SUPERTUX_SOURCES_C)
  508. list(SORT SUPERTUX_SOURCES_CXX)
  509. list(SORT SUPERTUX_RESOURCES)
  510. if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/src/scripting/wrapper.cpp)
  511. set(SUPERTUX_SOURCES_CXX ${SUPERTUX_SOURCES_CXX} ${CMAKE_CURRENT_SOURCE_DIR}/src/scripting/wrapper.cpp)
  512. endif(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/src/scripting/wrapper.cpp)
  513. ## Compile everything at once (roughly equivalent to cat *.cpp | gcc)
  514. option(COMPILE_AMALGATION "Compile all the files together at once (experimental)" OFF)
  515. if(COMPILE_AMALGATION)
  516. file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/amalgation.cpp "// Includes all source files of the project\n")
  517. foreach(ST_FILE ${SUPERTUX_SOURCES_CXX})
  518. file(RELATIVE_PATH CXX_FILE ${CMAKE_CURRENT_SOURCE_DIR}/src "${CMAKE_CURRENT_SOURCE_DIR}/${ST_FILE}")
  519. file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/amalgation.cpp "#include \"${CXX_FILE}\"\n")
  520. endforeach(ST_FILE)
  521. ## Build instead of CXX sources
  522. set(SUPERTUX_SOURCES_CXX ${CMAKE_CURRENT_BINARY_DIR}/amalgation.cpp)
  523. else(COMPILE_AMALGATION)
  524. if(EXISTS ${CMAKE_CURRENT_BINARY_DIR}/amalgation.cpp)
  525. file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/amalgation.cpp)
  526. endif(EXISTS ${CMAKE_CURRENT_BINARY_DIR}/amalgation.cpp)
  527. endif(COMPILE_AMALGATION)
  528. ## Debug options
  529. option(WERROR "Stop on first compiler warning" OFF)
  530. option(WARNINGS "Enable long list of warnings for compiler to check" OFF)
  531. option(USE_CLANG_TIDY "Run clang-tidy" OFF)
  532. if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  533. set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g" CACHE STRING "Debug flags")
  534. set(CMAKE_C_FLAGS_DEBUG "-O0 -g" CACHE STRING "Debug flags")
  535. set(CMAKE_CXX_FLAGS_PROFILE "-pg" CACHE STRING "Profile flags")
  536. set(CMAKE_C_FLAGS_PROFILE "-pg" CACHE STRING "Profile flags")
  537. set(CMAKE_LD_FLAGS_PROFILE "-lgmon" CACHE STRING "Profile flags")
  538. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-unused-parameter -funit-at-a-time")
  539. if(WERROR)
  540. add_definitions(-Werror)
  541. else(WERROR)
  542. remove_definitions(-Werror)
  543. endif(WERROR)
  544. if(WARNINGS)
  545. # temporarily disabled:
  546. # -Wsign-conversion -Wfloat-equal -Wundef -Wswitch-default
  547. # -Wswitch-enum -Wsign-promo -Wcast-qual -Woverloaded-virtual -Wmissing-format-attribute
  548. # -Wpadded -Wabi -Winline -Wunsafe-loop-optimizations -Wstrict-overflow=5
  549. # fails on MinGW:
  550. # -ansi
  551. if(CMAKE_COMPILER_IS_GNUCXX)
  552. string(CONCAT SUPERTUX2_EXTRA_WARNING_FLAGS
  553. "-fdiagnostics-show-option "
  554. "-pedantic "
  555. "-Wno-long-long "
  556. "-Wcast-align "
  557. "-Wdisabled-optimization "
  558. "-Winit-self -Winvalid-pch "
  559. "-Wmissing-include-dirs "
  560. "-Wmissing-noreturn "
  561. "-Wpacked -Wredundant-decls "
  562. "-Wformat=2 "
  563. "-Weffc++ "
  564. "-Wctor-dtor-privacy "
  565. "-Wno-unused-parameter "
  566. "-Wshadow "
  567. "-Wnon-virtual-dtor "
  568. "-Wcast-qual "
  569. "-Wold-style-cast "
  570. "-Wzero-as-null-pointer-constant "
  571. "-Wconversion "
  572. "-Wlogical-op "
  573. "-Wstrict-null-sentinel "
  574. "-Wsuggest-override "
  575. )
  576. if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 8)
  577. string(CONCAT SUPERTUX2_EXTRA_WARNING_FLAGS
  578. "${SUPERTUX2_EXTRA_WARNING_FLAGS} "
  579. "-Wint-in-bool-context "
  580. )
  581. endif()
  582. if(Boost_VERSION LESS 106500)
  583. string(CONCAT SUPERTUX2_EXTRA_WARNING_FLAGS
  584. "${SUPERTUX2_EXTRA_WARNING_FLAGS} "
  585. "-Wno-implicit-fallthrough ")
  586. endif()
  587. elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  588. string(CONCAT SUPERTUX2_EXTRA_WARNING_FLAGS
  589. "${SUPERTUX2_EXTRA_WARNING_FLAGS} "
  590. "-Weverything "
  591. # flags that we deliberately ignore
  592. "-Wno-c++98-compat "
  593. "-Wno-c++98-compat-pedantic "
  594. "-Wno-float-equal "
  595. "-Wno-padded "
  596. "-Wno-weak-vtables "
  597. "-Wno-disabled-macro-expansion "
  598. "-Wno-documentation "
  599. "-Wno-reserved-id-macro "
  600. "-Wno-sign-conversion "
  601. # warnings that should probably be fixed in code
  602. "-Wno-documentation-unknown-command "
  603. "-Wno-inconsistent-missing-destructor-override "
  604. "-Wno-deprecated-dynamic-exception-spec "
  605. "-Wno-deprecated "
  606. "-Wno-switch-enum "
  607. "-Wno-covered-switch-default "
  608. "-Wno-exit-time-destructors "
  609. "-Wno-global-constructors "
  610. "-Wno-duplicate-enum "
  611. "-Wno-unreachable-code "
  612. )
  613. # This snipped adapted from AOMediaCodec cmakefile
  614. # The detection of cross compilation by -Wpoison-system-directories has false positives on macOS because
  615. # --sysroot is implicitly added. Turn the warning off.
  616. if(NOT DEFINED HAVE_POISON_SYSTEM_DIRECTORIES_WARNING)
  617. check_cxx_compiler_flag(-Wpoison-system-directories HAVE_POISON_SYSTEM_DIRECTORIES_WARNING)
  618. endif()
  619. if(HAVE_POISON_SYSTEM_DIRECTORIES_WARNING)
  620. string(CONCAT SUPERTUX2_EXTRA_WARNING_FLAGS
  621. "${SUPERTUX2_EXTRA_WARNING_FLAGS} "
  622. "-Wno-poison-system-directories ")
  623. endif()
  624. endif()
  625. endif(WARNINGS)
  626. endif()
  627. ## If xgettext is available, generate messages.pot for sources
  628. option(GENERATE_MESSAGESPOT "Generate messages.pot files" OFF)
  629. if(GENERATE_MESSAGESPOT)
  630. mark_as_advanced(
  631. XGETTEXT_EXECUTABLE
  632. )
  633. find_program(XGETTEXT_EXECUTABLE xgettext)
  634. if(NOT XGETTEXT_EXECUTABLE)
  635. message(STATUS "Warning: xgettext not found - will not update messages.pot")
  636. else(NOT XGETTEXT_EXECUTABLE)
  637. message(STATUS "Found xgettext: ${XGETTEXT_EXECUTABLE}")
  638. set(MESSAGES_POT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/data/locale/messages.pot)
  639. add_custom_command(
  640. OUTPUT ${MESSAGES_POT_FILE}
  641. COMMAND ${XGETTEXT_EXECUTABLE}
  642. ARGS --keyword=_ --language=C++ --output=${MESSAGES_POT_FILE} ${SUPERTUX_SOURCES_CXX}
  643. DEPENDS ${SUPERTUX_SOURCES_CXX}
  644. WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
  645. COMMENT "Generating POT file ${MESSAGES_POT_FILE}"
  646. )
  647. list(APPEND MESSAGES_POT_FILES ${MESSAGES_POT_FILE})
  648. file(GLOB SUPERTUX_LEVEL_DIRS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} data/levels/*)
  649. foreach(SUPERTUX_LEVEL_DIR ${SUPERTUX_LEVEL_DIRS})
  650. file(GLOB SUPERTUX_LEVELS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${SUPERTUX_LEVEL_DIR}/*.stl ${SUPERTUX_LEVEL_DIR}/*.stwm ${SUPERTUX_LEVEL_DIR}/*.txt)
  651. ## Do not add target if SUPERTUX_LEVELS is empty. This is needed for cmake <=2.4
  652. if(SUPERTUX_LEVELS)
  653. set(MESSAGES_POT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/${SUPERTUX_LEVEL_DIR}/messages.pot)
  654. add_custom_command(
  655. OUTPUT ${MESSAGES_POT_FILE}
  656. COMMAND ${XGETTEXT_EXECUTABLE}
  657. ARGS --keyword="_:1" --language=Lisp --force-po --sort-by-file "--output=${MESSAGES_POT_FILE}" ${SUPERTUX_LEVELS}
  658. DEPENDS ${SUPERTUX_LEVELS}
  659. WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
  660. COMMENT "Generating POT file ${MESSAGES_POT_FILE}"
  661. )
  662. list(APPEND MESSAGES_POT_FILES ${MESSAGES_POT_FILE})
  663. endif(SUPERTUX_LEVELS)
  664. endforeach(SUPERTUX_LEVEL_DIR)
  665. add_custom_target(
  666. supertux2-messages ALL
  667. DEPENDS ${MESSAGES_POT_FILES}
  668. )
  669. endif(NOT XGETTEXT_EXECUTABLE)
  670. endif(GENERATE_MESSAGESPOT)
  671. ## Some additional compiler switches
  672. if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  673. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-strict-aliasing")
  674. endif()
  675. if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
  676. add_definitions(-DMACOSX)
  677. endif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
  678. ## On Windows, add an icon
  679. if(WIN32)
  680. # set(SUPERTUX_SOURCES_C ${SUPERTUX_SOURCES_C} ${CMAKE_CURRENT_SOURCE_DIR}/data/images/engine/icons/supertux.rc)
  681. if(MINGW)
  682. add_custom_command(
  683. OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/supertux_rc.o
  684. COMMAND ${CMAKE_RC_COMPILER} -I${CMAKE_CURRENT_SOURCE_DIR}/data/images/engine/icons -i${CMAKE_CURRENT_SOURCE_DIR}/data/images/engine/icons/supertux.rc -o ${CMAKE_CURRENT_BINARY_DIR}/supertux_rc.o)
  685. set(SUPERTUX_SOURCES_C ${SUPERTUX_SOURCES_C} ${CMAKE_CURRENT_BINARY_DIR}/supertux_rc.o)
  686. endif(MINGW)
  687. endif(WIN32)
  688. ## Build miniswig and generate miniswig wrapper
  689. option(GENERATE_WRAPPER "Build miniswig and generate the wrapper" OFF)
  690. if(GENERATE_WRAPPER)
  691. add_subdirectory(tools/miniswig)
  692. add_custom_command(
  693. OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/src/scripting/wrapper.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/scripting/wrapper.hpp
  694. COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && ${CMAKE_CXX_COMPILER}
  695. ARGS -x "c++" -E -CC -DSCRIPTING_API src/scripting/wrapper.interface.hpp -o ${CMAKE_CURRENT_BINARY_DIR}/miniswig.tmp -I${CMAKE_CURRENT_SOURCE_DIR}/src
  696. COMMAND tools/miniswig/miniswig
  697. ARGS --input miniswig.tmp --output-cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/scripting/wrapper.cpp --output-hpp ${CMAKE_CURRENT_SOURCE_DIR}/src/scripting/wrapper.hpp --module supertux --select-namespace scripting
  698. DEPENDS tools/miniswig/miniswig
  699. IMPLICIT_DEPENDS CXX ${CMAKE_CURRENT_SOURCE_DIR}/src/scripting/wrapper.interface.hpp
  700. )
  701. if(USE_CLANG_TIDY)
  702. set_target_properties(miniswig PROPERTIES CXX_CLANG_TIDY "")
  703. endif()
  704. endif(GENERATE_WRAPPER)
  705. ## Generate supertux executable in the right place
  706. #set(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_SOURCE_DIR})
  707. set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR})
  708. ## Add target for supertux binary
  709. add_library(supertux2_c OBJECT ${SUPERTUX_SOURCES_C})
  710. add_library(supertux2_lib STATIC ${CMAKE_BINARY_DIR}/version.h ${SUPERTUX_SOURCES_CXX} ${SUPERTUX_RESOURCES} $<TARGET_OBJECTS:supertux2_c>)
  711. if(WIN32)
  712. add_executable(supertux2 WIN32 src/main.cpp ${CMAKE_CURRENT_SOURCE_DIR}/data/images/engine/icons/supertux.rc)
  713. target_link_libraries(supertux2 ${SDL2MAIN_LIBRARIES})
  714. else()
  715. add_executable(supertux2 src/main.cpp)
  716. endif(WIN32)
  717. target_link_libraries(supertux2 supertux2_lib Boost::filesystem Boost::locale)
  718. set_target_properties(supertux2_lib PROPERTIES OUTPUT_NAME supertux2_lib)
  719. set_target_properties(supertux2_lib PROPERTIES COMPILE_FLAGS "${SUPERTUX2_EXTRA_WARNING_FLAGS}")
  720. if(WIN32 AND NOT VCPKG_BUILD)
  721. ## Copy dlls on windows
  722. add_custom_command(TARGET supertux2_lib POST_BUILD
  723. COMMAND ${CMAKE_COMMAND} -E copy_directory
  724. "${DEPENDENCY_FOLDER}/dll"
  725. $<TARGET_FILE_DIR:supertux2_lib>)
  726. endif(WIN32 AND NOT VCPKG_BUILD)
  727. ## Link supertux binary with squirrel and other libraries
  728. add_dependencies(supertux2_lib tinygettext)
  729. add_dependencies(supertux2_lib squirrel)
  730. add_dependencies(supertux2_lib SDL_ttf)
  731. if(VCPKG_BUILD)
  732. target_include_directories(supertux2_lib PUBLIC ${CURL_INCLUDE_DIRS})
  733. endif()
  734. target_include_directories(supertux2_lib SYSTEM PUBLIC ${SDL2_INCLUDE_DIRS})
  735. target_include_directories(supertux2_lib SYSTEM PUBLIC ${SDL2IMAGE_INCLUDE_DIRS})
  736. target_include_directories(supertux2_lib SYSTEM PUBLIC ${SDL_TTF_PREFIX}/include/SDL2)
  737. if(VCPKG_BUILD)
  738. target_link_libraries(supertux2_lib PRIVATE SDL2::SDL2main SDL2::SDL2 SDL2_image)
  739. else()
  740. target_link_libraries(supertux2_lib PUBLIC ${SDL2_LIBRARIES})
  741. target_link_libraries(supertux2_lib PUBLIC ${SDL2IMAGE_LIBRARIES})
  742. endif()
  743. target_link_libraries(supertux2_lib PUBLIC SDL_ttf_lib)
  744. target_link_libraries(supertux2_lib PUBLIC ${FREETYPE_LIBRARIES})
  745. if(RAQM_FOUND)
  746. target_link_libraries(supertux2_lib PUBLIC ${HARFBUZZ_LIBRARY} ${FRIBIDI_LIBRARY} ${RAQM_LIBRARY})
  747. endif()
  748. target_link_libraries(supertux2_lib PUBLIC squirrel_lib)
  749. target_link_libraries(supertux2_lib PUBLIC sqstdlib_lib)
  750. target_link_libraries(supertux2_lib PUBLIC tinygettext_lib)
  751. target_link_libraries(supertux2_lib PUBLIC sexp)
  752. target_link_libraries(supertux2_lib PUBLIC savepng)
  753. if(ENABLE_DISCORD)
  754. target_link_libraries(supertux2_lib PUBLIC discord-rpc)
  755. endif(ENABLE_DISCORD)
  756. if(VCPKG_BUILD)
  757. target_link_libraries(supertux2_lib PUBLIC OpenAL::OpenAL)
  758. else()
  759. target_link_libraries(supertux2_lib PUBLIC ${OPENAL_LIBRARY})
  760. endif()
  761. target_link_libraries(supertux2_lib PUBLIC ${OGGVORBIS_LIBRARIES})
  762. target_link_libraries(supertux2_lib PUBLIC ${Boost_LIBRARIES})
  763. if(USE_SYSTEM_PHYSFS)
  764. target_link_libraries(supertux2_lib PUBLIC ${PHYSFS_LIBRARY})
  765. else()
  766. add_dependencies(supertux2_lib physfs)
  767. target_link_libraries(supertux2_lib PUBLIC physfs_lib)
  768. if(APPLE)
  769. target_link_libraries(supertux2_lib PUBLIC "-framework CoreFoundation")
  770. target_link_libraries(supertux2_lib PUBLIC "-framework Foundation")
  771. target_link_libraries(supertux2_lib PUBLIC "-framework IOKit")
  772. endif()
  773. endif()
  774. if(HAVE_OPENGL)
  775. target_link_libraries(supertux2_lib PUBLIC ${OPENGL_LIBRARY})
  776. if(NOT ENABLE_OPENGLES2)
  777. if(GLBINDING_FOUND)
  778. target_link_libraries(supertux2_lib PUBLIC ${GLBINDING_LIBRARIES})
  779. else()
  780. target_link_libraries(supertux2_lib PUBLIC GLEW::GLEW)
  781. endif()
  782. endif()
  783. endif(HAVE_OPENGL)
  784. if(HAVE_LIBCURL)
  785. if(VCPKG_BUILD)
  786. target_link_libraries(supertux2_lib PUBLIC ${CURL_LIBRARIES})
  787. else()
  788. target_link_libraries(supertux2_lib PUBLIC ${CURL_LIBRARY})
  789. endif()
  790. endif(HAVE_LIBCURL)
  791. if(BUILD_TESTS)
  792. find_package(Threads REQUIRED)
  793. # build gtest
  794. # ${CMAKE_CURRENT_SOURCE_DIR} in include_directories is needed to generate -isystem instead of -I flags
  795. add_library(gtest_main STATIC ${CMAKE_CURRENT_SOURCE_DIR}/external/googletest/googletest/src/gtest_main.cc)
  796. target_include_directories(gtest_main SYSTEM PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/external/googletest/googletest/include/)
  797. add_library(gtest STATIC ${CMAKE_CURRENT_SOURCE_DIR}/external/googletest/googletest/src/gtest-all.cc)
  798. target_include_directories(gtest SYSTEM PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/external/googletest/googletest/)
  799. target_include_directories(gtest SYSTEM PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/external/googletest/googletest/include/)
  800. # build SuperTux tests
  801. file(GLOB TEST_SUPERTUX_SOURCES tests/*.cpp)
  802. add_executable(test_supertux2 ${TEST_SUPERTUX_SOURCES})
  803. target_compile_options(test_supertux2 PRIVATE ${WARNINGS_CXX_FLAGS})
  804. target_link_libraries(test_supertux2
  805. gtest gtest_main
  806. supertux2_lib
  807. ${CMAKE_THREAD_LIBS_INIT})
  808. # add 'make test' target, use 'make test ARGS="-V"' or 'ctest -V' for verbose
  809. enable_testing()
  810. add_test(NAME test_supertux2
  811. WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
  812. COMMAND test_supertux2)
  813. endif()
  814. ## Install stuff
  815. option(DISABLE_CPACK_BUNDLING "Build an .app bundle without CPack" OFF)
  816. if(WIN32 AND NOT UNIX)
  817. set(INSTALL_SUBDIR_BIN "bin" CACHE STRING "Installation subdir for binaries")
  818. set(INSTALL_SUBDIR_SHARE "data" CACHE STRING "Installation subdir for data")
  819. set(INSTALL_SUBDIR_DOC "doc" CACHE STRING "Installation subdir for docs")
  820. if(VCPKG_BUILD)
  821. install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/\${CMAKE_INSTALL_CONFIG_NAME}/" DESTINATION ${INSTALL_SUBDIR_BIN} FILES_MATCHING PATTERN "*.dll")
  822. else()
  823. install(FILES ${DLLS} DESTINATION ${INSTALL_SUBDIR_BIN})
  824. endif()
  825. install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/images/engine/icons/supertux.png ${CMAKE_CURRENT_SOURCE_DIR}/data/images/engine/icons/supertux.ico DESTINATION ".")
  826. option(PACKAGE_VCREDIST "Package the VCREDIST libraries with the program" OFF)
  827. if(PACKAGE_VCREDIST)
  828. set(CMAKE_INSTALL_UCRT_LIBRARIES true)
  829. include(InstallRequiredSystemLibraries)
  830. endif()
  831. else(WIN32 AND NOT UNIX)
  832. if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin" AND DISABLE_CPACK_BUNDLING)
  833. set(INFOPLIST_CFBUNDLEEXECUTABLE "supertux2")
  834. set(INSTALL_SUBDIR_BIN "SuperTux.app/Contents/MacOS" CACHE STRING "Installation subdir for binaries")
  835. set(INSTALL_SUBDIR_SHARE "SuperTux.app/Contents/Resources/data" CACHE STRING "Installation subdir for data")
  836. set(INSTALL_SUBDIR_DOC "SuperTux.app/Contents/Resources" CACHE STRING "Installation subdir for docs")
  837. configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tools/darwin/info.plist.in ${CMAKE_BINARY_DIR}/tools/darwin/info.plist)
  838. install(FILES ${CMAKE_BINARY_DIR}/tools/darwin/info.plist DESTINATION "SuperTux.app/Contents/")
  839. install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/tools/darwin/receipt DESTINATION "SuperTux.app/Contents/_MASReceipt/")
  840. install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/images/engine/icons/supertux.png ${CMAKE_CURRENT_SOURCE_DIR}/data/images/engine/icons/supertux.icns DESTINATION "SuperTux.app/Contents/Resources/")
  841. else(${CMAKE_SYSTEM_NAME} MATCHES "Darwin" AND DISABLE_CPACK_BUNDLING)
  842. set(INSTALL_SUBDIR_BIN "games" CACHE STRING "Installation subdir for binaries")
  843. set(INSTALL_SUBDIR_SHARE "share/games/supertux2" CACHE STRING "Installation subdir for data")
  844. set(INSTALL_SUBDIR_DOC "share/doc/supertux2" CACHE STRING "Installation subdir for docs")
  845. if(UBUNTU_TOUCH)
  846. set(LINUX_DESKTOP_ICON "assets/supertux-256x256.png")
  847. # FIXME: The "install" folder is a folder managed by Clickable and shouldn't be hardcoded here
  848. configure_file(${CMAKE_CURRENT_SOURCE_DIR}/supertux2.desktop.in "install/supertux2.desktop")
  849. install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/mk/ubports/supertux2.apparmor DESTINATION ".")
  850. configure_file(${CMAKE_CURRENT_SOURCE_DIR}/mk/ubports/manifest.json.in ${CMAKE_CURRENT_BINARY_DIR}/install/manifest.json)
  851. set(APPS "\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/supertux2")
  852. install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/images/engine/icons/supertux-256x256.png DESTINATION "assets")
  853. else(UBUNTU_TOUCH)
  854. set(LINUX_DESKTOP_ICON "supertux2")
  855. configure_file(${CMAKE_CURRENT_SOURCE_DIR}/supertux2.desktop.in "supertux2.desktop")
  856. install(FILES ${CMAKE_BINARY_DIR}/supertux2.desktop DESTINATION "share/applications")
  857. set(APPS "\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${INSTALL_SUBDIR_BIN}/supertux2")
  858. install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/images/engine/icons/supertux.png ${CMAKE_CURRENT_SOURCE_DIR}/data/images/engine/icons/supertux.xpm DESTINATION "share/pixmaps/")
  859. endif(UBUNTU_TOUCH)
  860. install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/supertux2.svg DESTINATION "share/icons/hicolor/scalable/apps")
  861. endif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin" AND DISABLE_CPACK_BUNDLING)
  862. endif(WIN32 AND NOT UNIX)
  863. if(UBUNTU_TOUCH)
  864. install(TARGETS supertux2 DESTINATION ".")
  865. else(UBUNTU_TOUCH)
  866. install(TARGETS supertux2 DESTINATION ${INSTALL_SUBDIR_BIN})
  867. endif(UBUNTU_TOUCH)
  868. if(WIN32)
  869. get_property(SQUIRREL_LIB_PATH TARGET squirrel_lib PROPERTY IMPORTED_LOCATION)
  870. get_property(SQSTDLIB_LIB_PATH TARGET sqstdlib_lib PROPERTY IMPORTED_LOCATION)
  871. get_property(PHYSFS_LIB_PATH TARGET physfs_lib PROPERTY IMPORTED_LOCATION)
  872. install(FILES ${SQUIRREL_LIB_PATH} ${SQSTDLIB_LIB_PATH} ${PHYSFS_LIB_PATH} DESTINATION ${INSTALL_SUBDIR_BIN})
  873. endif()
  874. install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/INSTALL.md ${CMAKE_CURRENT_SOURCE_DIR}/README.md ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.txt ${CMAKE_CURRENT_SOURCE_DIR}/NEWS.md DESTINATION ${INSTALL_SUBDIR_DOC})
  875. install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/credits.stxt DESTINATION ${INSTALL_SUBDIR_SHARE})
  876. install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/supertux2.appdata.xml DESTINATION "share/metainfo" )
  877. install(DIRECTORY
  878. ${CMAKE_CURRENT_SOURCE_DIR}/data/images
  879. ${CMAKE_CURRENT_SOURCE_DIR}/data/fonts
  880. ${CMAKE_CURRENT_SOURCE_DIR}/data/music
  881. ${CMAKE_CURRENT_SOURCE_DIR}/data/particles
  882. ${CMAKE_CURRENT_SOURCE_DIR}/data/scripts
  883. ${CMAKE_CURRENT_SOURCE_DIR}/data/shader
  884. ${CMAKE_CURRENT_SOURCE_DIR}/data/speech
  885. ${CMAKE_CURRENT_SOURCE_DIR}/data/sounds
  886. ${CMAKE_CURRENT_SOURCE_DIR}/data/locale
  887. DESTINATION ${INSTALL_SUBDIR_SHARE})
  888. if(CMAKE_BUILD_TYPE MATCHES "Release|RelWithDebInfo")
  889. install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/data/levels
  890. DESTINATION ${INSTALL_SUBDIR_SHARE}
  891. PATTERN "data/levels/test" EXCLUDE
  892. PATTERN "data/levels/test_old" EXCLUDE
  893. PATTERN "data/levels/incubator" EXCLUDE
  894. PATTERN "data/levels/misc/menu.stl.in" EXCLUDE)
  895. else()
  896. install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/data/levels
  897. DESTINATION ${INSTALL_SUBDIR_SHARE}
  898. PATTERN "data/levels/misc/menu.stl.in" EXCLUDE)
  899. endif()
  900. install(FILES "${CMAKE_BINARY_DIR}/data/levels/misc/menu.stl" DESTINATION "${INSTALL_SUBDIR_SHARE}/levels/misc")
  901. ## Create config.h now that INSTALL_SUBDIR_* have been set.
  902. configure_file(config.h.cmake ${CMAKE_BINARY_DIR}/config.h )
  903. ## Configure main menu logo
  904. if(("${SUPERTUX_VERSION_STRING}" MATCHES "^v[0-9]+\\.[0-9]+\\.[0-9]+$") OR IS_SUPERTUX_RELEASE)
  905. set(LOGO_FILE "logo_final.sprite")
  906. else()
  907. set(LOGO_FILE "logo.sprite")
  908. endif()
  909. configure_file(data/levels/misc/menu.stl.in ${CMAKE_BINARY_DIR}/data/levels/misc/menu.stl )
  910. ## CPack/Installation-specific stuff
  911. include(InstallRequiredSystemLibraries)
  912. set(DIRS ${Boost_LIBRARY_DIRS} ${CMAKE_CURRENT_BINARY_DIR}/external/squirrel ${CMAKE_CURRENT_BINARY_DIR}/external/tinygettext)
  913. if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin" AND NOT DISABLE_CPACK_BUNDLING)
  914. set(INFOPLIST_CFBUNDLEEXECUTABLE "SuperTux")
  915. find_package(png)
  916. foreach (_file ${PNG_LIBRARIES})
  917. get_filename_component(_resolvedFile "${_file}" REALPATH)
  918. get_filename_component(_name "${_file}" NAME)
  919. install(FILES ${_resolvedFile} DESTINATION "MacOS" RENAME ${_name})
  920. endforeach()
  921. find_package(jpeg)
  922. foreach (_file ${JPEG_LIBRARIES})
  923. get_filename_component(_resolvedFile "${_file}" REALPATH)
  924. get_filename_component(_name "${_file}" NAME)
  925. install(FILES ${_resolvedFile} DESTINATION "MacOS" RENAME ${_name})
  926. endforeach()
  927. install(CODE "
  928. if(\"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/\" MATCHES \".*\\\\.app.*\")
  929. include(BundleUtilities)
  930. fixup_bundle(\"${APPS}\" \"\" \"${DIRS}\")
  931. endif()
  932. ")
  933. configure_file("${CMAKE_CURRENT_SOURCE_DIR}/tools/darwin/info.plist.in" "${CMAKE_BINARY_DIR}/tools/darwin/info.plist")
  934. set(CPACK_BUNDLE_NAME "SuperTux")
  935. set(CPACK_BUNDLE_PLIST "${CMAKE_BINARY_DIR}/tools/darwin/info.plist")
  936. set(CPACK_BUNDLE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/data/images/engine/icons/supertux.icns")
  937. set(CPACK_BUNDLE_STARTUP_COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/tools/darwin/startup.sh")
  938. set(CPACK_DMG_VOLUME_NAME "SuperTux ${SUPERTUX_VERSION_STRING}")
  939. set(CPACK_DMG_DS_STORE_SETUP_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/tools/darwin/dsstore_setup.scpt")
  940. set(CPACK_DMG_BACKGROUND_IMAGE "${CMAKE_CURRENT_SOURCE_DIR}/tools/darwin/background.png")
  941. endif()
  942. set(CPACK_PACKAGE_NAME "SuperTux")
  943. set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Jump'n'Run Game featuring Tux")
  944. set(CPACK_PACKAGE_VENDOR "SuperTux Devel Team")
  945. set(CPACK_PACKAGE_CONTACT "SuperTux Devel Team <supertux-devel@lists.lethargik.org>")
  946. set(CPACK_SOURCE_IGNORE_FILES "/\\\\.git/;${CMAKE_BINARY_DIR};/\\\\..*")
  947. set(CPACK_DEBIAN_PACKAGE_NAME "supertux2")
  948. set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.5), libgcc1 (>= 1:4.1), libgl1-mesa-glx | libgl1, libogg0 (>= 1.1.3), libopenal0a, libphysfs-1.0-0, libsdl-image1.2 (>= 1.2.5), libsdl1.2debian (>= 1.2.10-1), libstdc++6 (>= 4.1.2), libvorbis0a (>= 1.1.2), libvorbisfile3 (>= 1.1.2), libcurl3 (>= 7.16)")
  949. set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "Classic 2D jump 'n run sidescroller with Tux\n SuperTux is a classic 2D jump 'n run sidescroller game in a similar\n style like the original SuperMario games. This release of SuperTux\n features 9 enemies, 26 playable levels, software and OpenGL rendering\n modes, configurable joystick and keyboard input, new music and\n completely redone graphics.\n .\n This is a development snapshot of SuperTux. It may suffer from\n critical bugs and has not been fully tested. \n .\n Homepage: http://supertux.lethargik.org/")
  950. set(CPACK_DEBIAN_PACKAGE_SECTION "games")
  951. set(CPACK_RPM_PACKAGE_NAME "supertux2")
  952. set(CPACK_RPM_PACKAGE_DESCRIPTION "Classic 2D jump 'n run sidescroller with Tux\n SuperTux is a classic 2D jump 'n run sidescroller game in a similar\n style like the original SuperMario games. This release of SuperTux\n features 9 enemies, 26 playable levels, software and OpenGL rendering\n modes, configurable joystick and keyboard input, new music and\n completely redone graphics.\n .\n This is a development snapshot of SuperTux. It may suffer from\n critical bugs and has not been fully tested. \n .\n Homepage: http://supertux.lethargik.org/")
  953. set(CPACK_RPM_PACKAGE_LICENSE "GNU General Public License (GPL)")
  954. set(CPACK_RPM_PACKAGE_GROUP "Amusements/Games/Action/Arcade")
  955. set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
  956. set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.txt")
  957. set(CPACK_PACKAGE_VERSION_MAJOR ${SUPERTUX_VERSION_MAJOR})
  958. set(CPACK_PACKAGE_VERSION_MINOR ${SUPERTUX_VERSION_MINOR})
  959. if(SUPERTUX_VERSION_TWEAK)
  960. set(CPACK_PACKAGE_VERSION_PATCH "${SUPERTUX_VERSION_PATCH}.${SUPERTUX_VERSION_TWEAK}")
  961. else()
  962. set(CPACK_PACKAGE_VERSION_PATCH ${SUPERTUX_VERSION_PATCH})
  963. endif(SUPERTUX_VERSION_TWEAK)
  964. set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${SUPERTUX_VERSION_STRING}-${SUPERTUX_SYSTEM_NAME}")
  965. set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${SUPERTUX_VERSION_STRING}-Source")
  966. set(CPACK_PACKAGE_INSTALL_DIRECTORY "SuperTux")
  967. set(CPACK_PACKAGE_EXECUTABLES "supertux2" "SuperTux")
  968. if(WIN32 AND NOT UNIX)
  969. set(CPACK_NSIS_INSTALLED_ICON_NAME "supertux2")
  970. set(CPACK_NSIS_DISPLAY_NAME "SuperTux")
  971. set(CPACK_NSIS_COMPRESSOR "/SOLID lzma")
  972. set(CPACK_WIX_PROGRAM_MENU_FOLDER "")
  973. set(CPACK_WIX_UPGRADE_GUID "93E16F4E-0A68-422A-8ADC-47BE5B9433B2")
  974. set(CPACK_WIX_PRODUCT_ICON "${CMAKE_CURRENT_SOURCE_DIR}/data/images/engine/icons/supertux.ico")
  975. set(CPACK_WIX_UI_BANNER "${CMAKE_CURRENT_SOURCE_DIR}/mk/wix/banner.png")
  976. set(CPACK_WIX_UI_DIALOG "${CMAKE_CURRENT_SOURCE_DIR}/mk/wix/dialog.png")
  977. set(CPACK_GENERATOR WIX)
  978. else(WIN32 AND NOT UNIX)
  979. endif(WIN32 AND NOT UNIX)
  980. include(CPack)
  981. # move some config clutter to the advanced section
  982. mark_as_advanced(
  983. INSTALL_SUBDIR_BIN
  984. INSTALL_SUBDIR_SHARE
  985. INSTALL_SUBDIR_DOC
  986. )
  987. mark_as_advanced(
  988. CMAKE_BACKWARDS_COMPATIBILITY
  989. CMAKE_BUILD_TYPE
  990. CMAKE_INSTALL_PREFIX
  991. EXECUTABLE_OUTPUT_PATH
  992. LIBRARY_OUTPUT_PATH
  993. CMAKE_OSX_ARCHITECTURES
  994. CMAKE_OSX_SYSROOT
  995. )
  996. mark_as_advanced(
  997. APPDATADIR
  998. )
  999. mark_as_advanced(
  1000. Boost_INCLUDE_DIR
  1001. Boost_LIBRARIES
  1002. )
  1003. mark_as_advanced(
  1004. GLEW_INCLUDE_DIR
  1005. GLEW_LIBRARY
  1006. )
  1007. mark_as_advanced(
  1008. SDL2_INCLUDE_DIRS
  1009. SDL2_LIBRARIES
  1010. )
  1011. mark_as_advanced(
  1012. SDL2IMAGE_INCLUDE_DIRS
  1013. SDL2IMAGE_LIBRARIES
  1014. )
  1015. mark_as_advanced(
  1016. OPENAL_INCLUDE_DIR
  1017. OPENAL_LIBRARY
  1018. )
  1019. mark_as_advanced(
  1020. SDL2TTF_INCLUDE_DIRS
  1021. SDL2TTF_LIBRARIES
  1022. )
  1023. mark_as_advanced(
  1024. OGG_LIBRARY
  1025. VORBISENC_LIBRARY
  1026. VORBISFILE_LIBRARY
  1027. VORBIS_INCLUDE_DIR
  1028. VORBIS_LIBRARY
  1029. )
  1030. mark_as_advanced(
  1031. PHYSFS_INCLUDE_DIR
  1032. PHYSFS_LIBRARY
  1033. )