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
|
|
|
|
|
|
|
cmake_minimum_required(VERSION 2.8.1)
|
2012-03-05 20:07:26 -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()
|
|
|
|
|
2013-11-17 18:01:21 -05: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)
|
2013-11-14 17:17:46 -05:00
|
|
|
if(UNIX)
|
|
|
|
option(USE_CPP2011 "Activate C++ 2011 mode (GCC only)" OFF)
|
|
|
|
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
|
|
|
|
STRING "Install executable to this directory, absolute or relative to CMAKE_INSTALL_PREFIX")
|
|
|
|
set(STK_INSTALL_DATA_DIR "share/supertuxkart" CACHE
|
|
|
|
STRING "Install data folder to this directory, absolute or relative to CMAKE_INSTALL_PREFIX")
|
2012-03-04 15:07:44 -05:00
|
|
|
|
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
|
|
|
|
2012-01-01 16:19:13 -05:00
|
|
|
# Build the Wiiuse library
|
|
|
|
if(USE_WIIUSE)
|
2012-09-18 19:09:12 -04:00
|
|
|
add_subdirectory("${PROJECT_SOURCE_DIR}/lib/wiiuse")
|
|
|
|
include_directories("${PROJECT_SOURCE_DIR}/lib/wiiuse")
|
2012-01-01 16:19:13 -05:00
|
|
|
endif()
|
2011-07-24 14:40:20 -04:00
|
|
|
|
2013-03-12 21:31:09 -04:00
|
|
|
# Build the irrlicht library
|
|
|
|
add_subdirectory("${PROJECT_SOURCE_DIR}/lib/irrlicht")
|
|
|
|
include_directories("${PROJECT_SOURCE_DIR}/lib/irrlicht/include")
|
2013-07-13 20:34:47 -04:00
|
|
|
include_directories("${PROJECT_SOURCE_DIR}/lib/irrlicht/source/Irrlicht")
|
|
|
|
|
2013-03-12 21:31:09 -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
|
|
|
|
2012-05-07 13:40:18 -04:00
|
|
|
# These variables enable MSVC to find libraries located in "dependencies"
|
|
|
|
if(MSVC)
|
|
|
|
set(ENV{PATH} ${PROJECT_SOURCE_DIR}/dependencies/include)
|
|
|
|
set(ENV{LIB} ${PROJECT_SOURCE_DIR}/dependencies/lib)
|
|
|
|
set(ENV{OPENALDIR} ${PROJECT_SOURCE_DIR}/dependencies)
|
2013-07-28 01:24:59 -04:00
|
|
|
add_definitions(/D_IRR_STATIC_LIB_)
|
2012-05-07 13:40:18 -04:00
|
|
|
endif()
|
2012-03-15 08:51:08 -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()
|
|
|
|
|
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
|
|
|
|
|
|
|
# CURL
|
2012-03-15 08:51:08 -04:00
|
|
|
find_package(CURL REQUIRED)
|
2012-03-05 19:18:51 -05:00
|
|
|
include_directories(${CURL_INCLUDE_DIRS})
|
2011-08-01 15:18:49 -04:00
|
|
|
|
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. "
|
|
|
|
"Either install fribidi or disable bidi support with -DUSE_FRIBIDI=0 "
|
|
|
|
"(if you don't use a right-to-left language then you don't need this).")
|
2011-10-20 22:07:12 -04:00
|
|
|
endif()
|
|
|
|
endif()
|
2012-03-06 15:40:06 -05:00
|
|
|
|
2013-11-14 17:17:46 -05:00
|
|
|
if(UNIX)
|
|
|
|
if(USE_CPP2011)
|
|
|
|
add_definitions("-std=gnu++11")
|
|
|
|
endif()
|
2013-01-16 21:20:12 -05:00
|
|
|
endif()
|
2012-03-06 15:40:06 -05:00
|
|
|
|
2012-11-05 20:18:10 -05:00
|
|
|
# OpenGL
|
|
|
|
find_package(OpenGL REQUIRED)
|
|
|
|
include_directories(${OPENGL_INCLUDE_DIR})
|
|
|
|
|
|
|
|
if(UNIX AND NOT APPLE)
|
|
|
|
find_library(IRRLICHT_XF86VM_LIBRARY Xxf86vm)
|
|
|
|
mark_as_advanced(IRRLICHT_XF86VM_LIBRARY)
|
|
|
|
else()
|
|
|
|
set(IRRLICHT_XF86VM_LIBRARY "")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
2012-11-05 20:46:41 -05:00
|
|
|
|
2011-08-01 15:18:49 -04:00
|
|
|
# Set some compiler options
|
|
|
|
if(UNIX)
|
2012-03-15 08:50:36 -04:00
|
|
|
add_definitions(-Wall)
|
2011-08-01 15:18:49 -04:00
|
|
|
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)
|
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
|
|
|
|
2012-03-06 15:40:06 -05:00
|
|
|
if(CMAKE_BUILD_TYPE MATCHES Debug)
|
2012-03-15 08:50:36 -04:00
|
|
|
add_definitions(-DDEBUG)
|
2011-07-24 14:40:20 -04:00
|
|
|
else()
|
2012-03-15 08:50:36 -04:00
|
|
|
add_definitions(-DNDEBUG)
|
2011-07-24 10:29:16 -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
|
|
|
${IOKIT_LIBRARY}
|
|
|
|
${QUICKTIME_LIBRARY}
|
|
|
|
${CARBON_LIBRARY}
|
|
|
|
${AUDIOUNIT_LIBRARY}
|
|
|
|
${COCOA_LIBRARY})
|
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
|
|
|
MACOSX_BUNDLE_INFO_PLIST ${PROJECT_SOURCE_DIR}/data/SuperTuxKart-Info.plist)
|
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
|
|
|
|
COMMAND ln -f -s ${PROJECT_SOURCE_DIR}/data ${CMAKE_BINARY_DIR}/bin/\${CONFIGURATION}/supertuxkart.app/Contents/Resources)
|
|
|
|
else()
|
|
|
|
add_custom_command(TARGET supertuxkart POST_BUILD
|
|
|
|
COMMAND ln -f -s ${PROJECT_SOURCE_DIR}/data ${CMAKE_BINARY_DIR}/bin/supertuxkart.app/Contents/Resources)
|
|
|
|
endif()
|
2011-08-29 14:17:45 -04:00
|
|
|
else()
|
2012-03-15 08:50:51 -04:00
|
|
|
find_library(PTHREAD_LIBRARY NAMES pthread pthreadVC2 PATHS ${PROJECT_SOURCE_DIR}/dependencies/lib)
|
|
|
|
mark_as_advanced(PTHREAD_LIBRARY)
|
|
|
|
|
2012-03-16 19:15:23 -04:00
|
|
|
# Set data dir (absolute or relative to CMAKE_INSTALL_PREFIX)
|
|
|
|
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()
|
2011-11-14 18:27:31 -05:00
|
|
|
|
2011-08-29 14:17:45 -04:00
|
|
|
# Build the final executable
|
2012-03-15 08:41:52 -04:00
|
|
|
add_executable(supertuxkart ${STK_SOURCES} ${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
|
|
|
|
2012-11-05 20:18:10 -05:00
|
|
|
|
2012-03-06 12:07:16 -05:00
|
|
|
# Common library dependencies
|
|
|
|
target_link_libraries(supertuxkart
|
|
|
|
bulletdynamics
|
|
|
|
bulletcollision
|
|
|
|
bulletmath
|
|
|
|
enet
|
2013-03-12 21:31:09 -04:00
|
|
|
stkirrlicht
|
2012-03-06 12:07:16 -05:00
|
|
|
${CURL_LIBRARIES}
|
|
|
|
${OGGVORBIS_LIBRARIES}
|
2012-11-05 20:18:10 -05:00
|
|
|
${IRRLICHT_XF86VM_LIBRARY}
|
2012-03-06 12:07:16 -05:00
|
|
|
${OPENAL_LIBRARY}
|
|
|
|
${OPENGL_LIBRARIES})
|
|
|
|
|
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
|
|
|
|
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})
|
|
|
|
else()
|
|
|
|
target_link_libraries(supertuxkart wiiuse bluetooth)
|
|
|
|
endif()
|
2012-03-15 08:50:36 -04:00
|
|
|
add_definitions(-DENABLE_WIIUSE)
|
2012-01-01 16:19:13 -05:00
|
|
|
endif()
|
|
|
|
|
2012-03-10 18:16:57 -05:00
|
|
|
|
2012-03-06 18:01:00 -05:00
|
|
|
# Optional tools
|
|
|
|
add_subdirectory(tools/font_tool)
|
|
|
|
|
2011-09-05 20:15:06 -04:00
|
|
|
|
2011-10-21 20:36:30 -04:00
|
|
|
# ==== Make dist target ====
|
2013-07-28 01:24:59 -04:00
|
|
|
if(MSVC)
|
|
|
|
# Don't create a dist target for VS
|
|
|
|
else()
|
|
|
|
add_custom_target(dist
|
2011-09-05 20:15:06 -04:00
|
|
|
COMMAND rm -rf ${CMAKE_BINARY_DIR}/SuperTuxKart-${PROJECT_VERSION} && rm -f ${CMAKE_BINARY_DIR}/SuperTuxKart-${PROJECT_VERSION}.tar.bz2
|
|
|
|
&& echo "Exporting..."
|
|
|
|
&& svn export ${PROJECT_SOURCE_DIR} ${CMAKE_BINARY_DIR}/SuperTuxKart-${PROJECT_VERSION}
|
|
|
|
&& echo "Compressing..."
|
|
|
|
&& cd ${CMAKE_BINARY_DIR}
|
|
|
|
&& tar -cjf ${CMAKE_BINARY_DIR}/SuperTuxKart-${PROJECT_VERSION}.tar.bz2 ./SuperTuxKart-${PROJECT_VERSION}
|
|
|
|
&& echo "Done, cleaning up"
|
|
|
|
&& rm -rf ${CMAKE_BINARY_DIR}/SuperTuxKart-${PROJECT_VERSION}
|
2013-07-28 01:24:59 -04:00
|
|
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
|
|
|
)
|
|
|
|
endif()
|
2011-09-05 20:15:06 -04:00
|
|
|
|
2011-10-21 20:36:30 -04:00
|
|
|
# ==== Install target ====
|
2012-03-16 19:15:23 -04:00
|
|
|
install(TARGETS supertuxkart RUNTIME DESTINATION ${STK_INSTALL_BINARY_DIR} BUNDLE DESTINATION .)
|
|
|
|
install(DIRECTORY ${STK_DATA_DIR} DESTINATION ${STK_INSTALL_DATA_DIR} PATTERN ".svn" EXCLUDE)
|
2012-03-05 19:18:51 -05:00
|
|
|
install(FILES ${PROJECT_BINARY_DIR}/supertuxkart.desktop DESTINATION share/applications)
|
2013-08-30 14:46:11 -04:00
|
|
|
install(FILES data/supertuxkart_32.png data/supertuxkart_128.png DESTINATION share/pixmaps)
|
2013-11-28 01:20:36 -05:00
|
|
|
install(FILES data/supertuxkart.appdata DESTINATION share/appdata)
|
2011-10-20 22:07:12 -04:00
|
|
|
|
2012-03-05 19:18:51 -05:00
|
|
|
set(PREFIX ${CMAKE_INSTALL_PREFIX})
|
|
|
|
configure_file(data/supertuxkart_desktop.template supertuxkart.desktop)
|
2012-11-05 20:46:41 -05:00
|
|
|
add_dependencies(supertuxkart supertuxkart.desktop)
|