2022-10-09 12:31:01 +02:00
|
|
|
cmake_minimum_required(VERSION 3.5)
|
|
|
|
# Set policies up to 3.9 since we want to enable the IPO option
|
|
|
|
if(${CMAKE_VERSION} VERSION_LESS 3.9)
|
|
|
|
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
|
|
|
|
else()
|
|
|
|
cmake_policy(VERSION 3.9)
|
|
|
|
endif()
|
2013-04-15 14:42:24 +02:00
|
|
|
|
|
|
|
# This can be read from ${PROJECT_NAME} after project() is called
|
2014-07-12 14:38:12 +02:00
|
|
|
project(voxelands)
|
2022-10-09 12:31:01 +02:00
|
|
|
set(PROJECT_NAME_CAPITALIZED "Voxelands")
|
2013-04-15 14:42:24 +02:00
|
|
|
|
|
|
|
# Also remember to set PROTOCOL_VERSION in clientserver.h when releasing
|
2022-10-09 12:31:01 +02:00
|
|
|
set(VERSION_MAJOR 2210)
|
2017-04-08 10:44:05 +02:00
|
|
|
set(VERSION_MINOR 00)
|
2022-10-09 12:31:01 +02:00
|
|
|
set(VERSION_EXTRA "" CACHE STRING "Stuff to append to version string")
|
|
|
|
|
|
|
|
# Change to false for releases
|
|
|
|
set(DEVELOPMENT_BUILD TRUE)
|
|
|
|
|
2017-09-24 06:59:00 +02:00
|
|
|
set(VERSION_STRING "${VERSION_MAJOR}.${VERSION_MINOR}")
|
2022-10-09 12:31:01 +02:00
|
|
|
if(VERSION_EXTRA)
|
|
|
|
set(VERSION_STRING "${VERSION_STRING}-${VERSION_EXTRA}")
|
|
|
|
elseif(DEVELOPMENT_BUILD)
|
|
|
|
set(VERSION_STRING "${VERSION_STRING}-dev")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (CMAKE_BUILD_TYPE STREQUAL Debug)
|
|
|
|
# Append "-debug" to version string
|
|
|
|
set(VERSION_STRING "${VERSION_STRING}-debug")
|
|
|
|
endif()
|
|
|
|
|
2013-04-15 14:42:24 +02:00
|
|
|
MESSAGE(STATUS "*** Will build version ${VERSION_STRING} ***")
|
|
|
|
|
|
|
|
# Configuration options
|
2022-10-09 12:31:01 +02:00
|
|
|
set(DEFAULT_RUN_IN_PLACE FALSE)
|
2013-04-15 14:42:24 +02:00
|
|
|
if(WIN32)
|
2022-10-09 12:31:01 +02:00
|
|
|
set(DEFAULT_RUN_IN_PLACE TRUE)
|
2013-04-15 14:42:24 +02:00
|
|
|
endif()
|
2022-10-09 12:31:01 +02:00
|
|
|
set(RUN_IN_PLACE ${DEFAULT_RUN_IN_PLACE} CACHE BOOL
|
|
|
|
"Run directly in source directory structure")
|
2013-04-15 14:42:24 +02:00
|
|
|
|
2022-10-09 12:31:01 +02:00
|
|
|
set(BUILD_CLIENT TRUE CACHE BOOL "Build client")
|
|
|
|
set(BUILD_SERVER FALSE CACHE BOOL "Build server")
|
|
|
|
# set(BUILD_UNITTESTS TRUE CACHE BOOL "Build unittests")
|
|
|
|
# set(BUILD_BENCHMARKS FALSE CACHE BOOL "Build benchmarks")
|
2013-04-15 14:42:24 +02:00
|
|
|
|
2016-01-08 01:28:26 +01:00
|
|
|
# conf options for building fresh voxelands.icns from voxelands.svg if a new icon is made.
|
2022-10-09 12:31:01 +02:00
|
|
|
set(REBUILD_ICNS FALSE CACHE BOOL "Rebuild icns from voxelands.svg .")
|
2016-01-08 01:28:26 +01:00
|
|
|
|
2022-10-09 12:31:01 +02:00
|
|
|
set(CPU_OPTS FALSE CACHE BOOL "Enable CPU optimizations")
|
2016-05-15 04:13:33 +02:00
|
|
|
set(CPUTYPE native CACHE STRING "CPU to optimize for")
|
2022-10-09 12:31:01 +02:00
|
|
|
set(ENABLE_SSP TRUE CACHE BOOL "Enable stack smashing protection")
|
|
|
|
set(ENABLE_SAFESTACK TRUE CACHE BOOL "Enable SafeStack if supported (LLVM only)")
|
|
|
|
set(ENABLE_PIE FALSE CACHE BOOL "Produce a Position Independent Executable")
|
2015-03-22 01:14:59 +01:00
|
|
|
|
2013-04-15 14:42:24 +02:00
|
|
|
if(NOT CMAKE_BUILD_TYPE)
|
|
|
|
# Default to release
|
|
|
|
set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type: Debug or Release" FORCE)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Included stuff
|
|
|
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
|
|
|
|
include(${CMAKE_SOURCE_DIR}/cmake/Modules/misc.cmake)
|
|
|
|
|
|
|
|
# This is done here so that relative search paths are more reasnable
|
|
|
|
find_package(Irrlicht)
|
|
|
|
|
|
|
|
#
|
|
|
|
# Installation
|
|
|
|
#
|
|
|
|
|
|
|
|
if(WIN32)
|
2014-09-26 20:50:18 +02:00
|
|
|
set(SHAREDIR "data")
|
2013-04-15 14:42:24 +02:00
|
|
|
set(BINDIR "bin")
|
|
|
|
set(DOCDIR "doc")
|
|
|
|
set(EXAMPLE_CONF_DIR ".")
|
|
|
|
elseif(APPLE)
|
|
|
|
# random placeholders
|
2014-09-26 20:50:18 +02:00
|
|
|
set(SHAREDIR "share/${PROJECT_NAME}")
|
2013-04-15 14:42:24 +02:00
|
|
|
set(BINDIR "bin")
|
|
|
|
set(DOCDIR "share/doc/${PROJECT_NAME}")
|
2014-09-26 20:50:18 +02:00
|
|
|
set(EXAMPLE_CONF_DIR ${DOCDIR})
|
2013-04-15 14:42:24 +02:00
|
|
|
elseif(UNIX) # Linux, BSD etc
|
2014-09-26 20:50:18 +02:00
|
|
|
if(RUN_IN_PLACE)
|
|
|
|
set(SHAREDIR "share/${PROJECT_NAME}")
|
|
|
|
set(BINDIR "bin")
|
|
|
|
set(DOCDIR "share/doc/${PROJECT_NAME}")
|
|
|
|
set(MANDIR "share/man")
|
|
|
|
set(EXAMPLE_CONF_DIR ${DOCDIR})
|
|
|
|
set(XDG_APPS_DIR "share/applications")
|
2016-01-08 01:28:26 +01:00
|
|
|
set(APPDATADIR "share/appdata")
|
2014-09-26 20:50:18 +02:00
|
|
|
set(ICONDIR "share/icons")
|
|
|
|
set(LOCALEDIR "share/${PROJECT_NAME}/locale")
|
|
|
|
else()
|
|
|
|
set(SHAREDIR "${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}")
|
|
|
|
set(BINDIR "${CMAKE_INSTALL_PREFIX}/bin")
|
|
|
|
set(DOCDIR "${CMAKE_INSTALL_PREFIX}/share/doc/${PROJECT_NAME}")
|
|
|
|
set(MANDIR "${CMAKE_INSTALL_PREFIX}/share/man")
|
|
|
|
set(EXAMPLE_CONF_DIR ${DOCDIR})
|
|
|
|
set(XDG_APPS_DIR "${CMAKE_INSTALL_PREFIX}/share/applications")
|
2016-01-08 01:28:26 +01:00
|
|
|
set(APPDATADIR "${CMAKE_INSTALL_PREFIX}/share/appdata")
|
2014-09-26 20:50:18 +02:00
|
|
|
set(ICONDIR "${CMAKE_INSTALL_PREFIX}/share/icons")
|
|
|
|
set(LOCALEDIR "${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}/locale")
|
|
|
|
endif()
|
2013-04-15 14:42:24 +02:00
|
|
|
endif()
|
|
|
|
|
|
|
|
install(FILES "README.txt" DESTINATION "${DOCDIR}")
|
|
|
|
install(FILES "doc/changelog.txt" DESTINATION "${DOCDIR}")
|
2017-09-06 11:30:20 +02:00
|
|
|
install(FILES "doc/example.cfg" DESTINATION "${DOCDIR}")
|
2014-09-26 20:50:18 +02:00
|
|
|
if (APPLE)
|
|
|
|
install(DIRECTORY "libs/" DESTINATION "libs")
|
|
|
|
endif()
|
|
|
|
if (UNIX AND NOT APPLE)
|
|
|
|
install(FILES "doc/voxelands.6" "doc/voxelands-server.6" DESTINATION "${MANDIR}/man6")
|
2014-10-22 05:31:03 +02:00
|
|
|
install(FILES "misc/freedesktop/voxelands.desktop" DESTINATION "${XDG_APPS_DIR}")
|
2016-01-08 01:28:26 +01:00
|
|
|
install(FILES "misc/voxelands.appdata.xml" DESTINATION "${APPDATADIR}")
|
2014-10-22 05:31:03 +02:00
|
|
|
install(FILES "misc/freedesktop/icons/scalable/apps/voxelands.svg" DESTINATION "${ICONDIR}/hicolor/scalable/apps")
|
|
|
|
install(FILES "misc/freedesktop/icons/192x192/apps/voxelands.png" DESTINATION "${ICONDIR}/hicolor/192x192/apps")
|
|
|
|
install(FILES "misc/freedesktop/icons/128x128/apps/voxelands.png" DESTINATION "${ICONDIR}/hicolor/128x128/apps")
|
|
|
|
install(FILES "misc/freedesktop/icons/64x64/apps/voxelands.png" DESTINATION "${ICONDIR}/hicolor/64x64/apps")
|
|
|
|
install(FILES "misc/freedesktop/icons/48x48/apps/voxelands.png" DESTINATION "${ICONDIR}/hicolor/48x48/apps")
|
|
|
|
install(FILES "misc/freedesktop/icons/32x32/apps/voxelands.png" DESTINATION "${ICONDIR}/hicolor/32x32/apps")
|
|
|
|
install(FILES "misc/freedesktop/icons/24x24/apps/voxelands.png" DESTINATION "${ICONDIR}/hicolor/24x24/apps")
|
|
|
|
install(FILES "misc/freedesktop/icons/22x22/apps/voxelands.png" DESTINATION "${ICONDIR}/hicolor/22x22/apps")
|
|
|
|
install(FILES "misc/freedesktop/icons/16x16/apps/voxelands.png" DESTINATION "${ICONDIR}/hicolor/16x16/apps")
|
2014-09-26 20:50:18 +02:00
|
|
|
endif()
|
2013-04-15 14:42:24 +02:00
|
|
|
#
|
|
|
|
# Subdirectories
|
|
|
|
# Be sure to add all relevant definitions above this
|
|
|
|
#
|
|
|
|
|
|
|
|
add_subdirectory(src)
|
|
|
|
|
|
|
|
# CPack
|
|
|
|
|
2014-07-12 14:38:12 +02:00
|
|
|
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "The Fun-Focused Free Software Voxel World Game")
|
2016-08-28 02:38:57 +02:00
|
|
|
set(CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR})
|
|
|
|
set(CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR})
|
2022-10-09 12:31:01 +02:00
|
|
|
set(CPACK_PACKAGE_VENDOR "rudzik8")
|
|
|
|
set(CPACK_PACKAGE_CONTACT "Mikita Wisniewski <rudzik8@protonmail.com>")
|
2013-04-15 14:42:24 +02:00
|
|
|
|
|
|
|
if(WIN32)
|
2022-10-09 12:31:01 +02:00
|
|
|
# Include all dynamically linked runtime libaries such as MSVCRxxx.dll
|
|
|
|
include(InstallRequiredSystemLibraries)
|
|
|
|
|
|
|
|
if(RUN_IN_PLACE)
|
|
|
|
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
|
|
|
set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${VERSION_STRING}-win64")
|
|
|
|
else()
|
|
|
|
set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${VERSION_STRING}-win32")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set(CPACK_GENERATOR ZIP)
|
|
|
|
|
|
|
|
else()
|
|
|
|
set(CPACK_GENERATOR WIX)
|
|
|
|
set(CPACK_PACKAGE_NAME "${PROJECT_NAME_CAPITALIZED}")
|
|
|
|
set(CPACK_PACKAGE_INSTALL_DIRECTORY ".")
|
|
|
|
set(CPACK_PACKAGE_EXECUTABLES ${PROJECT_NAME} "${PROJECT_NAME_CAPITALIZED}")
|
|
|
|
set(CPACK_CREATE_DESKTOP_LINKS ${PROJECT_NAME})
|
|
|
|
set(CPACK_PACKAGING_INSTALL_PREFIX "/${PROJECT_NAME_CAPITALIZED}")
|
|
|
|
|
|
|
|
set(CPACK_WIX_PRODUCT_ICON "${CMAKE_CURRENT_SOURCE_DIR}/voxelands-icon.ico")
|
|
|
|
# Supported languages can be found at
|
|
|
|
# http://wixtoolset.org/documentation/manual/v3/wixui/wixui_localization.html
|
|
|
|
#set(CPACK_WIX_CULTURES "ar-SA,bg-BG,ca-ES,hr-HR,cs-CZ,da-DK,nl-NL,en-US,et-EE,fi-FI,fr-FR,de-DE")
|
|
|
|
set(CPACK_WIX_UI_BANNER "${CMAKE_CURRENT_SOURCE_DIR}/misc/CPACK_WIX_UI_BANNER.BMP")
|
|
|
|
set(CPACK_WIX_UI_DIALOG "${CMAKE_CURRENT_SOURCE_DIR}/misc/CPACK_WIX_UI_DIALOG.BMP")
|
|
|
|
|
|
|
|
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/doc/gpl-3.0.txt")
|
|
|
|
|
|
|
|
# The correct way would be to include both x32 and x64 into one installer
|
|
|
|
# and install the appropriate one.
|
|
|
|
# CMake does not support that, so there are two separate GUID's
|
|
|
|
#if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
|
|
|
# set(CPACK_WIX_UPGRADE_GUID "745A0FB3-5552-44CA-A587-A91C397CCC56")
|
|
|
|
#else()
|
|
|
|
# set(CPACK_WIX_UPGRADE_GUID "814A2E2D-2779-4BBD-9ACD-FC3BD51FBBA2")
|
|
|
|
#endif()
|
|
|
|
endif()
|
2013-04-15 14:42:24 +02:00
|
|
|
elseif(APPLE)
|
|
|
|
# TODO
|
|
|
|
# see http://cmake.org/Wiki/CMake:CPackPackageGenerators#Bundle_.28OSX_only.29
|
|
|
|
#
|
2014-09-25 18:16:02 +02:00
|
|
|
set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${VERSION_STRING}-osx-${CMAKE_OSX_ARCHITECTURES}")
|
2014-09-02 17:45:14 +02:00
|
|
|
set(CPACK_PACKAGE_ICON ${CMAKE_CURRENT_SOURCE_DIR}/misc/mac/voxelands.icns)
|
2013-04-15 14:42:24 +02:00
|
|
|
set(CPACK_BUNDLE_NAME ${PROJECT_NAME})
|
2014-09-02 17:45:14 +02:00
|
|
|
set(CPACK_BUNDLE_ICON ${CPACK_PACKAGE_ICON})
|
|
|
|
set(CPACK_BUNDLE_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/misc/mac/Info.plist)
|
|
|
|
set(CPACK_BUNDLE_STARTUP_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/bin/Debug/voxelands)
|
2013-04-15 14:42:24 +02:00
|
|
|
set(CPACK_GENERATOR "Bundle")
|
|
|
|
else()
|
|
|
|
set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${VERSION_STRING}-linux")
|
|
|
|
set(CPACK_GENERATOR TGZ)
|
|
|
|
set(CPACK_SOURCE_GENERATOR TGZ)
|
2015-04-28 03:55:16 +02:00
|
|
|
SET ( CPACK_DEBIAN_PACKAGE_SECTION "other" )
|
|
|
|
SET ( CPACK_DEBIAN_PACKAGE_PRIORITY "optional" )
|
2022-10-09 12:31:01 +02:00
|
|
|
SET ( CPACK_DEBIAN_PACKAGE_MAINTAINER "Mikita Wisniewski <rudzik8@protonmail.com>" )
|
2015-04-28 03:55:16 +02:00
|
|
|
SET ( CPACK_GENERATOR "DEB;RPM" )
|
|
|
|
|
2013-04-15 14:42:24 +02:00
|
|
|
endif()
|
|
|
|
|
|
|
|
include(CPack)
|