CMakeLists.txt 45 KB

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