2017-09-22 23:36:31 -07:00
CMAKE_MINIMUM_REQUIRED ( VERSION 2.8.2 )
2018-05-07 09:28:35 -05:00
PROJECT ( ZetaGlest )
2010-06-05 17:34:55 +00:00
2012-03-14 21:52:13 +00:00
#SET(CMAKE_VERBOSE_MAKEFILE ON)
2010-12-12 08:10:18 +00:00
#
# *NOTE: For now we assume some variation of GCC Compiler (or MingW for Windows binaries)
2018-05-07 09:28:35 -05:00
# VC++ users should not use CMake yet but rather the build-zg.bat file in mk/windows
2010-12-12 08:10:18 +00:00
#
2015-09-22 00:52:09 +02:00
# build type
IF ( NOT CMAKE_BUILD_TYPE )
SET ( CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose build type: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel." FORCE )
ENDIF ( )
SET_PROPERTY ( CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS None Debug Release RelWithDebInfo MinSizeRel )
2010-12-12 08:10:18 +00:00
2015-10-07 21:12:04 +02:00
IF ( NOT CMAKE_VERSION VERSION_LESS "3.1" )
2015-09-27 19:46:35 +02:00
cmake_policy ( SET CMP0054 NEW )
ENDIF ( )
2010-12-12 08:10:18 +00:00
# add additional CMake modules
2013-11-19 16:23:31 +00:00
MESSAGE ( STATUS "CMAKE_SOURCE_DIR = ${CMAKE_SOURCE_DIR}" )
2010-12-12 08:10:18 +00:00
list ( APPEND CMAKE_MODULE_PATH ${ CMAKE_SOURCE_DIR } /mk/cmake/Modules )
2015-01-25 09:01:23 +01:00
IF ( CMAKE_BUILD_TYPE )
MESSAGE ( STATUS "Build type for this compile will be: ${CMAKE_BUILD_TYPE}" )
ENDIF ( )
2013-11-19 08:04:38 +00:00
IF ( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" )
2017-10-07 08:59:27 -07:00
SET ( CMAKE_COMPILER_IS_GNUCXX "YES" )
2014-02-06 19:14:14 -08:00
# ADD_DEFINITIONS("-Qunused-arguments -Wno-switch")
2017-10-07 08:59:27 -07:00
ADD_DEFINITIONS ( "-Wno-switch" )
2013-11-19 08:04:38 +00:00
ENDIF ( )
2018-05-07 09:28:35 -05:00
OPTION ( BUILD_ZETAGLEST_MODEL_IMPORT_EXPORT_TOOLS "Build model import/export tools" ON )
OPTION ( BUILD_ZETAGLEST_MODEL_VIEWER "Build model viewer" ON )
OPTION ( BUILD_ZETAGLEST_MAP_EDITOR "Build map editor" ON )
OPTION ( BUILD_ZETAGLEST "Build ZetaGlest" ON )
OPTION ( BUILD_ZETAGLEST_TESTS "Build ZetaGlest Unit Tests" OFF )
2015-09-27 19:46:35 +02:00
OPTION ( WANT_SINGLE_INSTALL_DIRECTORY "Use single install directory for everything. It is useful for example for MacOS cpack bundles." OFF )
2015-09-22 00:52:09 +02:00
OPTION ( WANT_STATIC_LIBS "Builds as many static libs as possible." OFF )
2015-09-27 19:46:35 +02:00
OPTION ( WANT_USE_VLC "Use libVLC to play videos." ON )
OPTION ( WANT_USE_OpenSSL "Use libOpenSSL during CURL linking." ON )
OPTION ( WANT_USE_FriBiDi "Enable libFriBIDi support." ON )
OPTION ( WANT_USE_GoogleBreakpad "Enable GoogleBreakpad support." ON )
OPTION ( WANT_USE_STREFLOP "Use the library streflop." ON )
OPTION ( WANT_USE_XercesC "Enable libXercesC support." OFF )
2011-10-17 16:59:22 +00:00
2011-12-15 18:01:07 +00:00
FIND_PROGRAM ( HELP2MAN "help2man" )
set ( XVFB_EXEC "" )
find_program ( XVFB_RUN NAMES "xvfb-run" )
if ( NOT ${ XVFB_RUN } MATCHES "XVFB_RUN-NOTFOUND" )
set ( XVFB_EXEC ${ XVFB_RUN } )
message ( STATUS "Using xvfb-run to run man2help." )
endif ( )
2015-09-22 00:52:09 +02:00
MARK_AS_ADVANCED ( HELP2MAN XVFB_RUN )
2011-12-15 18:01:07 +00:00
2015-09-22 00:52:09 +02:00
include ( ${ CMAKE_SOURCE_DIR } /mk/cmake/Modules/SpecialMacros.cmake )
2015-09-27 19:46:35 +02:00
include ( ${ CMAKE_SOURCE_DIR } /mk/cmake/Modules/ReqVersAndStaticConf.cmake )
2017-03-20 17:06:12 -07:00
MESSAGE ( STATUS "=====================================================================" )
2011-12-15 18:01:07 +00:00
2018-05-07 09:28:35 -05:00
SET ( PKG_NAME "zetaglest" )
2013-01-03 21:57:58 +00:00
# read version
2018-05-07 09:28:35 -05:00
FILE ( READ ${ PROJECT_SOURCE_DIR } /source/glest_game/facilities/game_util.cpp ZG_VERSION_H_CONTENTS )
2013-03-05 19:56:23 +00:00
MESSAGE ( STATUS "Determining version number system type to use:" )
2015-01-25 09:01:23 +01:00
SET ( Begin_otv_string "string glestVersionString" )
2018-05-07 09:28:35 -05:00
STRING ( REGEX MATCH "${Begin_otv_string}[ \t]*=[ \t]*\" [ \t]*v[ \t]*([0-9][^\\.]*)(\\.)([^\\.]*)(\\.)([^\"\\.;]*)\";" _threePartMatch "${ZG_VERSION_H_CONTENTS}" )
STRING ( REGEX MATCH "${Begin_otv_string}[ \t]*=[ \t]*\" [ \t]*v[ \t]*([0-9][^\\.]*)(\\.)([^\"\\.;]*)\";" _twoPartMatch "${ZG_VERSION_H_CONTENTS}" )
STRING ( REGEX MATCH "${Begin_otv_string}[ \t]*=[ \t]*\" [ \t]*v[ \t]*([0-9][^\"\\.;]*)\";" _onePartMatch "${ZG_VERSION_H_CONTENTS}" )
2015-01-25 09:01:23 +01:00
IF ( _threePartMatch )
MESSAGE ( STATUS "** Trying 3 part versioning " )
STRING ( REGEX REPLACE "[^=]*=[ \t]*\" [ \t]*v[ \t]*([0-9][^\\.]*)\\.[^\\.]*\\..*" "\\1" VER_MAJOR "${_threePartMatch}" )
STRING ( REGEX REPLACE "[^=]*=[ \t]*\" [ \t]*v[ \t]*[0-9][^\\.]*\\.([^\\.]*)\\..*" "\\1" VER_MINOR "${_threePartMatch}" )
STRING ( REGEX REPLACE "[^=]*=[ \t]*\" [ \t]*v[ \t]*[0-9][^\\.]*\\.[^\\.]*\\.([^\"\\.;]*).*" "\\1" VER_PATCH "${_threePartMatch}" )
2018-05-07 09:28:35 -05:00
SET ( ZETAGLEST_VERSION "${VER_MAJOR}.${VER_MINOR}.${VER_PATCH}" )
2015-01-25 09:01:23 +01:00
ELSEIF ( _twoPartMatch )
MESSAGE ( STATUS "** Trying 2 part versioning " )
STRING ( REGEX REPLACE "[^=]*=[ \t]*\" [ \t]*v[ \t]*([0-9][^\\.]*)\\..*" "\\1" VER_MAJOR "${_twoPartMatch}" )
STRING ( REGEX REPLACE "[^=]*=[ \t]*\" [ \t]*v[ \t]*[0-9][^\\.]*\\.([^\"\\.;]*).*" "\\1" VER_MINOR "${_twoPartMatch}" )
SET ( VER_PATCH "0" )
2018-05-07 09:28:35 -05:00
SET ( ZETAGLEST_VERSION "${VER_MAJOR}.${VER_MINOR}" )
2015-01-25 09:01:23 +01:00
ELSEIF ( _onePartMatch )
MESSAGE ( STATUS "** Trying 1 part versioning " )
STRING ( REGEX REPLACE "[^=]*=[ \t]*\" [ \t]*v[ \t]*([0-9][^\"\\.;]*).*" "\\1" VER_MAJOR "${_onePartMatch}" )
SET ( VER_MINOR "0" )
SET ( VER_PATCH "0" )
2018-05-07 09:28:35 -05:00
SET ( ZETAGLEST_VERSION "${VER_MAJOR}" )
2015-01-25 09:01:23 +01:00
ENDIF ( )
2018-05-07 09:28:35 -05:00
FOREACH ( ver_var VER_MAJOR;VER_MINOR;VER_PATCH;ZETAGLEST_VERSION )
2015-01-25 09:01:23 +01:00
STRING ( REGEX REPLACE "[ \t]" "" "${ver_var}" "${${ver_var}}" )
ENDFOREACH ( )
2018-05-07 09:28:35 -05:00
MESSAGE ( STATUS "Detected ZetaGlest Version is [v${ZETAGLEST_VERSION}] " )
2013-01-03 21:57:58 +00:00
2015-01-31 12:01:41 +01:00
SET ( PIC_FLAG "${PIC_FLAG} -fPIC" )
IF ( WANT_STATIC_LIBS AND "${CMAKE_SIZEOF_VOID_P}" EQUAL "8" )
# CMAKE_SIZEOF_VOID_P=8 => 64bit
ADD_DEFINITIONS ( "${PIC_FLAG}" )
ENDIF ( )
2014-12-22 22:24:46 +11:00
## Compiler flags, CPACK configuration and other Apple specific code.
2013-12-04 22:38:06 +01:00
IF ( APPLE )
2016-11-18 02:07:44 +01:00
include ( ${ PROJECT_SOURCE_DIR } /mk/macos/CMakeLists.txt )
2013-12-04 22:38:06 +01:00
ENDIF ( APPLE )
2010-12-12 08:10:18 +00:00
IF ( CMAKE_COMPILER_IS_GNUCXX OR MINGW )
2017-10-07 08:59:27 -07:00
IF ( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" )
MESSAGE ( STATUS "Detected CLANG Compiler..." )
2013-11-19 08:04:38 +00:00
ELSEIF ( CMAKE_COMPILER_IS_GNUCXX )
2010-12-12 08:10:18 +00:00
MESSAGE ( STATUS "Detected GNUC Compiler..." )
ELSEIF ( MINGW )
MESSAGE ( STATUS "Detected MINGW Compiler..." )
ENDIF ( )
2017-10-07 08:59:27 -07:00
# Common generic GNU type compiler options that work with all generic GCC compatible compilers
ADD_DEFINITIONS ( "-Wuninitialized -Wsign-compare -Wunused-function -Wunused-variable -Wreturn-type -fno-strict-aliasing" )
2014-02-06 19:14:14 -08:00
2011-01-06 23:31:07 +00:00
# For gcc warning options see: http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
2011-01-02 10:29:13 +00:00
IF ( NOT MINGW )
2011-01-06 23:31:07 +00:00
# For tons of verbose warnings add: -Wall
2011-12-23 04:51:44 +00:00
# ADD_DEFINITIONS("-Wreturn-type -fno-strict-aliasing -frounding-math -fsignaling-nans -mfpmath=sse -msse -rdynamic")
2014-02-06 19:14:14 -08:00
# ADD_DEFINITIONS("-Wuninitialized -Wsign-compare -Wunused-function -Wunused-variable -Wreturn-type -fno-strict-aliasing -frounding-math -fsignaling-nans -rdynamic")
2011-01-02 10:29:13 +00:00
ELSE ( )
2011-12-23 04:51:44 +00:00
# ADD_DEFINITIONS("-Wreturn-type -fno-strict-aliasing -frounding-math -fsignaling-nans -mfpmath=sse -msse -DUNICODE")
2014-02-06 19:14:14 -08:00
# ADD_DEFINITIONS("-Wuninitialized -Wsign-compare -Wunused-function -Wunused-variable -Wreturn-type -fno-strict-aliasing -frounding-math -fsignaling-nans -DUNICODE")
2017-10-07 08:59:27 -07:00
ADD_DEFINITIONS ( "-DUNICODE" )
2011-01-02 10:29:13 +00:00
ENDIF ( )
2014-02-06 19:14:14 -08:00
2017-10-07 08:59:27 -07:00
# CLang specific Compiler Options
IF ( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" )
2014-02-06 19:14:14 -08:00
2017-10-07 08:59:27 -07:00
# GCC specific Compiler Options
ELSE ( )
2018-06-16 23:54:26 -05:00
ADD_DEFINITIONS ( "-frounding-math -fsignaling-nans" )
2014-02-06 19:14:14 -08:00
# IF(NOT MINGW)
# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -rdynamic")
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -rdynamic")
# ENDIF()
2017-10-07 08:59:27 -07:00
ENDIF ( )
2014-02-06 19:14:14 -08:00
2018-01-14 11:17:14 -06:00
#SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
2017-10-07 08:59:27 -07:00
#MESSAGE(STATUS "*TEST: Checking for max SSE LEVEL [${FORCE_MAX_SSE_LEVEL}]")
2012-02-10 06:21:06 +00:00
2015-09-27 19:46:35 +02:00
OPTION ( FORCE_STREFLOP_SOFTWRAPPER "Set the streflop library to be forced to use the software emulator" OFF )
2017-10-07 08:59:27 -07:00
IF ( NOT FORCE_MAX_SSE_LEVEL AND NOT FORCE_STREFLOP_SOFTWRAPPER )
SET ( FORCE_MAX_SSE_LEVEL "1" CACHE STRING "Set the max SSE level to use if supported (0-3)" )
ENDIF ( )
2012-02-10 06:21:06 +00:00
2017-10-07 08:59:27 -07:00
IF ( NOT FORCE_STREFLOP_SOFTWRAPPER )
MESSAGE ( STATUS "*NOTE: Checking for max SSE LEVEL [${FORCE_MAX_SSE_LEVEL}]" )
special_check_for_sse ( ${ FORCE_MAX_SSE_LEVEL } )
ENDIF ( )
2011-12-24 03:20:21 +00:00
2015-09-27 19:46:35 +02:00
IF ( WANT_USE_STREFLOP )
2012-02-10 06:21:06 +00:00
ADD_DEFINITIONS ( "-DUSE_STREFLOP -DSTREFLOP_RANDOM_GEN_SIZE=32 -DLIBM_COMPILING_FLT32 -DN_SPECIALIZED=32" )
2011-12-24 03:20:21 +00:00
2017-10-07 08:59:27 -07:00
IF ( HAS_SSE_EXTENSIONS AND NOT ${ FORCE_MAX_SSE_LEVEL } MATCHES "0" AND NOT FORCE_STREFLOP_SOFTWRAPPER )
ADD_DEFINITIONS ( "-DSTREFLOP_SSE" )
MESSAGE ( STATUS "*NOTE: using SSE for STREFLOP." )
ELSE ( )
IF ( NOT FORCE_STREFLOP_SOFTWRAPPER )
special_check_for_x87 ( )
ENDIF ( )
IF ( HAS_X87_SUPPORT AND NOT FORCE_STREFLOP_SOFTWRAPPER )
ADD_DEFINITIONS ( "-DSTREFLOP_X87" )
MESSAGE ( STATUS "*NOTE: using X87 for STREFLOP." )
ELSE ( )
ADD_DEFINITIONS ( "-DSTREFLOP_SOFT" )
MESSAGE ( STATUS "*NOTE: using SOFT emulation for STREFLOP." )
ENDIF ( )
ENDIF ( )
2011-12-24 03:20:21 +00:00
ELSE ( )
MESSAGE ( STATUS "*WARNING: Disabled use of STREFLOP! Out of synchs may occur" )
ENDIF ( )
2010-12-12 08:10:18 +00:00
2012-04-16 19:29:37 +00:00
include ( CheckCXXSourceRuns )
check_cxx_source_runs ( "
#include <execinfo.h>
#include <stdio.h>
i n t main ( )
{
c o n s t s i z e _ t m a x _ d e p t h = 6 ;
v o i d * s t a c k _ a d d r s [ m a x _ d e p t h ] ;
s i z e _ t s t a c k _ d e p t h = backtrace ( stack_addrs, max_depth ) ;
} "
H A S _ G C C _ B A C K T R A C E )
IF ( HAS_GCC_BACKTRACE )
2017-10-07 08:59:27 -07:00
message ( STATUS "Found GCC backtrace lib, will support backtraces" )
ADD_DEFINITIONS ( -DHAS_GCC_BACKTRACE )
2012-04-16 19:29:37 +00:00
ELSE ( )
2017-10-07 08:59:27 -07:00
message ( STATUS "**WARNING DID NOT Find GCC backtrace lib" )
2012-04-16 19:29:37 +00:00
ENDIF ( )
2010-12-12 08:10:18 +00:00
# Debug compiler flags
SET ( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g3" )
# Release compiler flags
2010-12-25 21:23:20 +00:00
SET ( CMAKE_CXX_FLAGS_RELEASE "-O3 ${CMAKE_CXX_FLAGS_RELEASE} -O3 " )
2015-09-22 00:52:09 +02:00
IF ( NOT CMAKE_GENERATOR STREQUAL Xcode )
2014-12-15 20:31:24 +11:00
SET ( CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -s" ) ## Strip binary
ENDIF ( )
2010-12-12 08:10:18 +00:00
# Release with debug info compiler flags
2015-09-22 00:52:09 +02:00
SET ( CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 ${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -g -O3 " )
2010-12-12 08:10:18 +00:00
# Release minimum size compiler flags
2015-09-22 00:52:09 +02:00
IF ( NOT CMAKE_GENERATOR STREQUAL Xcode )
SET ( CMAKE_EXE_LINKER_FLAGS_MINSIZEREL "${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL} -s" ) ## Strip binary
2014-12-15 20:31:24 +11:00
ENDIF ( )
2010-12-12 08:10:18 +00:00
2018-05-07 09:28:35 -05:00
# see if this fixes compile issue for tomreyn: libpthread.so.0: error adding symbols: DSO missing from command line
IF ( UNIX )
MESSAGE ( STATUS "*NOTE: Apply fix for: libpthread.so.0: error adding symbols: DSO missing from command line" )
set ( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pthread" )
set ( CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -pthread" )
SET ( CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -pthread" )
SET ( CMAKE_EXE_LINKER_FLAGS_MINSIZEREL "${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL} -pthread" )
2014-12-07 15:43:04 +11:00
ENDIF ( )
2010-12-12 08:10:18 +00:00
2017-04-01 14:53:34 +02:00
SET ( COMMON_INFO_ABOUT_PATH "(if the path is relative then is appended to the CMAKE_INSTALL_PREFIX)" )
2011-05-03 23:34:25 +00:00
IF ( CMAKE_INSTALL_PREFIX STREQUAL "" )
MESSAGE ( STATUS "*NOTE: NOT USING a Custom Data Install Path..." )
ELSE ( )
2018-05-07 09:28:35 -05:00
IF ( WANT_SINGLE_INSTALL_DIRECTORY AND NOT ZETAGLEST_SINGLE_DIRECTORY_INSTALL_PATH )
SET ( ZETAGLEST_SINGLE_DIRECTORY_INSTALL_PATH "zetaglest-game/" CACHE STRING "The single directory installation path for game ${COMMON_INFO_ABOUT_PATH}" )
2015-02-23 20:19:49 +01:00
ENDIF ( )
2018-05-07 09:28:35 -05:00
IF ( NOT ZETAGLEST_BIN_INSTALL_PATH AND NOT WANT_SINGLE_INSTALL_DIRECTORY )
SET ( ZETAGLEST_BIN_INSTALL_PATH "bin/" CACHE STRING "The installation path for binaries ${COMMON_INFO_ABOUT_PATH}" )
2011-05-14 17:31:40 +00:00
ENDIF ( )
2018-05-07 09:28:35 -05:00
IF ( NOT ZETAGLEST_DATA_INSTALL_PATH AND NOT WANT_SINGLE_INSTALL_DIRECTORY )
SET ( ZETAGLEST_DATA_INSTALL_PATH "share/zetaglest/" CACHE STRING "The installation path for data files ${COMMON_INFO_ABOUT_PATH}" )
2011-05-14 17:31:40 +00:00
ENDIF ( )
2018-05-07 09:28:35 -05:00
SET ( ZETAGLEST_INI_INSTALL_PATH "${ZETAGLEST_DATA_INSTALL_PATH}" )
IF ( NOT ZETAGLEST_DESKTOP_INSTALL_PATH AND NOT WANT_SINGLE_INSTALL_DIRECTORY )
SET ( ZETAGLEST_DESKTOP_INSTALL_PATH "share/applications/" CACHE STRING "The installation path for desktop files ${COMMON_INFO_ABOUT_PATH}" )
2011-05-14 17:31:40 +00:00
ENDIF ( )
2018-05-07 09:28:35 -05:00
IF ( NOT ZETAGLEST_ICON_INSTALL_PATH AND NOT WANT_SINGLE_INSTALL_DIRECTORY )
SET ( ZETAGLEST_ICON_INSTALL_PATH "share/pixmaps/" CACHE STRING "The installation path for icon files ${COMMON_INFO_ABOUT_PATH}" )
2011-05-14 17:31:40 +00:00
ENDIF ( )
2018-05-07 09:28:35 -05:00
IF ( NOT ZETAGLEST_MANPAGE_INSTALL_PATH AND NOT WANT_SINGLE_INSTALL_DIRECTORY )
SET ( ZETAGLEST_MANPAGE_INSTALL_PATH "share/man/man6/" CACHE STRING "The installation path for manpage files ${COMMON_INFO_ABOUT_PATH}" )
2015-09-27 19:46:35 +02:00
ENDIF ( )
IF ( WANT_SINGLE_INSTALL_DIRECTORY )
2018-05-07 09:28:35 -05:00
FOREACH ( ZG_PATH BIN DATA INI DESKTOP ICON )
IF ( NOT ZETAGLEST_ ${ ZG_PATH } _INSTALL_PATH )
SET ( ZETAGLEST_ ${ ZG_PATH } _INSTALL_PATH "${ZETAGLEST_SINGLE_DIRECTORY_INSTALL_PATH}" )
2015-09-27 19:46:35 +02:00
ENDIF ( )
ENDFOREACH ( )
2011-05-26 14:36:43 +00:00
ENDIF ( )
2016-03-05 13:57:08 +01:00
IF ( NOT WANT_SINGLE_INSTALL_DIRECTORY )
2018-05-07 09:28:35 -05:00
FOREACH ( ZG_PATH DATA INI )
IF ( IS_ABSOLUTE "${ZETAGLEST_${ZG_PATH}_INSTALL_PATH}" )
SET ( ZETAGLEST_FULL_ ${ ZG_PATH } _INSTALL_PATH "${ZETAGLEST_${ZG_PATH}_INSTALL_PATH}/" )
2017-04-01 14:53:34 +02:00
ELSE ( )
2018-05-07 09:28:35 -05:00
SET ( ZETAGLEST_FULL_ ${ ZG_PATH } _INSTALL_PATH "${CMAKE_INSTALL_PREFIX}/${ZETAGLEST_${ZG_PATH}_INSTALL_PATH}/" )
2017-04-01 14:53:34 +02:00
ENDIF ( )
2018-05-07 09:28:35 -05:00
STRING ( REGEX REPLACE "//+" "/" ZETAGLEST_FULL_ ${ ZG_PATH } _INSTALL_PATH "${ZETAGLEST_FULL_${ZG_PATH}_INSTALL_PATH}" )
2017-04-01 14:53:34 +02:00
ENDFOREACH ( )
2016-03-05 13:57:08 +01:00
IF ( NOT CUSTOM_DATA_INSTALL_PATH )
2018-05-07 09:28:35 -05:00
SET ( CUSTOM_DATA_INSTALL_PATH "${ZETAGLEST_FULL_DATA_INSTALL_PATH}" )
2017-04-01 14:53:34 +02:00
# ^ someday this intermediate step may be removed
2016-03-05 13:57:08 +01:00
ENDIF ( )
2017-04-01 14:53:34 +02:00
SET ( CUSTOM_INSTALL_PATHS_VALUES "-DCUSTOM_DATA_INSTALL_PATH=${CUSTOM_DATA_INSTALL_PATH}" )
2011-05-14 17:31:40 +00:00
ENDIF ( )
2011-05-03 23:34:25 +00:00
2017-04-01 14:53:34 +02:00
#SET(PKG_DATADIR ${CUSTOM_DATA_INSTALL_PATH_VALUE})
2018-05-07 09:28:35 -05:00
#SET(PKG_BINDIR ${ZETAGLEST_BIN_INSTALL_PATH})
2017-04-01 14:53:34 +02:00
# ^ hard to tell for what it is needed and most likely both were set to wrong values, so let's try to not use them
2011-05-03 23:34:25 +00:00
MESSAGE ( STATUS "*NOTE: Custom Data Install Path is [${CUSTOM_DATA_INSTALL_PATH}]" )
ENDIF ( )
2018-05-07 09:28:35 -05:00
string ( TOUPPER "${CMAKE_BUILD_TYPE}" ZG_BUILD_TYPE )
2015-01-25 09:01:23 +01:00
IF ( HAS_GIT STREQUAL "TRUE" )
2018-05-07 09:28:35 -05:00
SET ( CMAKE_CXX_FLAGS_ ${ ZG_BUILD_TYPE } "${CMAKE_CXX_FLAGS_${ZG_BUILD_TYPE}} ${GIT_VERSION_CMD}" )
2015-01-25 09:01:23 +01:00
ENDIF ( )
2018-05-07 09:28:35 -05:00
SET ( CMAKE_CXX_FLAGS_ ${ ZG_BUILD_TYPE } "${CMAKE_CXX_FLAGS_${ZG_BUILD_TYPE}} ${CUSTOM_INSTALL_PATHS_VALUES}" )
2011-05-03 23:34:25 +00:00
2018-01-14 11:17:14 -06:00
# We do some funky character escaping to get the right stuff written out to
2013-11-29 13:13:30 -08:00
# the final Makefile so we get the GIT Global Revsion #
2018-05-07 09:28:35 -05:00
string ( REPLACE "'" "\" " CMAKE_CXX_FLAGS_${ZG_BUILD_TYPE} " ${ CMAKE_CXX_FLAGS_${ZG_BUILD_TYPE } } " )
2010-12-12 08:10:18 +00:00
2018-05-07 09:28:35 -05:00
message ( STATUS "CMAKE_CXX_FLAGS_${ZG_BUILD_TYPE}: ${CMAKE_CXX_FLAGS_${ZG_BUILD_TYPE}}" )
2010-12-12 08:10:18 +00:00
# Win32 specific Compiler Flags
IF ( WIN32 )
2011-07-13 19:57:29 +00:00
ADD_DEFINITIONS ( "-D_WINDOWS -D_WIN32 -D_STDCALL_SUPPORTED -D_M_IX86 -DXML_LIBRARY -D_LIB -DCURL_STATICLIB" )
ENDIF ( )
2010-12-12 08:10:18 +00:00
ENDIF ( )
2010-06-05 17:34:55 +00:00
2015-09-18 19:17:52 +02:00
IF ( UNIX AND NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "Linux" )
OPTION ( WANT_DEPRECATION_WARNINGS "Want to see warnings related with deprecated code parts." OFF )
# We don't wanna see bug reports with deprecation warnings from OSes where game isn't
# actively developed, and where usually those warnings can make "make log" completely unreadable.
# Main targets are: bsd and macos
2015-09-22 00:52:09 +02:00
MARK_AS_ADVANCED ( CLEAR wxWidgets_CONFIG_EXECUTABLE )
# This variable may be sometimes necessary to set manually.
2015-09-18 19:17:52 +02:00
ELSE ( )
OPTION ( WANT_DEPRECATION_WARNINGS "Want to see warnings related with deprecated code parts." ON )
ENDIF ( )
IF ( NOT WANT_DEPRECATION_WARNINGS )
ADD_DEFINITIONS ( -Wno-deprecated -Wno-deprecated-declarations )
ENDIF ( )
MARK_AS_ADVANCED ( WANT_DEPRECATION_WARNINGS )
2018-05-07 09:28:35 -05:00
IF ( NOT ZG_CMAKE_INSTALL_PREFIX AND NOT CMAKE_INSTALL_PREFIX STREQUAL "" )
SET ( ZG_CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}" )
2017-09-22 23:21:40 -07:00
ENDIF ( )
2018-05-07 09:28:35 -05:00
MESSAGE ( STATUS "**NOTE: ZG_CMAKE_INSTALL_PREFIX is [${ZG_CMAKE_INSTALL_PREFIX}]" )
2017-09-22 23:21:40 -07:00
2017-04-01 14:53:34 +02:00
SET ( SDL_WINDOWS_DIR_DINC "SDL-2.0.x" )
SET ( SDL_VERSION_NAME "SDL2" )
SET ( SDL_VERSION_SNAME "sdl" )
2015-09-18 19:17:52 +02:00
2015-09-22 00:52:09 +02:00
OPTION ( WANT_DEV_OUTPATH "Use developer friendly output paths." OFF )
2015-11-20 20:09:39 +01:00
IF ( UNIX AND "${CMAKE_SYSTEM_NAME}" STREQUAL "Linux" )
2018-05-07 09:28:35 -05:00
SET ( ZETAGLEST_FRIENDLY_OUTPUT_PATH "${PROJECT_SOURCE_DIR}/mk/linux/" )
2015-09-22 00:52:09 +02:00
ELSEIF ( UNIX AND APPLE )
2018-05-07 09:28:35 -05:00
SET ( ZETAGLEST_FRIENDLY_OUTPUT_PATH "${PROJECT_SOURCE_DIR}/mk/macos/" )
2015-11-20 20:09:39 +01:00
ELSEIF ( UNIX AND NOT APPLE )
2018-05-07 09:28:35 -05:00
SET ( ZETAGLEST_FRIENDLY_OUTPUT_PATH "${PROJECT_SOURCE_DIR}/mk/other_unix/" )
2015-09-22 00:52:09 +02:00
ELSE ( )
2018-05-07 09:28:35 -05:00
SET ( ZETAGLEST_FRIENDLY_OUTPUT_PATH "${PROJECT_SOURCE_DIR}/data/glest_game/" )
2015-09-22 00:52:09 +02:00
ENDIF ( )
2015-09-18 19:17:52 +02:00
2010-12-11 06:32:21 +00:00
IF ( WIN32 )
SET ( CMAKE_LIBRARY_PATH ${ CMAKE_LIBRARY_PATH }
2010-12-23 00:00:30 +00:00
$ { P R O J E C T _ S O U R C E _ D I R } / s o u r c e / w i n 3 2 _ d e p s / l i b
$ { P R O J E C T _ S O U R C E _ D I R } / s o u r c e / w i n 3 2 _ d e p s / x e r c e s - c - s r c _ 2 _ 8 _ 0 / l i b
2010-12-27 09:01:40 +00:00
$ { P R O J E C T _ S O U R C E _ D I R } / s o u r c e / w i n 3 2 _ d e p s / w x W i d g e t s - 2 . 8 . 1 0 / l i b )
2010-12-11 06:32:21 +00:00
SET ( CMAKE_INCLUDE_PATH ${ CMAKE_INCLUDE_PATH }
2010-12-23 00:00:30 +00:00
$ { P R O J E C T _ S O U R C E _ D I R } / s o u r c e / w i n 3 2 _ d e p s / i n c l u d e
$ { P R O J E C T _ S O U R C E _ D I R } / s o u r c e / w i n 3 2 _ d e p s / o p e n a l - s o f t - 1 . 1 2 . 8 5 4 / i n c l u d e
$ { P R O J E C T _ S O U R C E _ D I R } / s o u r c e / w i n 3 2 _ d e p s / o p e n a l - s o f t - 1 . 1 2 . 8 5 4
$ { P R O J E C T _ S O U R C E _ D I R } / s o u r c e / w i n 3 2 _ d e p s / x e r c e s - c - s r c _ 2 _ 8 _ 0 / i n c l u d e
$ { P R O J E C T _ S O U R C E _ D I R } / s o u r c e / w i n 3 2 _ d e p s / l i b o g g - 1 . 2 . 1 / i n c l u d e
$ { P R O J E C T _ S O U R C E _ D I R } / s o u r c e / w i n 3 2 _ d e p s / l u a - 5 . 1 / s r c
$ { P R O J E C T _ S O U R C E _ D I R } / s o u r c e / w i n 3 2 _ d e p s / j p e g - 8 b
$ { P R O J E C T _ S O U R C E _ D I R } / s o u r c e / w i n 3 2 _ d e p s / l p n g 1 4 1
$ { P R O J E C T _ S O U R C E _ D I R } / s o u r c e / w i n 3 2 _ d e p s / z l i b - 1 . 2 . 5
2011-01-01 11:39:04 +00:00
$ { P R O J E C T _ S O U R C E _ D I R } / s o u r c e / w i n 3 2 _ d e p s / c u r l - 7 . 2 1 . 3 / i n c l u d e
2015-09-18 19:17:52 +02:00
$ { P R O J E C T _ S O U R C E _ D I R } / s o u r c e / w i n 3 2 _ d e p s / $ { S D L _ W I N D O W S _ D I R _ D I N C } / i n c l u d e
2010-12-23 00:00:30 +00:00
$ { P R O J E C T _ S O U R C E _ D I R } / s o u r c e / w i n 3 2 _ d e p s / w x W i d g e t s - 2 . 8 . 1 0 / i n c l u d e )
2010-12-11 06:32:21 +00:00
link_directories ( ${ PROJECT_SOURCE_DIR } /source/win32_deps/lib )
link_directories ( ${ PROJECT_SOURCE_DIR } /source/win32_deps/xerces-c-src_2_8_0/lib )
2010-12-11 15:05:43 +00:00
link_directories ( ${ PROJECT_SOURCE_DIR } /source/win32_deps/wxWidgets-2.8.10/lib )
2010-12-11 06:32:21 +00:00
include_directories ( "${PROJECT_SOURCE_DIR}/source/win32_deps/Microsoft\ DirectX\ SDK \(November 2007\)/Include" )
include_directories ( ${ PROJECT_SOURCE_DIR } /source/win32_deps/openal-soft-1.12.854/include )
ENDIF ( )
2011-05-03 23:34:25 +00:00
2011-05-04 07:51:48 +00:00
# Check if sources exist
2011-05-04 21:00:34 +00:00
IF ( EXISTS "${PROJECT_SOURCE_DIR}/source/" )
2011-05-04 07:51:48 +00:00
MESSAGE ( STATUS "**Found game source code." )
2011-05-04 21:00:34 +00:00
ADD_SUBDIRECTORY ( ${ PROJECT_SOURCE_DIR } /source/shared_lib )
ADD_SUBDIRECTORY ( ${ PROJECT_SOURCE_DIR } /source/glest_game )
2011-05-04 07:51:48 +00:00
#if(wxWidgets_FOUND)
2011-05-04 21:00:34 +00:00
ADD_SUBDIRECTORY ( ${ PROJECT_SOURCE_DIR } /source/glest_map_editor )
ADD_SUBDIRECTORY ( ${ PROJECT_SOURCE_DIR } /source/g3d_viewer )
2011-05-04 07:51:48 +00:00
#else()
# MESSAGE(STATUS "WARNING... the following game tools will NOT be built since we cannot find wxWidgets on this machine")
2012-04-11 18:58:38 +00:00
# MESSAGE(STATUS "map editor, g3d viewer")
2011-05-04 07:51:48 +00:00
#endif()
2011-05-04 21:00:34 +00:00
ADD_SUBDIRECTORY ( ${ PROJECT_SOURCE_DIR } /source/tools/glexemel )
2011-05-04 07:51:48 +00:00
2017-09-22 23:21:40 -07:00
ADD_SUBDIRECTORY ( ${ PROJECT_SOURCE_DIR } /source/tests )
2011-05-04 07:51:48 +00:00
ENDIF ( )
2011-05-03 07:58:59 +00:00
2011-05-04 07:51:48 +00:00
# Check if data exist
2014-01-25 18:52:31 -08:00
IF ( EXISTS "${PROJECT_SOURCE_DIR}/data/glest_game/CMakeLists.txt" )
2017-09-22 23:21:40 -07:00
MESSAGE ( STATUS "**Found game data." )
2011-05-04 21:00:34 +00:00
ADD_SUBDIRECTORY ( ${ PROJECT_SOURCE_DIR } /data/glest_game )
2011-05-04 07:51:48 +00:00
ENDIF ( )
2011-05-15 02:24:54 +00:00
2014-02-06 19:14:14 -08:00
#get_directory_property( DirDefs COMPILE_DEFINITIONS )
#MESSAGE(STATUS ">>>> NOTICE Compiler definitions used: ${DirDefs}")
#MESSAGE(STATUS "END of compile defs...")
IF ( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" )
2017-09-22 23:21:40 -07:00
MESSAGE ( WARNING ">> CLANG is NOT currently compatible as it does not support the following essential GCC compiler settings: -frounding-math -fsignaling-nans" )
2014-02-06 19:14:14 -08:00
ENDIF ( )
2015-12-14 23:16:54 +01:00
IF ( NOT DEFINED CPACK_GENERATOR )
SET ( CPACK_GENERATOR "DEB" )
ENDIF ( )
2014-12-22 22:21:37 +11:00
# CPack configuration shared accross platforms
SET ( CPACK_PACKAGE_NAME ${ PKG_NAME } )
2018-05-07 09:28:35 -05:00
IF ( EXISTS "${PROJECT_SOURCE_DIR}/../zetaglest-data/others/zetaglest-long-description.txt.in" )
FILE ( READ "${PROJECT_SOURCE_DIR}/../zetaglest-data/others/zetaglest-long-description.txt.in" ZETAGLEST_LONG_DESCRIPTION )
SET ( CPACK_PACKAGE_DESCRIPTION_SUMMARY "${ZETAGLEST_LONG_DESCRIPTION}" )
2015-12-14 23:16:54 +01:00
ELSE ( )
2018-05-07 09:28:35 -05:00
SET ( CPACK_PACKAGE_DESCRIPTION_SUMMARY "ZetaGlest" )
2015-12-14 23:16:54 +01:00
ENDIF ( )
2018-05-07 09:28:35 -05:00
SET ( CPACK_PACKAGE_VENDOR "zetaglest.github.io" )
2014-12-22 22:21:37 +11:00
#SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README")
#SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING")
2018-05-07 09:28:35 -05:00
SET ( CPACK_PACKAGE_INSTALL_DIRECTORY "zetaglest" )
2015-12-14 23:16:54 +01:00
SET ( CPACK_PACKAGING_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}" )
2018-05-07 09:28:35 -05:00
SET ( CPACK_PACKAGE_VERSION "${ZETAGLEST_VERSION}" )
2015-01-25 09:01:23 +01:00
SET ( CPACK_PACKAGE_VERSION_MAJOR "${VER_MAJOR}" )
SET ( CPACK_PACKAGE_VERSION_MINOR "${VER_MINOR}" )
SET ( CPACK_PACKAGE_VERSION_PATCH "${VER_PATCH}" )
2014-12-22 22:21:37 +11:00
2015-12-14 23:16:54 +01:00
IF ( "${CPACK_GENERATOR}" STREQUAL "DEB" )
2018-05-07 09:28:35 -05:00
SET ( CPACK_DEBIAN_PACKAGE_MAINTAINER "ZetaGlest Team" ) #required
2015-12-14 23:16:54 +01:00
SET ( CPACK_DEBIAN_PACKAGE_SECTION "games" )
SET ( CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON )
SET ( CPACK_DEBIAN_PACKAGE_SUGGESTS "p7zip-full" )
ENDIF ( )
IF ( "${CPACK_GENERATOR}" STREQUAL "NSIS" )
2018-05-07 09:28:35 -05:00
SET ( CPACK_NSIS_DISPLAY_NAME "ZetaGlest" )
2018-03-05 04:20:26 +01:00
SET ( CPACK_NSIS_MUI_ICON "${PROJECT_SOURCE_DIR}/mk/windows/zetaglest.ico" )
SET ( CPACK_PACKAGE_ICON "${PROJECT_SOURCE_DIR}/mk/windows/zetaglest.ico" )
2018-05-07 09:28:35 -05:00
SET ( CPACK_NSIS_URL_INFO_ABOUT "https://zetaglest.github.io" )
2015-12-14 23:16:54 +01:00
ENDIF ( )
2014-12-22 22:21:37 +11:00
2013-01-03 21:57:58 +00:00
INCLUDE ( CPack )
2011-12-24 03:20:21 +00:00
get_directory_property ( DirDefs DIRECTORY ${ CMAKE_SOURCE_DIR } COMPILE_DEFINITIONS )
foreach ( d ${ DirDefs } )
message ( STATUS "=====> Found Define: " ${ d } )
endforeach ( )
2015-01-25 09:01:23 +01:00
#MESSAGE( STATUS "=====> DirDefs: " ${DirDefs} )
2011-12-24 03:20:21 +00:00
#MESSAGE(STATUS "*** Compiler definitions are [${COMPILE_DEFINITIONS}]")
2015-09-18 19:17:52 +02:00
MARK_AS_ADVANCED ( ${ SDL_VERSION_NAME } MAIN_LIBRARY )
MARK_AS_ADVANCED ( ${ SDL_VERSION_NAME } _INCLUDE_DIR )
MARK_AS_ADVANCED ( ${ SDL_VERSION_NAME } _LIBRARY )
2015-09-22 00:52:09 +02:00
MARK_AS_ADVANCED ( wxWidgets_CONFIG_EXECUTABLE )
MARK_AS_ADVANCED ( wxWidgets_wxrc_EXECUTABLE )
2015-09-27 19:46:35 +02:00
MARK_AS_ADVANCED ( wxWidgets_USE_DEBUG )