2011-12-04 18:04:02 -05:00
# root CMakeLists for the SuperTuxKart project
2012-03-05 20:07:26 -05:00
project ( SuperTuxKart )
2013-03-13 00:03:26 -04:00
set ( PROJECT_VERSION "0.8.1" )
2011-07-24 10:29:16 -04:00
2015-03-25 04:16:15 -04:00
cmake_minimum_required ( VERSION 2.8.4 )
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" )
2011-07-24 10:29:16 -04:00
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 ( )
2014-07-14 00:21:02 -04:00
option ( USE_WIIUSE "Support for wiimote input devices" ON )
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 )
2015-08-08 08:31:32 -04:00
option ( ENABLE_NETWORK_MULTIPLAYER "Enable network multiplayer. This will replace the online profile GUI in the main menu with the network multiplayer GUI" OFF )
2014-04-24 00:22:38 -04:00
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
2015-03-25 04:16:15 -04:00
if ( MINGW OR CYGWIN )
2014-09-03 08:05:34 -04:00
set ( USE_WIIUSE OFF )
endif ( )
2014-07-25 13:23:32 -04:00
if ( UNIX AND NOT APPLE )
2014-07-30 15:29:15 -04:00
option ( USE_XRANDR "Use xrandr instead of vidmode" ON )
2014-08-12 14:19:31 -04:00
option ( USE_ASAN "Build with Leak/Address sanitizer" 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 )
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 )
add_definitions ( -D_IRR_STATIC_LIB_ )
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
add_subdirectory ( "${PROJECT_SOURCE_DIR}/lib/glew" )
include_directories ( "${PROJECT_SOURCE_DIR}/lib/glew/include" )
2015-01-27 20:07:32 -05:00
if ( ( WIN32 AND NOT MINGW ) OR APPLE )
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
set ( SKIP_INSTALL_ALL TRUE )
set ( PNG_STATIC TRUE )
set ( PNG_TESTS FALSE )
set ( PNG_SHARED FALSE )
add_subdirectory ( "${PROJECT_SOURCE_DIR}/lib/libpng" )
include_directories ( "${PROJECT_SOURCE_DIR}/lib/libpng" )
#build jpeg library
add_subdirectory ( "${PROJECT_SOURCE_DIR}/lib/jpeglib" )
include_directories ( "${PROJECT_SOURCE_DIR}/lib/jpeglib" )
set ( PNG_PNG_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/lib/libpng/" )
set ( PNG_LIBRARY png15_static )
set ( JPEG_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/lib/jpeglib/" )
set ( JPEG_LIBRARY jpeglib )
2015-01-17 14:53:18 -05:00
endif ( )
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 )
2013-03-14 19:10:20 -04:00
set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -arch i386" )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -arch i386 -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
2014-09-03 11:18:49 -04:00
# OpenMP
find_package ( OpenMP )
if ( OPENMP_FOUND )
set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}" )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}" )
endif ( )
2012-11-05 20:18:10 -05:00
# OpenGL
find_package ( OpenGL REQUIRED )
include_directories ( ${ OPENGL_INCLUDE_DIR } )
if ( UNIX AND NOT APPLE )
2015-02-22 04:01:46 -05:00
find_package ( X11 REQUIRED )
include_directories ( ${ X11_INCLUDE_DIR } )
2014-07-25 13:23:32 -04:00
if ( USE_XRANDR )
find_package ( Xrandr REQUIRED )
2014-08-13 13:34:28 -04:00
if ( NOT XRANDR_FOUND )
message ( FATAL_ERROR "XRANDR not found." )
endif ( )
2014-07-25 13:23:32 -04:00
else ( )
find_library ( IRRLICHT_XF86VM_LIBRARY Xxf86vm )
mark_as_advanced ( IRRLICHT_XF86VM_LIBRARY )
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" )
2014-10-08 08:03:23 -04:00
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall" )
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 ( )
2015-09-06 15:00:50 -04:00
# Netwowk Multiplayer
if ( ENABLE_NETWORK_MULTIPLAYER )
add_definitions ( -DENABLE_NETWORK_MULTIPLAYER_SCREEN )
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 )
2014-08-21 15:38:59 -04:00
configure_file ( "${STK_SOURCE_DIR}/windows_installer/icon_rc.template" "${PROJECT_BINARY_DIR}/tmp/icon.rc" )
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 ( )
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
if ( WIN32 )
target_link_libraries ( supertuxkart ${ PROJECT_SOURCE_DIR } /dependencies/lib/libcurldll.a )
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
2014-09-15 02:33:46 -04:00
g l e w
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 }
2014-09-03 11:38:14 -04:00
$ { O P E N G L _ L I B R A R I E S }
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 }
2014-09-15 02:33:46 -04:00
)
2014-09-03 08:05:34 -04:00
2014-07-25 13:23:32 -04:00
if ( UNIX AND NOT APPLE )
2015-02-22 04:01:46 -05:00
target_link_libraries ( supertuxkart ${ X11_LIBRARIES } )
2014-07-25 13:23:32 -04:00
if ( USE_XRANDR )
target_link_libraries ( supertuxkart ${ XRANDR_LIBRARIES } )
else ( )
target_link_libraries ( supertuxkart ${ IRRLICHT_XF86VM_LIBRARY } )
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
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.
2013-03-14 19:10:20 -04:00
set_target_properties ( supertuxkart PROPERTIES LINK_FLAGS "-arch i386 -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 ( )
target_link_libraries ( supertuxkart ${ PROJECT_SOURCE_DIR } /dependencies/lib/wiiuse.lib )
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
" $ { 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 ( )
find_library ( LIBOPENMP NAMES "libgomp-1.dll" PATHS ${ CMAKE_FIND_ROOT_PATH } )
if ( LIBOPENMP )
file ( COPY ${ LIBOPENMP } 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 ( )
endif ( )
2011-09-05 20:15:06 -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 )
2015-01-30 12:36:10 -05:00
install ( FILES data/supertuxkart_32.png DESTINATION share/icons/hicolor/32x32/apps RENAME supertuxkart.png )
install ( FILES data/supertuxkart_128.png DESTINATION share/icons/hicolor/128x128/apps RENAME supertuxkart.png )
2014-05-17 10:28:05 -04:00
install ( FILES data/supertuxkart_32.png data/supertuxkart_128.png DESTINATION share/pixmaps )
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 ( )