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 )
2019-02-03 06:02:55 -05:00
set ( PROJECT_VERSION "git" )
2020-04-11 04:25:58 -04:00
if ( MINGW AND CMAKE_CXX_COMPILER_ID STREQUAL "Clang" )
set ( LLVM_MINGW TRUE )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -gcodeview" )
set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -gcodeview" )
endif ( )
2018-01-10 22:07:16 -05:00
add_definitions ( -DSUPERTUXKART_VERSION= "${PROJECT_VERSION}" )
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
2012-03-06 11:42:00 -05:00
include ( BuildTypeSTKRelease )
2018-02-01 15:36:28 -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 )
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 )
2019-04-07 16:10:33 -04:00
option ( USE_SYSTEM_ENET "Use system ENet instead of the built-in version, when available." ON )
2019-09-03 15:24:03 -04:00
option ( USE_IPV6 "Allow create or connect to game server with IPv6 address, system enet will not be used." ON )
2019-04-07 16:10:33 -04:00
option ( USE_SYSTEM_WIIUSE "Use system WiiUse instead of the built-in version, when available." OFF )
2019-05-05 12:19:58 -04:00
option ( USE_SQLITE3 "Use sqlite to manage server stats and ban list." ON )
2014-04-24 00:22:38 -04:00
2019-08-10 14:19:38 -04:00
option ( USE_CRYPTO_OPENSSL "Use OpenSSL instead of Nettle for cryptography in STK." ON )
2017-04-04 02:23:04 -04:00
CMAKE_DEPENDENT_OPTION ( BUILD_RECORDER "Build opengl recorder" ON
2018-05-24 16:07:33 -04:00
" N O T S E R V E R _ O N L Y ; N O T APPLE " O F F )
2019-05-13 17:51:21 -04:00
CMAKE_DEPENDENT_OPTION ( USE_SYSTEM_SQUISH "Use system Squish library instead of the built-in version, when available." ON
" N O T S E R V E R _ O N L Y " O F F )
2018-07-06 13:58:19 -04:00
CMAKE_DEPENDENT_OPTION ( USE_WIIUSE "Support for wiimote input devices" ON
2019-12-18 01:40:54 -05:00
" N O T S E R V E R _ O N L Y ; N O T CYGWIN " O F F )
2017-04-04 02:23:04 -04:00
2019-07-12 02:53:55 -04:00
if ( APPLE AND NOT IOS )
2021-01-09 17:31:21 -05:00
if ( ${ CMAKE_SYSTEM_PROCESSOR } STREQUAL "arm" )
set ( ARCHFLAGS "arm64" )
list ( APPEND CMAKE_PREFIX_PATH /opt/homebrew/opt )
include_directories ( /opt/homebrew/opt/openssl@1.1/include/ )
include_directories ( /opt/homebrew/opt/openssl@1.1/include/openssl/ )
include_directories ( /opt/homebrew/opt/freetype/include/freetype2/ )
include_directories ( /opt/homebrew/opt/harfbuzz/include/harfbuzz/ )
else ( )
set ( ARCHFLAGS "${CMAKE_SYSTEM_PROCESSOR}" )
list ( APPEND CMAKE_PREFIX_PATH /usr/local/opt )
include_directories ( /usr/local/opt/openssl@1.1/include/ )
include_directories ( /usr/local/opt/openssl@1.1/include/openssl/ )
include_directories ( /usr/local/opt/freetype/include/freetype2/ )
include_directories ( /usr/local/opt/harfbuzz/include/harfbuzz/ )
endif ( )
2018-06-05 19:56:15 -04:00
endif ( )
2019-07-12 02:53:55 -04:00
if ( IOS )
ADD_DEFINITIONS ( -DMOBILE_STK )
ADD_DEFINITIONS ( -DIOS_STK )
2019-07-17 02:50:49 -04:00
set ( CMAKE_XCODE_ATTRIBUTE_TARGETED_DEVICE_FAMILY "1,2" )
2019-07-12 02:53:55 -04:00
option ( USE_GLES2 "Use OpenGL ES2 renderer" ON )
endif ( )
2018-02-01 15:36:28 -05:00
if ( ( UNIX AND NOT APPLE ) AND NOT SERVER_ONLY )
2018-05-25 15:16:22 -04:00
if ( ( ${ CMAKE_SYSTEM_PROCESSOR } MATCHES "arm" ) OR
( $ { C M A K E _ S Y S T E M _ P R O C E S S O R } M A T C H E S " a a r c h 6 4 " ) )
option ( USE_GLES2 "Use OpenGL ES2 renderer" ON )
else ( )
option ( USE_GLES2 "Use OpenGL ES2 renderer" OFF )
endif ( )
2016-07-08 21:03:15 -04:00
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
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 )
2020-02-22 12:14:41 -05:00
option ( USE_TSAN "Build with Thread 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 ( )
2020-02-27 20:30:00 -05:00
if ( USE_ASAN )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer" )
set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fno-omit-frame-pointer" )
endif ( )
if ( USE_TSAN )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=thread -fno-omit-frame-pointer" )
set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=thread -fno-omit-frame-pointer" )
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
2018-02-01 15:36:28 -05:00
# Define dependencies path
2020-04-11 04:25:58 -04:00
if ( MSVC OR LLVM_MINGW )
2018-02-01 15:36:28 -05:00
set ( DEPENDENCIES "dependencies-vs" )
elseif ( MINGW )
set ( DEPENDENCIES "dependencies-mingw" )
else ( )
set ( DEPENDENCIES "dependencies" )
endif ( )
if ( CMAKE_SIZEOF_VOID_P EQUAL 8 )
set ( DEPENDENCIES "${DEPENDENCIES}-64bit" )
endif ( )
if ( WIN32 )
2019-06-25 23:32:18 -04:00
ADD_DEFINITIONS ( -DUNICODE )
ADD_DEFINITIONS ( -D_UNICODE )
2018-02-01 15:36:28 -05:00
if ( NOT IS_DIRECTORY "${PROJECT_SOURCE_DIR}/${DEPENDENCIES}" )
set ( DEPENDENCIES "dependencies" )
if ( CMAKE_SIZEOF_VOID_P EQUAL 8 )
set ( DEPENDENCIES "${DEPENDENCIES}-64bit" )
endif ( )
endif ( )
if ( NOT IS_DIRECTORY "${PROJECT_SOURCE_DIR}/${DEPENDENCIES}" )
message ( FATAL_ERROR "Dependencies directory not found." )
endif ( )
endif ( )
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_ )
2018-07-22 19:28:12 -04:00
include_directories ( ${ PROJECT_SOURCE_DIR } / ${ DEPENDENCIES } /include )
2015-01-19 04:52:11 -05:00
endif ( )
2016-06-23 20:47:13 -04:00
if ( USE_GLES2 )
add_definitions ( -DUSE_GLES2 )
2020-02-07 00:04:34 -05:00
if ( NOT IOS )
add_definitions ( -D_IRR_COMPILE_WITH_OGLES2_ )
endif ( )
add_definitions ( -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 )
2019-07-06 13:12:10 -04:00
add_definitions ( -DNO_IRR_COMPILE_WITH_X11_ -DNO_IRR_COMPILE_WITH_OPENGL_ )
2016-11-11 01:21:59 -05:00
endif ( )
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 ( )
2018-07-09 16:33:14 -04:00
if ( UNIX AND NOT APPLE )
find_package ( PkgConfig REQUIRED )
if ( NOT PKGCONFIG_FOUND )
message ( FATAL_ERROR "Pkg-config not found." )
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" )
2020-09-28 19:33:09 -04:00
include_directories ( BEFORE "${PROJECT_SOURCE_DIR}/lib/bullet/src" )
2011-07-24 10:29:16 -04:00
2020-10-10 09:14:49 -04:00
if ( WIN32 OR CMAKE_SYSTEM_NAME MATCHES "BSD" OR CMAKE_SYSTEM_NAME MATCHES "DragonFly" )
2020-02-05 11:46:38 -05:00
set ( LIBRESOLV_LIBRARY )
2020-06-14 14:41:38 -04:00
elseif ( HAIKU )
find_library ( LIBRESOLV_LIBRARY NAMES network socket )
2020-02-05 11:46:38 -05:00
else ( )
2020-10-10 09:14:49 -04:00
find_library ( LIBRESOLV_LIBRARY NAMES resolv libresolv )
2020-02-05 11:46:38 -05:00
endif ( )
2018-01-30 16:57:40 -05:00
# Find system ENet library or build it if missing
2019-08-18 12:05:34 -04:00
if ( ( UNIX AND NOT APPLE ) AND USE_SYSTEM_ENET AND NOT USE_IPV6 )
2018-07-09 16:33:14 -04:00
pkg_check_modules ( ENET libenet>=1.3.4 )
2018-01-30 16:57:40 -05:00
endif ( )
2019-08-18 12:05:34 -04:00
if ( USE_IPV6 )
add_definitions ( -DENABLE_IPV6 )
endif ( )
if ( ENET_FOUND AND NOT USE_IPV6 )
2018-07-09 16:33:14 -04:00
include_directories ( ${ ENET_INCLUDE_DIRS } )
2018-01-30 16:57:40 -05:00
else ( )
# Fallback to built-in version
add_subdirectory ( "${PROJECT_SOURCE_DIR}/lib/enet" )
2020-09-28 19:33:09 -04:00
include_directories ( BEFORE "${PROJECT_SOURCE_DIR}/lib/enet/include" )
2018-07-09 16:33:14 -04:00
set ( ENET_LIBRARIES "enet" )
2018-01-30 16:57:40 -05:00
endif ( )
2011-07-24 10:29:16 -04:00
2020-12-03 20:39:06 -05:00
if ( NOT SERVER_ONLY )
add_subdirectory ( "${PROJECT_SOURCE_DIR}/lib/graphics_engine" )
include_directories ( BEFORE "${PROJECT_SOURCE_DIR}/lib/graphics_engine/include" )
2016-06-23 20:47:13 -04:00
endif ( )
2014-09-15 02:33:46 -04:00
2018-07-06 21:27:39 -04:00
if ( NOT SERVER_ONLY )
# Add jpeg library
2019-07-05 04:34:40 -04:00
find_package ( JPEG REQUIRED )
include_directories ( ${ JPEG_INCLUDE_DIR } )
2017-03-22 05:24:33 -04:00
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
2018-05-22 16:00:49 -04:00
if ( NOT SERVER_ONLY )
2017-03-15 23:29:16 -04:00
add_subdirectory ( "${PROJECT_SOURCE_DIR}/lib/graphics_utils" )
2020-09-28 19:33:09 -04:00
include_directories ( BEFORE "${PROJECT_SOURCE_DIR}/lib/graphics_utils" )
2020-09-09 01:27:10 -04:00
add_subdirectory ( "${PROJECT_SOURCE_DIR}/lib/tinygettext" )
2020-09-28 19:33:09 -04:00
include_directories ( BEFORE "${PROJECT_SOURCE_DIR}/lib/tinygettext/include" )
2015-01-17 14:53:18 -05:00
endif ( )
2017-03-12 22:28:43 -04:00
2020-01-02 23:46:35 -05:00
# Libmcpp
find_library ( MCPP_LIBRARY NAMES mcpp libmcpp )
find_path ( MCPP_INCLUDEDIR NAMES mcpp_lib.h PATHS )
if ( NOT MCPP_LIBRARY OR NOT MCPP_INCLUDEDIR )
add_subdirectory ( "${PROJECT_SOURCE_DIR}/lib/mcpp" )
2020-09-28 19:33:09 -04:00
include_directories ( BEFORE "${PROJECT_SOURCE_DIR}/lib/mcpp" )
2020-01-02 23:46:35 -05:00
SET ( MCPP_LIBRARY mcpp )
message ( STATUS "System libmcpp not found, use the bundled one." )
else ( )
include_directories ( "${MCPP_INCLUDEDIR}" )
MESSAGE ( STATUS "Use system libmcpp: ${MCPP_LIBRARY}" )
endif ( )
2018-05-22 16:00:49 -04:00
if ( NOT SERVER_ONLY )
2019-05-13 17:51:21 -04:00
if ( USE_SYSTEM_SQUISH )
find_library ( SQUISH_LIBRARY NAMES squish libsquish )
find_path ( SQUISH_INCLUDEDIR NAMES squish.h PATHS )
endif ( )
2018-01-11 01:40:33 -05:00
if ( NOT SQUISH_LIBRARY OR NOT SQUISH_INCLUDEDIR )
add_subdirectory ( "${PROJECT_SOURCE_DIR}/lib/libsquish" )
2020-09-28 19:33:09 -04:00
include_directories ( BEFORE "${PROJECT_SOURCE_DIR}/lib/libsquish" )
2018-01-11 01:40:33 -05:00
SET ( SQUISH_LIBRARY squish )
else ( )
include_directories ( "${SQUISH_INCLUDEDIR}" )
MESSAGE ( STATUS "Use system libsquish: ${SQUISH_LIBRARY}" )
endif ( )
endif ( )
2017-12-25 01:00:10 -05:00
2020-04-20 12:14:32 -04:00
if ( NOT SERVER_ONLY )
# SDL2
find_library ( SDL2_LIBRARY NAMES SDL2 libSDL2 )
find_path ( SDL2_INCLUDEDIR NAMES SDL.h PATH_SUFFIXES SDL2 include/SDL2 include PATHS )
if ( NOT SDL2_LIBRARY OR NOT SDL2_INCLUDEDIR )
message ( FATAL_ERROR "SDL2 not found. "
" S D L 2 i s r e q u i r e d t o h a n d l e g a m e p a d i n S u p e r T u x K a r t . " )
else ( )
include_directories ( "${SDL2_INCLUDEDIR}" )
MESSAGE ( STATUS "Use system SDL2: ${SDL2_LIBRARY}" )
endif ( )
2020-10-23 06:23:43 -04:00
# DirectFB. Necessary if system SDL2 is built with DirectFB support.
find_path ( DIRECTFB_INCLUDEDIR NAMES directfb.h directfb++.h PATH_SUFFIXES directfb include/directfb include PATHS )
if ( DIRECTFB_INCLUDEDIR )
include_directories ( "${DIRECTFB_INCLUDEDIR}" )
message ( STATUS "Adding DirectFB include directories for DirectFB support in SDL2" )
endif ( )
2020-04-20 12:14:32 -04:00
endif ( )
2013-08-05 02:10:31 -04:00
# Build the irrlicht library
add_subdirectory ( "${PROJECT_SOURCE_DIR}/lib/irrlicht" )
2020-09-28 19:33:09 -04:00
include_directories ( BEFORE "${PROJECT_SOURCE_DIR}/lib/irrlicht/include" )
2013-08-05 02:10:31 -04:00
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 )
2019-04-07 16:10:33 -04:00
# Find system WiiUse library or build it if missing
2020-06-14 14:41:38 -04:00
if ( ( UNIX AND NOT ( APPLE OR HAIKU ) ) AND USE_SYSTEM_WIIUSE )
2019-04-07 16:10:33 -04:00
find_package ( WiiUse )
endif ( )
if ( WIIUSE_FOUND )
include_directories ( ${ WIIUSE_INCLUDE_DIR } )
else ( )
# Fallback to built-in version
if ( WIIUSE_BUILD )
add_subdirectory ( "${PROJECT_SOURCE_DIR}/lib/wiiuse" )
endif ( )
2020-09-28 19:33:09 -04:00
include_directories ( BEFORE "${PROJECT_SOURCE_DIR}/lib/wiiuse/src" )
2019-04-07 16:11:32 -04:00
set ( WIIUSE_LIBRARIES "wiiuse" "bluetooth" )
2013-08-05 02:10:31 -04:00
endif ( )
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
2019-07-12 02:53:55 -04:00
if ( APPLE AND NOT IOS )
2021-01-09 17:31:21 -05:00
set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -arch ${ARCHFLAGS}" )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -arch ${ARCHFLAGS} -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" )
2020-09-01 10:46:16 -04:00
include_directories ( BEFORE "${PROJECT_SOURCE_DIR}/lib/angelscript/include" )
2015-05-18 10:23:28 -04:00
set ( Angelscript_LIBRARIES angelscript )
endif ( )
2014-11-01 17:52:11 -04:00
2018-07-06 21:48:43 -04:00
if ( NOT SERVER_ONLY )
# OpenAL
find_package ( OpenAL REQUIRED )
include_directories ( ${ OPENAL_INCLUDE_DIR } )
# OggVorbis
find_package ( OggVorbis REQUIRED )
include_directories ( ${ OGGVORBIS_INCLUDE_DIRS } )
2012-03-06 12:07:16 -05:00
2018-07-06 21:48:43 -04:00
add_definitions ( -DENABLE_SOUND )
endif ( )
2011-08-01 15:18:49 -04:00
2020-08-23 12:58:07 -04:00
# Text handling in STK (We use freetype, harfbuzz and SheenBidifor i18n text handling)
2018-07-06 14:06:49 -04:00
if ( NOT SERVER_ONLY )
2020-08-23 12:53:04 -04:00
# SheenBidi
add_subdirectory ( "${PROJECT_SOURCE_DIR}/lib/sheenbidi" )
2020-09-28 19:33:09 -04:00
include_directories ( BEFORE "${PROJECT_SOURCE_DIR}/lib/sheenbidi/Headers" )
2020-08-23 12:53:04 -04:00
SET ( SHEENBIDI_LIBRARY sheenbidi )
2019-06-08 22:06:50 -04:00
# Freetype
2018-07-06 14:06:49 -04:00
find_package ( Freetype )
if ( FREETYPE_FOUND )
include_directories ( ${ FREETYPE_INCLUDE_DIRS } )
else ( )
message ( FATAL_ERROR "Freetype not found. "
2019-06-08 22:06:50 -04:00
" 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 . " )
endif ( )
# Harfbuzz
find_library ( HARFBUZZ_LIBRARY NAMES harfbuzz libharfbuzz )
find_path ( HARFBUZZ_INCLUDEDIR NAMES harfbuzz/hb.h hb.h PATHS )
if ( NOT HARFBUZZ_LIBRARY OR NOT HARFBUZZ_INCLUDEDIR )
message ( FATAL_ERROR "Harfbuzz not found. "
" H a r f b u z z 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 . " )
else ( )
include_directories ( "${HARFBUZZ_INCLUDEDIR}" )
MESSAGE ( STATUS "Use system harfbuzz: ${HARFBUZZ_LIBRARY}" )
2018-07-06 14:06:49 -04:00
endif ( )
2011-10-20 22:07:12 -04:00
endif ( )
2012-03-06 15:40:06 -05:00
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 ( )
2019-05-05 12:19:58 -04:00
# SQLITE
if ( USE_SQLITE3 )
find_library ( SQLITE3_LIBRARY NAMES sqlite3 libsqlite3 )
find_path ( SQLITE3_INCLUDEDIR NAMES sqlite3.h PATHS )
if ( NOT SQLITE3_LIBRARY OR NOT SQLITE3_INCLUDEDIR )
# add_subdirectory("${PROJECT_SOURCE_DIR}/lib/sqlite3")
2020-09-28 19:33:09 -04:00
# include_directories(BEFORE "${PROJECT_SOURCE_DIR}/lib/sqlite3")
2019-05-05 12:19:58 -04:00
# SET(SQLITE3_LIBRARY sqlite3)
set ( USE_SQLITE3 OFF CACHE BOOL "Use sqlite to manage server stats and ban list." FORCE )
message ( WARNING "Sqlite3 not found, disable advanced server management." )
else ( )
add_definitions ( -DENABLE_SQLITE3 )
include_directories ( "${SQLITE3_INCLUDEDIR}" )
MESSAGE ( STATUS "Use system libsqlite3: ${SQLITE3_LIBRARY}" )
endif ( )
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 ( )
2020-04-11 04:25:58 -04:00
if ( LLVM_MINGW )
SET ( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-pdb=supertuxkart.pdb" )
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 ( )
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 )
2019-07-12 02:53:55 -04:00
if ( APPLE AND NOT IOS )
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 ( 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 }
$ { 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 ( )
2020-04-11 04:25:58 -04:00
if ( NOT WIN32 )
find_library ( PTHREAD_LIBRARY NAMES pthread ${ PTHREAD_NAMES } PATHS ${ PROJECT_SOURCE_DIR } / ${ DEPENDENCIES } /lib )
mark_as_advanced ( PTHREAD_LIBRARY )
2015-01-08 07:24:15 -05:00
endif ( )
2012-03-15 08:50:51 -04:00
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
2019-07-13 01:44:03 -04:00
if ( IOS )
2020-02-07 00:02:07 -05:00
file ( GLOB IOS_ASSETS_FILES ${ IOS_ASSETS } ${ IOS_LAUNCHSCREEN } ${ IOS_IMAGES_XCASSETS } )
2019-07-13 01:44:03 -04:00
set_source_files_properties ( ${ IOS_ASSETS_FILES } PROPERTIES MACOSX_PACKAGE_LOCATION Resources )
add_executable ( supertuxkart ${ STK_SOURCES } ${ STK_RESOURCES } ${ STK_HEADERS } ${ IOS_ASSETS_FILES } )
2019-07-17 02:50:49 -04:00
set_target_properties ( supertuxkart PROPERTIES
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 - i O S . p l i s t
2019-07-18 13:59:02 -04:00
X C O D E _ A T T R I B U T E _ I P H O N E O S _ D E P L O Y M E N T _ T A R G E T 9 . 0
X C O D E _ A T T R I B U T E _ I N S T A L L _ P A T H / A p p l i c a t i o n s
2020-02-07 00:02:07 -05:00
X C O D E _ A T T R I B U T E _ S K I P _ I N S T A L L N o
X C O D E _ A T T R I B U T E _ A S S E T C A T A L O G _ C O M P I L E R _ A P P I C O N _ N A M E " A p p I c o n " )
2019-07-13 01:44:03 -04:00
else ( )
add_executable ( supertuxkart ${ STK_SOURCES } ${ STK_RESOURCES } ${ STK_HEADERS } )
endif ( )
2020-04-11 04:25:58 -04:00
if ( NOT WIN32 )
target_link_libraries ( supertuxkart ${ PTHREAD_LIBRARY } )
endif ( )
2011-08-29 14:17:45 -04:00
endif ( )
2011-07-24 10:29:16 -04:00
2019-09-15 12:23:30 -04:00
# check if linking against libatomic is required
include ( CheckCXXSourceCompiles )
check_cxx_source_compiles ( "
#include <atomic>
#include <cstdint>
i n t main ( ) {
s t d : : a t o m i c < u i n t 6 4 _ t > x { 0 } ;
x . load ( ) ;
r e t u r n 0 ;
}
" N O _ L I B A T O M I C _ N E E D E D )
if ( NOT NO_LIBATOMIC_NEEDED )
target_link_libraries ( supertuxkart atomic )
endif ( )
2018-08-31 13:05:22 -04:00
# CURL and OpenSSL or Nettle
2018-06-03 02:44:53 -04:00
# 1.0.1d for compatible AES GCM handling
SET ( OPENSSL_MINIMUM_VERSION "1.0.1d" )
2020-04-11 04:25:58 -04:00
if ( MSVC OR LLVM_MINGW )
2018-08-31 13:05:22 -04:00
set ( USE_CRYPTO_OPENSSL ON )
2017-04-06 09:59:01 -04:00
target_link_libraries ( supertuxkart ${ PROJECT_SOURCE_DIR } / ${ DEPENDENCIES } /lib/libcurl.lib )
2018-06-02 00:28:29 -04:00
target_link_libraries ( supertuxkart ${ PROJECT_SOURCE_DIR } / ${ DEPENDENCIES } /lib/libeay32.lib )
2017-04-06 05:39:53 -04:00
elseif ( MINGW )
2018-08-31 13:05:22 -04:00
set ( USE_CRYPTO_OPENSSL ON )
2020-04-13 22:56:07 -04:00
target_link_libraries ( supertuxkart ${ PROJECT_SOURCE_DIR } / ${ DEPENDENCIES } /lib/libcurl.dll )
2018-06-02 00:28:29 -04:00
target_link_libraries ( supertuxkart ${ PROJECT_SOURCE_DIR } / ${ DEPENDENCIES } /lib/libeay32.dll )
2014-01-21 20:24:37 -05:00
else ( )
find_package ( CURL REQUIRED )
2018-08-31 13:05:22 -04:00
include_directories ( ${ CURL_INCLUDE_DIRS } )
2018-11-24 17:20:27 -05:00
find_path ( NETTLE_INCLUDE_DIRS nettle/version.h )
2018-08-31 13:05:22 -04:00
find_library ( NETTLE_LIBRARY NAMES nettle libnettle )
if ( NOT NETTLE_INCLUDE_DIRS OR NOT NETTLE_LIBRARY OR USE_CRYPTO_OPENSSL )
set ( USE_CRYPTO_OPENSSL ON )
find_package ( OpenSSL REQUIRED )
2018-06-03 02:44:53 -04:00
2018-08-31 13:05:22 -04:00
if ( ${ OPENSSL_VERSION } VERSION_LESS ${ OPENSSL_MINIMUM_VERSION } OR
( $ { O P E N S S L _ V E R S I O N } V E R S I O N _ E Q U A L $ { O P E N S S L _ M I N I M U M _ V E R S I O N } A N D $ { O P E N S S L _ V E R S I O N } S T R L E S S $ { O P E N S S L _ M I N I M U M _ V E R S I O N } ) )
message ( FATAL_ERROR "OpenSSL version found (${OPENSSL_VERSION}) is less then the minimum required (${OPENSSL_MINIMUM_VERSION}), aborting." )
endif ( )
include_directories ( ${ OpenSSL_INCLUDE_DIRS } )
else ( )
set ( USE_CRYPTO_OPENSSL OFF )
include_directories ( ${ NETTLE_INCLUDE_DIRS } )
2018-06-03 02:44:53 -04:00
endif ( )
2018-08-31 13:05:22 -04:00
endif ( )
2018-06-03 02:44:53 -04:00
2018-08-31 13:05:22 -04:00
if ( USE_CRYPTO_OPENSSL )
message ( STATUS "OpenSSL will be used for cryptography in STK." )
add_definitions ( -DENABLE_CRYPTO_OPENSSL )
else ( )
message ( STATUS "Nettle will be used for cryptography in STK." )
add_definitions ( -DENABLE_CRYPTO_NETTLE )
2014-01-21 20:24:37 -05:00
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
2018-07-09 16:33:14 -04:00
$ { E N E T _ L I B R A R I E S }
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 }
2020-02-05 11:46:38 -05:00
$ { L I B R E S O L V _ L I B R A R Y }
2020-08-23 13:09:47 -04:00
$ { M C P P _ L I B R A R Y }
2014-09-15 02:33:46 -04:00
)
2014-09-03 08:05:34 -04:00
2019-05-05 12:19:58 -04:00
if ( USE_SQLITE3 )
target_link_libraries ( supertuxkart ${ SQLITE3_LIBRARY } )
endif ( )
2018-08-31 13:05:22 -04:00
if ( USE_CRYPTO_OPENSSL )
target_link_libraries ( supertuxkart ${ OPENSSL_CRYPTO_LIBRARY } )
else ( )
target_link_libraries ( supertuxkart ${ NETTLE_LIBRARY } )
endif ( )
2016-11-11 08:09:39 -05:00
if ( NOT SERVER_ONLY )
2020-12-03 20:39:06 -05:00
if ( IOS )
2020-04-20 22:11:41 -04:00
target_link_libraries ( supertuxkart "-framework QuartzCore -framework CoreGraphics -framework AVFoundation -framework AudioToolbox -framework Metal -framework GameController -framework OpenGLES -framework UIKit -framework CoreAudio -framework CoreMotion -framework Foundation -framework GLKit" )
2016-11-11 08:09:39 -05:00
endif ( )
2016-06-23 20:47:13 -04:00
2018-07-06 21:27:39 -04:00
target_link_libraries ( supertuxkart
$ { S Q U I S H _ L I B R A R Y }
$ { J P E G _ L I B R A R I E S }
2018-07-06 21:48:43 -04:00
$ { 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 }
2019-06-08 22:06:50 -04:00
$ { F R E E T Y P E _ L I B R A R I E S }
$ { H A R F B U Z Z _ L I B R A R Y }
2020-04-20 12:14:32 -04:00
$ { S D L 2 _ L I B R A R Y }
2020-08-23 12:53:04 -04:00
$ { S H E E N B I D I _ L I B R A R Y }
2020-09-09 01:27:10 -04:00
g r a p h i c s _ u t i l s
2020-12-03 20:39:06 -05:00
g r a p h i c s _ e n g i n e
2020-09-09 01:27:10 -04:00
t i n y g e t t e x t )
2017-12-25 01:00:10 -05: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 } )
2020-01-11 16:23:45 -05:00
if ( CMAKE_SYSTEM_NAME MATCHES "BSD" )
target_link_libraries ( supertuxkart execinfo )
endif ( )
2014-07-25 13:23:32 -04:00
endif ( )
2014-08-12 14:19:31 -04:00
if ( USE_ASAN )
target_link_libraries ( supertuxkart "-fsanitize=address" )
endif ( )
2020-02-22 12:14:41 -05:00
if ( USE_TSAN )
target_link_libraries ( supertuxkart "-fsanitize=thread" )
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
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 ( )
2019-04-07 16:10:33 -04:00
target_link_libraries ( supertuxkart ${ WIIUSE_LIBRARIES } )
2013-02-03 19:15:45 -05:00
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 )
2020-04-20 12:14:32 -04:00
target_link_libraries ( supertuxkart -ldxguid -ldnsapi )
2019-06-29 02:08:28 -04:00
if ( NOT CMAKE_BUILD_TYPE MATCHES Debug )
target_link_libraries ( supertuxkart -mwindows )
endif ( )
2020-04-11 04:25:58 -04:00
if ( LLVM_MINGW )
find_library ( LIBCPP NAMES "libc++.dll" PATHS ${ CMAKE_FIND_ROOT_PATH } )
if ( LIBCPP )
file ( COPY ${ LIBCPP } DESTINATION ${ CMAKE_BINARY_DIR } /bin/ )
endif ( )
find_library ( LIBUNWIND NAMES "libunwind.dll" PATHS ${ CMAKE_FIND_ROOT_PATH } )
if ( LIBUNWIND )
file ( COPY ${ LIBUNWIND } DESTINATION ${ CMAKE_BINARY_DIR } /bin/ )
endif ( )
else ( )
find_library ( LIBGCC NAMES "libgcc_s_dw2-1.dll" "libgcc_s_sjlj-1.dll" "libgcc_s_seh-1.dll" PATHS ${ CMAKE_FIND_ROOT_PATH } )
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 ( LIBPTHREAD NAMES "winpthread-1.dll" "libwinpthread-1.dll" "pthreadGC2.dll" PATHS ${ CMAKE_FIND_ROOT_PATH } )
if ( LIBPTHREAD )
file ( COPY ${ LIBPTHREAD } DESTINATION ${ CMAKE_BINARY_DIR } /bin/ )
endif ( )
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
2020-10-30 23:32:40 -04:00
# Find LibGamerzilla library or build it if missing
if ( NOT APPLE )
include ( FindPkgConfig )
pkg_search_module ( GAMERZILLA OPTIONAL gamerzilla )
if ( GAMERZILLA_LIBRARIES )
message ( STATUS "Gamerzilla found" )
include_directories ( ${ GAMERZILLA_INCLUDE_DIRS } )
target_link_libraries ( supertuxkart ${ GAMERZILLA_LIBRARIES } )
add_definitions ( -DGAMERZILLA )
endif ( )
endif ( )
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 )
2020-08-16 02:42:17 -04:00
install ( FILES data/supertuxkart_16.png DESTINATION share/icons/hicolor/16x16/apps RENAME supertuxkart.png )
install ( FILES data/supertuxkart_32.png DESTINATION share/icons/hicolor/32x32/apps RENAME supertuxkart.png )
2017-07-30 06:56:25 -04:00
install ( FILES data/supertuxkart_48.png DESTINATION share/icons/hicolor/48x48/apps RENAME supertuxkart.png )
2020-08-16 02:42:17 -04:00
install ( FILES data/supertuxkart_64.png DESTINATION share/icons/hicolor/64x64/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 )
2020-08-16 02:42:17 -04:00
install ( FILES data/supertuxkart_256.png DESTINATION share/icons/hicolor/256x256/apps RENAME supertuxkart.png )
install ( FILES data/supertuxkart_512.png DESTINATION share/icons/hicolor/512x512/apps RENAME supertuxkart.png )
install ( FILES data/supertuxkart_1024.png DESTINATION share/icons/hicolor/1024x1024/apps RENAME supertuxkart.png )
install ( FILES data/supertuxkart_512.png DESTINATION share/pixmaps RENAME supertuxkart.png )
2018-01-26 16:33:37 -05:00
install ( FILES data/supertuxkart.appdata.xml DESTINATION share/metainfo )
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 ( )
2020-04-11 04:25:58 -04:00
if ( LLVM_MINGW )
set ( COPY_PDB_CMD cp ${ CMAKE_BINARY_DIR } /supertuxkart.pdb ${ CMAKE_BINARY_DIR } /bin )
add_custom_command ( TARGET supertuxkart POST_BUILD COMMAND ${ COPY_PDB_CMD } )
endif ( )