CMakeLists.txt 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914
  1. cmake_minimum_required(VERSION 2.8.4)
  2. # root CMakeLists for the SuperTuxKart project
  3. project(SuperTuxKart)
  4. set(PROJECT_VERSION "git")
  5. add_definitions( -DSUPERTUXKART_VERSION="${PROJECT_VERSION}" )
  6. if(NOT (CMAKE_MAJOR_VERSION VERSION_LESS 3))
  7. cmake_policy(SET CMP0043 OLD)
  8. endif()
  9. set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake")
  10. include(CMakeDependentOption)
  11. include(BuildTypeSTKRelease)
  12. if(NOT CMAKE_BUILD_TYPE)
  13. message(STATUS "No build type selected, default to STKRelease")
  14. set(CMAKE_BUILD_TYPE "STKRelease")
  15. endif()
  16. CMAKE_DEPENDENT_OPTION(USE_SWITCH "Build targeting switch" OFF "NOT NINTENDO_SWITCH" ON)
  17. if(WIN32)
  18. option(USE_DIRECTX "Build DirectX 9 driver (requires DirectX SDK)" OFF)
  19. endif()
  20. option(SERVER_ONLY "Create a server only (i.e. no graphics or sound)" OFF)
  21. option(CHECK_ASSETS "Check if assets are installed in ../stk-assets" ON)
  22. option(USE_SYSTEM_ANGELSCRIPT "Use system angelscript instead of built-in angelscript. If you enable this option, make sure to use a compatible version." OFF)
  23. option(USE_SYSTEM_ENET "Use system ENet instead of the built-in version, when available." ON)
  24. CMAKE_DEPENDENT_OPTION(USE_IPV6 "Allow create or connect to game server with IPv6 address, system enet will not be used." ON
  25. "NOT USE_SWITCH" OFF)
  26. option(USE_SYSTEM_WIIUSE "Use system WiiUse instead of the built-in version, when available." OFF)
  27. option(USE_SQLITE3 "Use sqlite to manage server stats and ban list." ON)
  28. if(APPLE)
  29. CMAKE_DEPENDENT_OPTION(DLOPEN_MOLTENVK "Use dlopen to load MoltenVK for Apple." ON
  30. "NOT IOS;NOT SERVER_ONLY" OFF)
  31. endif()
  32. CMAKE_DEPENDENT_OPTION(USE_CRYPTO_OPENSSL "Use OpenSSL instead of MbedTLS for cryptography in STK." ON
  33. "NOT USE_SWITCH;NOT WIN32" OFF)
  34. CMAKE_DEPENDENT_OPTION(BUILD_RECORDER "Build opengl recorder" ON
  35. "NOT SERVER_ONLY;NOT APPLE;NOT USE_SWITCH" OFF)
  36. CMAKE_DEPENDENT_OPTION(USE_SYSTEM_SQUISH "Use system Squish library instead of the built-in version, when available." ON
  37. "NOT SERVER_ONLY" OFF)
  38. CMAKE_DEPENDENT_OPTION(USE_WIIUSE "Support for wiimote input devices" ON
  39. "NOT SERVER_ONLY;NOT CYGWIN;NOT USE_SWITCH;NOT MSVC" OFF)
  40. CMAKE_DEPENDENT_OPTION(USE_DNS_C "Build bundled dns resolver" OFF "NOT CYGWIN;NOT USE_SWITCH" ON)
  41. CMAKE_DEPENDENT_OPTION(USE_MOJOAL "Use bundled MojoAL instead of system OpenAL" OFF "NOT APPLE" ON)
  42. if (DLOPEN_MOLTENVK)
  43. ADD_DEFINITIONS(-DDLOPEN_MOLTENVK)
  44. endif()
  45. if((UNIX AND NOT APPLE) OR NINTENDO_SWITCH)
  46. include(FindPkgConfig)
  47. endif()
  48. if(IOS)
  49. include(cmake/XcodeHelper.cmake)
  50. endif()
  51. if(APPLE AND NOT IOS)
  52. if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "arm")
  53. set(ARCHFLAGS "arm64")
  54. list(APPEND CMAKE_PREFIX_PATH /opt/homebrew/opt)
  55. include_directories(/opt/homebrew/opt/openssl@1.1/include/)
  56. include_directories(/opt/homebrew/opt/openssl@1.1/include/openssl/)
  57. include_directories(/opt/homebrew/opt/freetype/include/freetype2/)
  58. include_directories(/opt/homebrew/opt/harfbuzz/include/harfbuzz/)
  59. else()
  60. set(ARCHFLAGS "${CMAKE_SYSTEM_PROCESSOR}")
  61. list(APPEND CMAKE_PREFIX_PATH /usr/local/opt)
  62. include_directories(/usr/local/opt/openssl@1.1/include/)
  63. include_directories(/usr/local/opt/openssl@1.1/include/openssl/)
  64. include_directories(/usr/local/opt/freetype/include/freetype2/)
  65. include_directories(/usr/local/opt/harfbuzz/include/harfbuzz/)
  66. endif()
  67. endif()
  68. if (IOS)
  69. ADD_DEFINITIONS(-DMOBILE_STK)
  70. ADD_DEFINITIONS(-DIOS_STK)
  71. set(CMAKE_XCODE_ATTRIBUTE_TARGETED_DEVICE_FAMILY "1,2")
  72. option(USE_GLES2 "Use OpenGL ES2 renderer" ON)
  73. endif()
  74. if((UNIX AND NOT APPLE) AND NOT SERVER_ONLY)
  75. if((${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm") OR
  76. (${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64") OR
  77. (${CMAKE_SYSTEM_PROCESSOR} MATCHES "riscv64"))
  78. option(USE_GLES2 "Use OpenGL ES2 renderer" ON)
  79. else()
  80. option(USE_GLES2 "Use OpenGL ES2 renderer" OFF)
  81. endif()
  82. endif()
  83. if(UNIX OR MINGW)
  84. option(DEBUG_SYMBOLS "Compile with debug symbols" OFF)
  85. endif()
  86. if(MSVC AND (MSVC_VERSION LESS 1900))
  87. # Normally hide the option to build wiiuse on VS, since it depends
  88. # on the installation of the Windows DDK (Driver Developer Kit),
  89. # which also needs an absolute path :(
  90. option(WIIUSE_BUILD "Build wiiuse lib (only for developers)" OFF)
  91. mark_as_advanced(WIIUSE_BUILD)
  92. else()
  93. set(WIIUSE_BUILD ON)
  94. endif()
  95. if(UNIX AND NOT APPLE)
  96. option(USE_ASAN "Build with Leak/Address sanitizer" OFF)
  97. option(USE_TSAN "Build with Thread sanitizer" OFF)
  98. option(USE_LIBBFD "Use libbfd for crash reporting and leak check" OFF)
  99. endif()
  100. if(USE_ASAN)
  101. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer")
  102. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fno-omit-frame-pointer")
  103. endif()
  104. if(USE_TSAN)
  105. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=thread -fno-omit-frame-pointer")
  106. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=thread -fno-omit-frame-pointer")
  107. endif()
  108. set(STK_SOURCE_DIR "src")
  109. set(STK_DATA_DIR "${PROJECT_SOURCE_DIR}/data")
  110. # CMAKE_RUNTIME_OUTPUT_DIRECTORY removes dSYMs in Xcode archive
  111. if(NOT CMAKE_GENERATOR MATCHES "Xcode")
  112. set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin")
  113. endif()
  114. # Define install paths
  115. set(STK_INSTALL_BINARY_DIR "bin" CACHE
  116. STRING "Install executable to this directory, absolute or relative to CMAKE_INSTALL_PREFIX")
  117. set(STK_INSTALL_DATA_DIR "share/supertuxkart" CACHE
  118. STRING "Install data folder to this directory, absolute or relative to CMAKE_INSTALL_PREFIX")
  119. # Define dependencies path
  120. string(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" arch_lower)
  121. set(BUILD_ARCH "unknown")
  122. if (CMAKE_GENERATOR_PLATFORM)
  123. set(BUILD_ARCH "${CMAKE_GENERATOR_PLATFORM}")
  124. endif()
  125. if(arch_lower MATCHES "arm64" OR arch_lower MATCHES "aarch64" OR ${CMAKE_GENERATOR} MATCHES "(ARM64)" OR ${BUILD_ARCH} MATCHES "(ARM64)")
  126. set(DEPENDENCIES "dependencies-win-aarch64")
  127. elseif(arch_lower MATCHES "armv7" OR arch_lower MATCHES "armv7" OR ${CMAKE_GENERATOR} MATCHES "(ARM)" OR ${BUILD_ARCH} MATCHES "(ARM)")
  128. set(DEPENDENCIES "dependencies-win-armv7")
  129. elseif(CMAKE_SIZEOF_VOID_P EQUAL 8)
  130. set(DEPENDENCIES "dependencies-win-x86_64")
  131. else()
  132. set(DEPENDENCIES "dependencies-win-i686")
  133. endif()
  134. if(WIN32)
  135. ADD_DEFINITIONS(-DUNICODE)
  136. ADD_DEFINITIONS(-D_UNICODE)
  137. if(NOT IS_DIRECTORY "${PROJECT_SOURCE_DIR}/${DEPENDENCIES}")
  138. message(FATAL_ERROR "Dependencies directory not found, make sure dependencies-win-(arch) exists inside stk-code directory.")
  139. endif()
  140. endif()
  141. # These variables enable MSVC to find libraries located in "dependencies"
  142. if(WIN32)
  143. set(ENV{PATH} "$ENV{PATH};${PROJECT_SOURCE_DIR}/${DEPENDENCIES}/include")
  144. set(ENV{LIB} ${PROJECT_SOURCE_DIR}/${DEPENDENCIES}/lib)
  145. set(ENV{OPENALDIR} ${PROJECT_SOURCE_DIR}/${DEPENDENCIES})
  146. add_definitions(-D_IRR_STATIC_LIB_)
  147. add_definitions(-DNO_IRR_COMPILE_WITH_X11_)
  148. include_directories(${PROJECT_SOURCE_DIR}/${DEPENDENCIES}/include)
  149. endif()
  150. if(WIN32 AND NOT USE_DIRECTX)
  151. add_definitions(-DNO_IRR_COMPILE_WITH_DIRECT3D_9_)
  152. endif()
  153. if(USE_GLES2)
  154. add_definitions(-DUSE_GLES2)
  155. if (NOT IOS)
  156. add_definitions(-D_IRR_COMPILE_WITH_OGLES2_)
  157. endif()
  158. add_definitions(-DNO_IRR_COMPILE_WITH_OPENGL_)
  159. endif()
  160. if(SERVER_ONLY)
  161. add_definitions(-DSERVER_ONLY)
  162. add_definitions(-DNO_IRR_COMPILE_WITH_X11_ -DNO_IRR_COMPILE_WITH_OPENGL_)
  163. endif()
  164. if(UNIX OR MINGW)
  165. if(DEBUG_SYMBOLS)
  166. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")
  167. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g")
  168. endif()
  169. endif()
  170. if(UNIX AND NOT APPLE AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
  171. find_package(PkgConfig REQUIRED)
  172. if(NOT PKGCONFIG_FOUND)
  173. message(FATAL_ERROR "Pkg-config not found.")
  174. endif()
  175. endif()
  176. # Build the Bullet physics library
  177. add_subdirectory("${PROJECT_SOURCE_DIR}/lib/bullet")
  178. include_directories(BEFORE "${PROJECT_SOURCE_DIR}/lib/bullet/src")
  179. # Build the DNS C library
  180. if(USE_DNS_C)
  181. add_definitions(-DDNS_C)
  182. add_subdirectory("${PROJECT_SOURCE_DIR}/lib/dnsc")
  183. include_directories(BEFORE "${PROJECT_SOURCE_DIR}/lib/dnsc")
  184. else()
  185. if(WIN32 OR CMAKE_SYSTEM_NAME MATCHES "BSD" OR CMAKE_SYSTEM_NAME MATCHES "DragonFly" OR USE_SWITCH)
  186. set(LIBRESOLV_LIBRARY)
  187. elseif (HAIKU)
  188. find_library(LIBRESOLV_LIBRARY NAMES network socket)
  189. else()
  190. find_library(LIBRESOLV_LIBRARY NAMES resolv libresolv)
  191. endif()
  192. endif()
  193. # Find system ENet library or build it if missing
  194. if((UNIX AND NOT APPLE) AND USE_SYSTEM_ENET AND NOT USE_IPV6)
  195. pkg_check_modules(ENET libenet>=1.3.4)
  196. endif()
  197. if (USE_IPV6)
  198. add_definitions(-DENABLE_IPV6)
  199. endif()
  200. if(ENET_FOUND AND NOT USE_IPV6)
  201. include_directories(${ENET_INCLUDE_DIRS})
  202. else()
  203. # Fallback to built-in version
  204. add_subdirectory("${PROJECT_SOURCE_DIR}/lib/enet")
  205. include_directories(BEFORE "${PROJECT_SOURCE_DIR}/lib/enet/include")
  206. set(ENET_LIBRARIES "enet")
  207. endif()
  208. if(NOT SERVER_ONLY)
  209. if(USE_SYSTEM_SQUISH)
  210. find_library(SQUISH_LIBRARY NAMES squish libsquish)
  211. find_path(SQUISH_INCLUDEDIR NAMES squish.h PATHS)
  212. endif()
  213. if (NOT SQUISH_LIBRARY OR NOT SQUISH_INCLUDEDIR)
  214. add_subdirectory("${PROJECT_SOURCE_DIR}/lib/libsquish")
  215. include_directories(BEFORE "${PROJECT_SOURCE_DIR}/lib/libsquish")
  216. SET(SQUISH_LIBRARY squish)
  217. else()
  218. include_directories("${SQUISH_INCLUDEDIR}")
  219. MESSAGE(STATUS "Use system libsquish: ${SQUISH_LIBRARY}")
  220. endif()
  221. endif()
  222. if(NOT SERVER_ONLY)
  223. if (IOS)
  224. find_library(SHADERC_LIBRARY NAMES shaderc_combined libshaderc_combined)
  225. else()
  226. find_library(SHADERC_LIBRARY NAMES shaderc_shared libshaderc_shared shaderc libshaderc)
  227. endif()
  228. find_path(SHADERC_INCLUDEDIR NAMES shaderc/shaderc.hpp PATHS)
  229. if (NOT SHADERC_LIBRARY OR NOT SHADERC_INCLUDEDIR)
  230. if (NOT NO_SHADERC)
  231. message(FATAL_ERROR "Please install shaderc from your distribution or disable vulkan support with -DNO_SHADERC=on")
  232. endif()
  233. else()
  234. include_directories("${SHADERC_INCLUDEDIR}")
  235. MESSAGE(STATUS "Use system shaderc: ${SHADERC_LIBRARY}")
  236. endif()
  237. if (NO_SHADERC)
  238. add_definitions(-DDISABLE_SHADERC)
  239. endif()
  240. add_subdirectory("${PROJECT_SOURCE_DIR}/lib/graphics_engine")
  241. endif()
  242. # MiniGLM is there
  243. include_directories(BEFORE "${PROJECT_SOURCE_DIR}/lib/graphics_engine/include")
  244. if (NOT SERVER_ONLY)
  245. # Add jpeg library
  246. find_package(JPEG REQUIRED)
  247. include_directories(${JPEG_INCLUDE_DIR})
  248. endif()
  249. if (BUILD_RECORDER)
  250. find_library(OPENGLRECORDER_LIBRARY NAMES openglrecorder libopenglrecorder PATHS "${PROJECT_SOURCE_DIR}/${DEPENDENCIES}/lib")
  251. find_path(OPENGLRECORDER_INCLUDEDIR NAMES openglrecorder.h PATHS "${PROJECT_SOURCE_DIR}/${DEPENDENCIES}/include")
  252. if (NOT OPENGLRECORDER_LIBRARY OR NOT OPENGLRECORDER_INCLUDEDIR)
  253. if(PROJECT_VERSION STREQUAL "git")
  254. message(WARNING "libopenglrecorder not found, disabling in-game recorder. "
  255. "To use recorder, install libopenglrecorder.")
  256. set(OPENGLRECORDER_LIBRARY CACHE INTERNAL "")
  257. set(OPENGLRECORDER_INCLUDEDIR CACHE INTERNAL "")
  258. set(BUILD_RECORDER OFF)
  259. else()
  260. message(FATAL_ERROR "libopenglrecorder not found. "
  261. "Either install libopenglrecorder or disable in-game recorder with -DBUILD_RECORDER=0")
  262. endif()
  263. else()
  264. include_directories(${OPENGLRECORDER_INCLUDEDIR})
  265. mark_as_advanced(OPENGLRECORDER_LIBRARY OPENGLRECORDER_INCLUDEDIR)
  266. add_definitions(-DENABLE_RECORDER)
  267. endif()
  268. endif()
  269. if(NOT SERVER_ONLY)
  270. add_subdirectory("${PROJECT_SOURCE_DIR}/lib/graphics_utils")
  271. include_directories(BEFORE "${PROJECT_SOURCE_DIR}/lib/graphics_utils")
  272. add_subdirectory("${PROJECT_SOURCE_DIR}/lib/tinygettext")
  273. include_directories(BEFORE "${PROJECT_SOURCE_DIR}/lib/tinygettext/include")
  274. endif()
  275. # Libmcpp
  276. find_library(MCPP_LIBRARY NAMES mcpp libmcpp)
  277. find_path(MCPP_INCLUDEDIR NAMES mcpp_lib.h PATHS)
  278. if (NOT MCPP_LIBRARY OR NOT MCPP_INCLUDEDIR)
  279. add_subdirectory("${PROJECT_SOURCE_DIR}/lib/mcpp")
  280. include_directories(BEFORE "${PROJECT_SOURCE_DIR}/lib/mcpp")
  281. SET(MCPP_LIBRARY mcpp)
  282. message(STATUS "System libmcpp not found, use the bundled one.")
  283. else()
  284. include_directories("${MCPP_INCLUDEDIR}")
  285. MESSAGE(STATUS "Use system libmcpp: ${MCPP_LIBRARY}")
  286. endif()
  287. if (NOT SERVER_ONLY)
  288. # SDL2
  289. find_library(SDL2_LIBRARY NAMES SDL2 libSDL2)
  290. find_path(SDL2_INCLUDEDIR NAMES SDL.h PATH_SUFFIXES SDL2 include/SDL2 include PATHS)
  291. if (NOT SDL2_LIBRARY OR NOT SDL2_INCLUDEDIR)
  292. message(FATAL_ERROR "SDL2 not found. "
  293. "SDL2 is required to handle gamepad in SuperTuxKart.")
  294. else()
  295. include_directories("${SDL2_INCLUDEDIR}")
  296. MESSAGE(STATUS "Use system SDL2: ${SDL2_LIBRARY}")
  297. endif()
  298. # DirectFB. Necessary if system SDL2 is built with DirectFB support.
  299. find_path(DIRECTFB_INCLUDEDIR NAMES directfb.h directfb++.h PATH_SUFFIXES directfb include/directfb include PATHS)
  300. if (DIRECTFB_INCLUDEDIR)
  301. include_directories("${DIRECTFB_INCLUDEDIR}")
  302. message(STATUS "Adding DirectFB include directories for DirectFB support in SDL2")
  303. endif()
  304. endif()
  305. # Build the irrlicht library
  306. add_subdirectory("${PROJECT_SOURCE_DIR}/lib/irrlicht")
  307. include_directories(BEFORE "${PROJECT_SOURCE_DIR}/lib/irrlicht/include")
  308. # Build the Wiiuse library
  309. # Note: wiiuse MUST be declared after irrlicht, since otherwise
  310. # (at least on VS) irrlicht will find wiiuse io.h file because
  311. # of the added include directory.
  312. if(USE_WIIUSE)
  313. # Find system WiiUse library or build it if missing
  314. if((UNIX AND NOT (APPLE OR HAIKU)) AND USE_SYSTEM_WIIUSE)
  315. find_package(WiiUse)
  316. endif()
  317. if(WIIUSE_FOUND)
  318. include_directories(${WIIUSE_INCLUDE_DIR})
  319. else()
  320. # Fallback to built-in version
  321. if(WIIUSE_BUILD)
  322. add_subdirectory("${PROJECT_SOURCE_DIR}/lib/wiiuse")
  323. endif()
  324. include_directories(BEFORE "${PROJECT_SOURCE_DIR}/lib/wiiuse/src/include")
  325. set(WIIUSE_LIBRARIES "wiiuse" "bluetooth")
  326. endif()
  327. endif()
  328. # Set include paths
  329. include_directories(${STK_SOURCE_DIR})
  330. if(APPLE AND NOT IOS)
  331. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -arch ${ARCHFLAGS}")
  332. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -arch ${ARCHFLAGS} -F/Library/Frameworks")
  333. elseif(MSVC)
  334. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") # Enable multi-processor compilation (faster)
  335. endif()
  336. if (${CMAKE_SYSTEM_NAME} MATCHES "SunOs")
  337. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m64")
  338. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64")
  339. endif()
  340. # Build the angelscript library if not in system
  341. if(USE_SYSTEM_ANGELSCRIPT)
  342. find_package(Angelscript)
  343. if(ANGELSCRIPT_FOUND)
  344. include_directories(${Angelscript_INCLUDE_DIRS})
  345. else()
  346. message(FATAL_ERROR "Angelscript not found. "
  347. "Either install angelscript or use built-in version using "
  348. "-DUSE_SYSTEM_ANGELSCRIPT=0")
  349. endif()
  350. else()
  351. add_subdirectory("${PROJECT_SOURCE_DIR}/lib/angelscript/projects/cmake")
  352. include_directories(BEFORE "${PROJECT_SOURCE_DIR}/lib/angelscript/include")
  353. set(Angelscript_LIBRARIES angelscript)
  354. endif()
  355. if(NOT SERVER_ONLY)
  356. # OpenAL
  357. if (USE_MOJOAL)
  358. find_library(LIBSAMPLERATE_LIBRARY NAMES samplerate libsamplerate)
  359. find_path(LIBSAMPLERATE_INCLUDEDIR NAMES samplerate.h PATHS)
  360. if (NOT LIBSAMPLERATE_LIBRARY OR NOT LIBSAMPLERATE_INCLUDEDIR)
  361. message(FATAL_ERROR "libsamplerate not found. "
  362. "libsamplerate is required to handle pitch for MojoAL.")
  363. else()
  364. include_directories("${LIBSAMPLERATE_INCLUDEDIR}")
  365. MESSAGE(STATUS "Use system libsamplerate: ${LIBSAMPLERATE_LIBRARY}")
  366. endif()
  367. add_definitions(-DAL_LIBTYPE_STATIC)
  368. add_subdirectory("${PROJECT_SOURCE_DIR}/lib/mojoal")
  369. include_directories(BEFORE "${PROJECT_SOURCE_DIR}/lib/mojoal")
  370. else()
  371. find_package(OpenAL REQUIRED)
  372. # Unclear why this happens, but on switch OPENAL_LIBRARY never set!
  373. if (NOT OPENAL_LIBRARY)
  374. find_library(OPENAL_LIBRARY NAMES al OpenAL AL openal REQUIRED)
  375. endif()
  376. if (NOT OPENAL_INCLUDE_DIR)
  377. find_path(OPENAL_INCLUDE_DIR NAMES AL/al.h REQUIRED)
  378. endif()
  379. include_directories(${OPENAL_INCLUDE_DIR})
  380. endif()
  381. # OggVorbis
  382. find_package(OggVorbis REQUIRED)
  383. include_directories(${OGGVORBIS_INCLUDE_DIRS})
  384. add_definitions(-DENABLE_SOUND)
  385. endif()
  386. # Text handling in STK (We use freetype, harfbuzz and SheenBidifor i18n text handling)
  387. if (NOT SERVER_ONLY)
  388. # SheenBidi
  389. add_subdirectory("${PROJECT_SOURCE_DIR}/lib/sheenbidi")
  390. include_directories(BEFORE "${PROJECT_SOURCE_DIR}/lib/sheenbidi/Headers")
  391. SET(SHEENBIDI_LIBRARY sheenbidi)
  392. # Freetype
  393. find_package(Freetype)
  394. if(FREETYPE_FOUND)
  395. include_directories(${FREETYPE_INCLUDE_DIRS})
  396. else()
  397. message(FATAL_ERROR "Freetype not found. "
  398. "Freetype is required to display characters in SuperTuxKart.")
  399. endif()
  400. # Harfbuzz
  401. find_library(HARFBUZZ_LIBRARY NAMES harfbuzz libharfbuzz)
  402. find_path(HARFBUZZ_INCLUDEDIR NAMES harfbuzz/hb.h hb.h PATHS)
  403. if (NOT HARFBUZZ_LIBRARY OR NOT HARFBUZZ_INCLUDEDIR)
  404. message(FATAL_ERROR "Harfbuzz not found. "
  405. "Harfbuzz is required to display characters in SuperTuxKart.")
  406. else()
  407. include_directories("${HARFBUZZ_INCLUDEDIR}")
  408. MESSAGE(STATUS "Use system harfbuzz: ${HARFBUZZ_LIBRARY}")
  409. endif()
  410. endif()
  411. if(USE_LIBBFD)
  412. find_package(Libbfd)
  413. if(LIBBFD_FOUND)
  414. add_definitions(-DENABLE_LIBBFD)
  415. include_directories(${LIBBFD_INCLUDE_DIRS})
  416. else()
  417. set(USE_LIBBFD OFF CACHE BOOL "Use libbfd for crash reporting and leak check" FORCE)
  418. message(WARNING "Libbfd not found, disable integrated stack trace.")
  419. endif()
  420. endif()
  421. # SQLITE
  422. if(USE_SQLITE3)
  423. find_library(SQLITE3_LIBRARY NAMES sqlite3 libsqlite3)
  424. find_path(SQLITE3_INCLUDEDIR NAMES sqlite3.h PATHS)
  425. if (NOT SQLITE3_LIBRARY OR NOT SQLITE3_INCLUDEDIR)
  426. # add_subdirectory("${PROJECT_SOURCE_DIR}/lib/sqlite3")
  427. # include_directories(BEFORE "${PROJECT_SOURCE_DIR}/lib/sqlite3")
  428. # SET(SQLITE3_LIBRARY sqlite3)
  429. set(USE_SQLITE3 OFF CACHE BOOL "Use sqlite to manage server stats and ban list." FORCE)
  430. message(WARNING "Sqlite3 not found, disable advanced server management.")
  431. else()
  432. add_definitions(-DENABLE_SQLITE3)
  433. include_directories("${SQLITE3_INCLUDEDIR}")
  434. MESSAGE(STATUS "Use system libsqlite3: ${SQLITE3_LIBRARY}")
  435. endif()
  436. endif()
  437. # Set some compiler options
  438. if(UNIX OR MINGW)
  439. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++0x")
  440. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-unused-function")
  441. endif()
  442. if(MINGW AND CMAKE_BUILD_TYPE MATCHES Release)
  443. SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--subsystem,windows")
  444. endif()
  445. if(WIN32)
  446. # By default windows.h has macros defined for min and max that screw up everything
  447. add_definitions(-DNOMINMAX)
  448. # And shut up about unsafe stuff
  449. add_definitions(-D_CRT_SECURE_NO_WARNINGS)
  450. # Avoid timespec structure redeclaration on Visual Studio 2015
  451. if (NOT (MSVC_VERSION LESS 1900))
  452. add_definitions(-DHAVE_STRUCT_TIMESPEC)
  453. endif()
  454. endif()
  455. if(MSVC)
  456. # VS will automatically add NDEBUG for release mode, but only _DEBUG in debug mode.
  457. # Since STK uses DEBUG, this is added for debug compilation only:
  458. set_property(DIRECTORY PROPERTY COMPILE_DEFINITIONS_DEBUG DEBUG)
  459. else()
  460. # All non VS generators used create only a single compile mode, so
  461. # compile flags can be simplye be added
  462. if(CMAKE_BUILD_TYPE MATCHES Debug)
  463. add_definitions(-DDEBUG)
  464. else()
  465. add_definitions(-DNDEBUG)
  466. endif()
  467. endif()
  468. if(WIN32)
  469. configure_file("${STK_SOURCE_DIR}/../tools/windows_installer/icon_rc.template" "${PROJECT_BINARY_DIR}/tmp/icon.rc")
  470. endif()
  471. # Provides list of source and header files (STK_SOURCES and STK_HEADERS)
  472. include(sources.cmake)
  473. # Generate source groups useful for MSVC project explorer
  474. include(cmake/SourceGroupFunctions.cmake)
  475. source_group_hierarchy(STK_SOURCES STK_HEADERS)
  476. if(APPLE AND NOT IOS)
  477. # icon files to copy in the bundle
  478. set(OSX_ICON_FILES ${PROJECT_SOURCE_DIR}/data/supertuxkart.icns)
  479. set_source_files_properties(${OSX_ICON_FILES} PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
  480. set(STK_SOURCES ${STK_SOURCES} ${OSX_ICON_FILES})
  481. # build the executable and create an app bundle
  482. add_executable(supertuxkart MACOSX_BUNDLE ${STK_SOURCES})
  483. find_library(IOKIT_LIBRARY IOKit)
  484. find_library(COCOA_LIBRARY Cocoa)
  485. target_link_libraries(supertuxkart
  486. ${IOKIT_LIBRARY}
  487. ${COCOA_LIBRARY})
  488. # configure CMake to use a custom Info.plist
  489. set_target_properties(supertuxkart PROPERTIES
  490. MACOSX_BUNDLE_INFO_PLIST ${PROJECT_SOURCE_DIR}/data/SuperTuxKart-Info.plist)
  491. if(CMAKE_GENERATOR MATCHES "Xcode")
  492. add_custom_command(TARGET supertuxkart POST_BUILD
  493. COMMAND ln -f -s ${PROJECT_SOURCE_DIR}/data ${CMAKE_BINARY_DIR}/\${CONFIGURATION}/supertuxkart.app/Contents/Resources)
  494. else()
  495. add_custom_command(TARGET supertuxkart POST_BUILD
  496. COMMAND ln -f -s ${PROJECT_SOURCE_DIR}/data ${CMAKE_BINARY_DIR}/bin/supertuxkart.app/Contents/Resources)
  497. endif()
  498. else()
  499. if (NOT WIN32)
  500. find_library(PTHREAD_LIBRARY NAMES pthread ${PTHREAD_NAMES} PATHS ${PROJECT_SOURCE_DIR}/${DEPENDENCIES}/lib)
  501. mark_as_advanced(PTHREAD_LIBRARY)
  502. endif()
  503. # Set data dir (absolute or relative to CMAKE_INSTALL_PREFIX)
  504. if(NOT STK_INSTALL_DATA_DIR_ABSOLUTE)
  505. get_filename_component(STK_INSTALL_DATA_DIR_ABSOLUTE ${STK_INSTALL_DATA_DIR} ABSOLUTE)
  506. if(${STK_INSTALL_DATA_DIR_ABSOLUTE} STREQUAL ${STK_INSTALL_DATA_DIR})
  507. add_definitions(-DSUPERTUXKART_DATADIR=\"${STK_INSTALL_DATA_DIR_ABSOLUTE}\")
  508. else()
  509. add_definitions(-DSUPERTUXKART_DATADIR=\"${CMAKE_INSTALL_PREFIX}/${STK_INSTALL_DATA_DIR}\")
  510. endif()
  511. else()
  512. add_definitions(-DSUPERTUXKART_DATADIR=\"${STK_INSTALL_DATA_DIR_ABSOLUTE}\")
  513. endif()
  514. # Build the final executable
  515. if (IOS)
  516. file(GLOB IOS_ASSETS_FILES ${IOS_ASSETS} ${IOS_LAUNCHSCREEN} ${IOS_IMAGES_XCASSETS})
  517. set_source_files_properties(${IOS_ASSETS_FILES} PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
  518. add_executable(supertuxkart ${STK_SOURCES} ${STK_RESOURCES} ${STK_HEADERS} ${IOS_ASSETS_FILES})
  519. set_target_properties(supertuxkart PROPERTIES
  520. MACOSX_BUNDLE_INFO_PLIST ${PROJECT_SOURCE_DIR}/data/SuperTuxKart-Info-iOS.plist
  521. XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET 9.0
  522. XCODE_ATTRIBUTE_INSTALL_PATH /Applications
  523. XCODE_ATTRIBUTE_SKIP_INSTALL No
  524. XCODE_ATTRIBUTE_ASSETCATALOG_COMPILER_APPICON_NAME "AppIcon")
  525. if(CMAKE_GENERATOR MATCHES "Xcode")
  526. get_all_targets(supertuxkart_targets ${CMAKE_CURRENT_LIST_DIR})
  527. foreach(target IN LISTS supertuxkart_targets)
  528. if (NOT target MATCHES "supertuxkart")
  529. set_target_properties(${target} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib$(EFFECTIVE_PLATFORM_NAME)/${target})
  530. endif()
  531. configure_xcode_defaults(${target})
  532. endforeach()
  533. endif()
  534. else()
  535. add_executable(supertuxkart ${STK_SOURCES} ${STK_RESOURCES} ${STK_HEADERS})
  536. endif()
  537. if (NOT WIN32)
  538. target_link_libraries(supertuxkart ${PTHREAD_LIBRARY})
  539. endif()
  540. endif()
  541. # check if linking against libatomic is required
  542. include(CheckCXXSourceCompiles)
  543. check_cxx_source_compiles("
  544. #include <atomic>
  545. #include <cstdint>
  546. int main() {
  547. std::atomic<uint64_t> x{0};
  548. x.load();
  549. return 0;
  550. }
  551. " NO_LIBATOMIC_NEEDED)
  552. if (NOT NO_LIBATOMIC_NEEDED)
  553. target_link_libraries(supertuxkart atomic)
  554. endif()
  555. # CURL and OpenSSL or MbedTLS
  556. # 1.0.1d for compatible AES GCM handling
  557. SET(OPENSSL_MINIMUM_VERSION "1.0.1d")
  558. find_package(CURL REQUIRED)
  559. include_directories(${CURL_INCLUDE_DIRS})
  560. find_path(MBEDTLS_INCLUDE_DIRS mbedtls/version.h)
  561. find_library(MBEDCRYPTO_LIBRARY NAMES mbedcrypto libmbedcrypto)
  562. if (NOT MBEDCRYPTO_LIBRARY OR NOT MBEDTLS_INCLUDE_DIRS OR USE_CRYPTO_OPENSSL)
  563. set(USE_CRYPTO_OPENSSL ON)
  564. find_package(OpenSSL REQUIRED)
  565. if(${OPENSSL_VERSION} VERSION_LESS ${OPENSSL_MINIMUM_VERSION} OR
  566. (${OPENSSL_VERSION} VERSION_EQUAL ${OPENSSL_MINIMUM_VERSION} AND ${OPENSSL_VERSION} STRLESS ${OPENSSL_MINIMUM_VERSION}))
  567. message(FATAL_ERROR "OpenSSL version found (${OPENSSL_VERSION}) is less then the minimum required (${OPENSSL_MINIMUM_VERSION}), aborting.")
  568. endif()
  569. include_directories(${OpenSSL_INCLUDE_DIRS})
  570. else()
  571. set(USE_CRYPTO_OPENSSL OFF)
  572. include_directories(${MBEDTLS_INCLUDE_DIRS})
  573. endif()
  574. if (USE_CRYPTO_OPENSSL)
  575. message(STATUS "OpenSSL will be used for cryptography in STK.")
  576. add_definitions(-DENABLE_CRYPTO_OPENSSL)
  577. else()
  578. message(STATUS "MbedTLS will be used for cryptography in STK.")
  579. add_definitions(-DENABLE_CRYPTO_MBEDTLS)
  580. endif()
  581. # Common library dependencies
  582. target_link_libraries(supertuxkart
  583. bulletdynamics
  584. bulletcollision
  585. bulletmath
  586. ${ENET_LIBRARIES}
  587. stkirrlicht
  588. ${Angelscript_LIBRARIES}
  589. ${CURL_LIBRARIES}
  590. ${MCPP_LIBRARY}
  591. )
  592. if (USE_SWITCH)
  593. include(cmake/FindEGL.cmake)
  594. find_library(NX_LIBRARY NAMES nx libnx REQUIRED)
  595. find_library(DRM_LIBRARY NAMES drm_nouveau libdrm_nouveau REQUIRED)
  596. find_library(GLAPI_LIBRARY NAMES glapi libglapi REQUIRED)
  597. find_library(ZLIB_LIBRARY NAMES z libz REQUIRED)
  598. find_library(PNG_LIBRARY NAMES png libpng REQUIRED)
  599. find_library(BZ2_LIBRARY NAMES bz2 libbz2 REQUIRED)
  600. target_link_libraries(supertuxkart
  601. ${NX_LIBRARY}
  602. ${ZLIB_LIBRARY}
  603. ${FREETYPE_LIBRARIES}
  604. -logg
  605. -lvorbis
  606. ${SDL2_LIBRARY}
  607. ${PNG_LIBRARY}
  608. ${BZ2_LIBRARY}
  609. ${HARFBUZZ_LIBRARY}
  610. ${OPENAL_LIBRARY}
  611. ${EGL_LIBRARY}
  612. ${DRM_LIBRARY}
  613. ${GLAPI_LIBRARY}
  614. ${NX_LIBRARY}
  615. )
  616. endif()
  617. if(NOT SERVER_ONLY)
  618. if (USE_MOJOAL)
  619. target_link_libraries(supertuxkart mojoal ${LIBSAMPLERATE_LIBRARY})
  620. else()
  621. target_link_libraries(supertuxkart ${OPENAL_LIBRARY})
  622. endif()
  623. endif()
  624. if (${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
  625. target_link_libraries(supertuxkart nsl socket vorbisfile)
  626. endif()
  627. if (${CMAKE_SYSTEM_NAME} MATCHES "Haiku")
  628. target_link_libraries(supertuxkart be network vorbisfile)
  629. endif()
  630. if (USE_DNS_C)
  631. target_link_libraries(supertuxkart dnsc)
  632. else()
  633. target_link_libraries(supertuxkart ${LIBRESOLV_LIBRARY})
  634. endif()
  635. if (USE_SQLITE3)
  636. target_link_libraries(supertuxkart ${SQLITE3_LIBRARY})
  637. endif()
  638. if (USE_CRYPTO_OPENSSL)
  639. target_link_libraries(supertuxkart ${OPENSSL_CRYPTO_LIBRARY})
  640. else()
  641. target_link_libraries(supertuxkart ${MBEDCRYPTO_LIBRARY})
  642. endif()
  643. if(NOT SERVER_ONLY)
  644. if (APPLE AND NOT DLOPEN_MOLTENVK)
  645. find_library(MOLTENVK_LIBRARY NAMES MoltenVK libMoltenVK REQUIRED)
  646. target_link_libraries(supertuxkart "-framework Metal -weak_framework IOSurface -framework QuartzCore ${MOLTENVK_LIBRARY}")
  647. endif()
  648. if (IOS)
  649. target_link_libraries(supertuxkart "-weak_framework CoreHaptics -framework QuartzCore -framework CoreGraphics -framework AVFoundation -framework AudioToolbox -framework Metal -framework GameController -framework OpenGLES -framework UIKit -framework CoreAudio -framework Foundation -framework GLKit")
  650. # tvOS doesn't have CoreMotion framwork
  651. include(CheckCSourceCompiles)
  652. set(prev_req_lib ${CMAKE_REQUIRED_LIBRARIES})
  653. set(CMAKE_REQUIRED_LIBRARIES "-framework CoreMotion")
  654. check_c_source_compiles("int main() { return 0; }" COREMOTION_EXISTS)
  655. set(CMAKE_REQUIRED_LIBRARIES ${prev_req_lib})
  656. if (COREMOTION_EXISTS)
  657. target_link_libraries(supertuxkart "-framework CoreMotion")
  658. endif()
  659. endif()
  660. target_link_libraries(supertuxkart
  661. ${SQUISH_LIBRARY}
  662. ${JPEG_LIBRARIES}
  663. ${OGGVORBIS_LIBRARIES}
  664. ${FREETYPE_LIBRARIES}
  665. ${HARFBUZZ_LIBRARY}
  666. ${SHEENBIDI_LIBRARY}
  667. graphics_utils
  668. graphics_engine
  669. ${SDL2_LIBRARY}
  670. tinygettext)
  671. if (NOT NO_SHADERC)
  672. target_link_libraries(supertuxkart ${SHADERC_LIBRARY})
  673. endif()
  674. endif()
  675. if(UNIX AND NOT APPLE)
  676. if(USE_LIBBFD)
  677. target_link_libraries(supertuxkart ${LIBBFD_LIBRARIES})
  678. if (CMAKE_SYSTEM_NAME MATCHES "BSD")
  679. target_link_libraries(supertuxkart execinfo)
  680. endif()
  681. endif()
  682. if(USE_ASAN)
  683. target_link_libraries(supertuxkart "-fsanitize=address")
  684. endif()
  685. if(USE_TSAN)
  686. target_link_libraries(supertuxkart "-fsanitize=thread")
  687. endif()
  688. endif()
  689. if(BUILD_RECORDER)
  690. target_link_libraries(supertuxkart ${OPENGLRECORDER_LIBRARY})
  691. endif()
  692. # FreeBSD does not search in /usr/local/lib, but at least Freetype is installed there :(
  693. if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
  694. SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L/usr/local/lib")
  695. endif()
  696. if(HAIKU)
  697. target_link_libraries(supertuxkart -lbe -lnetwork)
  698. endif()
  699. # Wiiuse
  700. # ------
  701. if(USE_WIIUSE)
  702. if(APPLE)
  703. find_library(BLUETOOTH_LIBRARY NAMES IOBluetooth PATHS /Developer/Library/Frameworks/IOBluetooth.framework)
  704. target_link_libraries(supertuxkart wiiuse ${BLUETOOTH_LIBRARY})
  705. elseif(WIN32)
  706. add_definitions(-DWIIUSE_STATIC)
  707. if(WIIUSE_BUILD)
  708. target_link_libraries(supertuxkart wiiuse)
  709. else()
  710. target_link_libraries(supertuxkart ${PROJECT_SOURCE_DIR}/${DEPENDENCIES}/lib/wiiuse.lib)
  711. endif()
  712. else()
  713. target_link_libraries(supertuxkart ${WIIUSE_LIBRARIES})
  714. endif()
  715. add_definitions(-DENABLE_WIIUSE)
  716. endif()
  717. if(MSVC OR MINGW)
  718. target_link_libraries(supertuxkart iphlpapi.lib)
  719. add_custom_command(TARGET supertuxkart POST_BUILD
  720. COMMAND ${CMAKE_COMMAND} -E copy_directory
  721. "${PROJECT_SOURCE_DIR}/${DEPENDENCIES}/bin"
  722. $<TARGET_FILE_DIR:supertuxkart>)
  723. add_custom_target(stkshaders SOURCES ${STK_SHADERS})
  724. endif()
  725. if(MINGW)
  726. target_link_libraries(supertuxkart -ldxguid -ldnsapi)
  727. if (NOT CMAKE_BUILD_TYPE MATCHES Debug)
  728. target_link_libraries(supertuxkart -mwindows)
  729. endif()
  730. find_library(LIBGCC NAMES "libgcc_s_dw2-1.dll" "libgcc_s_sjlj-1.dll" "libgcc_s_seh-1.dll" PATHS ${CMAKE_FIND_ROOT_PATH})
  731. if (LIBGCC)
  732. file(COPY ${LIBGCC} DESTINATION ${CMAKE_BINARY_DIR}/bin/)
  733. endif()
  734. find_library(LIBSTDCPP NAMES "libstdc++-6.dll" PATHS ${CMAKE_FIND_ROOT_PATH})
  735. if (LIBSTDCPP)
  736. file(COPY ${LIBSTDCPP} DESTINATION ${CMAKE_BINARY_DIR}/bin/)
  737. endif()
  738. find_library(LIBPTHREAD NAMES "winpthread-1.dll" "libwinpthread-1.dll" "pthreadGC2.dll" PATHS ${CMAKE_FIND_ROOT_PATH})
  739. if(LIBPTHREAD)
  740. file(COPY ${LIBPTHREAD} DESTINATION ${CMAKE_BINARY_DIR}/bin/)
  741. endif()
  742. endif()
  743. # Find LibGamerzilla library or build it if missing
  744. if (NOT APPLE)
  745. include(FindPkgConfig)
  746. pkg_search_module(GAMERZILLA OPTIONAL gamerzilla)
  747. if (GAMERZILLA_LIBRARIES)
  748. message(STATUS "Gamerzilla found")
  749. include_directories(${GAMERZILLA_INCLUDE_DIRS})
  750. target_link_libraries(supertuxkart ${GAMERZILLA_LIBRARIES})
  751. add_definitions(-DGAMERZILLA)
  752. endif()
  753. endif()
  754. # ==== Checking if data folder exists ====
  755. if(NOT IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/data)
  756. message( FATAL_ERROR "${CMAKE_CURRENT_SOURCE_DIR}/data folder doesn't exist" )
  757. endif()
  758. # ==== Checking if stk-assets folder exists ====
  759. if(CHECK_ASSETS)
  760. if((IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/data/karts) AND
  761. (IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/data/library) AND
  762. (IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/data/music) AND
  763. (IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/data/sfx) AND
  764. (IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/data/textures) AND
  765. (IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/data/tracks))
  766. message(STATUS "Assets found in data directory")
  767. elseif(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../stk-assets)
  768. set(STK_ASSETS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../stk-assets/)
  769. message(STATUS "Assets found")
  770. elseif(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../supertuxkart-assets)
  771. set(STK_ASSETS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../supertuxkart-assets/)
  772. message(STATUS "Assets found")
  773. else()
  774. set (CUR_DIR ${CMAKE_CURRENT_SOURCE_DIR})
  775. get_filename_component(PARENT_DIR ${CUR_DIR} PATH)
  776. message( FATAL_ERROR "${PARENT_DIR}/stk-assets folder doesn't exist. "
  777. "Please download the stk-assets, or disable this test with -DCHECK_ASSETS=off." )
  778. endif()
  779. endif()
  780. # ==== Install target ====
  781. install(TARGETS supertuxkart RUNTIME DESTINATION ${STK_INSTALL_BINARY_DIR} BUNDLE DESTINATION .)
  782. install(DIRECTORY ${STK_DATA_DIR} DESTINATION ${STK_INSTALL_DATA_DIR} PATTERN ".svn" EXCLUDE PATTERN ".git" EXCLUDE)
  783. if(STK_ASSETS_DIR AND CHECK_ASSETS)
  784. install(DIRECTORY ${STK_ASSETS_DIR} DESTINATION ${STK_INSTALL_DATA_DIR}/data PATTERN ".svn" EXCLUDE PATTERN ".git" EXCLUDE)
  785. endif()
  786. install(FILES ${STK_DATA_DIR}/supertuxkart.desktop DESTINATION share/applications)
  787. install(FILES data/supertuxkart_16.png DESTINATION share/icons/hicolor/16x16/apps RENAME supertuxkart.png)
  788. install(FILES data/supertuxkart_32.png DESTINATION share/icons/hicolor/32x32/apps RENAME supertuxkart.png)
  789. install(FILES data/supertuxkart_48.png DESTINATION share/icons/hicolor/48x48/apps RENAME supertuxkart.png)
  790. install(FILES data/supertuxkart_64.png DESTINATION share/icons/hicolor/64x64/apps RENAME supertuxkart.png)
  791. install(FILES data/supertuxkart_128.png DESTINATION share/icons/hicolor/128x128/apps RENAME supertuxkart.png)
  792. install(FILES data/supertuxkart_256.png DESTINATION share/icons/hicolor/256x256/apps RENAME supertuxkart.png)
  793. install(FILES data/supertuxkart_512.png DESTINATION share/icons/hicolor/512x512/apps RENAME supertuxkart.png)
  794. install(FILES data/supertuxkart_1024.png DESTINATION share/icons/hicolor/1024x1024/apps RENAME supertuxkart.png)
  795. install(FILES data/supertuxkart.appdata.xml DESTINATION share/metainfo)
  796. if(MINGW)
  797. install(DIRECTORY ${CMAKE_BINARY_DIR}/bin/ DESTINATION ${STK_INSTALL_BINARY_DIR}
  798. FILES_MATCHING PATTERN "*.dll")
  799. endif()