CMakeLists.txt 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901
  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. # allow building with CMake 2.8. Set compatibility options. Use some bundled modules as a fallback
  35. CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
  36. IF(COMMAND cmake_policy)
  37. CMAKE_POLICY(SET CMP0003 NEW)
  38. CMAKE_POLICY(SET CMP0008 NEW)
  39. CMAKE_POLICY(SET CMP0023 NEW)
  40. IF(POLICY CMP0043)
  41. CMAKE_POLICY(SET CMP0043 OLD)
  42. ENDIF(POLICY CMP0043)
  43. ENDIF(COMMAND cmake_policy)
  44. SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/mk/cmake)
  45. INCLUDE(ConfigureFiles)
  46. INCLUDE(ExternalProject)
  47. ## For autopackage
  48. SET(APPDATADIR "${CMAKE_INSTALL_PREFIX}/share/games/supertux2")
  49. SET(BUILD_DATA_DIR "${CMAKE_CURRENT_SOURCE_DIR}/data")
  50. SET(BUILD_CONFIG_DATA_DIR "${CMAKE_BINARY_DIR}/data")
  51. ## Check endianess
  52. INCLUDE(TestBigEndian)
  53. TEST_BIG_ENDIAN(WORDS_BIGENDIAN)
  54. ## Add definitions
  55. IF(CMAKE_BUILD_TYPE MATCHES Release)
  56. ADD_DEFINITIONS(-DRELEASE)
  57. ELSEIF(CMAKE_BUILD_TYPE MATCHES Debug)
  58. ADD_DEFINITIONS(-DDEBUG)
  59. ENDIF()
  60. SET(SUPERTUX_SYSTEM_NAME ${CMAKE_SYSTEM_NAME})
  61. ## These variables enable MSVC to find libraries located in "dependencies{32|64}"
  62. IF(WIN32)
  63. ## Store path of dependecy folder
  64. SET(DEPENDENCY_FOLDER "${PROJECT_SOURCE_DIR}/dependencies")
  65. ## To test if the host (not the build) is x64:
  66. ## "$ENV{PROCESSOR_ARCHITEW6432}" STREQUAL "AMD64"
  67. IF(${CMAKE_SIZEOF_VOID_P} EQUAL 8)
  68. SET(WIN64 ON)
  69. SET(DEPENDENCY_FOLDER "${DEPENDENCY_FOLDER}64")
  70. ELSE(${CMAKE_SIZEOF_VOID_P} EQUAL 8)
  71. SET(WIN64 OFF)
  72. SET(DEPENDENCY_FOLDER "${DEPENDENCY_FOLDER}32")
  73. ENDIF(${CMAKE_SIZEOF_VOID_P} EQUAL 8)
  74. IF(WIN64)
  75. SET(SUPERTUX_SYSTEM_NAME win64)
  76. ELSE(WIN64)
  77. SET(SUPERTUX_SYSTEM_NAME win32)
  78. ENDIF(WIN64)
  79. SET(ENV{PATH} "$ENV{PATH};${DEPENDENCY_FOLDER}/include")
  80. SET(ENV{LIB} "${DEPENDENCY_FOLDER}/lib")
  81. SET(ENV{OPENALDIR} "${DEPENDENCY_FOLDER}")
  82. SET_PROPERTY(DIRECTORY PROPERTY COMPILE_DEFINITIONS_DEBUG DEBUG)
  83. ## Enable multi-processor compilation (faster)
  84. SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
  85. ## And shut up about unsafe stuff
  86. ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
  87. ## Add an icon
  88. CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/mk/msvc/icon_rc.template" "${PROJECT_BINARY_DIR}/tmp/icon.rc")
  89. ## Find all used libraries
  90. FILE(GLOB DLLS "${DEPENDENCY_FOLDER}/dll/*")
  91. ENDIF(WIN32)
  92. ## Add lots of dependencies to compiler switches
  93. SET(Boost_ADDITIONAL_VERSIONS "1.41" "1.41.0")
  94. OPTION(ENABLE_BOOST_STATIC_LIBS "Use boost static libraries" ON)
  95. IF(ENABLE_BOOST_STATIC_LIBS)
  96. SET(Boost_USE_STATIC_LIBS TRUE)
  97. ELSE(ENABLE_BOOST_STATIC_LIBS)
  98. SET(Boost_USE_STATIC_LIBS FALSE)
  99. ENDIF(ENABLE_BOOST_STATIC_LIBS)
  100. FIND_PATH(PHYSFS_INCLUDE_DIR NAMES physfs.h PATHS "${DEPENDENCY_FOLDER}/include/physfs")
  101. FIND_PACKAGE(Boost REQUIRED COMPONENTS filesystem system)
  102. INCLUDE_DIRECTORIES(SYSTEM ${Boost_INCLUDE_DIR})
  103. LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})
  104. IF(WIN32)
  105. FIND_PATH(SDL2_INCLUDE_DIRS NAMES SDL.h PATHS "${DEPENDENCY_FOLDER}/include/SDL2")
  106. FIND_PATH(SDL2IMAGE_INCLUDE_DIRS NAMES SDL_image.h PATHS "${DEPENDENCY_FOLDER}/include/SDL2_image")
  107. FIND_LIBRARY(SDL2_LIBRARIES NAMES SDL2 PATHS "${DEPENDENCY_FOLDER}/lib")
  108. FIND_LIBRARY(SDL2IMAGE_LIBRARIES NAMES SDL2_image PATHS "${DEPENDENCY_FOLDER}/lib")
  109. FIND_LIBRARY(SDL2MAIN_LIBRARIES NAMES SDL2main PATHS "${DEPENDENCY_FOLDER}/lib")
  110. ELSE(WIN32)
  111. INCLUDE(FindPkgConfig)
  112. PKG_SEARCH_MODULE(SDL2 REQUIRED sdl2>=2.0.1)
  113. PKG_SEARCH_MODULE(SDL2IMAGE REQUIRED SDL2_image>=2.0.0)
  114. ENDIF(WIN32)
  115. SET(HAVE_SDL TRUE)
  116. OPTION(BUILD_TESTS "Build test cases" OFF)
  117. OPTION(ENABLE_OPENGL "Enable OpenGL support" ON)
  118. OPTION(GLBINDING_ENABLED "Use glbinding instead of GLEW" OFF)
  119. OPTION(GLBINDING_DEBUG_OUTPUT "Enable glbinding debug output for each called OpenGL function" OFF)
  120. IF(ENABLE_OPENGL)
  121. FIND_PACKAGE(OpenGL)
  122. IF(OPENGL_FOUND)
  123. INCLUDE_DIRECTORIES(SYSTEM ${OPENGL_INCLUDE_DIR})
  124. SET(HAVE_OPENGL TRUE)
  125. ENDIF(OPENGL_FOUND)
  126. IF(GLBINDING_ENABLED)
  127. FIND_PACKAGE(GLBINDING REQUIRED)
  128. IF(GLBINDING_FOUND)
  129. INCLUDE_DIRECTORIES(SYSTEM ${GLBINDING_INCLUDES})
  130. ADD_DEFINITIONS(-DUSE_GLBINDING)
  131. IF (GLBINDING_DEBUG_OUTPUT)
  132. ADD_DEFINITIONS(-DUSE_GLBINDING_DEBUG_OUTPUT)
  133. ENDIF()
  134. ENDIF()
  135. ELSE()
  136. FIND_PACKAGE(GLEW REQUIRED)
  137. IF(GLEW_FOUND)
  138. INCLUDE_DIRECTORIES(SYSTEM ${GLEW_INCLUDE_DIR})
  139. ENDIF(GLEW_FOUND)
  140. ENDIF()
  141. ENDIF(ENABLE_OPENGL)
  142. FIND_PACKAGE(OpenAL REQUIRED)
  143. INCLUDE_DIRECTORIES(SYSTEM ${OPENAL_INCLUDE_DIR})
  144. FIND_PACKAGE(OggVorbis REQUIRED)
  145. INCLUDE_DIRECTORIES(SYSTEM ${VORBIS_INCLUDE_DIR})
  146. INCLUDE(CheckSymbolExists)
  147. FIND_PACKAGE(PhysFS)
  148. CHECK_SYMBOL_EXISTS("PHYSFS_getPrefDir" "${PHYSFS_INCLUDE_DIR}/physfs.h" HAVE_PHYSFS_GETPREFDIR)
  149. IF(HAVE_PHYSFS_GETPREFDIR)
  150. SET(USE_SYSTEM_PHYSFS ON CACHE BOOL "Use preinstalled physfs (must support getPrefDir)")
  151. ELSE(HAVE_PHYSFS_GETPREFDIR)
  152. SET(USE_SYSTEM_PHYSFS OFF CACHE BOOL "Use preinstalled physfs (must support getPrefDir)")
  153. ENDIF(HAVE_PHYSFS_GETPREFDIR)
  154. IF(NOT USE_SYSTEM_PHYSFS)
  155. IF(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/external/physfs/CMakeLists.txt)
  156. message(FATAL_ERROR "physfs submodule is not checked out or ${CMAKE_CURRENT_SOURCE_DIR}/external/physfs/CMakeLists.txt is missing")
  157. ENDIF()
  158. IF(WIN32)
  159. SET(PHYSFS_BUILD_SHARED TRUE)
  160. SET(PHYSFS_BUILD_STATIC FALSE)
  161. ELSE(WIN32)
  162. SET(PHYSFS_BUILD_SHARED FALSE)
  163. SET(PHYSFS_BUILD_STATIC TRUE)
  164. ENDIF()
  165. SET(PHYSFS_PREFIX ${CMAKE_BINARY_DIR}/physfs/)
  166. ExternalProject_Add(physfs
  167. SOURCE_DIR "${CMAKE_SOURCE_DIR}/external/physfs/"
  168. CMAKE_ARGS
  169. -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
  170. -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
  171. -DCMAKE_INSTALL_PREFIX=${PHYSFS_PREFIX}
  172. -DLIB_SUFFIX=${LIB_SUFFIX}
  173. -DPHYSFS_BUILD_SHARED=${PHYSFS_BUILD_SHARED}
  174. -DPHYSFS_BUILD_STATIC=${PHYSFS_BUILD_STATIC}
  175. -DPHYSFS_BUILD_TEST=FALSE)
  176. IF(WIN32)
  177. ADD_LIBRARY(physfs_lib SHARED IMPORTED)
  178. SET_TARGET_PROPERTIES(physfs_lib PROPERTIES IMPORTED_LOCATION "${PHYSFS_PREFIX}/bin/${CMAKE_SHARED_LIBRARY_PREFIX}physfs${CMAKE_SHARED_LIBRARY_SUFFIX}")
  179. SET_TARGET_PROPERTIES(physfs_lib PROPERTIES IMPORTED_IMPLIB "${PHYSFS_PREFIX}/lib${LIB_SUFFIX}/physfs${CMAKE_LINK_LIBRARY_SUFFIX}")
  180. ELSE()
  181. ADD_LIBRARY(physfs_lib STATIC IMPORTED)
  182. SET_TARGET_PROPERTIES(physfs_lib PROPERTIES IMPORTED_LOCATION "${PHYSFS_PREFIX}/lib${LIB_SUFFIX}/${CMAKE_STATIC_LIBRARY_PREFIX}physfs${CMAKE_STATIC_LIBRARY_SUFFIX}")
  183. ENDIF()
  184. SET(PHYSFS_INCLUDE_DIR "${PHYSFS_PREFIX}/include/")
  185. ENDIF()
  186. INCLUDE_DIRECTORIES(BEFORE SYSTEM ${PHYSFS_INCLUDE_DIR})
  187. ## The curl headers are in the standard include path in dependencies
  188. ## so it's not required to add them here
  189. FIND_PACKAGE(CURL REQUIRED)
  190. IF(CURL_FOUND)
  191. INCLUDE_DIRECTORIES(SYSTEM ${CURL_INCLUDE_DIR})
  192. SET(HAVE_LIBCURL TRUE)
  193. ENDIF(CURL_FOUND)
  194. #FIND_PACKAGE(ICONV REQUIRED)
  195. #INCLUDE_DIRECTORIES(SYSTEM ${ICONV_INCLUDE_DIR})
  196. #LINK_LIBRARIES(${ICONV_LIBRARY})
  197. IF(EXISTS "${CMAKE_SOURCE_DIR}/.git")
  198. ## Find revision of WC
  199. MARK_AS_ADVANCED(GIT_EXECUTABLE)
  200. FIND_PROGRAM(GIT_EXECUTABLE git)
  201. IF(NOT GIT_EXECUTABLE EQUAL "GIT_EXECUTABLE-NOTFOUND")
  202. INCLUDE(GetGitRevisionDescription)
  203. git_describe(VERSION_STRING_GIT "--tags" "--match" "?[0-9]*.[0-9]*.[0-9]*")
  204. STRING(REPLACE "v" "" VERSION_LIST ${VERSION_STRING_GIT})
  205. STRING(REGEX REPLACE "(-|_|\\.)" ";" VERSION_LIST ";${VERSION_LIST}")
  206. ENDIF()
  207. ENDIF(EXISTS "${CMAKE_SOURCE_DIR}/.git")
  208. GET_FILENAME_COMPONENT(BASEDIR ${CMAKE_SOURCE_DIR} NAME)
  209. IF("${VERSION_LIST}" STREQUAL "")
  210. IF(${BASEDIR} MATCHES "supertux2-[0-9\\.]*")
  211. STRING(REGEX REPLACE "(\\.|_|-)" ";" VERSION_LIST ${BASEDIR})
  212. ENDIF()
  213. ENDIF()
  214. FILE(GLOB ORIG_TGZ ../*.orig.tar.gz)
  215. IF("${VERSION_LIST}" STREQUAL "" AND (NOT "${ORIG_TGZ}" STREQUAL ""))
  216. GET_FILENAME_COMPONENT(BASEDIR ${ORIG_TGZ} NAME)
  217. STRING(REGEX REPLACE "(\\.|_|-)" ";" VERSION_LIST ${BASEDIR})
  218. ENDIF()
  219. LIST(LENGTH VERSION_LIST VERSION_LIST_SIZE)
  220. IF(${VERSION_LIST_SIZE} GREATER 0)
  221. LIST(GET VERSION_LIST 1 MAJOR_VERSION_GIT)
  222. LIST(GET VERSION_LIST 2 MINOR_VERSION_GIT)
  223. LIST(GET VERSION_LIST 3 PATCH_VERSION_GIT)
  224. IF("${VERSION_STRING_GIT}" STREQUAL "")
  225. SET(VERSION_STRING_GIT "${MAJOR_VERSION_GIT}.${MINOR_VERSION_GIT}.${PATCH_VERSION_GIT}")
  226. ENDIF()
  227. CONFIGURE_FILE("${CMAKE_SOURCE_DIR}/version.cmake.in" "${CMAKE_SOURCE_DIR}/version.cmake")
  228. ENDIF()
  229. IF(NOT EXISTS "${CMAKE_SOURCE_DIR}/version.cmake")
  230. MESSAGE( SEND_ERROR "Cound not find GIT or valid version.cmake. Version information will be invalid." )
  231. ENDIF(NOT EXISTS "${CMAKE_SOURCE_DIR}/version.cmake")
  232. INCLUDE("${CMAKE_SOURCE_DIR}/version.cmake")
  233. SET(SUPERTUX_VERSION ${SUPERTUX_VERSION_STRING})
  234. configure_file(version.h.in ${CMAKE_BINARY_DIR}/version.h )
  235. SET_SOURCE_FILES_PROPERTIES(${CMAKE_BINARY_DIR}/version.h
  236. PROPERTIES GENERATED true)
  237. SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_SOURCE_DIR}/src/supertux/main.cpp
  238. PROPERTIES OBJECT_DEPENDS "${CMAKE_BINARY_DIR}/version.h")
  239. SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_SOURCE_DIR}/src/supertux/title_screen.cpp
  240. PROPERTIES OBJECT_DEPENDS "${CMAKE_BINARY_DIR}/version.h")
  241. SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_SOURCE_DIR}/src/addon/addon_manager.cpp
  242. PROPERTIES OBJECT_DEPENDS "${CMAKE_BINARY_DIR}/version.h")
  243. configure_file(${CMAKE_CURRENT_SOURCE_DIR}/data/levels/misc/menu.stl.in ${CMAKE_BINARY_DIR}/data/levels/misc/menu.stl )
  244. ## Update Doxyfile's version number
  245. configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile)
  246. ## Check platform-dependent build options
  247. INCLUDE(ConfigureChecks)
  248. ## Also build external/squirrel
  249. IF(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/external/squirrel/CMakeLists.txt)
  250. message(FATAL_ERROR "squirrel submodule is not checked out or ${CMAKE_CURRENT_SOURCE_DIR}/external/squirrel/CMakeLists.txt is missing")
  251. ENDIF()
  252. SET(SQUIRREL_PREFIX ${CMAKE_BINARY_DIR}/squirrel/)
  253. ExternalProject_Add(squirrel
  254. SOURCE_DIR "${CMAKE_SOURCE_DIR}/external/squirrel/"
  255. CMAKE_ARGS
  256. -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
  257. -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
  258. -DCMAKE_INSTALL_PREFIX=${SQUIRREL_PREFIX}
  259. -DINSTALL_INC_DIR=include)
  260. IF(WIN32)
  261. ADD_LIBRARY(squirrel_lib SHARED IMPORTED)
  262. SET_TARGET_PROPERTIES(squirrel_lib PROPERTIES IMPORTED_LOCATION "${SQUIRREL_PREFIX}/bin/${CMAKE_SHARED_LIBRARY_PREFIX}squirrel${CMAKE_SHARED_LIBRARY_SUFFIX}")
  263. SET_TARGET_PROPERTIES(squirrel_lib PROPERTIES IMPORTED_IMPLIB "${SQUIRREL_PREFIX}/lib/squirrel${CMAKE_LINK_LIBRARY_SUFFIX}")
  264. ADD_LIBRARY(sqstdlib_lib SHARED IMPORTED)
  265. SET_TARGET_PROPERTIES(sqstdlib_lib PROPERTIES IMPORTED_LOCATION "${SQUIRREL_PREFIX}/bin/${CMAKE_SHARED_LIBRARY_PREFIX}sqstdlib${CMAKE_SHARED_LIBRARY_SUFFIX}")
  266. SET_TARGET_PROPERTIES(sqstdlib_lib PROPERTIES IMPORTED_IMPLIB "${SQUIRREL_PREFIX}/lib/sqstdlib${CMAKE_LINK_LIBRARY_SUFFIX}")
  267. #For debug run purposes
  268. CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/mk/msvc/run_supertux.bat.in" "${PROJECT_BINARY_DIR}/run_supertux.bat")
  269. ELSE()
  270. ADD_LIBRARY(squirrel_lib STATIC IMPORTED)
  271. SET_TARGET_PROPERTIES(squirrel_lib PROPERTIES IMPORTED_LOCATION "${SQUIRREL_PREFIX}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}squirrel_static${CMAKE_STATIC_LIBRARY_SUFFIX}")
  272. ADD_LIBRARY(sqstdlib_lib STATIC IMPORTED)
  273. SET_TARGET_PROPERTIES(sqstdlib_lib PROPERTIES IMPORTED_LOCATION "${SQUIRREL_PREFIX}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}sqstdlib_static${CMAKE_STATIC_LIBRARY_SUFFIX}")
  274. ENDIF()
  275. INCLUDE_DIRECTORIES(SYSTEM ${SQUIRREL_PREFIX}/include)
  276. ## Also build external/tinygettext
  277. IF(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/external/tinygettext/CMakeLists.txt)
  278. message(FATAL_ERROR "tinygettext submodule is not checked out or ${CMAKE_CURRENT_SOURCE_DIR}/external/tinygettext/CMakeLists.txt is missing")
  279. ENDIF()
  280. set(TINYGETTEXT_PREFIX ${CMAKE_BINARY_DIR}/tinygettext/)
  281. ExternalProject_Add(tinygettext
  282. SOURCE_DIR "${CMAKE_SOURCE_DIR}/external/tinygettext/"
  283. CMAKE_ARGS
  284. -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
  285. -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
  286. -DBUILD_SHARED_LIBS=OFF
  287. -DHAVE_SDL=ON
  288. -DCMAKE_INSTALL_PREFIX=${TINYGETTEXT_PREFIX}
  289. -DSDL2_INCLUDE_DIRS=${SDL2_INCLUDE_DIRS}
  290. -DLIB_SUFFIX=${LIB_SUFFIX})
  291. ADD_LIBRARY(tinygettext_lib STATIC IMPORTED)
  292. SET_TARGET_PROPERTIES(tinygettext_lib PROPERTIES IMPORTED_LOCATION "${TINYGETTEXT_PREFIX}/lib${LIB_SUFFIX}/${CMAKE_STATIC_LIBRARY_PREFIX}tinygettext${CMAKE_STATIC_LIBRARY_SUFFIX}")
  293. INCLUDE_DIRECTORIES(SYSTEM ${TINYGETTEXT_PREFIX}/include)
  294. ## Some additional include paths
  295. include_directories(${CMAKE_BINARY_DIR}/)
  296. include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/)
  297. include_directories(SYSTEM ${CMAKE_CURRENT_SOURCE_DIR}/external/findlocale/)
  298. include_directories(SYSTEM ${CMAKE_CURRENT_SOURCE_DIR}/external/obstack/)
  299. include_directories(SYSTEM ${CMAKE_CURRENT_SOURCE_DIR}/external/sexp-cpp/include/)
  300. IF(WIN32)
  301. ADD_DEFINITIONS(-D_USE_MATH_DEFINES -DNOMINMAX)
  302. ADD_DEFINITIONS(-DWIN32)
  303. ENDIF(WIN32)
  304. ## Build list of sources for supertux binary
  305. FILE(GLOB SUPERTUX_SOURCES_C RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} external/obstack/*.c external/findlocale/findlocale.c)
  306. FILE(GLOB SUPERTUX_SOURCES_CXX RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} src/*/*.cpp src/supertux/menu/*.cpp src/video/sdl/*.cpp)
  307. FILE(GLOB SUPERTUX_RESOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "${PROJECT_BINARY_DIR}/tmp/*.rc")
  308. IF(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/external/sexp-cpp/CMakeLists.txt)
  309. message(FATAL_ERROR "sexp-cpp submodule is not checked out or ${CMAKE_CURRENT_SOURCE_DIR}/external/sexp-cpp/CMakeLists.txt is missing")
  310. ENDIF()
  311. FILE(GLOB SEXP_SOURCES_CXX RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} external/sexp-cpp/src/*.cpp)
  312. ADD_LIBRARY(sexp STATIC ${SEXP_SOURCES_CXX})
  313. IF(HAVE_OPENGL)
  314. FILE(GLOB SUPERTUX_OPENGL_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} src/video/gl/*.cpp)
  315. SET(SUPERTUX_SOURCES_CXX ${SUPERTUX_SOURCES_CXX} ${SUPERTUX_OPENGL_SOURCES})
  316. ENDIF(HAVE_OPENGL)
  317. ## Sort source lists to have deterministic linking order
  318. LIST(SORT SUPERTUX_SOURCES_C)
  319. LIST(SORT SUPERTUX_SOURCES_CXX)
  320. LIST(SORT SUPERTUX_RESOURCES)
  321. IF(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/src/scripting/wrapper.cpp)
  322. SET(SUPERTUX_SOURCES_CXX ${SUPERTUX_SOURCES_CXX} ${CMAKE_CURRENT_SOURCE_DIR}/src/scripting/wrapper.cpp)
  323. ENDIF(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/src/scripting/wrapper.cpp)
  324. ## Compile everything at once (roughly equivalent to cat *.cpp | gcc)
  325. OPTION(COMPILE_AMALGATION "Compile all the files together at once (experimental)" OFF)
  326. IF(COMPILE_AMALGATION)
  327. FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/amalgation.cpp "// Includes all source files of the project\n")
  328. FOREACH(ST_FILE ${SUPERTUX_SOURCES_CXX})
  329. FILE(RELATIVE_PATH CXX_FILE ${CMAKE_CURRENT_SOURCE_DIR}/src "${CMAKE_CURRENT_SOURCE_DIR}/${ST_FILE}")
  330. FILE(APPEND ${CMAKE_CURRENT_BINARY_DIR}/amalgation.cpp "#include \"${CXX_FILE}\"\n")
  331. ENDFOREACH(ST_FILE)
  332. ## Build instead of CXX sources
  333. SET(SUPERTUX_SOURCES_CXX ${CMAKE_CURRENT_BINARY_DIR}/amalgation.cpp)
  334. ELSE(COMPILE_AMALGATION)
  335. IF(EXISTS ${CMAKE_CURRENT_BINARY_DIR}/amalgation.cpp)
  336. FILE(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/amalgation.cpp)
  337. ENDIF(EXISTS ${CMAKE_CURRENT_BINARY_DIR}/amalgation.cpp)
  338. ENDIF(COMPILE_AMALGATION)
  339. ## Debug options
  340. OPTION(WERROR "Stop on first compiler warning" OFF)
  341. OPTION(WARNINGS "Enable long list of warnings for compiler to check" OFF)
  342. if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  343. # http://www.guyrutenberg.com/2014/01/05/enabling-c11-c0x-in-cmake/
  344. include(CheckCXXCompilerFlag)
  345. CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
  346. if(COMPILER_SUPPORTS_CXX11)
  347. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
  348. else(COMPILER_SUPPORTS_CXX11)
  349. CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
  350. if(COMPILER_SUPPORTS_CXX0X)
  351. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
  352. else(COMPILER_SUPPORTS_CXX0X)
  353. message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
  354. endif(COMPILER_SUPPORTS_CXX0X)
  355. endif(COMPILER_SUPPORTS_CXX11)
  356. SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g" CACHE STRING "Debug flags")
  357. SET(CMAKE_C_FLAGS_DEBUG "-O0 -g" CACHE STRING "Debug flags")
  358. SET(CMAKE_CXX_FLAGS_PROFILE "-pg" CACHE STRING "Profile flags")
  359. SET(CMAKE_C_FLAGS_PROFILE "-pg" CACHE STRING "Profile flags")
  360. SET(CMAKE_LD_FLAGS_PROFILE "-lgmon" CACHE STRING "Profile flags")
  361. SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-unused-parameter -funit-at-a-time")
  362. IF(WERROR)
  363. ADD_DEFINITIONS(-Werror)
  364. ELSE(WERROR)
  365. REMOVE_DEFINITIONS(-Werror)
  366. ENDIF(WERROR)
  367. IF(WARNINGS)
  368. # temporarily disabled:
  369. # -Wsign-conversion -Wfloat-equal -Wconversion -Wundef -Wswitch-default
  370. # -Wswitch-enum -Wsign-promo -Wcast-qual -Woverloaded-virtual -Wmissing-format-attribute
  371. # -Wold-style-cast -Wpadded -Wabi -Winline -Wunsafe-loop-optimizations -Wstrict-overflow=5
  372. # fails on MinGW:
  373. # -ansi
  374. # fails on clang:
  375. # -Wlogical-op -Wstrict-null-sentinel
  376. SET(SUPERTUX2_EXTRA_WARNING_FLAGS "-fdiagnostics-show-option -pedantic -Wno-long-long -Wcast-align -Wdisabled-optimization -Winit-self -Winvalid-pch -Wmissing-include-dirs -Wmissing-noreturn -Wpacked -Wredundant-decls -Wstack-protector -Wformat=2 -Weffc++ -Wctor-dtor-privacy -Wno-unused-parameter -Wshadow -Wnon-virtual-dtor -Wcast-qual")
  377. ENDIF(WARNINGS)
  378. endif()
  379. ## If xgettext is available, generate messages.pot for sources
  380. OPTION(GENERATE_MESSAGESPOT "Generate messages.pot files" OFF)
  381. IF(GENERATE_MESSAGESPOT)
  382. MARK_AS_ADVANCED(
  383. XGETTEXT_EXECUTABLE
  384. )
  385. FIND_PROGRAM(XGETTEXT_EXECUTABLE xgettext)
  386. IF(NOT XGETTEXT_EXECUTABLE)
  387. MESSAGE(STATUS "Warning: xgettext not found - will not update messages.pot")
  388. ELSE(NOT XGETTEXT_EXECUTABLE)
  389. MESSAGE(STATUS "Found xgettext: ${XGETTEXT_EXECUTABLE}")
  390. SET(MESSAGES_POT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/data/locale/messages.pot)
  391. ADD_CUSTOM_COMMAND(
  392. OUTPUT ${MESSAGES_POT_FILE}
  393. COMMAND ${XGETTEXT_EXECUTABLE}
  394. ARGS --keyword=_ --language=C++ --output=${MESSAGES_POT_FILE} ${SUPERTUX_SOURCES_CXX}
  395. DEPENDS ${SUPERTUX_SOURCES_CXX}
  396. WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
  397. COMMENT "Generating POT file ${MESSAGES_POT_FILE}"
  398. )
  399. LIST(APPEND MESSAGES_POT_FILES ${MESSAGES_POT_FILE})
  400. FILE(GLOB SUPERTUX_LEVEL_DIRS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} data/levels/*)
  401. FOREACH(SUPERTUX_LEVEL_DIR ${SUPERTUX_LEVEL_DIRS})
  402. FILE(GLOB SUPERTUX_LEVELS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${SUPERTUX_LEVEL_DIR}/*.stl ${SUPERTUX_LEVEL_DIR}/*.stwm ${SUPERTUX_LEVEL_DIR}/*.txt)
  403. ## Do not add target if SUPERTUX_LEVELS is empty. This is needed for cmake <=2.4
  404. IF(SUPERTUX_LEVELS)
  405. SET(MESSAGES_POT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/${SUPERTUX_LEVEL_DIR}/messages.pot)
  406. ADD_CUSTOM_COMMAND(
  407. OUTPUT ${MESSAGES_POT_FILE}
  408. COMMAND ${XGETTEXT_EXECUTABLE}
  409. ARGS --keyword="_:1" --language=Lisp --force-po --sort-by-file "--output=${MESSAGES_POT_FILE}" ${SUPERTUX_LEVELS}
  410. DEPENDS ${SUPERTUX_LEVELS}
  411. WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
  412. COMMENT "Generating POT file ${MESSAGES_POT_FILE}"
  413. )
  414. LIST(APPEND MESSAGES_POT_FILES ${MESSAGES_POT_FILE})
  415. ENDIF(SUPERTUX_LEVELS)
  416. ENDFOREACH(SUPERTUX_LEVEL_DIR)
  417. ADD_CUSTOM_TARGET(
  418. supertux2-messages ALL
  419. DEPENDS ${MESSAGES_POT_FILES}
  420. )
  421. ENDIF(NOT XGETTEXT_EXECUTABLE)
  422. ENDIF(GENERATE_MESSAGESPOT)
  423. ## Some additional compiler switches
  424. if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  425. SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-strict-aliasing")
  426. endif()
  427. IF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
  428. ADD_DEFINITIONS(-DMACOSX)
  429. ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
  430. ## On Windows, add an icon
  431. IF(WIN32)
  432. # SET(SUPERTUX_SOURCES_C ${SUPERTUX_SOURCES_C} ${CMAKE_CURRENT_SOURCE_DIR}/data/images/engine/icons/supertux.rc)
  433. IF(MINGW)
  434. ADD_CUSTOM_COMMAND(
  435. OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/supertux_rc.o
  436. 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)
  437. SET(SUPERTUX_SOURCES_C ${SUPERTUX_SOURCES_C} ${CMAKE_CURRENT_BINARY_DIR}/supertux_rc.o)
  438. ENDIF(MINGW)
  439. ENDIF(WIN32)
  440. ## Build miniswig and generate miniswig wrapper
  441. OPTION(GENERATE_WRAPPER "Build miniswig and generate the wrapper" OFF)
  442. IF(GENERATE_WRAPPER)
  443. ADD_SUBDIRECTORY(tools/miniswig)
  444. ADD_CUSTOM_COMMAND(
  445. OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/src/scripting/wrapper.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/scripting/wrapper.hpp
  446. COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && ${CMAKE_CXX_COMPILER}
  447. 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
  448. COMMAND tools/miniswig/miniswig
  449. 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
  450. DEPENDS tools/miniswig/miniswig
  451. IMPLICIT_DEPENDS CXX ${CMAKE_CURRENT_SOURCE_DIR}/src/scripting/wrapper.interface.hpp
  452. )
  453. ENDIF(GENERATE_WRAPPER)
  454. ## Generate supertux executable in the right place
  455. #SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_SOURCE_DIR})
  456. SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR})
  457. ## Add target for supertux binary
  458. add_library(supertux2_c OBJECT ${SUPERTUX_SOURCES_C})
  459. add_library(supertux2_lib STATIC ${CMAKE_BINARY_DIR}/version.h ${SUPERTUX_SOURCES_CXX} ${SUPERTUX_RESOURCES} $<TARGET_OBJECTS:supertux2_c>)
  460. IF(WIN32)
  461. add_executable(supertux2 WIN32 src/main.cpp ${CMAKE_CURRENT_SOURCE_DIR}/data/images/engine/icons/supertux.rc)
  462. TARGET_LINK_LIBRARIES(supertux2 ${SDL2MAIN_LIBRARIES})
  463. ELSE()
  464. add_executable(supertux2 src/main.cpp)
  465. ENDIF(WIN32)
  466. target_link_libraries(supertux2 supertux2_lib)
  467. set_target_properties(supertux2 PROPERTIES OUTPUT_NAME supertux2)
  468. set_target_properties(supertux2_lib PROPERTIES OUTPUT_NAME supertux2)
  469. set_target_properties(supertux2_lib PROPERTIES COMPILE_FLAGS "${SUPERTUX2_EXTRA_WARNING_FLAGS}")
  470. IF(WIN32)
  471. ## Copy dlls on windows
  472. ADD_CUSTOM_COMMAND(TARGET supertux2_lib POST_BUILD
  473. COMMAND ${CMAKE_COMMAND} -E copy_directory
  474. "${DEPENDENCY_FOLDER}/dll"
  475. $<TARGET_FILE_DIR:supertux2_lib>)
  476. # ADD_CUSTOM_COMMAND(TARGET supertux2 POST_BUILD
  477. # COMMAND ${CMAKE_COMMAND} -E copy
  478. # "${DEPENDENCY_FOLDER}/DigiCertHighAssuranceEVRootCA.pem"
  479. # $<TARGET_FILE_DIR:supertux2_lib>)
  480. ENDIF(WIN32)
  481. ## Link supertux binary with squirrel and other libraries
  482. ADD_DEPENDENCIES(supertux2_lib tinygettext)
  483. ADD_DEPENDENCIES(supertux2_lib squirrel)
  484. TARGET_INCLUDE_DIRECTORIES(supertux2_lib SYSTEM PUBLIC ${SDL2_INCLUDE_DIRS})
  485. TARGET_INCLUDE_DIRECTORIES(supertux2_lib SYSTEM PUBLIC ${SDL2IMAGE_INCLUDE_DIRS})
  486. TARGET_LINK_LIBRARIES(supertux2_lib PUBLIC ${SDL2_LIBRARIES})
  487. TARGET_LINK_LIBRARIES(supertux2_lib PUBLIC ${SDL2IMAGE_LIBRARIES})
  488. TARGET_LINK_LIBRARIES(supertux2_lib PUBLIC squirrel_lib)
  489. TARGET_LINK_LIBRARIES(supertux2_lib PUBLIC sqstdlib_lib)
  490. TARGET_LINK_LIBRARIES(supertux2_lib PUBLIC tinygettext_lib)
  491. TARGET_LINK_LIBRARIES(supertux2_lib PUBLIC sexp)
  492. TARGET_LINK_LIBRARIES(supertux2_lib PUBLIC ${OPENAL_LIBRARY})
  493. TARGET_LINK_LIBRARIES(supertux2_lib PUBLIC ${OGGVORBIS_LIBRARIES})
  494. TARGET_LINK_LIBRARIES(supertux2_lib PUBLIC ${Boost_LIBRARIES})
  495. IF(USE_SYSTEM_PHYSFS)
  496. TARGET_LINK_LIBRARIES(supertux2_lib PUBLIC ${PHYSFS_LIBRARY})
  497. ELSE()
  498. ADD_DEPENDENCIES(supertux2_lib physfs)
  499. TARGET_LINK_LIBRARIES(supertux2_lib PUBLIC physfs_lib)
  500. IF(APPLE)
  501. TARGET_LINK_LIBRARIES(supertux2_lib PUBLIC "-framework CoreFoundation")
  502. TARGET_LINK_LIBRARIES(supertux2_lib PUBLIC "-framework IOKit")
  503. ENDIF()
  504. ENDIF()
  505. IF(HAVE_OPENGL)
  506. TARGET_LINK_LIBRARIES(supertux2_lib PUBLIC ${OPENGL_LIBRARY})
  507. IF(GLBINDING_FOUND)
  508. TARGET_LINK_LIBRARIES(supertux2_lib PUBLIC ${GLBINDING_LIBRARIES})
  509. ELSE()
  510. TARGET_LINK_LIBRARIES(supertux2_lib PUBLIC ${GLEW_LIBRARY})
  511. ENDIF()
  512. ENDIF(HAVE_OPENGL)
  513. IF(HAVE_LIBCURL)
  514. TARGET_LINK_LIBRARIES(supertux2_lib PUBLIC ${CURL_LIBRARY})
  515. ENDIF(HAVE_LIBCURL)
  516. if(BUILD_TESTS)
  517. find_package(Threads REQUIRED)
  518. # build gtest
  519. # ${CMAKE_CURRENT_SOURCE_DIR} in include_directories is needed to generate -isystem instead of -I flags
  520. add_library(gtest_main STATIC ${CMAKE_CURRENT_SOURCE_DIR}/external/googletest/googletest/src/gtest_main.cc)
  521. target_include_directories(gtest_main SYSTEM PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/external/googletest/googletest/include/)
  522. add_library(gtest STATIC ${CMAKE_CURRENT_SOURCE_DIR}/external/googletest/googletest/src/gtest-all.cc)
  523. target_include_directories(gtest SYSTEM PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/external/googletest/googletest/)
  524. target_include_directories(gtest SYSTEM PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/external/googletest/googletest/include/)
  525. # build SuperTux tests
  526. file(GLOB TEST_SUPERTUX_SOURCES tests/*.cpp)
  527. add_executable(test_supertux2 ${TEST_SUPERTUX_SOURCES})
  528. target_compile_options(test_supertux2 PRIVATE ${WARNINGS_CXX_FLAGS})
  529. target_link_libraries(test_supertux2
  530. gtest gtest_main
  531. supertux2_lib
  532. ${CMAKE_THREAD_LIBS_INIT})
  533. # add 'make test' target, use 'make test ARGS="-V"' or 'ctest -V' for verbose
  534. enable_testing()
  535. add_test(NAME test_supertux2
  536. WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
  537. COMMAND test_supertux2)
  538. endif()
  539. ## Install stuff
  540. OPTION(DISABLE_CPACK_BUNDLING "Build an .app bundle without CPack" OFF)
  541. IF(WIN32 AND NOT UNIX)
  542. SET(INSTALL_SUBDIR_BIN "bin" CACHE STRING "Installation subdir for binaries")
  543. SET(INSTALL_SUBDIR_SHARE "data" CACHE STRING "Installation subdir for data")
  544. SET(INSTALL_SUBDIR_DOC "doc" CACHE STRING "Installation subdir for docs")
  545. INSTALL(FILES ${DLLS} DESTINATION ${INSTALL_SUBDIR_BIN})
  546. INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/images/engine/icons/supertux.png ${CMAKE_CURRENT_SOURCE_DIR}/data/images/engine/icons/supertux.ico DESTINATION ".")
  547. OPTION(PACKAGE_VCREDIST "Package the VCREDIST libraries with the program" OFF)
  548. IF(PACKAGE_VCREDIST)
  549. include(InstallRequiredSystemLibraries)
  550. INSTALL(FILES ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS} DESTINATION ${INSTALL_SUBDIR_BIN})
  551. include(FindWindowsSDK)
  552. IF(${CMAKE_VS_PLATFORM_NAME} STREQUAL "Win32")
  553. SET(UCRT_PATH "${WINDOWSSDK_PREFERRED_DIR}/Redist/ucrt/DLLs/x86")
  554. ELSE()
  555. SET(UCRT_PATH "${WINDOWSSDK_PREFERRED_DIR}/Redist/ucrt/DLLs/x64")
  556. ENDIF()
  557. FILE(GLOB UCRT_DLLS "${UCRT_PATH}/*")
  558. INSTALL(FILES ${UCRT_DLLS} DESTINATION ${INSTALL_SUBDIR_BIN})
  559. ENDIF()
  560. ELSE(WIN32 AND NOT UNIX)
  561. IF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin" AND DISABLE_CPACK_BUNDLING)
  562. SET(INFOPLIST_CFBUNDLEEXECUTABLE "supertux2")
  563. SET(INSTALL_SUBDIR_BIN "SuperTux.app/Contents/MacOS" CACHE STRING "Installation subdir for binaries")
  564. SET(INSTALL_SUBDIR_SHARE "SuperTux.app/Contents/Resources/data" CACHE STRING "Installation subdir for data")
  565. SET(INSTALL_SUBDIR_DOC "SuperTux.app/Contents/Resources" CACHE STRING "Installation subdir for docs")
  566. CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/tools/darwin/info.plist.in ${CMAKE_BINARY_DIR}/tools/darwin/info.plist)
  567. INSTALL(FILES ${CMAKE_BINARY_DIR}/tools/darwin/info.plist DESTINATION "SuperTux.app/Contents/")
  568. INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/tools/darwin/receipt DESTINATION "SuperTux.app/Contents/_MASReceipt/")
  569. 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/")
  570. ELSE(${CMAKE_SYSTEM_NAME} MATCHES "Darwin" AND DISABLE_CPACK_BUNDLING)
  571. SET(INSTALL_SUBDIR_BIN "games" CACHE STRING "Installation subdir for binaries")
  572. SET(INSTALL_SUBDIR_SHARE "share/games/supertux2" CACHE STRING "Installation subdir for data")
  573. SET(INSTALL_SUBDIR_DOC "share/doc/supertux2" CACHE STRING "Installation subdir for docs")
  574. INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/supertux2.desktop DESTINATION "share/applications")
  575. SET(APPS "\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${INSTALL_SUBDIR_BIN}/supertux2")
  576. 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/")
  577. ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin" AND DISABLE_CPACK_BUNDLING)
  578. ENDIF(WIN32 AND NOT UNIX)
  579. INSTALL(TARGETS supertux2 DESTINATION ${INSTALL_SUBDIR_BIN})
  580. IF(WIN32)
  581. GET_PROPERTY(SQUIRREL_LIB_PATH TARGET squirrel_lib PROPERTY IMPORTED_LOCATION)
  582. GET_PROPERTY(SQSTDLIB_LIB_PATH TARGET sqstdlib_lib PROPERTY IMPORTED_LOCATION)
  583. GET_PROPERTY(PHYSFS_LIB_PATH TARGET physfs_lib PROPERTY IMPORTED_LOCATION)
  584. INSTALL(FILES ${SQUIRREL_LIB_PATH} ${SQSTDLIB_LIB_PATH} ${PHYSFS_LIB_PATH} DESTINATION ${INSTALL_SUBDIR_BIN})
  585. ENDIF()
  586. 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})
  587. INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/credits.stxt DESTINATION ${INSTALL_SUBDIR_SHARE})
  588. INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/supertux2.appdata.xml DESTINATION "share/appdata" )
  589. INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/data/images
  590. ${CMAKE_CURRENT_SOURCE_DIR}/data/fonts
  591. ${CMAKE_CURRENT_SOURCE_DIR}/data/music
  592. ${CMAKE_CURRENT_SOURCE_DIR}/data/scripts
  593. ${CMAKE_CURRENT_SOURCE_DIR}/data/speech
  594. ${CMAKE_CURRENT_SOURCE_DIR}/data/sounds
  595. ${CMAKE_CURRENT_SOURCE_DIR}/data/locale
  596. DESTINATION ${INSTALL_SUBDIR_SHARE})
  597. IF(CMAKE_BUILD_TYPE MATCHES Release)
  598. INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/data/levels
  599. DESTINATION ${INSTALL_SUBDIR_SHARE}
  600. PATTERN "data/levels/test" EXCLUDE
  601. PATTERN "data/levels/test_old" EXCLUDE
  602. PATTERN "data/levels/incubator" EXCLUDE
  603. PATTERN "data/levels/misc/menu.stl.in" EXCLUDE)
  604. ELSE()
  605. INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/data/levels
  606. DESTINATION ${INSTALL_SUBDIR_SHARE}
  607. PATTERN "data/levels/misc/menu.stl.in" EXCLUDE)
  608. ENDIF()
  609. INSTALL(FILES "${CMAKE_BINARY_DIR}/data/levels/misc/menu.stl" DESTINATION "${INSTALL_SUBDIR_SHARE}/levels/misc")
  610. ## Create config.h now that INSTALL_SUBDIR_* have been set.
  611. configure_file(config.h.cmake ${CMAKE_BINARY_DIR}/config.h )
  612. ## Configure main menu logo
  613. IF(CMAKE_BUILD_TYPE MATCHES Release)
  614. SET(LOGO_FILE "logo_final.sprite")
  615. ELSE()
  616. SET(LOGO_FILE "logo.sprite")
  617. ENDIF()
  618. configure_file(data/levels/misc/menu.stl.in ${CMAKE_BINARY_DIR}/data/levels/misc/menu.stl )
  619. ## CPack/Installation-specific stuff
  620. INCLUDE(InstallRequiredSystemLibraries)
  621. SET(DIRS ${Boost_LIBRARY_DIRS} ${CMAKE_CURRENT_BINARY_DIR}/external/squirrel ${CMAKE_CURRENT_BINARY_DIR}/external/tinygettext)
  622. IF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin" AND NOT DISABLE_CPACK_BUNDLING)
  623. SET(INFOPLIST_CFBUNDLEEXECUTABLE "SuperTux")
  624. FIND_PACKAGE(png)
  625. foreach (_file ${PNG_LIBRARIES})
  626. get_filename_component(_resolvedFile "${_file}" REALPATH)
  627. get_filename_component(_name "${_file}" NAME)
  628. INSTALL(FILES ${_resolvedFile} DESTINATION "MacOS" RENAME ${_name})
  629. endforeach()
  630. FIND_PACKAGE(jpeg)
  631. foreach (_file ${JPEG_LIBRARIES})
  632. get_filename_component(_resolvedFile "${_file}" REALPATH)
  633. get_filename_component(_name "${_file}" NAME)
  634. INSTALL(FILES ${_resolvedFile} DESTINATION "MacOS" RENAME ${_name})
  635. endforeach()
  636. INSTALL(CODE "
  637. if(\"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/\" MATCHES \".*\\\\.app.*\")
  638. include(BundleUtilities)
  639. fixup_bundle(\"${APPS}\" \"\" \"${DIRS}\")
  640. endif()
  641. ")
  642. CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/tools/darwin/info.plist.in" "${CMAKE_BINARY_DIR}/tools/darwin/info.plist")
  643. SET(CPACK_BUNDLE_NAME "SuperTux")
  644. SET(CPACK_BUNDLE_PLIST "${CMAKE_BINARY_DIR}/tools/darwin/info.plist")
  645. SET(CPACK_BUNDLE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/data/images/engine/icons/supertux.icns")
  646. SET(CPACK_BUNDLE_STARTUP_COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/tools/darwin/startup.sh")
  647. SET(CPACK_DMG_VOLUME_NAME "SuperTux ${SUPERTUX_VERSION_STRING}")
  648. SET(CPACK_DMG_DS_STORE "${CMAKE_CURRENT_SOURCE_DIR}/tools/darwin/DS_Store")
  649. SET(CPACK_DMG_BACKGROUND_IMAGE "${CMAKE_CURRENT_SOURCE_DIR}/tools/darwin/background.png")
  650. ENDIF()
  651. SET(CPACK_PACKAGE_NAME "SuperTux")
  652. SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Jump'n'Run Game featuring Tux")
  653. SET(CPACK_PACKAGE_VENDOR "SuperTux Devel Team")
  654. SET(CPACK_PACKAGE_CONTACT "SuperTux Devel Team <supertux-devel@lists.lethargik.org>")
  655. SET(CPACK_SOURCE_IGNORE_FILES "/\\\\.git/;${CMAKE_BINARY_DIR};/\\\\..*")
  656. SET(CPACK_DEBIAN_PACKAGE_NAME "supertux2")
  657. 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)")
  658. 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/")
  659. SET(CPACK_DEBIAN_PACKAGE_SECTION "games")
  660. SET(CPACK_RPM_PACKAGE_NAME "supertux2")
  661. 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/")
  662. SET(CPACK_RPM_PACKAGE_LICENSE "GNU General Public License (GPL)")
  663. SET(CPACK_RPM_PACKAGE_GROUP "Amusements/Games/Action/Arcade")
  664. SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
  665. SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.txt")
  666. SET(CPACK_PACKAGE_VERSION_MAJOR ${SUPERTUX_VERSION_MAJOR})
  667. SET(CPACK_PACKAGE_VERSION_MINOR ${SUPERTUX_VERSION_MINOR})
  668. IF(SUPERTUX_VERSION_TWEAK)
  669. SET(CPACK_PACKAGE_VERSION_PATCH "${SUPERTUX_VERSION_PATCH}.${SUPERTUX_VERSION_TWEAK}")
  670. ELSE()
  671. SET(CPACK_PACKAGE_VERSION_PATCH ${SUPERTUX_VERSION_PATCH})
  672. ENDIF(SUPERTUX_VERSION_TWEAK)
  673. SET(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${SUPERTUX_VERSION_STRING}-${SUPERTUX_SYSTEM_NAME}")
  674. SET(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${SUPERTUX_VERSION_STRING}-Source")
  675. SET(CPACK_PACKAGE_INSTALL_DIRECTORY "SuperTux")
  676. SET(CPACK_PACKAGE_EXECUTABLES "supertux2" "SuperTux")
  677. IF(WIN32 AND NOT UNIX)
  678. SET(CPACK_NSIS_INSTALLED_ICON_NAME "supertux2")
  679. SET(CPACK_NSIS_DISPLAY_NAME "SuperTux")
  680. SET(CPACK_NSIS_COMPRESSOR "/SOLID lzma")
  681. SET(CPACK_WIX_PROGRAM_MENU_FOLDER "")
  682. SET(CPACK_WIX_UPGRADE_GUID "93E16F4E-0A68-422A-8ADC-47BE5B9433B2")
  683. SET(CPACK_WIX_PRODUCT_ICON "${CMAKE_CURRENT_SOURCE_DIR}/data/images/engine/icons/supertux.ico")
  684. SET(CPACK_WIX_UI_BANNER "${CMAKE_CURRENT_SOURCE_DIR}/mk/wix/banner.png")
  685. SET(CPACK_WIX_UI_DIALOG "${CMAKE_CURRENT_SOURCE_DIR}/mk/wix/dialog.png")
  686. SET(CPACK_GENERATOR WIX)
  687. ELSE(WIN32 AND NOT UNIX)
  688. ENDIF(WIN32 AND NOT UNIX)
  689. INCLUDE(CPack)
  690. # move some config clutter to the advanced section
  691. MARK_AS_ADVANCED(
  692. INSTALL_SUBDIR_BIN
  693. INSTALL_SUBDIR_SHARE
  694. INSTALL_SUBDIR_DOC
  695. )
  696. MARK_AS_ADVANCED(
  697. CMAKE_BACKWARDS_COMPATIBILITY
  698. CMAKE_BUILD_TYPE
  699. CMAKE_INSTALL_PREFIX
  700. EXECUTABLE_OUTPUT_PATH
  701. LIBRARY_OUTPUT_PATH
  702. CMAKE_OSX_ARCHITECTURES
  703. CMAKE_OSX_SYSROOT
  704. )
  705. MARK_AS_ADVANCED(
  706. APPDATADIR
  707. )
  708. MARK_AS_ADVANCED(
  709. Boost_INCLUDE_DIR
  710. Boost_LIBRARIES
  711. )
  712. MARK_AS_ADVANCED(
  713. GLEW_INCLUDE_DIR
  714. GLEW_LIBRARY
  715. )
  716. MARK_AS_ADVANCED(
  717. SDL2_INCLUDE_DIRS
  718. SDL2_LIBRARIES
  719. )
  720. MARK_AS_ADVANCED(
  721. SDL2IMAGE_INCLUDE_DIRS
  722. SDL2IMAGE_LIBRARIES
  723. )
  724. MARK_AS_ADVANCED(
  725. OPENAL_INCLUDE_DIR
  726. OPENAL_LIBRARY
  727. )
  728. MARK_AS_ADVANCED(
  729. OGG_LIBRARY
  730. VORBISENC_LIBRARY
  731. VORBISFILE_LIBRARY
  732. VORBIS_INCLUDE_DIR
  733. VORBIS_LIBRARY
  734. )
  735. MARK_AS_ADVANCED(
  736. PHYSFS_INCLUDE_DIR
  737. PHYSFS_LIBRARY
  738. )