2012-07-01 17:27:41 +03:00
|
|
|
project(vcmi)
|
|
|
|
cmake_minimum_required(VERSION 2.6)
|
|
|
|
|
|
|
|
# where to look for cmake modules
|
|
|
|
set(CMAKE_MODULE_PATH ${CMAKE_HOME_DIRECTORY}/cmake_modules)
|
|
|
|
|
2012-07-19 21:52:44 +03:00
|
|
|
# enable Release mode but only if it was not set
|
|
|
|
if (NOT CMAKE_BUILD_TYPE)
|
|
|
|
set(CMAKE_BUILD_TYPE Release)
|
|
|
|
endif()
|
2012-07-01 17:27:41 +03:00
|
|
|
|
2013-02-21 20:32:50 +03:00
|
|
|
# VCMI version
|
|
|
|
set(VCMI_VERSION_MAJOR 0)
|
|
|
|
set(VCMI_VERSION_MINOR 91)
|
|
|
|
set(VCMI_VERSION_PATCH 0)
|
|
|
|
|
2012-11-03 22:31:16 +03:00
|
|
|
option(DISABLE_ERM "Disable compilation of ERM scripting module" ON)
|
2013-02-17 00:14:36 +03:00
|
|
|
option(ENABLE_EDITOR "Enable compilation of map editor" OFF)
|
2012-10-05 15:38:17 +03:00
|
|
|
|
|
|
|
############################################
|
|
|
|
# Building section #
|
|
|
|
############################################
|
|
|
|
|
2012-12-01 09:30:52 +03:00
|
|
|
if (APPLE)
|
|
|
|
# Default location for thirdparty libs
|
2012-12-27 12:21:30 +03:00
|
|
|
set(CMAKE_INCLUDE_PATH "../include" "${CMAKE_OSX_SYSROOT}/usr/include")
|
2012-12-01 09:30:52 +03:00
|
|
|
set(CMAKE_LIBRARY_PATH "../lib")
|
|
|
|
set(CMAKE_FRAMEWORK_PATH "../Frameworks")
|
|
|
|
set(BOOST_ROOT "../")
|
|
|
|
|
|
|
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_HOME_DIRECTORY}/bin")
|
|
|
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_HOME_DIRECTORY}/bin")
|
|
|
|
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_HOME_DIRECTORY}/bin")
|
|
|
|
|
|
|
|
set(CMAKE_XCODE_ATTRIBUTE_CONFIGURATION_BUILD_DIR "${CMAKE_HOME_DIRECTORY}/bin/$(CONFIGURATION)")
|
|
|
|
set(CMAKE_XCODE_ATTRIBUTE_LD_RUNPATH_SEARCH_PATHS "@executable_path/../Frameworks")
|
|
|
|
|
|
|
|
# Build with clang ang libc++
|
|
|
|
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++11")
|
|
|
|
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++")
|
2013-03-02 00:32:26 +03:00
|
|
|
|
|
|
|
# On OS X we use Sparkle framework for updates
|
|
|
|
find_path(SPARKLE_INCLUDE_DIR Sparkle.h)
|
|
|
|
find_library(SPARKLE_FRAMEWORK NAMES Sparkle)
|
2012-12-01 09:30:52 +03:00
|
|
|
endif()
|
|
|
|
|
2012-10-05 21:03:49 +03:00
|
|
|
find_package(Boost 1.46.0 COMPONENTS program_options filesystem system thread REQUIRED)
|
2012-07-01 17:27:41 +03:00
|
|
|
find_package(SDL REQUIRED)
|
|
|
|
find_package(SDL_image REQUIRED)
|
|
|
|
find_package(SDL_mixer REQUIRED)
|
|
|
|
find_package(SDL_ttf REQUIRED)
|
|
|
|
find_package(ZLIB REQUIRED)
|
|
|
|
|
2013-02-17 00:14:36 +03:00
|
|
|
if (ENABLE_EDITOR)
|
|
|
|
# Widgets finds its own dependencies (QtGui and QtCore).
|
|
|
|
find_package(Qt5Widgets REQUIRED)
|
|
|
|
endif()
|
|
|
|
|
2012-10-05 15:38:17 +03:00
|
|
|
if(NOT WIN32)
|
2013-01-26 22:39:54 +03:00
|
|
|
set(FFmpeg_FIND_COMPONENTS AVFORMAT SWSCALE)
|
|
|
|
find_package(FFmpeg REQUIRED)
|
2012-10-05 15:38:17 +03:00
|
|
|
|
|
|
|
INCLUDE(CheckLibraryExists)
|
|
|
|
|
|
|
|
#check if some platform-specific libraries are needed for linking client and server
|
|
|
|
CHECK_LIBRARY_EXISTS(rt shm_open "" HAVE_RT_LIB)
|
|
|
|
if(HAVE_RT_LIB)
|
|
|
|
set(RT_LIB -lrt)
|
|
|
|
endif()
|
2012-07-15 19:05:41 +03:00
|
|
|
|
2012-10-05 15:38:17 +03:00
|
|
|
CHECK_LIBRARY_EXISTS(dl dlopen "" HAVE_DL_LIB)
|
|
|
|
if(HAVE_DL_LIB)
|
|
|
|
set(DL_LIB -ldl)
|
|
|
|
endif()
|
2012-07-15 19:05:41 +03:00
|
|
|
endif()
|
|
|
|
|
2012-10-05 15:38:17 +03:00
|
|
|
if(CMAKE_COMPILER_IS_GNUCXX OR NOT WIN32) #so far all *nix compilers support such parameters
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -Wall -Wextra -Wpointer-arith -Wno-switch -Wno-sign-compare -Wno-unused-parameter -Wno-overloaded-virtual")
|
2012-07-15 19:05:41 +03:00
|
|
|
endif()
|
|
|
|
|
2012-10-05 15:38:17 +03:00
|
|
|
if(WIN32) # on Win everything goes into H3 root directory
|
|
|
|
set(BIN_DIR "" CACHE STRING "Where to install binaries")
|
|
|
|
set(LIB_DIR "" CACHE STRING "Where to install main library")
|
|
|
|
set(DATA_DIR "" CACHE STRING "Where to install data files")
|
2012-12-01 09:30:52 +03:00
|
|
|
elseif(APPLE)
|
|
|
|
# includes lib path which determines where to install shared libraries (either /lib or /lib64)
|
|
|
|
include(GNUInstallDirs)
|
|
|
|
|
|
|
|
set(BIN_DIR "." CACHE STRING "Where to install binaries")
|
|
|
|
set(LIB_DIR "." CACHE STRING "Where to install main library")
|
|
|
|
set(DATA_DIR "../h3" CACHE STRING "Where to install data files")
|
2012-10-05 15:38:17 +03:00
|
|
|
else()
|
2012-10-06 19:09:20 +03:00
|
|
|
# includes lib path which determines where to install shared libraries (either /lib or /lib64)
|
|
|
|
include(GNUInstallDirs)
|
|
|
|
|
2013-02-25 22:17:36 +03:00
|
|
|
if (NOT BIN_DIR)
|
|
|
|
set(BIN_DIR "bin" CACHE STRING "Where to install binaries")
|
|
|
|
endif()
|
|
|
|
if (NOT LIB_DIR)
|
|
|
|
set(LIB_DIR "${CMAKE_INSTALL_LIBDIR}/vcmi" CACHE STRING "Where to install main library")
|
|
|
|
endif()
|
|
|
|
if (NOT DATA_DIR)
|
|
|
|
set(DATA_DIR "share/vcmi" CACHE STRING "Where to install data files")
|
|
|
|
endif()
|
2012-07-01 17:27:41 +03:00
|
|
|
endif()
|
|
|
|
|
2012-10-05 15:38:17 +03:00
|
|
|
set (AI_LIB_DIR "${LIB_DIR}/AI")
|
|
|
|
set (SCRIPTING_LIB_DIR "${LIB_DIR}/Scripting")
|
|
|
|
|
2012-07-15 19:05:41 +03:00
|
|
|
#define required constants
|
2012-10-05 15:38:17 +03:00
|
|
|
add_definitions(-DM_DATA_DIR="${CMAKE_INSTALL_PREFIX}/${DATA_DIR}")
|
|
|
|
add_definitions(-DM_BIN_DIR="${CMAKE_INSTALL_PREFIX}/${BIN_DIR}")
|
|
|
|
add_definitions(-DM_LIB_DIR="${CMAKE_INSTALL_PREFIX}/${LIB_DIR}")
|
2012-07-15 19:05:41 +03:00
|
|
|
|
2012-11-03 22:31:16 +03:00
|
|
|
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/vcmi")
|
2012-10-06 19:09:20 +03:00
|
|
|
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
|
|
|
|
2012-07-01 17:27:41 +03:00
|
|
|
add_subdirectory(lib)
|
|
|
|
add_subdirectory(client)
|
|
|
|
add_subdirectory(server)
|
|
|
|
add_subdirectory(AI)
|
2012-08-10 11:49:18 +03:00
|
|
|
if (NOT DISABLE_ERM)
|
|
|
|
add_subdirectory(Scripting/ERM)
|
|
|
|
endif()
|
2013-02-17 00:14:36 +03:00
|
|
|
if (ENABLE_EDITOR)
|
|
|
|
add_subdirectory(Editor)
|
|
|
|
endif()
|
2012-07-19 21:52:44 +03:00
|
|
|
|
2012-10-05 15:38:17 +03:00
|
|
|
#######################################
|
|
|
|
# Installation section #
|
|
|
|
#######################################
|
|
|
|
|
2012-12-01 09:30:52 +03:00
|
|
|
# For apple this files will be already inside vcmiclient bundle
|
|
|
|
if (NOT APPLE)
|
|
|
|
# copy whole directory but .svn control files and user-specific settings.json
|
|
|
|
install(DIRECTORY config DESTINATION ${DATA_DIR} PATTERN ".svn" EXCLUDE PATTERN "settings.json" EXCLUDE)
|
|
|
|
# copy vcmi mod along with all its content
|
|
|
|
install(DIRECTORY Mods/vcmi DESTINATION ${DATA_DIR}/Mods PATTERN ".svn" EXCLUDE)
|
2012-12-12 18:13:26 +03:00
|
|
|
# copy only mod.json for WoG
|
|
|
|
install(FILES Mods/WoG/mod.json DESTINATION ${DATA_DIR}/Mods/WoG)
|
2012-12-03 19:00:17 +03:00
|
|
|
|
2012-12-10 23:08:00 +03:00
|
|
|
install(FILES vcmibuilder DESTINATION ${BIN_DIR} PERMISSIONS
|
|
|
|
OWNER_WRITE OWNER_READ OWNER_EXECUTE
|
|
|
|
GROUP_READ GROUP_EXECUTE
|
|
|
|
WORLD_READ WORLD_EXECUTE)
|
2012-12-01 09:30:52 +03:00
|
|
|
endif()
|
2012-10-05 15:38:17 +03:00
|
|
|
|
|
|
|
if(WIN32)
|
|
|
|
#TODO: install any additional dll's. This version (may be broken) will copy all dll's including H3 ones
|
|
|
|
#FILE(GLOB dll_files "${CMAKE_BINARY_DIR}/*.dll")
|
|
|
|
#INSTALL(FILES ${dll_files} DESTINATION ${BIN_DIR})
|
2012-12-01 09:30:52 +03:00
|
|
|
elseif(APPLE)
|
2012-10-05 15:38:17 +03:00
|
|
|
else()
|
|
|
|
#install icons and desktop file on Linux
|
2013-02-21 20:32:50 +03:00
|
|
|
install(FILES "${CMAKE_SOURCE_DIR}/client/icons/vcmiclient.64x64.png" DESTINATION share/icons/hicolor/64x64/apps RENAME vcmiclient.png)
|
|
|
|
install(FILES "${CMAKE_SOURCE_DIR}/client/icons/vcmiclient.48x48.png" DESTINATION share/icons/hicolor/48x48/apps RENAME vcmiclient.png)
|
|
|
|
install(FILES "${CMAKE_SOURCE_DIR}/client/icons/vcmiclient.32x32.png" DESTINATION share/icons/hicolor/32x32/apps RENAME vcmiclient.png)
|
2013-02-01 11:58:14 +03:00
|
|
|
install(FILES "${CMAKE_SOURCE_DIR}/client/icons/vcmiclient.256x256.png" DESTINATION share/icons/hicolor/256x256/apps RENAME vcmiclient.png)
|
2013-02-21 20:32:50 +03:00
|
|
|
install(FILES "${CMAKE_SOURCE_DIR}/client/icons/vcmiclient.desktop" DESTINATION share/applications)
|
2012-10-05 15:38:17 +03:00
|
|
|
endif()
|
|
|
|
|
|
|
|
#######################################
|
|
|
|
# Packaging section #
|
|
|
|
#######################################
|
|
|
|
|
2013-02-21 20:32:50 +03:00
|
|
|
set(CPACK_PACKAGE_VERSION_MAJOR ${VCMI_VERSION_MAJOR})
|
|
|
|
set(CPACK_PACKAGE_VERSION_MINOR ${VCMI_VERSION_MINOR})
|
|
|
|
set(CPACK_PACKAGE_VERSION_PATCH ${VCMI_VERSION_PATCH})
|
2012-10-05 15:38:17 +03:00
|
|
|
|
|
|
|
# vcmi does not have "patch version" in version string
|
|
|
|
set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}")
|
|
|
|
#TODO: remove version from Global.h and use this one as define?
|
|
|
|
|
|
|
|
set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY 0)
|
|
|
|
|
|
|
|
if(WIN32)
|
|
|
|
set(CPACK_GENERATOR ZIP) # just use zip? CPack has some GUI install as well
|
2012-12-01 09:30:52 +03:00
|
|
|
elseif(APPLE)
|
|
|
|
set(CPACK_GENERATOR DragNDrop)
|
2012-12-27 12:21:30 +03:00
|
|
|
set(CPACK_DMG_BACKGROUND_IMAGE "${CMAKE_SOURCE_DIR}/osx/dmg_background.png")
|
|
|
|
set(CPACK_DMG_DS_STORE "${CMAKE_SOURCE_DIR}/osx/dmg_DS_Store")
|
2012-10-05 15:38:17 +03:00
|
|
|
else()
|
|
|
|
set(CPACK_GENERATOR TGZ)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
INCLUDE(CPack)
|
|
|
|
|