2014-05-20 12:35:27 -04:00
|
|
|
cmake_minimum_required(VERSION 2.6)
|
|
|
|
|
|
|
|
#
|
|
|
|
# Execute these commands in this directory:
|
|
|
|
#
|
|
|
|
# 1. mkdir build/; cd build/
|
|
|
|
#
|
|
|
|
# 2. Choose compiler:
|
|
|
|
# Build with native toolchain:
|
|
|
|
# cmake -DCMAKE_BUILD_TYPE=Debug ..
|
|
|
|
#
|
|
|
|
# Build with mingw:
|
|
|
|
# cmake -DCMAKE_TOOLCHAIN_FILE=../CMakeLists_mingw.txt -DCMAKE_BUILD_TYPE=Debug ..
|
|
|
|
#
|
|
|
|
# 3. make
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
|
|
# project title
|
|
|
|
set (PROJECT openrct2)
|
|
|
|
# OpenRCT2 resource directory
|
|
|
|
set (ORCT2_RESOURCE_DIR ${CMAKE_INSTALL_PREFIX}/share/${PROJECT}/)
|
|
|
|
|
|
|
|
project(${PROJECT})
|
|
|
|
|
|
|
|
add_definitions(-DORCT2_RESOURCE_DIR="${ORCT2_RESOURCE_DIR}")
|
2014-09-05 21:56:42 -04:00
|
|
|
add_definitions(-DHAVE_CONFIG_H)
|
2015-05-25 15:38:33 -04:00
|
|
|
add_definitions(-DCURL_STATICLIB)
|
2015-09-24 16:47:14 -04:00
|
|
|
|
|
|
|
INCLUDE(FindPkgConfig)
|
|
|
|
|
2015-08-03 19:08:42 -04:00
|
|
|
option(DISABLE_HTTP_TWITCH "Disable HTTP and Twitch support.")
|
|
|
|
if (DISABLE_HTTP_TWITCH)
|
|
|
|
add_definitions(-DDISABLE_HTTP -DDISABLE_TWITCH)
|
2015-09-24 16:47:14 -04:00
|
|
|
else (DISABLE_HTTP_TWITCH)
|
|
|
|
PKG_CHECK_MODULES(LIBCURL REQUIRED libcurl)
|
|
|
|
PKG_CHECK_MODULES(JANSSON REQUIRED jansson)
|
|
|
|
SET(HTTPLIBS ${LIBCURL_LIBRARIES} ${JANSSON_LIBRARIES})
|
|
|
|
if (WIN32)
|
|
|
|
SET(HTTPLIBS ${HTTPLIBS} ssl crypto winmm.lib ws2_32)
|
|
|
|
endif (WIN32)
|
2015-08-03 19:08:42 -04:00
|
|
|
endif (DISABLE_HTTP_TWITCH)
|
2015-05-25 15:38:33 -04:00
|
|
|
|
2015-08-18 03:30:55 -04:00
|
|
|
option(DISABLE_NETWORK "Disable multiplayer functionality. Mainly for testing.")
|
|
|
|
if (DISABLE_NETWORK)
|
|
|
|
add_definitions(-DDISABLE_NETWORK)
|
2015-09-28 18:01:51 -04:00
|
|
|
else (DISABLE_NETWORK)
|
|
|
|
if (WIN32)
|
|
|
|
SET(NETWORKLIBS ${NETWORKLIBS} ws2_32)
|
|
|
|
endif (WIN32)
|
2015-08-18 03:30:55 -04:00
|
|
|
endif (DISABLE_NETWORK)
|
|
|
|
|
2014-10-06 14:41:43 -04:00
|
|
|
# include lib
|
|
|
|
include_directories("lib/")
|
2014-09-05 21:56:42 -04:00
|
|
|
# include speex header
|
2014-10-06 14:41:43 -04:00
|
|
|
include_directories("lib/libspeex/")
|
2014-05-24 07:22:01 -04:00
|
|
|
# add source files
|
2014-10-06 14:41:43 -04:00
|
|
|
file(GLOB_RECURSE ORCT2_SOURCES "src/*.c" "src/*.cpp" "lib/*.c")
|
2014-05-20 12:35:27 -04:00
|
|
|
|
|
|
|
if (UNIX)
|
|
|
|
# force 32bit build for now and set necessary flags to compile code as is
|
2015-08-04 16:39:44 -04:00
|
|
|
set(CMAKE_C_FLAGS "-m32 -masm=intel -fvar-tracking-assignments -std=gnu99")
|
|
|
|
set(CMAKE_CXX_FLAGS "-m32 -std=gnu++11 -fvar-tracking-assignments -masm=intel")
|
2015-09-24 16:47:14 -04:00
|
|
|
set(CMAKE_SHARED_LINKER_FLAGS "-m32 -Wl,-melf_i386")
|
2015-08-18 03:30:55 -04:00
|
|
|
set(CMAKE_EXE_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS})
|
2014-05-20 12:35:27 -04:00
|
|
|
endif (UNIX)
|
|
|
|
|
2015-09-24 16:47:14 -04:00
|
|
|
# find and include SDL2
|
|
|
|
PKG_CHECK_MODULES(SDL2 REQUIRED sdl2 SDL2_ttf)
|
|
|
|
INCLUDE_DIRECTORIES(${SDL2_INCLUDE_DIRS} ${LIBCURL_INCLUDE_DIRS} ${JANSSON_INCLUDE_DIRS})
|
|
|
|
|
|
|
|
LINK_DIRECTORIES(${SDL2_LIBRARY_DIRS} ${JANSSON_LIBRARY_DIRS} ${LIBCURL_LIBRARY_DIRS})
|
2015-09-20 17:19:38 -04:00
|
|
|
|
2015-08-04 16:39:44 -04:00
|
|
|
if (WIN32)
|
|
|
|
# build as library for now, replace with add_executable
|
|
|
|
add_library(${PROJECT} SHARED ${ORCT2_SOURCES})
|
|
|
|
else (WIN32)
|
|
|
|
add_executable(${PROJECT} ${ORCT2_SOURCES})
|
|
|
|
endif (WIN32)
|
2014-05-24 07:22:01 -04:00
|
|
|
|
|
|
|
# install into ${CMAKE_INSTALL_PREFIX}/bin/
|
|
|
|
#install (TARGETS ${PROJECT} DESTINATION bin)
|
|
|
|
|
|
|
|
# libopenrct2.dll -> openrct2.dll
|
|
|
|
set_target_properties(${PROJECT} PROPERTIES PREFIX "")
|
|
|
|
|
2015-09-28 18:01:51 -04:00
|
|
|
TARGET_LINK_LIBRARIES(${PROJECT} ${SDL2_LIBRARIES} ${ORCTLIBS_LIB} ${JANSSON_LIBRARIES} ${HTTPLIBS} ${NETWORKLIBS})
|