CMakeLists.txt 52 KB

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