CMakeLists.txt 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544
  1. # root CMakeLists for the SuperTuxKart project
  2. project(SuperTuxKart)
  3. set(PROJECT_VERSION "0.9.1")
  4. cmake_minimum_required(VERSION 2.8.4)
  5. if(NOT (CMAKE_MAJOR_VERSION VERSION_LESS 3))
  6. cmake_policy(SET CMP0043 OLD)
  7. endif()
  8. set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake")
  9. include(CMakeDependentOption)
  10. include(BuildTypeSTKRelease)
  11. if (NOT CMAKE_BUILD_TYPE)
  12. message(STATUS "No build type selected, default to STKRelease")
  13. set(CMAKE_BUILD_TYPE "STKRelease")
  14. endif()
  15. option(SERVER_ONLY "Create a server only (i.e. no graphics or sound)" OFF)
  16. option(USE_FRIBIDI "Support for right-to-left languages" ON)
  17. option(CHECK_ASSETS "Check if assets are installed in ../stk-assets" ON)
  18. 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)
  19. option(ENABLE_NETWORK_MULTIPLAYER "Enable network multiplayer. This will replace the online profile GUI in the main menu with the network multiplayer GUI" OFF)
  20. CMAKE_DEPENDENT_OPTION(BUILD_RECORDER "Build opengl recorder" ON
  21. "NOT SERVER_ONLY;NOT USE_GLES2;NOT APPLE" OFF)
  22. if (UNIX AND NOT APPLE)
  23. option(USE_GLES2 "Use OpenGL ES2 renderer" OFF)
  24. endif()
  25. if(MSVC AND (MSVC_VERSION LESS 1900))
  26. # Normally hide the option to build wiiuse on VS, since it depends
  27. # on the installation of the Windows DDK (Driver Developer Kit),
  28. # which also needs an absolute path :(
  29. option(WIIUSE_BUILD "Build wiiuse lib (only for developers)" OFF)
  30. mark_as_advanced(WIIUSE_BUILD)
  31. else()
  32. set(WIIUSE_BUILD ON)
  33. endif()
  34. if(MINGW OR CYGWIN OR SERVER_ONLY)
  35. option(USE_WIIUSE "Support for wiimote input devices" OFF)
  36. else()
  37. option(USE_WIIUSE "Support for wiimote input devices" ON)
  38. endif()
  39. if(UNIX AND NOT APPLE)
  40. option(USE_ASAN "Build with Leak/Address sanitizer" OFF)
  41. option(USE_LIBBFD "Use libbfd for crash reporting and leak check" OFF)
  42. endif()
  43. set(STK_SOURCE_DIR "src")
  44. set(STK_DATA_DIR "${PROJECT_SOURCE_DIR}/data")
  45. set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin")
  46. # Define install paths
  47. set(STK_INSTALL_BINARY_DIR "bin" CACHE
  48. STRING "Install executable to this directory, absolute or relative to CMAKE_INSTALL_PREFIX")
  49. set(STK_INSTALL_DATA_DIR "share/supertuxkart" CACHE
  50. STRING "Install data folder to this directory, absolute or relative to CMAKE_INSTALL_PREFIX")
  51. # These variables enable MSVC to find libraries located in "dependencies"
  52. if(WIN32)
  53. set(ENV{PATH} "$ENV{PATH};${PROJECT_SOURCE_DIR}/dependencies/include")
  54. set(ENV{LIB} ${PROJECT_SOURCE_DIR}/dependencies/lib)
  55. set(ENV{OPENALDIR} ${PROJECT_SOURCE_DIR}/dependencies)
  56. add_definitions(-D_IRR_STATIC_LIB_)
  57. add_definitions(-DNO_IRR_COMPILE_WITH_X11_)
  58. endif()
  59. if(USE_GLES2)
  60. add_definitions(-DUSE_GLES2)
  61. endif()
  62. if(SERVER_ONLY)
  63. add_definitions(-DSERVER_ONLY)
  64. add_definitions(-DNO_IRR_COMPILE_WITH_X11_)
  65. endif()
  66. if(DISABLE_VPX)
  67. add_definitions(-DNO_VPX)
  68. endif()
  69. if(BUILD_RECORDER)
  70. add_definitions(-DENABLE_RECORDER)
  71. endif()
  72. # Build the Bullet physics library
  73. add_subdirectory("${PROJECT_SOURCE_DIR}/lib/bullet")
  74. include_directories("${PROJECT_SOURCE_DIR}/lib/bullet/src")
  75. # Build the ENet UDP network library
  76. add_subdirectory("${PROJECT_SOURCE_DIR}/lib/enet")
  77. include_directories("${PROJECT_SOURCE_DIR}/lib/enet/include")
  78. # Build glew library
  79. if(NOT USE_GLES2 AND NOT SERVER_ONLY)
  80. add_definitions(-DGLEW_NO_GLU)
  81. add_subdirectory("${PROJECT_SOURCE_DIR}/lib/glew")
  82. include_directories("${PROJECT_SOURCE_DIR}/lib/glew/include")
  83. endif()
  84. if((WIN32 AND NOT MINGW) OR APPLE)
  85. if (NOT APPLE)
  86. # Build zlib library
  87. add_subdirectory("${PROJECT_SOURCE_DIR}/lib/zlib")
  88. include_directories("${PROJECT_SOURCE_DIR}/lib/zlib")
  89. set(ZLIB_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/lib/zlib" "${PROJECT_BINARY_DIR}/lib/zlib/")
  90. set(ZLIB_LIBRARY zlibstatic)
  91. endif()
  92. # Build png library
  93. set (SKIP_INSTALL_ALL TRUE)
  94. set (PNG_STATIC TRUE)
  95. set (PNG_TESTS FALSE)
  96. set (PNG_SHARED FALSE)
  97. add_subdirectory("${PROJECT_SOURCE_DIR}/lib/libpng")
  98. include_directories("${PROJECT_SOURCE_DIR}/lib/libpng")
  99. set(PNG_PNG_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/lib/libpng/")
  100. set(PNG_LIBRARY png15_static)
  101. endif()
  102. # Add jpeg library
  103. if (APPLE)
  104. add_subdirectory("${PROJECT_SOURCE_DIR}/lib/jpeglib")
  105. include_directories("${PROJECT_SOURCE_DIR}/lib/jpeglib")
  106. set(JPEG_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/lib/jpeglib/")
  107. set(JPEG_LIBRARY jpeglib)
  108. else()
  109. find_package(JPEG REQUIRED)
  110. include_directories(${JPEG_INCLUDE_DIR})
  111. endif()
  112. if (BUILD_RECORDER)
  113. find_library(OPENGLRECORDER_LIBRARY NAMES openglrecorder libopenglrecorder PATHS "${PROJECT_SOURCE_DIR}/dependencies/lib")
  114. find_path(OPENGLRECORDER_INCLUDEDIR NAMES openglrecorder.h PATHS "${PROJECT_SOURCE_DIR}/dependencies/include")
  115. if (NOT OPENGLRECORDER_LIBRARY OR NOT OPENGLRECORDER_INCLUDEDIR)
  116. message(FATAL_ERROR "libopenglrecorder not found. "
  117. "Either install libopenglrecorder or disable ingame recorder with -DBUILD_RECORDER=0")
  118. endif()
  119. include_directories(${OPENGLRECORDER_INCLUDEDIR})
  120. mark_as_advanced(OPENGLRECORDER_LIBRARY OPENGLRECORDER_INCLUDEDIR)
  121. endif()
  122. if(NOT SERVER_ONLY AND NOT USE_GLES2)
  123. add_subdirectory("${PROJECT_SOURCE_DIR}/lib/graphics_utils")
  124. include_directories("${PROJECT_SOURCE_DIR}/lib/graphics_utils")
  125. endif()
  126. # Build the irrlicht library
  127. add_subdirectory("${PROJECT_SOURCE_DIR}/lib/irrlicht")
  128. include_directories("${PROJECT_SOURCE_DIR}/lib/irrlicht/include")
  129. # Build the Wiiuse library
  130. # Note: wiiuse MUST be declared after irrlicht, since otherwise
  131. # (at least on VS) irrlicht will find wiiuse io.h file because
  132. # of the added include directory.
  133. if(USE_WIIUSE)
  134. if(WIIUSE_BUILD)
  135. add_subdirectory("${PROJECT_SOURCE_DIR}/lib/wiiuse")
  136. endif()
  137. include_directories("${PROJECT_SOURCE_DIR}/lib/wiiuse")
  138. endif()
  139. # Set include paths
  140. include_directories(${STK_SOURCE_DIR})
  141. if(APPLE)
  142. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -arch x86_64")
  143. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -arch x86_64 -F/Library/Frameworks")
  144. elseif(MSVC)
  145. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") # Enable multi-processor compilation (faster)
  146. endif()
  147. # Build the angelscript library if not in system
  148. if(USE_SYSTEM_ANGELSCRIPT)
  149. find_package(Angelscript)
  150. if(ANGELSCRIPT_FOUND)
  151. include_directories(${Angelscript_INCLUDE_DIRS})
  152. else()
  153. message(FATAL_ERROR "Angelscript not found. "
  154. "Either install angelscript or use built-in version using "
  155. "-DUSE_SYSTEM_ANGELSCRIPT=0")
  156. endif()
  157. else()
  158. add_subdirectory("${PROJECT_SOURCE_DIR}/lib/angelscript/projects/cmake")
  159. include_directories("${PROJECT_SOURCE_DIR}/lib/angelscript/include")
  160. set(Angelscript_LIBRARIES angelscript)
  161. endif()
  162. # OpenAL
  163. if(APPLE)
  164. # In theory it would be cleaner to let CMake detect the right dependencies. In practice, this means that if a OSX user has
  165. # unix-style installs of Vorbis/Ogg/OpenAL/etc. they will be picked up over our frameworks. This is blocking when I make releases :
  166. # the mac I use to make STK releases does have other installs of vorbis/ogg/etc. which aren't compatible with STK, so letting
  167. # CMake pick the library it wants essentially means I can't build.
  168. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -framework OpenAL")
  169. set(OPENAL_LIBRARY)
  170. else()
  171. find_package(OpenAL REQUIRED)
  172. include_directories(${OPENAL_INCLUDE_DIR})
  173. endif()
  174. # OggVorbis
  175. if(APPLE)
  176. # In theory it would be cleaner to let CMake detect the right dependencies. In practice, this means that if a OSX user has
  177. # unix-style installs of Vorbis/Ogg/OpenAL/etc. they will be picked up over our frameworks. This is blocking when I make releases :
  178. # the mac I use to make STK releases does have other installs of vorbis/ogg/etc. which aren't compatible with STK, so letting
  179. # CMake pick the library it wants essentially means I can't build.
  180. set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -I/Library/Frameworks/Ogg.framework/Versions/A/Headers -I/Library/Frameworks/Vorbis.framework/Versions/A/Headers")
  181. else()
  182. find_package(OggVorbis REQUIRED)
  183. include_directories(${OGGVORBIS_INCLUDE_DIRS})
  184. endif()
  185. # Freetype
  186. find_package(Freetype)
  187. if(FREETYPE_FOUND)
  188. include_directories(${FREETYPE_INCLUDE_DIRS})
  189. else()
  190. message(FATAL_ERROR "Freetype not found. "
  191. "Freetype is required to display characters in SuperTuxKart. ")
  192. endif()
  193. # Fribidi
  194. if(USE_FRIBIDI)
  195. find_package(Fribidi)
  196. if(FRIBIDI_FOUND)
  197. include_directories(${FRIBIDI_INCLUDE_DIRS})
  198. else()
  199. message(FATAL_ERROR "Fribidi not found. "
  200. "Either install fribidi or disable bidi support with -DUSE_FRIBIDI=0 "
  201. "(if you don't use a right-to-left language then you don't need this).")
  202. endif()
  203. endif()
  204. # OpenGL
  205. if(NOT USE_GLES2 AND NOT SERVER_ONLY)
  206. find_package(OpenGL REQUIRED)
  207. include_directories(${OPENGL_INCLUDE_DIR})
  208. endif()
  209. if(UNIX AND NOT APPLE AND NOT SERVER_ONLY)
  210. find_package(X11 REQUIRED)
  211. include_directories(${X11_INCLUDE_DIR})
  212. find_package(Xrandr REQUIRED)
  213. if(NOT XRANDR_FOUND)
  214. message(FATAL_ERROR "XRANDR not found.")
  215. endif()
  216. if(USE_LIBBFD)
  217. find_package(Libbfd)
  218. if(LIBBFD_FOUND)
  219. add_definitions(-DENABLE_LIBBFD)
  220. include_directories(${LIBBFD_INCLUDE_DIRS})
  221. else()
  222. set(USE_LIBBFD OFF CACHE BOOL "Use libbfd for crash reporting and leak check" FORCE)
  223. message(WARNING "Libbfd not found, disable integrated stack trace.")
  224. endif()
  225. endif()
  226. endif()
  227. # Set some compiler options
  228. if(UNIX OR MINGW)
  229. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++0x")
  230. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-unused-function")
  231. endif()
  232. if(MINGW AND CMAKE_BUILD_TYPE MATCHES Release)
  233. SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--subsystem,windows")
  234. endif()
  235. # Netwowk Multiplayer
  236. if(ENABLE_NETWORK_MULTIPLAYER)
  237. add_definitions(-DENABLE_NETWORK_MULTIPLAYER_SCREEN)
  238. endif()
  239. if(WIN32)
  240. # By default windows.h has macros defined for min and max that screw up everything
  241. add_definitions(-DNOMINMAX)
  242. # And shut up about unsafe stuff
  243. add_definitions(-D_CRT_SECURE_NO_WARNINGS)
  244. # Avoid timespec structure redeclaration on Visual Studio 2015
  245. if (NOT (MSVC_VERSION LESS 1900))
  246. add_definitions(-DHAVE_STRUCT_TIMESPEC)
  247. endif()
  248. endif()
  249. if(MSVC)
  250. # VS will automatically add NDEBUG for release mode, but only _DEBUG in debug mode.
  251. # Since STK uses DEBUG, this is added for debug compilation only:
  252. set_property(DIRECTORY PROPERTY COMPILE_DEFINITIONS_DEBUG DEBUG)
  253. else()
  254. # All non VS generators used create only a single compile mode, so
  255. # compile flags can be simplye be added
  256. if(CMAKE_BUILD_TYPE MATCHES Debug)
  257. add_definitions(-DDEBUG)
  258. else()
  259. add_definitions(-DNDEBUG)
  260. endif()
  261. endif()
  262. # TODO: remove this switch
  263. add_definitions(-DHAVE_OGGVORBIS)
  264. if(WIN32)
  265. configure_file("${STK_SOURCE_DIR}/../tools/windows_installer/icon_rc.template" "${PROJECT_BINARY_DIR}/tmp/icon.rc")
  266. endif()
  267. # Provides list of source and header files (STK_SOURCES and STK_HEADERS)
  268. include(sources.cmake)
  269. # Generate source groups useful for MSVC project explorer
  270. include(cmake/SourceGroupFunctions.cmake)
  271. source_group_hierarchy(STK_SOURCES STK_HEADERS)
  272. if(APPLE)
  273. # icon files to copy in the bundle
  274. set(OSX_ICON_FILES ${PROJECT_SOURCE_DIR}/data/supertuxkart.icns)
  275. set_source_files_properties(${OSX_ICON_FILES} PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
  276. set(STK_SOURCES ${STK_SOURCES} ${OSX_ICON_FILES})
  277. # build the executable and create an app bundle
  278. add_executable(supertuxkart MACOSX_BUNDLE ${STK_SOURCES})
  279. find_library(IOKIT_LIBRARY IOKit)
  280. find_library(QUICKTIME_LIBRARY QuickTime)
  281. find_library(CARBON_LIBRARY Carbon)
  282. find_library(AUDIOUNIT_LIBRARY AudioUnit)
  283. find_library(COCOA_LIBRARY Cocoa)
  284. target_link_libraries(supertuxkart
  285. ${IOKIT_LIBRARY}
  286. ${QUICKTIME_LIBRARY}
  287. ${CARBON_LIBRARY}
  288. ${AUDIOUNIT_LIBRARY}
  289. ${COCOA_LIBRARY})
  290. # configure CMake to use a custom Info.plist
  291. set_target_properties(supertuxkart PROPERTIES
  292. MACOSX_BUNDLE_INFO_PLIST ${PROJECT_SOURCE_DIR}/data/SuperTuxKart-Info.plist)
  293. if(CMAKE_GENERATOR MATCHES "Xcode")
  294. add_custom_command(TARGET supertuxkart POST_BUILD
  295. COMMAND ln -f -s ${PROJECT_SOURCE_DIR}/data ${CMAKE_BINARY_DIR}/bin/\${CONFIGURATION}/supertuxkart.app/Contents/Resources)
  296. else()
  297. add_custom_command(TARGET supertuxkart POST_BUILD
  298. COMMAND ln -f -s ${PROJECT_SOURCE_DIR}/data ${CMAKE_BINARY_DIR}/bin/supertuxkart.app/Contents/Resources)
  299. endif()
  300. else()
  301. if(MSVC)
  302. set(PTHREAD_NAMES pthreadVC2)
  303. elseif(MINGW)
  304. set(PTHREAD_NAMES "winpthread-1" "libwinpthread-1" "pthreadGC2")
  305. endif()
  306. find_library(PTHREAD_LIBRARY NAMES pthread ${PTHREAD_NAMES} PATHS ${PROJECT_SOURCE_DIR}/dependencies/lib)
  307. mark_as_advanced(PTHREAD_LIBRARY)
  308. # Set data dir (absolute or relative to CMAKE_INSTALL_PREFIX)
  309. if(NOT STK_INSTALL_DATA_DIR_ABSOLUTE)
  310. get_filename_component(STK_INSTALL_DATA_DIR_ABSOLUTE ${STK_INSTALL_DATA_DIR} ABSOLUTE)
  311. if(${STK_INSTALL_DATA_DIR_ABSOLUTE} STREQUAL ${STK_INSTALL_DATA_DIR})
  312. add_definitions(-DSUPERTUXKART_DATADIR=\"${STK_INSTALL_DATA_DIR_ABSOLUTE}\")
  313. else()
  314. add_definitions(-DSUPERTUXKART_DATADIR=\"${CMAKE_INSTALL_PREFIX}/${STK_INSTALL_DATA_DIR}\")
  315. endif()
  316. else()
  317. add_definitions(-DSUPERTUXKART_DATADIR=\"${STK_INSTALL_DATA_DIR_ABSOLUTE}\")
  318. endif()
  319. # Build the final executable
  320. add_executable(supertuxkart ${STK_SOURCES} ${STK_RESOURCES} ${STK_HEADERS})
  321. target_link_libraries(supertuxkart ${PTHREAD_LIBRARY})
  322. endif()
  323. # CURL
  324. if(MSVC)
  325. target_link_libraries(supertuxkart ${PROJECT_SOURCE_DIR}/dependencies/lib/libcurl.lib)
  326. elseif(MINGW)
  327. target_link_libraries(supertuxkart ${PROJECT_SOURCE_DIR}/dependencies/lib/libcurldll.a)
  328. else()
  329. find_package(CURL REQUIRED)
  330. include_directories(${CURL_INCLUDE_DIRS})
  331. endif()
  332. # Common library dependencies
  333. target_link_libraries(supertuxkart
  334. bulletdynamics
  335. bulletcollision
  336. bulletmath
  337. enet
  338. stkirrlicht
  339. ${Angelscript_LIBRARIES}
  340. ${CURL_LIBRARIES}
  341. ${OGGVORBIS_LIBRARIES}
  342. ${OPENAL_LIBRARY}
  343. ${FREETYPE_LIBRARIES}
  344. ${JPEG_LIBRARIES}
  345. ${TURBOJPEG_LIBRARY}
  346. ${VPX_LIBRARIES}
  347. )
  348. if(NOT SERVER_ONLY)
  349. if(NOT USE_GLES2)
  350. target_link_libraries(supertuxkart ${OPENGL_gl_LIBRARY} glew graphics_utils)
  351. else()
  352. target_link_libraries(supertuxkart EGL GLESv2)
  353. endif()
  354. endif()
  355. if(UNIX AND NOT APPLE)
  356. target_link_libraries(supertuxkart ${X11_LIBRARIES} ${XRANDR_LIBRARIES})
  357. if(USE_LIBBFD)
  358. target_link_libraries(supertuxkart ${LIBBFD_LIBRARIES})
  359. endif()
  360. if(USE_ASAN)
  361. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer")
  362. target_link_libraries(supertuxkart "-fsanitize=address")
  363. endif()
  364. endif()
  365. if(BUILD_RECORDER)
  366. target_link_libraries(supertuxkart ${OPENGLRECORDER_LIBRARY})
  367. endif()
  368. # FreeBSD does not search in /usr/local/lib, but at least Freetype is installed there :(
  369. if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
  370. SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L/usr/local/lib")
  371. endif()
  372. if(APPLE)
  373. # In theory it would be cleaner to let CMake detect the right dependencies. In practice, this means that if a OSX user has
  374. # unix-style installs of Vorbis/Ogg/OpenAL/etc. they will be picked up over our frameworks. This is blocking when I make releases :
  375. # the mac I use to make STK releases does have other installs of vorbis/ogg/etc. which aren't compatible with STK, so letting
  376. # CMake pick the library it wants essentially means I can't build.
  377. set_target_properties(supertuxkart PROPERTIES LINK_FLAGS "-arch x86_64 -F/Library/Frameworks -framework OpenAL -framework Ogg -framework Vorbis")
  378. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I/Library/Frameworks/OpenAL.framework/Versions/A/Headers")
  379. endif()
  380. if(USE_FRIBIDI)
  381. target_link_libraries(supertuxkart ${FRIBIDI_LIBRARIES})
  382. add_definitions(-DENABLE_BIDI)
  383. endif()
  384. # Wiiuse
  385. # ------
  386. if(USE_WIIUSE)
  387. if(APPLE)
  388. find_library(BLUETOOTH_LIBRARY NAMES IOBluetooth PATHS /Developer/Library/Frameworks/IOBluetooth.framework)
  389. target_link_libraries(supertuxkart wiiuse ${BLUETOOTH_LIBRARY})
  390. elseif(WIN32)
  391. add_definitions(-DWIIUSE_STATIC)
  392. if(WIIUSE_BUILD)
  393. target_link_libraries(supertuxkart wiiuse)
  394. else()
  395. target_link_libraries(supertuxkart ${PROJECT_SOURCE_DIR}/dependencies/lib/wiiuse.lib)
  396. endif()
  397. else()
  398. target_link_libraries(supertuxkart wiiuse bluetooth)
  399. endif()
  400. add_definitions(-DENABLE_WIIUSE)
  401. endif()
  402. if(MSVC OR MINGW)
  403. target_link_libraries(supertuxkart iphlpapi.lib)
  404. add_custom_command(TARGET supertuxkart POST_BUILD
  405. COMMAND ${CMAKE_COMMAND} -E copy_directory
  406. "${PROJECT_SOURCE_DIR}/dependencies/dll"
  407. $<TARGET_FILE_DIR:supertuxkart>)
  408. add_custom_target(stkshaders SOURCES ${STK_SHADERS})
  409. endif()
  410. if(MINGW)
  411. find_library(LIBGCC NAMES "libgcc_s_dw2-1.dll" "libgcc_s_sjlj-1.dll" "libgcc_s_seh-1.dll" PATHS ${CMAKE_FIND_ROOT_PATH})
  412. if(LIBGCC)
  413. file(COPY ${LIBGCC} DESTINATION ${CMAKE_BINARY_DIR}/bin/)
  414. endif()
  415. find_library(LIBSTDCPP NAMES "libstdc++-6.dll" PATHS ${CMAKE_FIND_ROOT_PATH})
  416. if(LIBSTDCPP)
  417. file(COPY ${LIBSTDCPP} DESTINATION ${CMAKE_BINARY_DIR}/bin/)
  418. endif()
  419. find_library(LIBPTHREAD NAMES "winpthread-1.dll" "libwinpthread-1.dll" "pthreadGC2.dll" PATHS ${CMAKE_FIND_ROOT_PATH})
  420. if(LIBPTHREAD)
  421. file(COPY ${LIBPTHREAD} DESTINATION ${CMAKE_BINARY_DIR}/bin/)
  422. endif()
  423. endif()
  424. # ==== Checking if data folder exists ====
  425. if(NOT IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/data)
  426. message( FATAL_ERROR "${CMAKE_CURRENT_SOURCE_DIR}/data folder doesn't exist" )
  427. endif()
  428. # ==== Checking if stk-assets folder exists ====
  429. if(CHECK_ASSETS)
  430. if((IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/data/karts) AND
  431. (IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/data/library) AND
  432. (IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/data/music) AND
  433. (IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/data/sfx) AND
  434. (IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/data/textures) AND
  435. (IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/data/tracks))
  436. message(STATUS "Assets found in data directory")
  437. elseif(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../stk-assets)
  438. set(STK_ASSETS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../stk-assets/)
  439. message(STATUS "Assets found")
  440. elseif(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../supertuxkart-assets)
  441. set(STK_ASSETS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../supertuxkart-assets/)
  442. message(STATUS "Assets found")
  443. else()
  444. set (CUR_DIR ${CMAKE_CURRENT_SOURCE_DIR})
  445. get_filename_component(PARENT_DIR ${CUR_DIR} PATH)
  446. message( FATAL_ERROR "${PARENT_DIR}/stk-assets folder doesn't exist. "
  447. "Please download the stk-assets, or disable this test with -DCHECK_ASSETS=off." )
  448. endif()
  449. endif()
  450. # ==== Install target ====
  451. install(TARGETS supertuxkart RUNTIME DESTINATION ${STK_INSTALL_BINARY_DIR} BUNDLE DESTINATION .)
  452. install(DIRECTORY ${STK_DATA_DIR} DESTINATION ${STK_INSTALL_DATA_DIR} PATTERN ".svn" EXCLUDE PATTERN ".git" EXCLUDE)
  453. if(STK_ASSETS_DIR AND CHECK_ASSETS)
  454. install(DIRECTORY ${STK_ASSETS_DIR} DESTINATION ${STK_INSTALL_DATA_DIR}/data PATTERN ".svn" EXCLUDE PATTERN ".git" EXCLUDE)
  455. endif()
  456. install(FILES ${STK_DATA_DIR}/supertuxkart.desktop DESTINATION share/applications)
  457. install(FILES data/supertuxkart_32.png DESTINATION share/icons/hicolor/32x32/apps RENAME supertuxkart.png)
  458. install(FILES data/supertuxkart_128.png DESTINATION share/icons/hicolor/128x128/apps RENAME supertuxkart.png)
  459. install(FILES data/supertuxkart_32.png data/supertuxkart_128.png DESTINATION share/pixmaps)
  460. install(FILES data/supertuxkart.appdata.xml DESTINATION share/appdata)
  461. if(MINGW)
  462. install(DIRECTORY ${CMAKE_BINARY_DIR}/bin/ DESTINATION ${STK_INSTALL_BINARY_DIR}
  463. FILES_MATCHING PATTERN "*.dll")
  464. endif()