2018-01-07 15:15:08 -05:00
cmake_minimum_required ( VERSION 2.8.4 )
2011-12-04 18:04:02 -05:00
# root CMakeLists for the SuperTuxKart project
2012-03-05 20:07:26 -05:00
project ( SuperTuxKart )
2017-06-22 20:27:29 -04:00
set ( PROJECT_VERSION "git" )
2011-07-24 10:29:16 -04:00
2014-09-23 07:01:04 -04:00
if ( NOT ( CMAKE_MAJOR_VERSION VERSION_LESS 3 ) )
cmake_policy ( SET CMP0043 OLD )
endif ( )
2014-02-21 14:09:10 -05:00
set ( CMAKE_MODULE_PATH ${ CMAKE_MODULE_PATH } "${PROJECT_SOURCE_DIR}/cmake" )
2017-04-04 02:23:04 -04:00
include ( CMakeDependentOption )
2011-07-24 10:29:16 -04:00
2017-04-06 09:59:01 -04:00
set ( DEPENDENCIES "dependencies" )
# In case of 64-bit windows, use a different path for dependencies
# so that both dependencies can be installed next to each other
if ( WIN32 AND ( CMAKE_SIZEOF_VOID_P EQUAL 8 ) )
set ( DEPENDENCIES "dependencies-64bit" )
endif ( )
2012-03-06 11:42:00 -05:00
include ( BuildTypeSTKRelease )
2012-03-04 15:07:44 -05:00
if ( NOT CMAKE_BUILD_TYPE )
2012-03-06 11:42:00 -05:00
message ( STATUS "No build type selected, default to STKRelease" )
set ( CMAKE_BUILD_TYPE "STKRelease" )
2012-03-04 15:07:44 -05:00
endif ( )
2016-11-11 01:21:59 -05:00
option ( SERVER_ONLY "Create a server only (i.e. no graphics or sound)" OFF )
2012-03-06 15:40:06 -05:00
option ( USE_FRIBIDI "Support for right-to-left languages" ON )
2014-04-24 00:22:38 -04:00
option ( CHECK_ASSETS "Check if assets are installed in ../stk-assets" ON )
2015-06-15 18:46:06 -04:00
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 )
2014-04-24 00:22:38 -04:00
2017-04-04 02:23:04 -04:00
CMAKE_DEPENDENT_OPTION ( BUILD_RECORDER "Build opengl recorder" ON
" N O T S E R V E R _ O N L Y ; N O T U S E _ G L E S 2 ; N O T APPLE " O F F )
2018-01-09 14:35:33 -05:00
if ( ( UNIX AND NOT APPLE ) AND NOT SERVER_ONLY )
2018-01-07 15:23:21 -05:00
option ( ENABLE_WAYLAND_DEVICE "Enable Wayland device for linux build" ON )
2016-07-08 21:03:15 -04:00
option ( USE_GLES2 "Use OpenGL ES2 renderer" OFF )
endif ( )
2014-04-24 00:22:38 -04:00
2017-11-12 17:55:28 -05:00
if ( UNIX OR MINGW )
option ( DEBUG_SYMBOLS "Compile with debug symbols" OFF )
endif ( )
2015-08-06 13:57:22 -04:00
if ( MSVC AND ( MSVC_VERSION LESS 1900 ) )
2013-08-05 02:10:31 -04:00
# Normally hide the option to build wiiuse on VS, since it depends
2014-09-03 08:05:34 -04:00
# on the installation of the Windows DDK (Driver Developer Kit),
2013-08-05 02:10:31 -04:00
# which also needs an absolute path :(
option ( WIIUSE_BUILD "Build wiiuse lib (only for developers)" OFF )
mark_as_advanced ( WIIUSE_BUILD )
2014-07-14 00:21:02 -04:00
else ( )
set ( WIIUSE_BUILD ON )
2013-08-05 02:10:31 -04:00
endif ( )
2011-07-24 10:29:16 -04:00
2016-11-11 01:21:59 -05:00
if ( MINGW OR CYGWIN OR SERVER_ONLY )
2015-12-03 08:47:08 -05:00
option ( USE_WIIUSE "Support for wiimote input devices" OFF )
else ( )
option ( USE_WIIUSE "Support for wiimote input devices" ON )
2014-09-03 08:05:34 -04:00
endif ( )
2014-07-25 13:23:32 -04:00
if ( UNIX AND NOT APPLE )
2014-08-12 14:19:31 -04:00
option ( USE_ASAN "Build with Leak/Address sanitizer" OFF )
2016-06-23 04:18:17 -04:00
option ( USE_LIBBFD "Use libbfd for crash reporting and leak check" OFF )
2014-07-25 13:23:32 -04:00
endif ( )
2011-07-24 10:29:16 -04:00
set ( STK_SOURCE_DIR "src" )
2012-03-06 11:39:57 -05:00
set ( STK_DATA_DIR "${PROJECT_SOURCE_DIR}/data" )
2012-03-06 11:35:11 -05:00
set ( CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin" )
2011-07-24 14:40:20 -04:00
2012-03-16 19:15:23 -04:00
# Define install paths
set ( STK_INSTALL_BINARY_DIR "bin" CACHE
S T R I N G " I n s t a l l e x e c u t a b l e t o t h i s d i r e c t o r y , a b s o l u t e o r r e l a t i v e t o C M A K E _ I N S T A L L _ P R E F I X " )
set ( STK_INSTALL_DATA_DIR "share/supertuxkart" CACHE
S T R I N G " I n s t a l l d a t a f o l d e r t o t h i s d i r e c t o r y , a b s o l u t e o r r e l a t i v e t o C M A K E _ I N S T A L L _ P R E F I X " )
2012-03-04 15:07:44 -05:00
2015-01-19 04:52:11 -05:00
# These variables enable MSVC to find libraries located in "dependencies"
if ( WIN32 )
2017-04-06 09:59:01 -04:00
set ( ENV{PATH} "$ENV{PATH};${PROJECT_SOURCE_DIR}/${DEPENDENCIES}/include" )
set ( ENV{LIB} ${ PROJECT_SOURCE_DIR } / ${ DEPENDENCIES } /lib )
set ( ENV{OPENALDIR} ${ PROJECT_SOURCE_DIR } / ${ DEPENDENCIES } )
2015-01-19 04:52:11 -05:00
add_definitions ( -D_IRR_STATIC_LIB_ )
2016-11-14 02:25:00 -05:00
add_definitions ( -DNO_IRR_COMPILE_WITH_X11_ )
2015-01-19 04:52:11 -05:00
endif ( )
2016-06-23 20:47:13 -04:00
if ( USE_GLES2 )
add_definitions ( -DUSE_GLES2 )
2017-10-17 17:28:20 -04:00
add_definitions ( -D_IRR_COMPILE_WITH_OGLES2_ -DNO_IRR_COMPILE_WITH_OPENGL_ )
2016-06-23 20:47:13 -04:00
endif ( )
2016-11-11 01:21:59 -05:00
if ( SERVER_ONLY )
add_definitions ( -DSERVER_ONLY )
2016-11-15 08:19:09 -05:00
add_definitions ( -DNO_IRR_COMPILE_WITH_X11_ )
2016-11-11 01:21:59 -05:00
endif ( )
2017-10-17 20:08:15 -04:00
#if(DISABLE_VPX)
# add_definitions(-DNO_VPX)
#endif()
2017-04-04 13:10:44 -04:00
2017-11-12 17:55:28 -05:00
if ( UNIX OR MINGW )
if ( DEBUG_SYMBOLS )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g" )
set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g" )
endif ( )
endif ( )
2011-07-24 10:29:16 -04:00
# Build the Bullet physics library
2012-09-18 19:09:12 -04:00
add_subdirectory ( "${PROJECT_SOURCE_DIR}/lib/bullet" )
include_directories ( "${PROJECT_SOURCE_DIR}/lib/bullet/src" )
2011-07-24 10:29:16 -04:00
# Build the ENet UDP network library
2012-09-18 19:09:12 -04:00
add_subdirectory ( "${PROJECT_SOURCE_DIR}/lib/enet" )
include_directories ( "${PROJECT_SOURCE_DIR}/lib/enet/include" )
2011-07-24 10:29:16 -04:00
2014-09-15 02:33:46 -04:00
# Build glew library
2016-11-11 01:21:59 -05:00
if ( NOT USE_GLES2 AND NOT SERVER_ONLY )
2016-07-11 17:23:02 -04:00
add_definitions ( -DGLEW_NO_GLU )
2016-06-23 20:47:13 -04:00
add_subdirectory ( "${PROJECT_SOURCE_DIR}/lib/glew" )
include_directories ( "${PROJECT_SOURCE_DIR}/lib/glew/include" )
endif ( )
2014-09-15 02:33:46 -04:00
2017-07-10 15:14:28 -04:00
if ( MSVC OR APPLE )
2015-01-27 20:07:32 -05:00
if ( NOT APPLE )
2015-01-19 04:52:11 -05:00
# Build zlib library
add_subdirectory ( "${PROJECT_SOURCE_DIR}/lib/zlib" )
include_directories ( "${PROJECT_SOURCE_DIR}/lib/zlib" )
set ( ZLIB_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/lib/zlib" "${PROJECT_BINARY_DIR}/lib/zlib/" )
set ( ZLIB_LIBRARY zlibstatic )
2015-01-27 20:07:32 -05:00
endif ( )
2015-01-19 04:52:11 -05:00
# Build png library
2017-06-05 15:54:44 -04:00
set ( SKIP_INSTALL_ALL TRUE )
set ( PNG_STATIC TRUE CACHE BOOL "Build static lib" )
set ( PNG_TESTS FALSE CACHE BOOL "Build libpng tests" )
set ( PNG_SHARED FALSE CACHE BOOL "Build shared lib" )
2015-01-19 04:52:11 -05:00
add_subdirectory ( "${PROJECT_SOURCE_DIR}/lib/libpng" )
include_directories ( "${PROJECT_SOURCE_DIR}/lib/libpng" )
set ( PNG_PNG_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/lib/libpng/" )
2017-06-05 15:54:44 -04:00
set ( PNG_LIBRARY png_static )
2015-01-17 14:53:18 -05:00
endif ( )
2017-03-12 22:28:43 -04:00
2017-04-04 02:23:04 -04:00
# Add jpeg library
2017-03-22 05:24:33 -04:00
if ( APPLE )
add_subdirectory ( "${PROJECT_SOURCE_DIR}/lib/jpeglib" )
include_directories ( "${PROJECT_SOURCE_DIR}/lib/jpeglib" )
2015-01-19 04:52:11 -05:00
set ( JPEG_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/lib/jpeglib/" )
set ( JPEG_LIBRARY jpeglib )
2017-03-22 05:24:33 -04:00
else ( )
find_package ( JPEG REQUIRED )
include_directories ( ${ JPEG_INCLUDE_DIR } )
endif ( )
2017-04-13 01:59:36 -04:00
if ( BUILD_RECORDER )
2017-11-05 15:54:43 -05:00
find_library ( OPENGLRECORDER_LIBRARY NAMES openglrecorder libopenglrecorder PATHS "${PROJECT_SOURCE_DIR}/${DEPENDENCIES}/lib" )
find_path ( OPENGLRECORDER_INCLUDEDIR NAMES openglrecorder.h PATHS "${PROJECT_SOURCE_DIR}/${DEPENDENCIES}/include" )
2017-04-13 01:59:36 -04:00
if ( NOT OPENGLRECORDER_LIBRARY OR NOT OPENGLRECORDER_INCLUDEDIR )
2017-06-22 20:27:29 -04:00
if ( PROJECT_VERSION STREQUAL "git" )
message ( WARNING "libopenglrecorder not found, disabling in-game recorder. "
" T o u s e r e c o r d e r , i n s t a l l l i b o p e n g l r e c o r d e r . " )
2017-06-27 19:56:53 -04:00
set ( OPENGLRECORDER_LIBRARY CACHE INTERNAL "" )
set ( OPENGLRECORDER_INCLUDEDIR CACHE INTERNAL "" )
set ( BUILD_RECORDER OFF )
2017-06-22 20:27:29 -04:00
else ( )
message ( FATAL_ERROR "libopenglrecorder not found. "
" E i t h e r i n s t a l l l i b o p e n g l r e c o r d e r o r d i s a b l e i n - g a m e r e c o r d e r w i t h - D B U I L D _ R E C O R D E R = 0 " )
endif ( )
else ( )
include_directories ( ${ OPENGLRECORDER_INCLUDEDIR } )
mark_as_advanced ( OPENGLRECORDER_LIBRARY OPENGLRECORDER_INCLUDEDIR )
add_definitions ( -DENABLE_RECORDER )
2017-04-13 01:59:36 -04:00
endif ( )
2017-03-31 12:52:38 -04:00
endif ( )
2017-03-24 09:51:17 -04:00
2017-03-15 23:29:16 -04:00
if ( NOT SERVER_ONLY AND NOT USE_GLES2 )
add_subdirectory ( "${PROJECT_SOURCE_DIR}/lib/graphics_utils" )
include_directories ( "${PROJECT_SOURCE_DIR}/lib/graphics_utils" )
2015-01-17 14:53:18 -05:00
endif ( )
2017-03-12 22:28:43 -04:00
2013-08-05 02:10:31 -04:00
# Build the irrlicht library
add_subdirectory ( "${PROJECT_SOURCE_DIR}/lib/irrlicht" )
include_directories ( "${PROJECT_SOURCE_DIR}/lib/irrlicht/include" )
2012-01-01 16:19:13 -05:00
# Build the Wiiuse library
2013-08-05 02:10:31 -04:00
# Note: wiiuse MUST be declared after irrlicht, since otherwise
# (at least on VS) irrlicht will find wiiuse io.h file because
# of the added include directory.
2012-01-01 16:19:13 -05:00
if ( USE_WIIUSE )
2013-08-05 02:10:31 -04:00
if ( WIIUSE_BUILD )
add_subdirectory ( "${PROJECT_SOURCE_DIR}/lib/wiiuse" )
endif ( )
2012-09-18 19:09:12 -04:00
include_directories ( "${PROJECT_SOURCE_DIR}/lib/wiiuse" )
2012-01-01 16:19:13 -05:00
endif ( )
2011-07-24 14:40:20 -04:00
2012-03-06 15:40:06 -05:00
# Set include paths
include_directories ( ${ STK_SOURCE_DIR } )
2011-07-24 10:29:16 -04:00
2013-03-13 21:39:23 -04:00
if ( APPLE )
2016-03-21 20:16:59 -04:00
set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -arch x86_64" )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -arch x86_64 -F/Library/Frameworks" )
2013-10-22 09:28:06 -04:00
elseif ( MSVC )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP" ) # Enable multi-processor compilation (faster)
2013-03-13 21:39:23 -04:00
endif ( )
2014-11-01 17:52:11 -04:00
2015-05-18 10:23:28 -04:00
# Build the angelscript library if not in system
2015-09-07 12:14:57 -04:00
if ( USE_SYSTEM_ANGELSCRIPT )
find_package ( Angelscript )
if ( ANGELSCRIPT_FOUND )
include_directories ( ${ Angelscript_INCLUDE_DIRS } )
else ( )
message ( FATAL_ERROR "Angelscript not found. "
" E i t h e r i n s t a l l a n g e l s c r i p t o r u s e b u i l t - i n v e r s i o n u s i n g "
" - D U S E _ S Y S T E M _ A N G E L S C R I P T = 0 " )
endif ( )
2015-05-18 10:23:28 -04:00
else ( )
add_subdirectory ( "${PROJECT_SOURCE_DIR}/lib/angelscript/projects/cmake" )
include_directories ( "${PROJECT_SOURCE_DIR}/lib/angelscript/include" )
set ( Angelscript_LIBRARIES angelscript )
endif ( )
2014-11-01 17:52:11 -04:00
2011-08-01 15:18:49 -04:00
# OpenAL
2013-03-13 21:39:23 -04:00
if ( APPLE )
# In theory it would be cleaner to let CMake detect the right dependencies. In practice, this means that if a OSX user has
# unix-style installs of Vorbis/Ogg/OpenAL/etc. they will be picked up over our frameworks. This is blocking when I make releases :
# the mac I use to make STK releases does have other installs of vorbis/ogg/etc. which aren't compatible with STK, so letting
# CMake pick the library it wants essentially means I can't build.
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -framework OpenAL" )
set ( OPENAL_LIBRARY )
else ( )
find_package ( OpenAL REQUIRED )
include_directories ( ${ OPENAL_INCLUDE_DIR } )
endif ( )
2012-03-06 12:07:16 -05:00
# OggVorbis
2013-03-13 21:39:23 -04:00
if ( APPLE )
# In theory it would be cleaner to let CMake detect the right dependencies. In practice, this means that if a OSX user has
# unix-style installs of Vorbis/Ogg/OpenAL/etc. they will be picked up over our frameworks. This is blocking when I make releases :
# the mac I use to make STK releases does have other installs of vorbis/ogg/etc. which aren't compatible with STK, so letting
# CMake pick the library it wants essentially means I can't build.
set ( CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -I/Library/Frameworks/Ogg.framework/Versions/A/Headers -I/Library/Frameworks/Vorbis.framework/Versions/A/Headers" )
else ( )
find_package ( OggVorbis REQUIRED )
include_directories ( ${ OGGVORBIS_INCLUDE_DIRS } )
endif ( )
2011-08-01 15:18:49 -04:00
2015-10-03 23:59:44 -04:00
# Freetype
2015-10-30 06:08:02 -04:00
find_package ( Freetype )
if ( FREETYPE_FOUND )
include_directories ( ${ FREETYPE_INCLUDE_DIRS } )
else ( )
message ( FATAL_ERROR "Freetype not found. "
" F r e e t y p e i s r e q u i r e d t o d i s p l a y c h a r a c t e r s i n S u p e r T u x K a r t . " )
2015-10-03 23:59:44 -04:00
endif ( )
2011-10-20 22:07:12 -04:00
# Fribidi
if ( USE_FRIBIDI )
2012-03-05 20:07:26 -05:00
find_package ( Fribidi )
if ( FRIBIDI_FOUND )
include_directories ( ${ FRIBIDI_INCLUDE_DIRS } )
2011-10-20 22:07:12 -04:00
else ( )
2012-03-05 20:07:26 -05:00
message ( FATAL_ERROR "Fribidi not found. "
" E i t h e r i n s t a l l f r i b i d i o r d i s a b l e b i d i s u p p o r t w i t h - D U S E _ F R I B I D I = 0 "
" ( i f y o u d o n ' t u s e a r i g h t - t o - l e f t l a n g u a g e t h e n y o u d o n ' t n e e d t h i s ) . " )
2011-10-20 22:07:12 -04:00
endif ( )
endif ( )
2012-03-06 15:40:06 -05:00
2012-11-05 20:18:10 -05:00
# OpenGL
2016-11-11 01:21:59 -05:00
if ( NOT USE_GLES2 AND NOT SERVER_ONLY )
2016-06-23 20:47:13 -04:00
find_package ( OpenGL REQUIRED )
include_directories ( ${ OPENGL_INCLUDE_DIR } )
2014-09-03 11:18:49 -04:00
endif ( )
2017-09-27 15:45:08 -04:00
if ( USE_LIBBFD )
find_package ( Libbfd )
if ( LIBBFD_FOUND )
add_definitions ( -DENABLE_LIBBFD )
include_directories ( ${ LIBBFD_INCLUDE_DIRS } )
else ( )
set ( USE_LIBBFD OFF CACHE BOOL "Use libbfd for crash reporting and leak check" FORCE )
message ( WARNING "Libbfd not found, disable integrated stack trace." )
2014-07-25 13:23:32 -04:00
endif ( )
2012-11-05 20:18:10 -05:00
endif ( )
2011-08-01 15:18:49 -04:00
# Set some compiler options
2014-09-29 07:35:17 -04:00
if ( UNIX OR MINGW )
2015-03-30 14:12:25 -04:00
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++0x" )
2016-01-17 20:52:34 -05:00
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-unused-function" )
2011-08-01 15:18:49 -04:00
endif ( )
2015-03-30 14:12:25 -04:00
if ( MINGW AND CMAKE_BUILD_TYPE MATCHES Release )
SET ( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--subsystem,windows" )
endif ( )
2012-03-10 18:16:57 -05:00
if ( WIN32 )
# By default windows.h has macros defined for min and max that screw up everything
add_definitions ( -DNOMINMAX )
2012-03-15 08:50:36 -04:00
# And shut up about unsafe stuff
add_definitions ( -D_CRT_SECURE_NO_WARNINGS )
2015-08-06 04:00:08 -04:00
# Avoid timespec structure redeclaration on Visual Studio 2015
2015-09-02 11:37:23 -04:00
if ( NOT ( MSVC_VERSION LESS 1900 ) )
2015-08-06 04:00:08 -04:00
add_definitions ( -DHAVE_STRUCT_TIMESPEC )
endif ( )
2014-09-29 07:35:17 -04:00
endif ( )
if ( MSVC )
2014-07-25 13:23:32 -04:00
# VS will automatically add NDEBUG for release mode, but only _DEBUG in debug mode.
# Since STK uses DEBUG, this is added for debug compilation only:
2014-01-06 21:04:31 -05:00
set_property ( DIRECTORY PROPERTY COMPILE_DEFINITIONS_DEBUG DEBUG )
else ( )
# All non VS generators used create only a single compile mode, so
2014-07-25 13:23:32 -04:00
# compile flags can be simplye be added
2014-01-06 21:04:31 -05:00
if ( CMAKE_BUILD_TYPE MATCHES Debug )
add_definitions ( -DDEBUG )
else ( )
add_definitions ( -DNDEBUG )
endif ( )
2012-03-10 18:16:57 -05:00
endif ( )
2012-03-06 15:40:06 -05:00
# TODO: remove this switch
add_definitions ( -DHAVE_OGGVORBIS )
2011-07-24 14:40:20 -04:00
2014-10-08 08:03:23 -04:00
if ( WIN32 )
2016-04-21 17:54:40 -04:00
configure_file ( "${STK_SOURCE_DIR}/../tools/windows_installer/icon_rc.template" "${PROJECT_BINARY_DIR}/tmp/icon.rc" )
2014-08-21 15:38:59 -04:00
endif ( )
2012-03-06 15:40:06 -05:00
2012-03-15 08:41:52 -04:00
# Provides list of source and header files (STK_SOURCES and STK_HEADERS)
2012-03-05 19:18:51 -05:00
include ( sources.cmake )
2011-08-29 14:17:45 -04:00
2012-03-15 08:41:52 -04:00
# Generate source groups useful for MSVC project explorer
include ( cmake/SourceGroupFunctions.cmake )
source_group_hierarchy ( STK_SOURCES STK_HEADERS )
2012-03-06 15:40:06 -05:00
if ( APPLE )
2011-08-29 14:17:45 -04:00
# icon files to copy in the bundle
2013-11-21 19:27:33 -05:00
set ( OSX_ICON_FILES ${ PROJECT_SOURCE_DIR } /data/supertuxkart.icns )
2012-03-06 15:40:06 -05:00
set_source_files_properties ( ${ OSX_ICON_FILES } PROPERTIES MACOSX_PACKAGE_LOCATION Resources )
set ( STK_SOURCES ${ STK_SOURCES } ${ OSX_ICON_FILES } )
2012-03-15 08:50:36 -04:00
2011-08-29 14:17:45 -04:00
# build the executable and create an app bundle
2012-03-06 15:40:06 -05:00
add_executable ( supertuxkart MACOSX_BUNDLE ${ STK_SOURCES } )
2012-03-15 08:50:36 -04:00
2012-03-06 12:07:16 -05:00
find_library ( IOKIT_LIBRARY IOKit )
find_library ( QUICKTIME_LIBRARY QuickTime )
find_library ( CARBON_LIBRARY Carbon )
find_library ( AUDIOUNIT_LIBRARY AudioUnit )
find_library ( COCOA_LIBRARY Cocoa )
2012-03-15 08:50:36 -04:00
2011-08-29 14:17:45 -04:00
target_link_libraries ( supertuxkart
2012-03-06 12:07:16 -05:00
$ { I O K I T _ L I B R A R Y }
$ { Q U I C K T I M E _ L I B R A R Y }
$ { C A R B O N _ L I B R A R Y }
$ { A U D I O U N I T _ L I B R A R Y }
$ { C O C O A _ L I B R A R Y } )
2012-03-15 08:50:36 -04:00
2011-08-29 14:17:45 -04:00
# configure CMake to use a custom Info.plist
2012-03-06 15:40:06 -05:00
set_target_properties ( supertuxkart PROPERTIES
2013-11-21 19:27:33 -05:00
M A C O S X _ B U N D L E _ I N F O _ P L I S T $ { P R O J E C T _ S O U R C E _ D I R } / d a t a / S u p e r T u x K a r t - I n f o . p l i s t )
2012-03-15 08:50:36 -04:00
2013-03-13 22:06:09 -04:00
if ( CMAKE_GENERATOR MATCHES "Xcode" )
add_custom_command ( TARGET supertuxkart POST_BUILD
C O M M A N D l n - f - s $ { P R O J E C T _ S O U R C E _ D I R } / d a t a $ { C M A K E _ B I N A R Y _ D I R } / b i n / \ $ { C O N F I G U R A T I O N } / s u p e r t u x k a r t . a p p / C o n t e n t s / R e s o u r c e s )
else ( )
add_custom_command ( TARGET supertuxkart POST_BUILD
C O M M A N D l n - f - s $ { P R O J E C T _ S O U R C E _ D I R } / d a t a $ { C M A K E _ B I N A R Y _ D I R } / b i n / s u p e r t u x k a r t . a p p / C o n t e n t s / R e s o u r c e s )
endif ( )
2011-08-29 14:17:45 -04:00
else ( )
2015-01-08 07:24:15 -05:00
if ( MSVC )
set ( PTHREAD_NAMES pthreadVC2 )
elseif ( MINGW )
2015-03-03 01:17:48 -05:00
set ( PTHREAD_NAMES "winpthread-1" "libwinpthread-1" "pthreadGC2" )
2015-01-08 07:24:15 -05:00
endif ( )
2017-04-06 09:59:01 -04:00
find_library ( PTHREAD_LIBRARY NAMES pthread ${ PTHREAD_NAMES } PATHS ${ PROJECT_SOURCE_DIR } / ${ DEPENDENCIES } /lib )
2012-03-15 08:50:51 -04:00
mark_as_advanced ( PTHREAD_LIBRARY )
2012-03-16 19:15:23 -04:00
# Set data dir (absolute or relative to CMAKE_INSTALL_PREFIX)
2015-01-12 16:48:06 -05:00
if ( NOT STK_INSTALL_DATA_DIR_ABSOLUTE )
get_filename_component ( STK_INSTALL_DATA_DIR_ABSOLUTE ${ STK_INSTALL_DATA_DIR } ABSOLUTE )
if ( ${ STK_INSTALL_DATA_DIR_ABSOLUTE } STREQUAL ${ STK_INSTALL_DATA_DIR } )
add_definitions ( -DSUPERTUXKART_DATADIR=\ "${STK_INSTALL_DATA_DIR_ABSOLUTE}\" )
else ( )
add_definitions ( -DSUPERTUXKART_DATADIR=\ "${CMAKE_INSTALL_PREFIX}/${STK_INSTALL_DATA_DIR}\" )
endif ( )
2012-03-16 19:15:23 -04:00
else ( )
2015-01-12 16:48:06 -05:00
add_definitions ( -DSUPERTUXKART_DATADIR=\ "${STK_INSTALL_DATA_DIR_ABSOLUTE}\" )
2012-03-16 19:15:23 -04:00
endif ( )
2011-11-14 18:27:31 -05:00
2011-08-29 14:17:45 -04:00
# Build the final executable
2014-08-21 15:38:59 -04:00
add_executable ( supertuxkart ${ STK_SOURCES } ${ STK_RESOURCES } ${ STK_HEADERS } )
2012-03-15 08:50:51 -04:00
target_link_libraries ( supertuxkart ${ PTHREAD_LIBRARY } )
2011-08-29 14:17:45 -04:00
endif ( )
2011-07-24 10:29:16 -04:00
2014-01-21 20:24:37 -05:00
# CURL
2017-04-06 05:39:53 -04:00
if ( MSVC )
2017-04-06 09:59:01 -04:00
target_link_libraries ( supertuxkart ${ PROJECT_SOURCE_DIR } / ${ DEPENDENCIES } /lib/libcurl.lib )
2017-04-06 05:39:53 -04:00
elseif ( MINGW )
2017-04-06 09:59:01 -04:00
target_link_libraries ( supertuxkart ${ PROJECT_SOURCE_DIR } / ${ DEPENDENCIES } /lib/libcurldll.a )
2014-01-21 20:24:37 -05:00
else ( )
find_package ( CURL REQUIRED )
include_directories ( ${ CURL_INCLUDE_DIRS } )
endif ( )
2012-11-05 20:18:10 -05:00
2012-03-06 12:07:16 -05:00
# Common library dependencies
target_link_libraries ( supertuxkart
b u l l e t d y n a m i c s
b u l l e t c o l l i s i o n
b u l l e t m a t h
e n e t
2013-03-12 21:31:09 -04:00
s t k i r r l i c h t
2015-05-18 10:23:28 -04:00
$ { A n g e l s c r i p t _ L I B R A R I E S }
2012-03-06 12:07:16 -05:00
$ { C U R L _ L I B R A R I E S }
$ { O G G V O R B I S _ L I B R A R I E S }
$ { O P E N A L _ L I B R A R Y }
2015-10-30 06:08:02 -04:00
$ { F R E E T Y P E _ L I B R A R I E S }
2017-03-22 05:24:33 -04:00
$ { J P E G _ L I B R A R I E S }
2017-03-25 04:30:41 -04:00
$ { T U R B O J P E G _ L I B R A R Y }
2017-10-17 20:08:15 -04:00
#${VPX_LIBRARIES}
2014-09-15 02:33:46 -04:00
)
2014-09-03 08:05:34 -04:00
2016-11-11 08:09:39 -05:00
if ( NOT SERVER_ONLY )
if ( NOT USE_GLES2 )
2017-04-08 06:31:09 -04:00
target_link_libraries ( supertuxkart ${ OPENGL_gl_LIBRARY } glew graphics_utils )
2014-07-25 13:23:32 -04:00
else ( )
2017-05-06 15:53:32 -04:00
target_link_libraries ( supertuxkart GLESv2 )
2016-11-11 08:09:39 -05:00
endif ( )
2016-06-23 20:47:13 -04:00
endif ( )
2014-07-25 13:23:32 -04:00
if ( UNIX AND NOT APPLE )
2016-06-23 20:59:39 -04:00
if ( USE_LIBBFD )
target_link_libraries ( supertuxkart ${ LIBBFD_LIBRARIES } )
2014-07-25 13:23:32 -04:00
endif ( )
2014-08-12 14:19:31 -04:00
if ( USE_ASAN )
2014-10-08 08:03:23 -04:00
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer" )
2014-08-12 14:19:31 -04:00
target_link_libraries ( supertuxkart "-fsanitize=address" )
endif ( )
2014-07-25 13:23:32 -04:00
endif ( )
2014-01-21 18:23:08 -05:00
2017-04-04 02:23:04 -04:00
if ( BUILD_RECORDER )
2017-04-11 23:51:59 -04:00
target_link_libraries ( supertuxkart ${ OPENGLRECORDER_LIBRARY } )
2017-04-04 02:23:04 -04:00
endif ( )
2016-05-30 23:43:07 -04:00
# FreeBSD does not search in /usr/local/lib, but at least Freetype is installed there :(
if ( ${ CMAKE_SYSTEM_NAME } MATCHES "FreeBSD" )
SET ( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L/usr/local/lib" )
endif ( )
2013-03-13 21:39:23 -04:00
if ( APPLE )
# In theory it would be cleaner to let CMake detect the right dependencies. In practice, this means that if a OSX user has
# unix-style installs of Vorbis/Ogg/OpenAL/etc. they will be picked up over our frameworks. This is blocking when I make releases :
# the mac I use to make STK releases does have other installs of vorbis/ogg/etc. which aren't compatible with STK, so letting
# CMake pick the library it wants essentially means I can't build.
2016-03-21 20:16:59 -04:00
set_target_properties ( supertuxkart PROPERTIES LINK_FLAGS "-arch x86_64 -F/Library/Frameworks -framework OpenAL -framework Ogg -framework Vorbis" )
2013-03-13 21:39:23 -04:00
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I/Library/Frameworks/OpenAL.framework/Versions/A/Headers" )
endif ( )
2011-07-24 14:40:20 -04:00
if ( USE_FRIBIDI )
2012-03-05 20:07:26 -05:00
target_link_libraries ( supertuxkart ${ FRIBIDI_LIBRARIES } )
2012-03-06 12:07:16 -05:00
add_definitions ( -DENABLE_BIDI )
2011-07-24 14:40:20 -04:00
endif ( )
2011-10-18 18:59:36 -04:00
2013-08-05 02:10:31 -04:00
# Wiiuse
# ------
2012-01-01 16:19:13 -05:00
if ( USE_WIIUSE )
2013-02-03 19:15:45 -05:00
if ( APPLE )
find_library ( BLUETOOTH_LIBRARY NAMES IOBluetooth PATHS /Developer/Library/Frameworks/IOBluetooth.framework )
target_link_libraries ( supertuxkart wiiuse ${ BLUETOOTH_LIBRARY } )
2014-09-03 08:05:34 -04:00
elseif ( WIN32 )
2014-10-08 08:03:23 -04:00
add_definitions ( -DWIIUSE_STATIC )
2013-08-05 02:10:31 -04:00
if ( WIIUSE_BUILD )
target_link_libraries ( supertuxkart wiiuse )
else ( )
2017-04-06 09:59:01 -04:00
target_link_libraries ( supertuxkart ${ PROJECT_SOURCE_DIR } / ${ DEPENDENCIES } /lib/wiiuse.lib )
2013-08-05 02:10:31 -04:00
endif ( )
2013-02-03 19:15:45 -05:00
else ( )
target_link_libraries ( supertuxkart wiiuse bluetooth )
endif ( )
2012-03-15 08:50:36 -04:00
add_definitions ( -DENABLE_WIIUSE )
2013-08-05 02:10:31 -04:00
2012-01-01 16:19:13 -05:00
endif ( )
2014-09-03 08:05:34 -04:00
if ( MSVC OR MINGW )
2013-12-05 22:54:31 -05:00
target_link_libraries ( supertuxkart iphlpapi.lib )
2014-01-21 18:23:08 -05:00
add_custom_command ( TARGET supertuxkart POST_BUILD
C O M M A N D $ { C M A K E _ C O M M A N D } - E c o p y _ d i r e c t o r y
2017-04-06 09:59:01 -04:00
" $ { P R O J E C T _ S O U R C E _ D I R } / $ { D E P E N D E N C I E S } / d l l "
2014-09-03 08:05:34 -04:00
$ < T A R G E T _ F I L E _ D I R : s u p e r t u x k a r t > )
2014-04-11 13:05:24 -04:00
add_custom_target ( stkshaders SOURCES ${ STK_SHADERS } )
2013-12-05 22:54:31 -05:00
endif ( )
2012-03-10 18:16:57 -05:00
2015-03-02 07:56:48 -05:00
if ( MINGW )
2015-10-12 17:15:23 -04:00
find_library ( LIBGCC NAMES "libgcc_s_dw2-1.dll" "libgcc_s_sjlj-1.dll" "libgcc_s_seh-1.dll" PATHS ${ CMAKE_FIND_ROOT_PATH } )
2015-03-02 13:30:26 -05:00
if ( LIBGCC )
file ( COPY ${ LIBGCC } DESTINATION ${ CMAKE_BINARY_DIR } /bin/ )
endif ( )
find_library ( LIBSTDCPP NAMES "libstdc++-6.dll" PATHS ${ CMAKE_FIND_ROOT_PATH } )
if ( LIBSTDCPP )
file ( COPY ${ LIBSTDCPP } DESTINATION ${ CMAKE_BINARY_DIR } /bin/ )
endif ( )
2015-03-03 01:17:48 -05:00
find_library ( LIBPTHREAD NAMES "winpthread-1.dll" "libwinpthread-1.dll" "pthreadGC2.dll" PATHS ${ CMAKE_FIND_ROOT_PATH } )
2015-03-02 13:30:26 -05:00
if ( LIBPTHREAD )
file ( COPY ${ LIBPTHREAD } DESTINATION ${ CMAKE_BINARY_DIR } /bin/ )
2015-03-02 07:56:48 -05:00
endif ( )
2013-07-25 03:19:30 -04:00
endif ( )
2011-09-05 20:15:06 -04:00
2011-10-20 22:07:12 -04:00
2014-03-06 10:21:09 -05:00
# ==== Checking if data folder exists ====
2014-05-06 23:23:22 -04:00
if ( NOT IS_DIRECTORY ${ CMAKE_CURRENT_SOURCE_DIR } /data )
2014-03-06 10:21:09 -05:00
message ( FATAL_ERROR "${CMAKE_CURRENT_SOURCE_DIR}/data folder doesn't exist" )
endif ( )
# ==== Checking if stk-assets folder exists ====
2014-04-24 00:22:38 -04:00
if ( CHECK_ASSETS )
2014-09-03 08:05:34 -04:00
if ( ( IS_DIRECTORY ${ CMAKE_CURRENT_SOURCE_DIR } /data/karts ) AND
( I S _ D I R E C T O R Y $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / d a t a / l i b r a r y ) A N D
( I S _ D I R E C T O R Y $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / d a t a / m u s i c ) A N D
2014-05-17 10:28:05 -04:00
( I S _ D I R E C T O R Y $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / d a t a / s f x ) A N D
( I S _ D I R E C T O R Y $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / d a t a / t e x t u r e s ) A N D
( I S _ D I R E C T O R Y $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / d a t a / t r a c k s ) )
message ( STATUS "Assets found in data directory" )
elseif ( IS_DIRECTORY ${ CMAKE_CURRENT_SOURCE_DIR } /../stk-assets )
set ( STK_ASSETS_DIR ${ CMAKE_CURRENT_SOURCE_DIR } /../stk-assets/ )
message ( STATUS "Assets found" )
elseif ( IS_DIRECTORY ${ CMAKE_CURRENT_SOURCE_DIR } /../supertuxkart-assets )
set ( STK_ASSETS_DIR ${ CMAKE_CURRENT_SOURCE_DIR } /../supertuxkart-assets/ )
2014-05-17 08:36:59 -04:00
message ( STATUS "Assets found" )
else ( )
2014-04-24 00:22:38 -04:00
set ( CUR_DIR ${ CMAKE_CURRENT_SOURCE_DIR } )
get_filename_component ( PARENT_DIR ${ CUR_DIR } PATH )
message ( FATAL_ERROR "${PARENT_DIR}/stk-assets folder doesn't exist. "
" P l e a s e d o w n l o a d t h e s t k - a s s e t s , o r d i s a b l e t h i s t e s t w i t h - D C H E C K _ A S S E T S = o f f . " )
endif ( )
2014-03-06 10:21:09 -05:00
endif ( )
2014-05-17 10:28:05 -04:00
# ==== Install target ====
install ( TARGETS supertuxkart RUNTIME DESTINATION ${ STK_INSTALL_BINARY_DIR } BUNDLE DESTINATION . )
install ( DIRECTORY ${ STK_DATA_DIR } DESTINATION ${ STK_INSTALL_DATA_DIR } PATTERN ".svn" EXCLUDE PATTERN ".git" EXCLUDE )
if ( STK_ASSETS_DIR AND CHECK_ASSETS )
install ( DIRECTORY ${ STK_ASSETS_DIR } DESTINATION ${ STK_INSTALL_DATA_DIR } /data PATTERN ".svn" EXCLUDE PATTERN ".git" EXCLUDE )
endif ( )
2014-08-24 15:57:56 -04:00
install ( FILES ${ STK_DATA_DIR } /supertuxkart.desktop DESTINATION share/applications )
2017-07-30 06:56:25 -04:00
install ( FILES data/supertuxkart_48.png DESTINATION share/icons/hicolor/48x48/apps RENAME supertuxkart.png )
2015-01-30 12:36:10 -05:00
install ( FILES data/supertuxkart_128.png DESTINATION share/icons/hicolor/128x128/apps RENAME supertuxkart.png )
2017-07-30 06:56:25 -04:00
install ( FILES data/supertuxkart_48.png DESTINATION share/pixmaps RENAME supertuxkart.png )
2014-11-08 15:05:00 -05:00
install ( FILES data/supertuxkart.appdata.xml DESTINATION share/appdata )
2015-03-02 07:56:48 -05:00
if ( MINGW )
install ( DIRECTORY ${ CMAKE_BINARY_DIR } /bin/ DESTINATION ${ STK_INSTALL_BINARY_DIR }
F I L E S _ M A T C H I N G P A T T E R N " * . d l l " )
endif ( )