CMakeLists.txt 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605
  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. ## Version, for display in title bar.
  34. ## Will add 'commit <hash>' to the end if git is available and this is a git repository.
  35. SET(SUPERTUX_VERSION "0.4.0-git")
  36. ### CMake configuration
  37. # allow building with CMake 2.6. Set compatibility options. Use some bundled modules as a fallback
  38. CMAKE_MINIMUM_REQUIRED(VERSION 2.6.1)
  39. IF(COMMAND cmake_policy)
  40. CMAKE_POLICY(SET CMP0003 NEW)
  41. CMAKE_POLICY(SET CMP0008 NEW)
  42. IF(POLICY CMP0043)
  43. CMAKE_POLICY(SET CMP0043 OLD)
  44. ENDIF(POLICY CMP0043)
  45. ENDIF(COMMAND cmake_policy)
  46. SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/mk/cmake)
  47. ## For autopackage
  48. SET(APPDATADIR "${CMAKE_INSTALL_PREFIX}/share/games/supertux2")
  49. ## Check endianess
  50. INCLUDE(TestBigEndian)
  51. TEST_BIG_ENDIAN(WORDS_BIGENDIAN)
  52. ## These variables enable MSVC to find libraries located in "dependencies{32|64}"
  53. IF(WIN32)
  54. ## Store path of dependecy folder
  55. SET(DEPENDENCY_FOLDER "${PROJECT_SOURCE_DIR}/dependencies")
  56. ## To test if the host (not the build) is x64:
  57. ## "$ENV{PROCESSOR_ARCHITEW6432}" STREQUAL "AMD64"
  58. IF(${CMAKE_SIZEOF_VOID_P} EQUAL 8)
  59. SET(WIN64 ON)
  60. SET(DEPENDENCY_FOLDER "${DEPENDENCY_FOLDER}64")
  61. ELSE(${CMAKE_SIZEOF_VOID_P} EQUAL 8)
  62. SET(WIN64 OFF)
  63. SET(DEPENDENCY_FOLDER "${DEPENDENCY_FOLDER}32")
  64. ENDIF(${CMAKE_SIZEOF_VOID_P} EQUAL 8)
  65. SET(ENV{PATH} "$ENV{PATH};${DEPENDENCY_FOLDER}/include")
  66. SET(ENV{LIB} "${DEPENDENCY_FOLDER}/lib")
  67. SET(ENV{OPENALDIR} "${DEPENDENCY_FOLDER}")
  68. SET_PROPERTY(DIRECTORY PROPERTY COMPILE_DEFINITIONS_DEBUG DEBUG)
  69. ## Enable multi-processor compilation (faster)
  70. SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
  71. ## And shut up about unsafe stuff
  72. ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
  73. ## Add an icon
  74. CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/mk/msvc/icon_rc.template" "${PROJECT_BINARY_DIR}/tmp/icon.rc")
  75. ## Find all used libraries
  76. FILE(GLOB DLLS "${DEPENDENCY_FOLDER}/dll/*")
  77. ENDIF(WIN32)
  78. ## Add lots of dependencies to compiler switches
  79. SET(Boost_ADDITIONAL_VERSIONS "1.41" "1.41.0")
  80. FIND_PATH(PHYSFS_INCLUDE_DIR NAMES physfs.h PATHS "${DEPENDENCY_FOLDER}/include/physfs")
  81. FIND_PACKAGE(Boost REQUIRED)
  82. INCLUDE_DIRECTORIES(SYSTEM ${Boost_INCLUDE_DIR})
  83. LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})
  84. IF(WIN32)
  85. FIND_PATH(SDL2_INCLUDE_DIRS NAMES SDL.h PATHS "${DEPENDENCY_FOLDER}/include/SDL2")
  86. FIND_PATH(SDL2IMAGE_INCLUDE_DIRS NAMES SDL_image.h PATHS "${DEPENDENCY_FOLDER}/include/SDL2_image")
  87. FIND_LIBRARY(SDL2_LIBRARIES NAMES SDL2 PATHS "${DEPENDENCY_FOLDER}/lib")
  88. FIND_LIBRARY(SDL2IMAGE_LIBRARIES NAMES SDL2_image PATHS "${DEPENDENCY_FOLDER}/lib")
  89. ELSE(WIN32)
  90. INCLUDE(FindPkgConfig)
  91. PKG_SEARCH_MODULE(SDL2 REQUIRED sdl2>=2.0.1)
  92. PKG_SEARCH_MODULE(SDL2IMAGE REQUIRED SDL2_image>=2.0.0)
  93. ENDIF(WIN32)
  94. SET(HAVE_SDL TRUE)
  95. OPTION(ENABLE_OPENGL "Enable OpenGL support" ON)
  96. OPTION(GLBINDING_ENABLED "Use glbinding instead of GLEW" OFF)
  97. OPTION(GLBINDING_DEBUG_OUTPUT "Enable glbinding debug output for each called OpenGL function" OFF)
  98. IF(ENABLE_OPENGL)
  99. FIND_PACKAGE(OpenGL)
  100. IF(OPENGL_FOUND)
  101. INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR})
  102. SET(HAVE_OPENGL TRUE)
  103. ENDIF(OPENGL_FOUND)
  104. IF(GLBINDING_ENABLED)
  105. FIND_PACKAGE(GLBINDING REQUIRED)
  106. IF(GLBINDING_FOUND)
  107. INCLUDE_DIRECTORIES(${GLBINDING_INCLUDES})
  108. ADD_DEFINITIONS(-DUSE_GLBINDING)
  109. IF (GLBINDING_DEBUG_OUTPUT)
  110. ADD_DEFINITIONS(-DUSE_GLBINDING_DEBUG_OUTPUT)
  111. ENDIF()
  112. ENDIF()
  113. ELSE()
  114. FIND_PACKAGE(GLEW REQUIRED)
  115. IF(GLEW_FOUND)
  116. INCLUDE_DIRECTORIES(${GLEW_INCLUDE_DIR})
  117. ENDIF(GLEW_FOUND)
  118. ENDIF()
  119. ENDIF(ENABLE_OPENGL)
  120. FIND_PACKAGE(OpenAL REQUIRED)
  121. INCLUDE_DIRECTORIES(${OPENAL_INCLUDE_DIR})
  122. FIND_PACKAGE(OggVorbis REQUIRED)
  123. INCLUDE_DIRECTORIES(${VORBIS_INCLUDE_DIR})
  124. FIND_PACKAGE(PhysFS REQUIRED)
  125. INCLUDE_DIRECTORIES(${PHYSFS_INCLUDE_DIR})
  126. ## The curl headers are in the standard include path in dependencies
  127. ## so it's not required to add them here
  128. IF(NOT WIN32 OR WIN64)
  129. FIND_PACKAGE(CURL REQUIRED)
  130. IF(CURL_FOUND)
  131. INCLUDE_DIRECTORIES(${CURL_INCLUDE_DIR})
  132. SET(HAVE_LIBCURL TRUE)
  133. ENDIF(CURL_FOUND)
  134. ENDIF(NOT WIN32 OR WIN64)
  135. #FIND_PACKAGE(ICONV REQUIRED)
  136. #INCLUDE_DIRECTORIES(${ICONV_INCLUDE_DIR})
  137. #LINK_LIBRARIES(${ICONV_LIBRARY})
  138. ## Find revision of WC
  139. MARK_AS_ADVANCED(GIT_EXECUTABLE)
  140. FIND_PROGRAM(GIT_EXECUTABLE git)
  141. # The .git directory inside the base directory
  142. SET(GIT_CFG_DIR "${CMAKE_CURRENT_SOURCE_DIR}/.git/")
  143. IF(GIT_EXECUTABLE AND EXISTS ${GIT_CFG_DIR})
  144. ADD_CUSTOM_COMMAND(OUTPUT "${CMAKE_BINARY_DIR}/version.h"
  145. COMMAND ${CMAKE_COMMAND} -E echo "#ifndef VERSION_H" > "${CMAKE_BINARY_DIR}/version.h.tmp"
  146. COMMAND ${CMAKE_COMMAND} -E echo "#define VERSION_H" >> "${CMAKE_BINARY_DIR}/version.h.tmp"
  147. COMMAND ${CMAKE_COMMAND} >> "${CMAKE_BINARY_DIR}/version.h.tmp" -E echo_append "#define PACKAGE_VERSION \"${SUPERTUX_VERSION} commit "
  148. COMMAND ${GIT_EXECUTABLE} rev-parse --sq HEAD >> "${CMAKE_BINARY_DIR}/version.h.tmp"
  149. COMMAND ${CMAKE_COMMAND} >> "${CMAKE_BINARY_DIR}/version.h.tmp" -E echo "\""
  150. COMMAND ${CMAKE_COMMAND} -E echo "#endif" >> "${CMAKE_BINARY_DIR}/version.h.tmp"
  151. COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_BINARY_DIR}/version.h.tmp" "${CMAKE_BINARY_DIR}/version.h"
  152. COMMAND ${CMAKE_COMMAND} -E remove "${CMAKE_BINARY_DIR}/version.h.tmp"
  153. WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
  154. COMMENT "Updating ${CMAKE_BINARY_DIR}/version.h..."
  155. VERBATIM)
  156. ELSE(GIT_EXECUTABLE AND EXISTS ${GIT_CFG_DIR})
  157. ADD_CUSTOM_COMMAND(OUTPUT "${CMAKE_BINARY_DIR}/version.h"
  158. COMMAND ${CMAKE_COMMAND} -E echo "#ifndef VERSION_H" > "${CMAKE_BINARY_DIR}/version.h.tmp"
  159. COMMAND ${CMAKE_COMMAND} -E echo "#define VERSION_H" >> "${CMAKE_BINARY_DIR}/version.h.tmp"
  160. COMMAND ${CMAKE_COMMAND} >> "${CMAKE_BINARY_DIR}/version.h.tmp" -E echo "#define PACKAGE_VERSION \"${SUPERTUX_VERSION}\""
  161. COMMAND ${CMAKE_COMMAND} -E echo "#endif" >> "${CMAKE_BINARY_DIR}/version.h.tmp"
  162. COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_BINARY_DIR}/version.h.tmp" "${CMAKE_BINARY_DIR}/version.h"
  163. COMMAND ${CMAKE_COMMAND} -E remove "${CMAKE_BINARY_DIR}/version.h.tmp"
  164. WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
  165. COMMENT "Updating ${CMAKE_BINARY_DIR}/version.h..."
  166. VERBATIM)
  167. ENDIF(GIT_EXECUTABLE AND EXISTS ${GIT_CFG_DIR})
  168. SET_SOURCE_FILES_PROPERTIES(${CMAKE_BINARY_DIR}/version.h
  169. PROPERTIES GENERATED true)
  170. SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_SOURCE_DIR}/src/supertux/main.cpp
  171. PROPERTIES OBJECT_DEPENDS "${CMAKE_BINARY_DIR}/version.h")
  172. SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_SOURCE_DIR}/src/supertux/title_screen.cpp
  173. PROPERTIES OBJECT_DEPENDS "${CMAKE_BINARY_DIR}/version.h")
  174. SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_SOURCE_DIR}/src/addon/addon_manager.cpp
  175. PROPERTIES OBJECT_DEPENDS "${CMAKE_BINARY_DIR}/version.h")
  176. ## Check platform-dependent build options
  177. INCLUDE(ConfigureChecks)
  178. ## Also execute instructions in external/squirrel/CMakeLists.txt
  179. ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/external/squirrel)
  180. ## Add squirrel lib dir to search path
  181. LINK_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/external/squirrel)
  182. ## Some additional include paths
  183. include_directories (${CMAKE_BINARY_DIR}/)
  184. include_directories (${CMAKE_CURRENT_SOURCE_DIR}/src/)
  185. include_directories (${CMAKE_CURRENT_SOURCE_DIR}/external/squirrel/include/)
  186. include_directories (${CMAKE_CURRENT_SOURCE_DIR}/external/tinygettext/include/)
  187. include_directories (${CMAKE_CURRENT_SOURCE_DIR}/external/findlocale/)
  188. include_directories (${CMAKE_CURRENT_SOURCE_DIR}/external/obstack/)
  189. IF(WIN32)
  190. ADD_DEFINITIONS(-D_USE_MATH_DEFINES -DNOMINMAX)
  191. ENDIF(WIN32)
  192. ## Build list of sources for supertux binary
  193. FILE(GLOB SUPERTUX_SOURCES_C RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} external/obstack/*.c external/findlocale/findlocale.c)
  194. FILE(GLOB SUPERTUX_SOURCES_CXX RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} src/main.cpp src/*/*.cpp src/supertux/menu/*.cpp src/video/sdl/*.cpp)
  195. FILE(GLOB SUPERTUX_RESOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "${PROJECT_BINARY_DIR}/tmp/*.rc")
  196. FILE(GLOB TINYGETTEXT_SOURCES_CXX RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} external/tinygettext/src/*.cpp)
  197. SET_SOURCE_FILES_PROPERTIES(${TINYGETTEXT_SOURCES_CXX} PROPERTIES COMPILE_DEFINITIONS HAVE_SDL)
  198. IF(HAVE_OPENGL)
  199. FILE(GLOB SUPERTUX_OPENGL_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} src/video/gl/*.cpp)
  200. SET(SUPERTUX_SOURCES_CXX ${SUPERTUX_SOURCES_CXX} ${SUPERTUX_OPENGL_SOURCES})
  201. ENDIF(HAVE_OPENGL)
  202. ## Build miniswig and generate miniswig wrapper
  203. OPTION(GENERATE_WRAPPER "Build miniswig and generate the wrapper" OFF)
  204. IF(GENERATE_WRAPPER)
  205. ADD_SUBDIRECTORY(tools/miniswig)
  206. ADD_CUSTOM_COMMAND(
  207. OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/src/scripting/wrapper.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/scripting/wrapper.hpp
  208. COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && ${CMAKE_CXX_COMPILER}
  209. 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
  210. COMMAND tools/miniswig/miniswig
  211. 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
  212. DEPENDS tools/miniswig/miniswig
  213. IMPLICIT_DEPENDS CXX ${CMAKE_CURRENT_SOURCE_DIR}/src/scripting/wrapper.interface.hpp
  214. )
  215. ENDIF(GENERATE_WRAPPER)
  216. IF(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/src/scripting/wrapper.cpp)
  217. SET(SUPERTUX_SOURCES_CXX ${SUPERTUX_SOURCES_CXX} ${CMAKE_CURRENT_SOURCE_DIR}/src/scripting/wrapper.cpp)
  218. ENDIF(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/src/scripting/wrapper.cpp)
  219. ## Compile everything at once (roughly equivalent to cat *.cpp | gcc)
  220. OPTION(COMPILE_AMALGATION "Compile all the files together at once (experimental)" OFF)
  221. IF(COMPILE_AMALGATION)
  222. FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/amalgation.cpp "// Includes all source files of the project\n")
  223. FOREACH(ST_FILE ${SUPERTUX_SOURCES_CXX})
  224. FILE(RELATIVE_PATH CXX_FILE ${CMAKE_CURRENT_SOURCE_DIR}/src "${CMAKE_CURRENT_SOURCE_DIR}/${ST_FILE}")
  225. FILE(APPEND ${CMAKE_CURRENT_BINARY_DIR}/amalgation.cpp "#include \"${CXX_FILE}\"\n")
  226. ENDFOREACH(ST_FILE)
  227. ## Build instead of CXX sources
  228. SET(SUPERTUX_SOURCES_CXX ${CMAKE_CURRENT_BINARY_DIR}/amalgation.cpp)
  229. ELSE(COMPILE_AMALGATION)
  230. IF(EXISTS ${CMAKE_CURRENT_BINARY_DIR}/amalgation.cpp)
  231. FILE(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/amalgation.cpp)
  232. ENDIF(EXISTS ${CMAKE_CURRENT_BINARY_DIR}/amalgation.cpp)
  233. ENDIF(COMPILE_AMALGATION)
  234. ## Debug options
  235. OPTION(WERROR "Stop on first compiler warning" OFF)
  236. OPTION(WARNINGS "Enable long list of warnings for compiler to check" OFF)
  237. # http://www.guyrutenberg.com/2014/01/05/enabling-c11-c0x-in-cmake/
  238. include(CheckCXXCompilerFlag)
  239. CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
  240. if(COMPILER_SUPPORTS_CXX11)
  241. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
  242. else(COMPILER_SUPPORTS_CXX11)
  243. CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
  244. if(COMPILER_SUPPORTS_CXX0X)
  245. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
  246. else(COMPILER_SUPPORTS_CXX0X)
  247. message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
  248. endif(COMPILER_SUPPORTS_CXX0X)
  249. endif(COMPILER_SUPPORTS_CXX11)
  250. IF(CMAKE_COMPILER_IS_GNUCC)
  251. SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g" CACHE STRING "Debug flags")
  252. SET(CMAKE_C_FLAGS_DEBUG "-O0 -g" CACHE STRING "Debug flags")
  253. SET(CMAKE_CXX_FLAGS_PROFILE "-pg" CACHE STRING "Profile flags")
  254. SET(CMAKE_C_FLAGS_PROFILE "-pg" CACHE STRING "Profile flags")
  255. SET(CMAKE_LD_FLAGS_PROFILE "-lgmon" CACHE STRING "Profile flags")
  256. ADD_DEFINITIONS(-Wall -Wextra -Wno-unused-parameter -funit-at-a-time)
  257. IF(WERROR)
  258. ADD_DEFINITIONS(-Werror)
  259. ELSE(WERROR)
  260. REMOVE_DEFINITIONS(-Werror)
  261. ENDIF(WERROR)
  262. IF(WARNINGS)
  263. # temporarily disabled:
  264. # -Wsign-conversion -Wfloat-equal -Wconversion -Wundef -Wswitch-default
  265. # -Wswitch-enum -Wsign-promo -Wcast-qual -Woverloaded-virtual -Wmissing-format-attribute
  266. # -Wold-style-cast -Wpadded -Wabi -Winline -Wunsafe-loop-optimizations -Wstrict-overflow=5
  267. # fails on MinGW:
  268. # -ansi
  269. # fails on clang:
  270. # -Wlogical-op -Wstrict-null-sentinel
  271. 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")
  272. ENDIF(WARNINGS)
  273. ENDIF(CMAKE_COMPILER_IS_GNUCC)
  274. ## If xgettext is available, generate messages.pot for sources
  275. OPTION(GENERATE_MESSAGESPOT "Generate messages.pot files" OFF)
  276. IF(GENERATE_MESSAGESPOT)
  277. MARK_AS_ADVANCED(
  278. XGETTEXT_EXECUTABLE
  279. )
  280. FIND_PROGRAM(XGETTEXT_EXECUTABLE xgettext)
  281. IF(NOT XGETTEXT_EXECUTABLE)
  282. MESSAGE(STATUS "Warning: xgettext not found - will not update messages.pot")
  283. ELSE(NOT XGETTEXT_EXECUTABLE)
  284. MESSAGE(STATUS "Found xgettext: ${XGETTEXT_EXECUTABLE}")
  285. SET(MESSAGES_POT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/data/locale/messages.pot)
  286. ADD_CUSTOM_COMMAND(
  287. OUTPUT ${MESSAGES_POT_FILE}
  288. COMMAND ${XGETTEXT_EXECUTABLE}
  289. ARGS --keyword=_ --language=C++ --output=${MESSAGES_POT_FILE} ${SUPERTUX_SOURCES_CXX}
  290. DEPENDS ${SUPERTUX_SOURCES_CXX}
  291. WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
  292. COMMENT "Generating POT file ${MESSAGES_POT_FILE}"
  293. )
  294. LIST(APPEND MESSAGES_POT_FILES ${MESSAGES_POT_FILE})
  295. FILE(GLOB SUPERTUX_LEVEL_DIRS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} data/levels/*)
  296. FOREACH(SUPERTUX_LEVEL_DIR ${SUPERTUX_LEVEL_DIRS})
  297. FILE(GLOB SUPERTUX_LEVELS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${SUPERTUX_LEVEL_DIR}/*.stl ${SUPERTUX_LEVEL_DIR}/*.stwm ${SUPERTUX_LEVEL_DIR}/*.txt)
  298. ## Do not add target if SUPERTUX_LEVELS is empty. This is needed for cmake <=2.4
  299. IF(SUPERTUX_LEVELS)
  300. SET(MESSAGES_POT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/${SUPERTUX_LEVEL_DIR}/messages.pot)
  301. ADD_CUSTOM_COMMAND(
  302. OUTPUT ${MESSAGES_POT_FILE}
  303. COMMAND ${XGETTEXT_EXECUTABLE}
  304. ARGS --keyword="_:1" --language=Lisp --force-po --sort-by-file "--output=${MESSAGES_POT_FILE}" ${SUPERTUX_LEVELS}
  305. DEPENDS ${SUPERTUX_LEVELS}
  306. WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
  307. COMMENT "Generating POT file ${MESSAGES_POT_FILE}"
  308. )
  309. LIST(APPEND MESSAGES_POT_FILES ${MESSAGES_POT_FILE})
  310. ENDIF(SUPERTUX_LEVELS)
  311. ENDFOREACH(SUPERTUX_LEVEL_DIR)
  312. ADD_CUSTOM_TARGET(
  313. supertux2-messages ALL
  314. DEPENDS ${MESSAGES_POT_FILES}
  315. )
  316. ENDIF(NOT XGETTEXT_EXECUTABLE)
  317. ENDIF(GENERATE_MESSAGESPOT)
  318. ## Some additional compiler switches
  319. IF(CMAKE_COMPILER_IS_GNUCC)
  320. ADD_DEFINITIONS(-fno-strict-aliasing)
  321. ENDIF(CMAKE_COMPILER_IS_GNUCC)
  322. IF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
  323. ADD_DEFINITIONS(-DMACOSX)
  324. ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
  325. ## On Windows, add an icon
  326. IF(WIN32)
  327. # SET(SUPERTUX_SOURCES_C ${SUPERTUX_SOURCES_C} ${CMAKE_CURRENT_SOURCE_DIR}/data/images/engine/icons/supertux.rc)
  328. IF(MINGW)
  329. ADD_CUSTOM_COMMAND(
  330. OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/supertux_rc.o
  331. 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)
  332. SET(SUPERTUX_SOURCES_C ${SUPERTUX_SOURCES_C} ${CMAKE_CURRENT_BINARY_DIR}/supertux_rc.o)
  333. ENDIF(MINGW)
  334. ENDIF(WIN32)
  335. ## Generate supertux executable in the right place
  336. SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_SOURCE_DIR})
  337. ## Add target for supertux binary
  338. ADD_LIBRARY(supertux2_c OBJECT ${SUPERTUX_SOURCES_C})
  339. ADD_EXECUTABLE(supertux2 ${CMAKE_BINARY_DIR}/version.h ${SUPERTUX_SOURCES_CXX} ${TINYGETTEXT_SOURCES_CXX} ${SUPERTUX_RESOURCES} $<TARGET_OBJECTS:supertux2_c>)
  340. SET_TARGET_PROPERTIES(supertux2 PROPERTIES COMPILE_FLAGS "${SUPERTUX2_EXTRA_WARNING_FLAGS}")
  341. IF(WIN32)
  342. ## Copy dlls on windows
  343. ADD_CUSTOM_COMMAND(TARGET supertux2 POST_BUILD
  344. COMMAND ${CMAKE_COMMAND} -E copy_directory
  345. "${DEPENDENCY_FOLDER}/dll"
  346. $<TARGET_FILE_DIR:supertux2>)
  347. ADD_CUSTOM_COMMAND(TARGET supertux2 POST_BUILD
  348. COMMAND ${CMAKE_COMMAND} -E copy
  349. "${DEPENDENCY_FOLDER}/DigiCertHighAssuranceEVRootCA.pem"
  350. $<TARGET_FILE_DIR:supertux2>)
  351. ENDIF(WIN32)
  352. ## Link supertux binary with squirrel and other libraries
  353. TARGET_INCLUDE_DIRECTORIES(supertux2 SYSTEM PUBLIC ${SDL2_INCLUDE_DIRS})
  354. TARGET_INCLUDE_DIRECTORIES(supertux2 SYSTEM PUBLIC ${SDL2IMAGE_INCLUDE_DIRS})
  355. TARGET_LINK_LIBRARIES(supertux2 ${SDL2_LIBRARIES})
  356. TARGET_LINK_LIBRARIES(supertux2 ${SDL2IMAGE_LIBRARIES})
  357. TARGET_LINK_LIBRARIES(supertux2 squirrel)
  358. TARGET_LINK_LIBRARIES(supertux2 ${OPENAL_LIBRARY})
  359. TARGET_LINK_LIBRARIES(supertux2 ${OGGVORBIS_LIBRARIES})
  360. TARGET_LINK_LIBRARIES(supertux2 ${PHYSFS_LIBRARY})
  361. IF(HAVE_OPENGL)
  362. TARGET_LINK_LIBRARIES(supertux2 ${OPENGL_LIBRARY})
  363. IF(GLBINDING_FOUND)
  364. TARGET_LINK_LIBRARIES(supertux2 ${GLBINDING_LIBRARIES})
  365. ELSE()
  366. TARGET_LINK_LIBRARIES(supertux2 ${GLEW_LIBRARY})
  367. ENDIF()
  368. ENDIF(HAVE_OPENGL)
  369. IF(HAVE_LIBCURL)
  370. TARGET_LINK_LIBRARIES(supertux2 ${CURL_LIBRARY})
  371. ENDIF(HAVE_LIBCURL)
  372. ## Link curl on windows
  373. IF(WIN32 AND NOT WIN64)
  374. TARGET_LINK_LIBRARIES(supertux2 "${DEPENDENCY_FOLDER}/lib/libcurldll.a")
  375. ENDIF()
  376. ## Install stuff
  377. IF(WIN32 AND NOT UNIX)
  378. SET(INSTALL_SUBDIR_BIN "." CACHE STRING "Installation subdir for binaries")
  379. SET(INSTALL_SUBDIR_SHARE "data" CACHE STRING "Installation subdir for data")
  380. SET(INSTALL_SUBDIR_DOC "." CACHE STRING "Installation subdir for docs")
  381. INSTALL(FILES ${DLLS} DESTINATION ${INSTALL_SUBDIR_BIN})
  382. INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/images/engine/icons/supertux.png ${CMAKE_CURRENT_SOURCE_DIR}/data/images/engine/icons/supertux.ico DESTINATION ".")
  383. ELSE(WIN32 AND NOT UNIX)
  384. IF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
  385. SET(INSTALL_SUBDIR_BIN "SuperTux.app/Contents/MacOS" CACHE STRING "Installation subdir for binaries")
  386. SET(INSTALL_SUBDIR_SHARE "SuperTux.app/Contents/Resources/data" CACHE STRING "Installation subdir for data")
  387. SET(INSTALL_SUBDIR_DOC "SuperTux.app/Contents/Resources" CACHE STRING "Installation subdir for docs")
  388. INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/tools/darwin/info.plist DESTINATION "SuperTux.app/Contents/")
  389. INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/tools/darwin/receipt DESTINATION "SuperTux.app/Contents/_MASReceipt/")
  390. 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/")
  391. ELSE(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
  392. SET(INSTALL_SUBDIR_BIN "games" CACHE STRING "Installation subdir for binaries")
  393. SET(INSTALL_SUBDIR_SHARE "share/games/supertux2" CACHE STRING "Installation subdir for data")
  394. SET(INSTALL_SUBDIR_DOC "share/doc/supertux2" CACHE STRING "Installation subdir for docs")
  395. INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/supertux2.desktop DESTINATION "share/applications")
  396. 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/")
  397. ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
  398. ENDIF(WIN32 AND NOT UNIX)
  399. INSTALL(TARGETS supertux2 DESTINATION ${INSTALL_SUBDIR_BIN})
  400. INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/INSTALL.md ${CMAKE_CURRENT_SOURCE_DIR}/README.md ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/NEWS.md DESTINATION ${INSTALL_SUBDIR_DOC})
  401. INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/credits.txt DESTINATION ${INSTALL_SUBDIR_SHARE})
  402. INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/supertux2.appdata.xml DESTINATION "share/appdata" )
  403. INSTALL(DIRECTORY data/images
  404. data/fonts
  405. data/levels
  406. data/music
  407. data/scripts
  408. data/speech
  409. data/sounds
  410. data/locale
  411. DESTINATION ${INSTALL_SUBDIR_SHARE})
  412. ## Create config.h now that INSTALL_SUBDIR_* have been set.
  413. configure_file(config.h.cmake ${CMAKE_BINARY_DIR}/config.h )
  414. ## CPack/Installation-specific stuff
  415. INCLUDE(InstallRequiredSystemLibraries)
  416. SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Jump'n'Run Game featuring Tux")
  417. SET(CPACK_PACKAGE_VENDOR "SuperTux Devel Team")
  418. SET(CPACK_PACKAGE_CONTACT "SuperTux Devel Team <supertux-devel@lists.lethargik.org>")
  419. SET(CPACK_DEBIAN_PACKAGE_NAME "supertux2")
  420. 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)")
  421. 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/")
  422. SET(CPACK_DEBIAN_PACKAGE_SECTION "games")
  423. SET(CPACK_RPM_PACKAGE_NAME "supertux2")
  424. 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/")
  425. SET(CPACK_RPM_PACKAGE_LICENSE "GNU General Public License (GPL)")
  426. SET(CPACK_RPM_PACKAGE_GROUP "Amusements/Games/Action/Arcade")
  427. IF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
  428. # The OS X PackageMaker doesn't seem to like files with no extension
  429. ELSE(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
  430. SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
  431. SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
  432. ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
  433. SET(CPACK_PACKAGE_VERSION_MAJOR "0")
  434. SET(CPACK_PACKAGE_VERSION_MINOR "3")
  435. SET(CPACK_PACKAGE_VERSION_PATCH "4-GIT")
  436. SET(CPACK_PACKAGE_INSTALL_DIRECTORY "SuperTux ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
  437. SET(CPACK_PACKAGE_EXECUTABLES "..\\\\supertux2" "SuperTux ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
  438. IF(WIN32 AND NOT UNIX)
  439. SET(CPACK_NSIS_INSTALLED_ICON_NAME "..\\\\supertux2")
  440. SET(CPACK_NSIS_DISPLAY_NAME "SuperTux ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
  441. SET(CPACK_NSIS_COMPRESSOR "/SOLID lzma")
  442. ELSE(WIN32 AND NOT UNIX)
  443. ENDIF(WIN32 AND NOT UNIX)
  444. INCLUDE(CPack)
  445. # move some config clutter to the advanced section
  446. MARK_AS_ADVANCED(
  447. INSTALL_SUBDIR_BIN
  448. INSTALL_SUBDIR_SHARE
  449. INSTALL_SUBDIR_DOC
  450. )
  451. MARK_AS_ADVANCED(
  452. CMAKE_BACKWARDS_COMPATIBILITY
  453. CMAKE_BUILD_TYPE
  454. CMAKE_INSTALL_PREFIX
  455. EXECUTABLE_OUTPUT_PATH
  456. LIBRARY_OUTPUT_PATH
  457. CMAKE_OSX_ARCHITECTURES
  458. CMAKE_OSX_SYSROOT
  459. )
  460. MARK_AS_ADVANCED(
  461. APPDATADIR
  462. )
  463. MARK_AS_ADVANCED(
  464. Boost_INCLUDE_DIR
  465. Boost_LIBRARIES
  466. )
  467. MARK_AS_ADVANCED(
  468. GLEW_INCLUDE_DIR
  469. GLEW_LIBRARY
  470. )
  471. MARK_AS_ADVANCED(
  472. SDL2_INCLUDE_DIRS
  473. SDL2_LIBRARIES
  474. )
  475. MARK_AS_ADVANCED(
  476. SDL2IMAGE_INCLUDE_DIRS
  477. SDL2IMAGE_LIBRARIES
  478. )
  479. MARK_AS_ADVANCED(
  480. OPENAL_INCLUDE_DIR
  481. OPENAL_LIBRARY
  482. )
  483. MARK_AS_ADVANCED(
  484. OGG_LIBRARY
  485. VORBISENC_LIBRARY
  486. VORBISFILE_LIBRARY
  487. VORBIS_INCLUDE_DIR
  488. VORBIS_LIBRARY
  489. )
  490. MARK_AS_ADVANCED(
  491. PHYSFS_INCLUDE_DIR
  492. PHYSFS_LIBRARY
  493. )