CMakeLists.txt 50 KB

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