CMakeLists.txt 45 KB

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