CMakeLists.txt 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922
  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_PACKAGE(Boost REQUIRED COMPONENTS filesystem system date_time)
  101. INCLUDE_DIRECTORIES(SYSTEM ${Boost_INCLUDE_DIR})
  102. LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})
  103. IF(WIN32)
  104. FIND_PATH(SDL2_INCLUDE_DIRS NAMES SDL.h PATHS "${DEPENDENCY_FOLDER}/include/SDL2")
  105. FIND_PATH(SDL2IMAGE_INCLUDE_DIRS NAMES SDL_image.h PATHS "${DEPENDENCY_FOLDER}/include/SDL2_image")
  106. FIND_LIBRARY(SDL2_LIBRARIES NAMES SDL2 PATHS "${DEPENDENCY_FOLDER}/lib")
  107. FIND_LIBRARY(SDL2IMAGE_LIBRARIES NAMES SDL2_image PATHS "${DEPENDENCY_FOLDER}/lib")
  108. FIND_LIBRARY(SDL2MAIN_LIBRARIES NAMES SDL2main PATHS "${DEPENDENCY_FOLDER}/lib")
  109. FIND_PATH(PHYSFS_INCLUDE_DIR NAMES physfs.h PATHS "${DEPENDENCY_FOLDER}/include/physfs")
  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. ## Configure doxygen
  245. # Adapted from https://tty1.net/blog/2014/cmake-doxygen_en.html
  246. # add a target to generate API documentation with Doxygen
  247. find_package(Doxygen)
  248. option(BUILD_DOCUMENTATION "Build API documentation using Doxygen" ${DOXYGEN_FOUND})
  249. if(BUILD_DOCUMENTATION)
  250. if(NOT DOXYGEN_FOUND)
  251. message(FATAL_ERROR "Doxygen is needed to build the documentation.")
  252. endif()
  253. set(doxyfile_in ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in)
  254. set(doxyfile ${CMAKE_CURRENT_BINARY_DIR}/docs/Doxyfile)
  255. configure_file(${doxyfile_in} ${doxyfile} @ONLY)
  256. add_custom_target(doc
  257. COMMAND ${DOXYGEN_EXECUTABLE} ${doxyfile}
  258. WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
  259. COMMENT "Generating API documentation with Doxygen"
  260. VERBATIM)
  261. endif()
  262. ## Check platform-dependent build options
  263. INCLUDE(ConfigureChecks)
  264. ## Also build external/squirrel
  265. IF(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/external/squirrel/CMakeLists.txt)
  266. message(FATAL_ERROR "squirrel submodule is not checked out or ${CMAKE_CURRENT_SOURCE_DIR}/external/squirrel/CMakeLists.txt is missing")
  267. ENDIF()
  268. SET(SQUIRREL_PREFIX ${CMAKE_BINARY_DIR}/squirrel/)
  269. ExternalProject_Add(squirrel
  270. SOURCE_DIR "${CMAKE_SOURCE_DIR}/external/squirrel/"
  271. CMAKE_ARGS
  272. -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
  273. -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
  274. -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
  275. -DCMAKE_INSTALL_PREFIX=${SQUIRREL_PREFIX}
  276. -DINSTALL_INC_DIR=include)
  277. IF(WIN32)
  278. ADD_LIBRARY(squirrel_lib SHARED IMPORTED)
  279. SET_TARGET_PROPERTIES(squirrel_lib PROPERTIES IMPORTED_LOCATION "${SQUIRREL_PREFIX}/bin/${CMAKE_SHARED_LIBRARY_PREFIX}squirrel${CMAKE_SHARED_LIBRARY_SUFFIX}")
  280. SET_TARGET_PROPERTIES(squirrel_lib PROPERTIES IMPORTED_IMPLIB "${SQUIRREL_PREFIX}/lib/squirrel${CMAKE_LINK_LIBRARY_SUFFIX}")
  281. ADD_LIBRARY(sqstdlib_lib SHARED IMPORTED)
  282. SET_TARGET_PROPERTIES(sqstdlib_lib PROPERTIES IMPORTED_LOCATION "${SQUIRREL_PREFIX}/bin/${CMAKE_SHARED_LIBRARY_PREFIX}sqstdlib${CMAKE_SHARED_LIBRARY_SUFFIX}")
  283. SET_TARGET_PROPERTIES(sqstdlib_lib PROPERTIES IMPORTED_IMPLIB "${SQUIRREL_PREFIX}/lib/sqstdlib${CMAKE_LINK_LIBRARY_SUFFIX}")
  284. #For debug run purposes
  285. CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/mk/msvc/run_supertux.bat.in" "${PROJECT_BINARY_DIR}/run_supertux.bat")
  286. ELSE()
  287. ADD_LIBRARY(squirrel_lib STATIC IMPORTED)
  288. SET_TARGET_PROPERTIES(squirrel_lib PROPERTIES IMPORTED_LOCATION "${SQUIRREL_PREFIX}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}squirrel_static${CMAKE_STATIC_LIBRARY_SUFFIX}")
  289. ADD_LIBRARY(sqstdlib_lib STATIC IMPORTED)
  290. SET_TARGET_PROPERTIES(sqstdlib_lib PROPERTIES IMPORTED_LOCATION "${SQUIRREL_PREFIX}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}sqstdlib_static${CMAKE_STATIC_LIBRARY_SUFFIX}")
  291. ENDIF()
  292. INCLUDE_DIRECTORIES(SYSTEM ${SQUIRREL_PREFIX}/include)
  293. ## Also build external/tinygettext
  294. IF(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/external/tinygettext/CMakeLists.txt)
  295. message(FATAL_ERROR "tinygettext submodule is not checked out or ${CMAKE_CURRENT_SOURCE_DIR}/external/tinygettext/CMakeLists.txt is missing")
  296. ENDIF()
  297. set(TINYGETTEXT_PREFIX ${CMAKE_BINARY_DIR}/tinygettext/)
  298. ExternalProject_Add(tinygettext
  299. SOURCE_DIR "${CMAKE_SOURCE_DIR}/external/tinygettext/"
  300. CMAKE_ARGS
  301. -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
  302. -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
  303. -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
  304. -DBUILD_SHARED_LIBS=OFF
  305. -DHAVE_SDL=ON
  306. -DCMAKE_INSTALL_PREFIX=${TINYGETTEXT_PREFIX}
  307. -DSDL2_INCLUDE_DIRS=${SDL2_INCLUDE_DIRS}
  308. -DLIB_SUFFIX=${LIB_SUFFIX})
  309. ADD_LIBRARY(tinygettext_lib STATIC IMPORTED)
  310. SET_TARGET_PROPERTIES(tinygettext_lib PROPERTIES IMPORTED_LOCATION "${TINYGETTEXT_PREFIX}/lib${LIB_SUFFIX}/${CMAKE_STATIC_LIBRARY_PREFIX}tinygettext${CMAKE_STATIC_LIBRARY_SUFFIX}")
  311. INCLUDE_DIRECTORIES(SYSTEM ${TINYGETTEXT_PREFIX}/include)
  312. ## Some additional include paths
  313. include_directories(${CMAKE_BINARY_DIR}/)
  314. include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/)
  315. include_directories(SYSTEM ${CMAKE_CURRENT_SOURCE_DIR}/external/findlocale/)
  316. include_directories(SYSTEM ${CMAKE_CURRENT_SOURCE_DIR}/external/obstack/)
  317. include_directories(SYSTEM ${CMAKE_CURRENT_SOURCE_DIR}/external/sexp-cpp/include/)
  318. IF(WIN32)
  319. ADD_DEFINITIONS(-D_USE_MATH_DEFINES -DNOMINMAX)
  320. ADD_DEFINITIONS(-DWIN32)
  321. ENDIF(WIN32)
  322. ## Build list of sources for supertux binary
  323. FILE(GLOB SUPERTUX_SOURCES_C RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} external/obstack/*.c external/findlocale/findlocale.c)
  324. FILE(GLOB SUPERTUX_SOURCES_CXX RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} src/*/*.cpp src/supertux/menu/*.cpp src/video/sdl/*.cpp)
  325. FILE(GLOB SUPERTUX_RESOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "${PROJECT_BINARY_DIR}/tmp/*.rc")
  326. IF(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/external/sexp-cpp/CMakeLists.txt)
  327. message(FATAL_ERROR "sexp-cpp submodule is not checked out or ${CMAKE_CURRENT_SOURCE_DIR}/external/sexp-cpp/CMakeLists.txt is missing")
  328. ENDIF()
  329. FILE(GLOB SEXP_SOURCES_CXX RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} external/sexp-cpp/src/*.cpp)
  330. ADD_LIBRARY(sexp STATIC ${SEXP_SOURCES_CXX})
  331. IF(HAVE_OPENGL)
  332. FILE(GLOB SUPERTUX_OPENGL_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} src/video/gl/*.cpp)
  333. SET(SUPERTUX_SOURCES_CXX ${SUPERTUX_SOURCES_CXX} ${SUPERTUX_OPENGL_SOURCES})
  334. ENDIF(HAVE_OPENGL)
  335. ## Sort source lists to have deterministic linking order
  336. LIST(SORT SUPERTUX_SOURCES_C)
  337. LIST(SORT SUPERTUX_SOURCES_CXX)
  338. LIST(SORT SUPERTUX_RESOURCES)
  339. IF(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/src/scripting/wrapper.cpp)
  340. SET(SUPERTUX_SOURCES_CXX ${SUPERTUX_SOURCES_CXX} ${CMAKE_CURRENT_SOURCE_DIR}/src/scripting/wrapper.cpp)
  341. ENDIF(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/src/scripting/wrapper.cpp)
  342. ## Compile everything at once (roughly equivalent to cat *.cpp | gcc)
  343. OPTION(COMPILE_AMALGATION "Compile all the files together at once (experimental)" OFF)
  344. IF(COMPILE_AMALGATION)
  345. FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/amalgation.cpp "// Includes all source files of the project\n")
  346. FOREACH(ST_FILE ${SUPERTUX_SOURCES_CXX})
  347. FILE(RELATIVE_PATH CXX_FILE ${CMAKE_CURRENT_SOURCE_DIR}/src "${CMAKE_CURRENT_SOURCE_DIR}/${ST_FILE}")
  348. FILE(APPEND ${CMAKE_CURRENT_BINARY_DIR}/amalgation.cpp "#include \"${CXX_FILE}\"\n")
  349. ENDFOREACH(ST_FILE)
  350. ## Build instead of CXX sources
  351. SET(SUPERTUX_SOURCES_CXX ${CMAKE_CURRENT_BINARY_DIR}/amalgation.cpp)
  352. ELSE(COMPILE_AMALGATION)
  353. IF(EXISTS ${CMAKE_CURRENT_BINARY_DIR}/amalgation.cpp)
  354. FILE(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/amalgation.cpp)
  355. ENDIF(EXISTS ${CMAKE_CURRENT_BINARY_DIR}/amalgation.cpp)
  356. ENDIF(COMPILE_AMALGATION)
  357. ## Debug options
  358. OPTION(WERROR "Stop on first compiler warning" OFF)
  359. OPTION(WARNINGS "Enable long list of warnings for compiler to check" OFF)
  360. if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  361. # http://www.guyrutenberg.com/2014/01/05/enabling-c11-c0x-in-cmake/
  362. include(CheckCXXCompilerFlag)
  363. CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
  364. if(COMPILER_SUPPORTS_CXX11)
  365. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
  366. else(COMPILER_SUPPORTS_CXX11)
  367. CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
  368. if(COMPILER_SUPPORTS_CXX0X)
  369. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
  370. else(COMPILER_SUPPORTS_CXX0X)
  371. message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
  372. endif(COMPILER_SUPPORTS_CXX0X)
  373. endif(COMPILER_SUPPORTS_CXX11)
  374. SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g" CACHE STRING "Debug flags")
  375. SET(CMAKE_C_FLAGS_DEBUG "-O0 -g" CACHE STRING "Debug flags")
  376. SET(CMAKE_CXX_FLAGS_PROFILE "-pg" CACHE STRING "Profile flags")
  377. SET(CMAKE_C_FLAGS_PROFILE "-pg" CACHE STRING "Profile flags")
  378. SET(CMAKE_LD_FLAGS_PROFILE "-lgmon" CACHE STRING "Profile flags")
  379. SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-unused-parameter -funit-at-a-time")
  380. IF(WERROR)
  381. ADD_DEFINITIONS(-Werror)
  382. ELSE(WERROR)
  383. REMOVE_DEFINITIONS(-Werror)
  384. ENDIF(WERROR)
  385. IF(WARNINGS)
  386. # temporarily disabled:
  387. # -Wsign-conversion -Wfloat-equal -Wconversion -Wundef -Wswitch-default
  388. # -Wswitch-enum -Wsign-promo -Wcast-qual -Woverloaded-virtual -Wmissing-format-attribute
  389. # -Wold-style-cast -Wpadded -Wabi -Winline -Wunsafe-loop-optimizations -Wstrict-overflow=5
  390. # fails on MinGW:
  391. # -ansi
  392. # fails on clang:
  393. # -Wlogical-op -Wstrict-null-sentinel
  394. 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")
  395. ENDIF(WARNINGS)
  396. endif()
  397. ## If xgettext is available, generate messages.pot for sources
  398. OPTION(GENERATE_MESSAGESPOT "Generate messages.pot files" OFF)
  399. IF(GENERATE_MESSAGESPOT)
  400. MARK_AS_ADVANCED(
  401. XGETTEXT_EXECUTABLE
  402. )
  403. FIND_PROGRAM(XGETTEXT_EXECUTABLE xgettext)
  404. IF(NOT XGETTEXT_EXECUTABLE)
  405. MESSAGE(STATUS "Warning: xgettext not found - will not update messages.pot")
  406. ELSE(NOT XGETTEXT_EXECUTABLE)
  407. MESSAGE(STATUS "Found xgettext: ${XGETTEXT_EXECUTABLE}")
  408. SET(MESSAGES_POT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/data/locale/messages.pot)
  409. ADD_CUSTOM_COMMAND(
  410. OUTPUT ${MESSAGES_POT_FILE}
  411. COMMAND ${XGETTEXT_EXECUTABLE}
  412. ARGS --keyword=_ --language=C++ --output=${MESSAGES_POT_FILE} ${SUPERTUX_SOURCES_CXX}
  413. DEPENDS ${SUPERTUX_SOURCES_CXX}
  414. WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
  415. COMMENT "Generating POT file ${MESSAGES_POT_FILE}"
  416. )
  417. LIST(APPEND MESSAGES_POT_FILES ${MESSAGES_POT_FILE})
  418. FILE(GLOB SUPERTUX_LEVEL_DIRS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} data/levels/*)
  419. FOREACH(SUPERTUX_LEVEL_DIR ${SUPERTUX_LEVEL_DIRS})
  420. FILE(GLOB SUPERTUX_LEVELS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${SUPERTUX_LEVEL_DIR}/*.stl ${SUPERTUX_LEVEL_DIR}/*.stwm ${SUPERTUX_LEVEL_DIR}/*.txt)
  421. ## Do not add target if SUPERTUX_LEVELS is empty. This is needed for cmake <=2.4
  422. IF(SUPERTUX_LEVELS)
  423. SET(MESSAGES_POT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/${SUPERTUX_LEVEL_DIR}/messages.pot)
  424. ADD_CUSTOM_COMMAND(
  425. OUTPUT ${MESSAGES_POT_FILE}
  426. COMMAND ${XGETTEXT_EXECUTABLE}
  427. ARGS --keyword="_:1" --language=Lisp --force-po --sort-by-file "--output=${MESSAGES_POT_FILE}" ${SUPERTUX_LEVELS}
  428. DEPENDS ${SUPERTUX_LEVELS}
  429. WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
  430. COMMENT "Generating POT file ${MESSAGES_POT_FILE}"
  431. )
  432. LIST(APPEND MESSAGES_POT_FILES ${MESSAGES_POT_FILE})
  433. ENDIF(SUPERTUX_LEVELS)
  434. ENDFOREACH(SUPERTUX_LEVEL_DIR)
  435. ADD_CUSTOM_TARGET(
  436. supertux2-messages ALL
  437. DEPENDS ${MESSAGES_POT_FILES}
  438. )
  439. ENDIF(NOT XGETTEXT_EXECUTABLE)
  440. ENDIF(GENERATE_MESSAGESPOT)
  441. ## Some additional compiler switches
  442. if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  443. SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-strict-aliasing")
  444. endif()
  445. IF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
  446. ADD_DEFINITIONS(-DMACOSX)
  447. ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
  448. ## On Windows, add an icon
  449. IF(WIN32)
  450. # SET(SUPERTUX_SOURCES_C ${SUPERTUX_SOURCES_C} ${CMAKE_CURRENT_SOURCE_DIR}/data/images/engine/icons/supertux.rc)
  451. IF(MINGW)
  452. ADD_CUSTOM_COMMAND(
  453. OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/supertux_rc.o
  454. 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)
  455. SET(SUPERTUX_SOURCES_C ${SUPERTUX_SOURCES_C} ${CMAKE_CURRENT_BINARY_DIR}/supertux_rc.o)
  456. ENDIF(MINGW)
  457. ENDIF(WIN32)
  458. ## Build miniswig and generate miniswig wrapper
  459. OPTION(GENERATE_WRAPPER "Build miniswig and generate the wrapper" OFF)
  460. IF(GENERATE_WRAPPER)
  461. ADD_SUBDIRECTORY(tools/miniswig)
  462. ADD_CUSTOM_COMMAND(
  463. OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/src/scripting/wrapper.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/scripting/wrapper.hpp
  464. COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && ${CMAKE_CXX_COMPILER}
  465. 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
  466. COMMAND tools/miniswig/miniswig
  467. 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
  468. DEPENDS tools/miniswig/miniswig
  469. IMPLICIT_DEPENDS CXX ${CMAKE_CURRENT_SOURCE_DIR}/src/scripting/wrapper.interface.hpp
  470. )
  471. ENDIF(GENERATE_WRAPPER)
  472. ## Generate supertux executable in the right place
  473. #SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_SOURCE_DIR})
  474. SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR})
  475. ## Add target for supertux binary
  476. add_library(supertux2_c OBJECT ${SUPERTUX_SOURCES_C})
  477. add_library(supertux2_lib STATIC ${CMAKE_BINARY_DIR}/version.h ${SUPERTUX_SOURCES_CXX} ${SUPERTUX_RESOURCES} $<TARGET_OBJECTS:supertux2_c>)
  478. IF(WIN32)
  479. add_executable(supertux2 WIN32 src/main.cpp ${CMAKE_CURRENT_SOURCE_DIR}/data/images/engine/icons/supertux.rc)
  480. TARGET_LINK_LIBRARIES(supertux2 ${SDL2MAIN_LIBRARIES})
  481. ELSE()
  482. add_executable(supertux2 src/main.cpp)
  483. ENDIF(WIN32)
  484. target_link_libraries(supertux2 supertux2_lib)
  485. set_target_properties(supertux2 PROPERTIES OUTPUT_NAME supertux2)
  486. set_target_properties(supertux2_lib PROPERTIES OUTPUT_NAME supertux2)
  487. set_target_properties(supertux2_lib PROPERTIES COMPILE_FLAGS "${SUPERTUX2_EXTRA_WARNING_FLAGS}")
  488. IF(WIN32)
  489. ## Copy dlls on windows
  490. ADD_CUSTOM_COMMAND(TARGET supertux2_lib POST_BUILD
  491. COMMAND ${CMAKE_COMMAND} -E copy_directory
  492. "${DEPENDENCY_FOLDER}/dll"
  493. $<TARGET_FILE_DIR:supertux2_lib>)
  494. # ADD_CUSTOM_COMMAND(TARGET supertux2 POST_BUILD
  495. # COMMAND ${CMAKE_COMMAND} -E copy
  496. # "${DEPENDENCY_FOLDER}/DigiCertHighAssuranceEVRootCA.pem"
  497. # $<TARGET_FILE_DIR:supertux2_lib>)
  498. ENDIF(WIN32)
  499. ## Link supertux binary with squirrel and other libraries
  500. ADD_DEPENDENCIES(supertux2_lib tinygettext)
  501. ADD_DEPENDENCIES(supertux2_lib squirrel)
  502. TARGET_INCLUDE_DIRECTORIES(supertux2_lib SYSTEM PUBLIC ${SDL2_INCLUDE_DIRS})
  503. TARGET_INCLUDE_DIRECTORIES(supertux2_lib SYSTEM PUBLIC ${SDL2IMAGE_INCLUDE_DIRS})
  504. TARGET_LINK_LIBRARIES(supertux2_lib PUBLIC ${SDL2_LIBRARIES})
  505. TARGET_LINK_LIBRARIES(supertux2_lib PUBLIC ${SDL2IMAGE_LIBRARIES})
  506. TARGET_LINK_LIBRARIES(supertux2_lib PUBLIC squirrel_lib)
  507. TARGET_LINK_LIBRARIES(supertux2_lib PUBLIC sqstdlib_lib)
  508. TARGET_LINK_LIBRARIES(supertux2_lib PUBLIC tinygettext_lib)
  509. TARGET_LINK_LIBRARIES(supertux2_lib PUBLIC sexp)
  510. TARGET_LINK_LIBRARIES(supertux2_lib PUBLIC ${OPENAL_LIBRARY})
  511. TARGET_LINK_LIBRARIES(supertux2_lib PUBLIC ${OGGVORBIS_LIBRARIES})
  512. TARGET_LINK_LIBRARIES(supertux2_lib PUBLIC ${Boost_LIBRARIES})
  513. IF(USE_SYSTEM_PHYSFS)
  514. TARGET_LINK_LIBRARIES(supertux2_lib PUBLIC ${PHYSFS_LIBRARY})
  515. ELSE()
  516. ADD_DEPENDENCIES(supertux2_lib physfs)
  517. TARGET_LINK_LIBRARIES(supertux2_lib PUBLIC physfs_lib)
  518. IF(APPLE)
  519. TARGET_LINK_LIBRARIES(supertux2_lib PUBLIC "-framework CoreFoundation")
  520. TARGET_LINK_LIBRARIES(supertux2_lib PUBLIC "-framework IOKit")
  521. ENDIF()
  522. ENDIF()
  523. IF(HAVE_OPENGL)
  524. TARGET_LINK_LIBRARIES(supertux2_lib PUBLIC ${OPENGL_LIBRARY})
  525. IF(GLBINDING_FOUND)
  526. TARGET_LINK_LIBRARIES(supertux2_lib PUBLIC ${GLBINDING_LIBRARIES})
  527. ELSE()
  528. TARGET_LINK_LIBRARIES(supertux2_lib PUBLIC ${GLEW_LIBRARY})
  529. ENDIF()
  530. ENDIF(HAVE_OPENGL)
  531. IF(HAVE_LIBCURL)
  532. TARGET_LINK_LIBRARIES(supertux2_lib PUBLIC ${CURL_LIBRARY})
  533. ENDIF(HAVE_LIBCURL)
  534. if(BUILD_TESTS)
  535. find_package(Threads REQUIRED)
  536. # build gtest
  537. # ${CMAKE_CURRENT_SOURCE_DIR} in include_directories is needed to generate -isystem instead of -I flags
  538. add_library(gtest_main STATIC ${CMAKE_CURRENT_SOURCE_DIR}/external/googletest/googletest/src/gtest_main.cc)
  539. target_include_directories(gtest_main SYSTEM PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/external/googletest/googletest/include/)
  540. add_library(gtest STATIC ${CMAKE_CURRENT_SOURCE_DIR}/external/googletest/googletest/src/gtest-all.cc)
  541. target_include_directories(gtest SYSTEM PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/external/googletest/googletest/)
  542. target_include_directories(gtest SYSTEM PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/external/googletest/googletest/include/)
  543. # build SuperTux tests
  544. file(GLOB TEST_SUPERTUX_SOURCES tests/*.cpp)
  545. add_executable(test_supertux2 ${TEST_SUPERTUX_SOURCES})
  546. target_compile_options(test_supertux2 PRIVATE ${WARNINGS_CXX_FLAGS})
  547. target_link_libraries(test_supertux2
  548. gtest gtest_main
  549. supertux2_lib
  550. ${CMAKE_THREAD_LIBS_INIT})
  551. # add 'make test' target, use 'make test ARGS="-V"' or 'ctest -V' for verbose
  552. enable_testing()
  553. add_test(NAME test_supertux2
  554. WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
  555. COMMAND test_supertux2)
  556. endif()
  557. ## Install stuff
  558. OPTION(DISABLE_CPACK_BUNDLING "Build an .app bundle without CPack" OFF)
  559. IF(WIN32 AND NOT UNIX)
  560. SET(INSTALL_SUBDIR_BIN "bin" CACHE STRING "Installation subdir for binaries")
  561. SET(INSTALL_SUBDIR_SHARE "data" CACHE STRING "Installation subdir for data")
  562. SET(INSTALL_SUBDIR_DOC "doc" CACHE STRING "Installation subdir for docs")
  563. INSTALL(FILES ${DLLS} DESTINATION ${INSTALL_SUBDIR_BIN})
  564. INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/images/engine/icons/supertux.png ${CMAKE_CURRENT_SOURCE_DIR}/data/images/engine/icons/supertux.ico DESTINATION ".")
  565. OPTION(PACKAGE_VCREDIST "Package the VCREDIST libraries with the program" OFF)
  566. IF(PACKAGE_VCREDIST)
  567. include(InstallRequiredSystemLibraries)
  568. INSTALL(FILES ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS} DESTINATION ${INSTALL_SUBDIR_BIN})
  569. include(FindWindowsSDK)
  570. IF(${CMAKE_VS_PLATFORM_NAME} STREQUAL "Win32")
  571. SET(UCRT_PATH "${WINDOWSSDK_PREFERRED_DIR}/Redist/ucrt/DLLs/x86")
  572. ELSE()
  573. SET(UCRT_PATH "${WINDOWSSDK_PREFERRED_DIR}/Redist/ucrt/DLLs/x64")
  574. ENDIF()
  575. FILE(GLOB UCRT_DLLS "${UCRT_PATH}/*")
  576. INSTALL(FILES ${UCRT_DLLS} DESTINATION ${INSTALL_SUBDIR_BIN})
  577. ENDIF()
  578. ELSE(WIN32 AND NOT UNIX)
  579. IF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin" AND DISABLE_CPACK_BUNDLING)
  580. SET(INFOPLIST_CFBUNDLEEXECUTABLE "supertux2")
  581. SET(INSTALL_SUBDIR_BIN "SuperTux.app/Contents/MacOS" CACHE STRING "Installation subdir for binaries")
  582. SET(INSTALL_SUBDIR_SHARE "SuperTux.app/Contents/Resources/data" CACHE STRING "Installation subdir for data")
  583. SET(INSTALL_SUBDIR_DOC "SuperTux.app/Contents/Resources" CACHE STRING "Installation subdir for docs")
  584. CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/tools/darwin/info.plist.in ${CMAKE_BINARY_DIR}/tools/darwin/info.plist)
  585. INSTALL(FILES ${CMAKE_BINARY_DIR}/tools/darwin/info.plist DESTINATION "SuperTux.app/Contents/")
  586. INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/tools/darwin/receipt DESTINATION "SuperTux.app/Contents/_MASReceipt/")
  587. 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/")
  588. ELSE(${CMAKE_SYSTEM_NAME} MATCHES "Darwin" AND DISABLE_CPACK_BUNDLING)
  589. SET(INSTALL_SUBDIR_BIN "games" CACHE STRING "Installation subdir for binaries")
  590. SET(INSTALL_SUBDIR_SHARE "share/games/supertux2" CACHE STRING "Installation subdir for data")
  591. SET(INSTALL_SUBDIR_DOC "share/doc/supertux2" CACHE STRING "Installation subdir for docs")
  592. INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/supertux2.desktop DESTINATION "share/applications")
  593. SET(APPS "\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${INSTALL_SUBDIR_BIN}/supertux2")
  594. 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/")
  595. ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin" AND DISABLE_CPACK_BUNDLING)
  596. ENDIF(WIN32 AND NOT UNIX)
  597. INSTALL(TARGETS supertux2 DESTINATION ${INSTALL_SUBDIR_BIN})
  598. IF(WIN32)
  599. GET_PROPERTY(SQUIRREL_LIB_PATH TARGET squirrel_lib PROPERTY IMPORTED_LOCATION)
  600. GET_PROPERTY(SQSTDLIB_LIB_PATH TARGET sqstdlib_lib PROPERTY IMPORTED_LOCATION)
  601. GET_PROPERTY(PHYSFS_LIB_PATH TARGET physfs_lib PROPERTY IMPORTED_LOCATION)
  602. INSTALL(FILES ${SQUIRREL_LIB_PATH} ${SQSTDLIB_LIB_PATH} ${PHYSFS_LIB_PATH} DESTINATION ${INSTALL_SUBDIR_BIN})
  603. ENDIF()
  604. 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})
  605. INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/credits.stxt DESTINATION ${INSTALL_SUBDIR_SHARE})
  606. INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/supertux2.appdata.xml DESTINATION "share/appdata" )
  607. INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/data/images
  608. ${CMAKE_CURRENT_SOURCE_DIR}/data/fonts
  609. ${CMAKE_CURRENT_SOURCE_DIR}/data/music
  610. ${CMAKE_CURRENT_SOURCE_DIR}/data/scripts
  611. ${CMAKE_CURRENT_SOURCE_DIR}/data/speech
  612. ${CMAKE_CURRENT_SOURCE_DIR}/data/sounds
  613. ${CMAKE_CURRENT_SOURCE_DIR}/data/locale
  614. DESTINATION ${INSTALL_SUBDIR_SHARE})
  615. IF(CMAKE_BUILD_TYPE MATCHES Release)
  616. INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/data/levels
  617. DESTINATION ${INSTALL_SUBDIR_SHARE}
  618. PATTERN "data/levels/test" EXCLUDE
  619. PATTERN "data/levels/test_old" EXCLUDE
  620. PATTERN "data/levels/incubator" EXCLUDE
  621. PATTERN "data/levels/misc/menu.stl.in" EXCLUDE)
  622. ELSE()
  623. INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/data/levels
  624. DESTINATION ${INSTALL_SUBDIR_SHARE}
  625. PATTERN "data/levels/misc/menu.stl.in" EXCLUDE)
  626. ENDIF()
  627. INSTALL(FILES "${CMAKE_BINARY_DIR}/data/levels/misc/menu.stl" DESTINATION "${INSTALL_SUBDIR_SHARE}/levels/misc")
  628. ## Create config.h now that INSTALL_SUBDIR_* have been set.
  629. configure_file(config.h.cmake ${CMAKE_BINARY_DIR}/config.h )
  630. ## Configure main menu logo
  631. IF(CMAKE_BUILD_TYPE MATCHES Release)
  632. SET(LOGO_FILE "logo_final.sprite")
  633. ELSE()
  634. SET(LOGO_FILE "logo.sprite")
  635. ENDIF()
  636. configure_file(data/levels/misc/menu.stl.in ${CMAKE_BINARY_DIR}/data/levels/misc/menu.stl )
  637. ## CPack/Installation-specific stuff
  638. INCLUDE(InstallRequiredSystemLibraries)
  639. SET(DIRS ${Boost_LIBRARY_DIRS} ${CMAKE_CURRENT_BINARY_DIR}/external/squirrel ${CMAKE_CURRENT_BINARY_DIR}/external/tinygettext)
  640. IF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin" AND NOT DISABLE_CPACK_BUNDLING)
  641. SET(INFOPLIST_CFBUNDLEEXECUTABLE "SuperTux")
  642. FIND_PACKAGE(png)
  643. foreach (_file ${PNG_LIBRARIES})
  644. get_filename_component(_resolvedFile "${_file}" REALPATH)
  645. get_filename_component(_name "${_file}" NAME)
  646. INSTALL(FILES ${_resolvedFile} DESTINATION "MacOS" RENAME ${_name})
  647. endforeach()
  648. FIND_PACKAGE(jpeg)
  649. foreach (_file ${JPEG_LIBRARIES})
  650. get_filename_component(_resolvedFile "${_file}" REALPATH)
  651. get_filename_component(_name "${_file}" NAME)
  652. INSTALL(FILES ${_resolvedFile} DESTINATION "MacOS" RENAME ${_name})
  653. endforeach()
  654. INSTALL(CODE "
  655. if(\"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/\" MATCHES \".*\\\\.app.*\")
  656. include(BundleUtilities)
  657. fixup_bundle(\"${APPS}\" \"\" \"${DIRS}\")
  658. endif()
  659. ")
  660. CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/tools/darwin/info.plist.in" "${CMAKE_BINARY_DIR}/tools/darwin/info.plist")
  661. SET(CPACK_BUNDLE_NAME "SuperTux")
  662. SET(CPACK_BUNDLE_PLIST "${CMAKE_BINARY_DIR}/tools/darwin/info.plist")
  663. SET(CPACK_BUNDLE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/data/images/engine/icons/supertux.icns")
  664. SET(CPACK_BUNDLE_STARTUP_COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/tools/darwin/startup.sh")
  665. SET(CPACK_DMG_VOLUME_NAME "SuperTux ${SUPERTUX_VERSION_STRING}")
  666. SET(CPACK_DMG_DS_STORE "${CMAKE_CURRENT_SOURCE_DIR}/tools/darwin/DS_Store")
  667. SET(CPACK_DMG_BACKGROUND_IMAGE "${CMAKE_CURRENT_SOURCE_DIR}/tools/darwin/background.png")
  668. ENDIF()
  669. SET(CPACK_PACKAGE_NAME "SuperTux")
  670. SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Jump'n'Run Game featuring Tux")
  671. SET(CPACK_PACKAGE_VENDOR "SuperTux Devel Team")
  672. SET(CPACK_PACKAGE_CONTACT "SuperTux Devel Team <supertux-devel@lists.lethargik.org>")
  673. SET(CPACK_SOURCE_IGNORE_FILES "/\\\\.git/;${CMAKE_BINARY_DIR};/\\\\..*")
  674. SET(CPACK_DEBIAN_PACKAGE_NAME "supertux2")
  675. 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)")
  676. 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/")
  677. SET(CPACK_DEBIAN_PACKAGE_SECTION "games")
  678. SET(CPACK_RPM_PACKAGE_NAME "supertux2")
  679. 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/")
  680. SET(CPACK_RPM_PACKAGE_LICENSE "GNU General Public License (GPL)")
  681. SET(CPACK_RPM_PACKAGE_GROUP "Amusements/Games/Action/Arcade")
  682. SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
  683. SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.txt")
  684. SET(CPACK_PACKAGE_VERSION_MAJOR ${SUPERTUX_VERSION_MAJOR})
  685. SET(CPACK_PACKAGE_VERSION_MINOR ${SUPERTUX_VERSION_MINOR})
  686. IF(SUPERTUX_VERSION_TWEAK)
  687. SET(CPACK_PACKAGE_VERSION_PATCH "${SUPERTUX_VERSION_PATCH}.${SUPERTUX_VERSION_TWEAK}")
  688. ELSE()
  689. SET(CPACK_PACKAGE_VERSION_PATCH ${SUPERTUX_VERSION_PATCH})
  690. ENDIF(SUPERTUX_VERSION_TWEAK)
  691. SET(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${SUPERTUX_VERSION_STRING}-${SUPERTUX_SYSTEM_NAME}")
  692. SET(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${SUPERTUX_VERSION_STRING}-Source")
  693. SET(CPACK_PACKAGE_INSTALL_DIRECTORY "SuperTux")
  694. SET(CPACK_PACKAGE_EXECUTABLES "supertux2" "SuperTux")
  695. IF(WIN32 AND NOT UNIX)
  696. SET(CPACK_NSIS_INSTALLED_ICON_NAME "supertux2")
  697. SET(CPACK_NSIS_DISPLAY_NAME "SuperTux")
  698. SET(CPACK_NSIS_COMPRESSOR "/SOLID lzma")
  699. SET(CPACK_WIX_PROGRAM_MENU_FOLDER "")
  700. SET(CPACK_WIX_UPGRADE_GUID "93E16F4E-0A68-422A-8ADC-47BE5B9433B2")
  701. SET(CPACK_WIX_PRODUCT_ICON "${CMAKE_CURRENT_SOURCE_DIR}/data/images/engine/icons/supertux.ico")
  702. SET(CPACK_WIX_UI_BANNER "${CMAKE_CURRENT_SOURCE_DIR}/mk/wix/banner.png")
  703. SET(CPACK_WIX_UI_DIALOG "${CMAKE_CURRENT_SOURCE_DIR}/mk/wix/dialog.png")
  704. SET(CPACK_GENERATOR WIX)
  705. ELSE(WIN32 AND NOT UNIX)
  706. ENDIF(WIN32 AND NOT UNIX)
  707. INCLUDE(CPack)
  708. # move some config clutter to the advanced section
  709. MARK_AS_ADVANCED(
  710. INSTALL_SUBDIR_BIN
  711. INSTALL_SUBDIR_SHARE
  712. INSTALL_SUBDIR_DOC
  713. )
  714. MARK_AS_ADVANCED(
  715. CMAKE_BACKWARDS_COMPATIBILITY
  716. CMAKE_BUILD_TYPE
  717. CMAKE_INSTALL_PREFIX
  718. EXECUTABLE_OUTPUT_PATH
  719. LIBRARY_OUTPUT_PATH
  720. CMAKE_OSX_ARCHITECTURES
  721. CMAKE_OSX_SYSROOT
  722. )
  723. MARK_AS_ADVANCED(
  724. APPDATADIR
  725. )
  726. MARK_AS_ADVANCED(
  727. Boost_INCLUDE_DIR
  728. Boost_LIBRARIES
  729. )
  730. MARK_AS_ADVANCED(
  731. GLEW_INCLUDE_DIR
  732. GLEW_LIBRARY
  733. )
  734. MARK_AS_ADVANCED(
  735. SDL2_INCLUDE_DIRS
  736. SDL2_LIBRARIES
  737. )
  738. MARK_AS_ADVANCED(
  739. SDL2IMAGE_INCLUDE_DIRS
  740. SDL2IMAGE_LIBRARIES
  741. )
  742. MARK_AS_ADVANCED(
  743. OPENAL_INCLUDE_DIR
  744. OPENAL_LIBRARY
  745. )
  746. MARK_AS_ADVANCED(
  747. OGG_LIBRARY
  748. VORBISENC_LIBRARY
  749. VORBISFILE_LIBRARY
  750. VORBIS_INCLUDE_DIR
  751. VORBIS_LIBRARY
  752. )
  753. MARK_AS_ADVANCED(
  754. PHYSFS_INCLUDE_DIR
  755. PHYSFS_LIBRARY
  756. )