mirror of
https://github.com/glest/glest-source.git
synced 2025-08-22 07:52:51 +02:00
Make snapcraft build work.
This commit is contained in:
@@ -13,7 +13,7 @@ ENDIF()
|
|||||||
SET_PROPERTY(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS None Debug Release RelWithDebInfo MinSizeRel)
|
SET_PROPERTY(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS None Debug Release RelWithDebInfo MinSizeRel)
|
||||||
|
|
||||||
IF(NOT CMAKE_VERSION VERSION_LESS "3.1")
|
IF(NOT CMAKE_VERSION VERSION_LESS "3.1")
|
||||||
cmake_policy(SET CMP0054 NEW)
|
cmake_policy(SET CMP0054 NEW)
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
# add additional CMake modules
|
# add additional CMake modules
|
||||||
@@ -28,9 +28,9 @@ ENDIF()
|
|||||||
# using CC=`which egcc` CXX=`which eg++`
|
# using CC=`which egcc` CXX=`which eg++`
|
||||||
|
|
||||||
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||||
SET(CMAKE_COMPILER_IS_GNUCXX "YES")
|
SET(CMAKE_COMPILER_IS_GNUCXX "YES")
|
||||||
# ADD_DEFINITIONS("-Qunused-arguments -Wno-switch")
|
# ADD_DEFINITIONS("-Qunused-arguments -Wno-switch")
|
||||||
ADD_DEFINITIONS("-Wno-switch")
|
ADD_DEFINITIONS("-Wno-switch")
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
OPTION(BUILD_GLEST "Build Glest" ON)
|
OPTION(BUILD_GLEST "Build Glest" ON)
|
||||||
@@ -60,15 +60,15 @@ ENDIF()
|
|||||||
|
|
||||||
IF(CMAKE_COMPILER_IS_GNUCXX OR MINGW)
|
IF(CMAKE_COMPILER_IS_GNUCXX OR MINGW)
|
||||||
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||||
MESSAGE(STATUS "Detected CLANG Compiler...")
|
MESSAGE(STATUS "Detected CLANG Compiler...")
|
||||||
ELSEIF(CMAKE_COMPILER_IS_GNUCXX)
|
ELSEIF(CMAKE_COMPILER_IS_GNUCXX)
|
||||||
MESSAGE(STATUS "Detected GNUC Compiler...")
|
MESSAGE(STATUS "Detected GNUC Compiler...")
|
||||||
ELSEIF(MINGW)
|
ELSEIF(MINGW)
|
||||||
MESSAGE(STATUS "Detected MINGW Compiler...")
|
MESSAGE(STATUS "Detected MINGW Compiler...")
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
# Common generic GNU type compiler options that work with all generic GCC compatible compilers
|
# 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")
|
ADD_DEFINITIONS("-Wuninitialized -Wsign-compare -Wunused-function -Wunused-variable -Wreturn-type -fno-strict-aliasing")
|
||||||
|
|
||||||
# For gcc warning options see: http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
|
# For gcc warning options see: http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
|
||||||
IF(NOT MINGW)
|
IF(NOT MINGW)
|
||||||
@@ -78,32 +78,32 @@ IF(CMAKE_COMPILER_IS_GNUCXX OR MINGW)
|
|||||||
ELSE()
|
ELSE()
|
||||||
# ADD_DEFINITIONS("-Wreturn-type -fno-strict-aliasing -frounding-math -fsignaling-nans -mfpmath=sse -msse -DUNICODE")
|
# ADD_DEFINITIONS("-Wreturn-type -fno-strict-aliasing -frounding-math -fsignaling-nans -mfpmath=sse -msse -DUNICODE")
|
||||||
# ADD_DEFINITIONS("-Wuninitialized -Wsign-compare -Wunused-function -Wunused-variable -Wreturn-type -fno-strict-aliasing -frounding-math -fsignaling-nans -DUNICODE")
|
# ADD_DEFINITIONS("-Wuninitialized -Wsign-compare -Wunused-function -Wunused-variable -Wreturn-type -fno-strict-aliasing -frounding-math -fsignaling-nans -DUNICODE")
|
||||||
ADD_DEFINITIONS("-DUNICODE")
|
ADD_DEFINITIONS("-DUNICODE")
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
# CLang specific Compiler Options
|
# CLang specific Compiler Options
|
||||||
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||||
|
|
||||||
# GCC specific Compiler Options
|
# GCC specific Compiler Options
|
||||||
ELSE()
|
ELSE()
|
||||||
ADD_DEFINITIONS("-frounding-math -fsignaling-nans")
|
ADD_DEFINITIONS("-frounding-math -fsignaling-nans")
|
||||||
|
|
||||||
IF((NOT CMAKE_GENERATOR STREQUAL Xcode) AND (NOT MINGW))
|
IF((NOT CMAKE_GENERATOR STREQUAL Xcode) AND (NOT MINGW))
|
||||||
# Debug compiler flags
|
# Debug compiler flags
|
||||||
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -no-pie -fno-pie")
|
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -no-pie -fno-pie")
|
||||||
|
|
||||||
# Release compiler flags
|
# Release compiler flags
|
||||||
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -no-pie -fno-pie")
|
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -no-pie -fno-pie")
|
||||||
|
|
||||||
# Release with debug info compiler flags
|
# Release with debug info compiler flags
|
||||||
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -no-pie -fno-pie")
|
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -no-pie -fno-pie")
|
||||||
|
|
||||||
# IF(NOT MINGW)
|
# IF(NOT MINGW)
|
||||||
# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -rdynamic")
|
# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -rdynamic")
|
||||||
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -rdynamic")
|
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -rdynamic")
|
||||||
# ENDIF()
|
# ENDIF()
|
||||||
|
ENDIF()
|
||||||
ENDIF()
|
ENDIF()
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
IF(WANT_USE_STREFLOP)
|
IF(WANT_USE_STREFLOP)
|
||||||
OPTION(FORCE_STREFLOP_SOFTWRAPPER "Set the streflop library to be forced to use the software emulator" OFF)
|
OPTION(FORCE_STREFLOP_SOFTWRAPPER "Set the streflop library to be forced to use the software emulator" OFF)
|
||||||
@@ -142,25 +142,25 @@ IF(CMAKE_COMPILER_IS_GNUCXX OR MINGW)
|
|||||||
MESSAGE(STATUS "libstreflop disabled")
|
MESSAGE(STATUS "libstreflop disabled")
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
include(CheckCXXSourceRuns)
|
include(CheckCXXSourceRuns)
|
||||||
|
|
||||||
check_cxx_source_runs("
|
check_cxx_source_runs("
|
||||||
#include <execinfo.h>
|
#include <execinfo.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
const size_t max_depth = 6;
|
const size_t max_depth = 6;
|
||||||
void *stack_addrs[max_depth];
|
void *stack_addrs[max_depth];
|
||||||
size_t stack_depth = backtrace(stack_addrs, max_depth);
|
size_t stack_depth = backtrace(stack_addrs, max_depth);
|
||||||
}"
|
}"
|
||||||
HAS_GCC_BACKTRACE)
|
HAS_GCC_BACKTRACE)
|
||||||
|
|
||||||
IF(HAS_GCC_BACKTRACE)
|
IF(HAS_GCC_BACKTRACE)
|
||||||
message(STATUS "Found GCC backtrace lib, will support backtraces")
|
message(STATUS "Found GCC backtrace lib, will support backtraces")
|
||||||
ADD_DEFINITIONS(-DHAS_GCC_BACKTRACE)
|
ADD_DEFINITIONS(-DHAS_GCC_BACKTRACE)
|
||||||
ELSE()
|
ELSE()
|
||||||
message(STATUS "**WARNING DID NOT Find GCC backtrace lib")
|
message(STATUS "**WARNING DID NOT Find GCC backtrace lib")
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
# Debug compiler flags
|
# Debug compiler flags
|
||||||
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g3")
|
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g3")
|
||||||
@@ -188,6 +188,12 @@ IF(CMAKE_COMPILER_IS_GNUCXX OR MINGW)
|
|||||||
SET(CMAKE_EXE_LINKER_FLAGS_MINSIZEREL "${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL} -pthread")
|
SET(CMAKE_EXE_LINKER_FLAGS_MINSIZEREL "${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL} -pthread")
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
|
# Snapcraft build definition.
|
||||||
|
IF(DEFINED ENV{SNAPCRAFT_STAGE})
|
||||||
|
MESSAGE(STATUS "Using snapcraft path...")
|
||||||
|
ADD_DEFINITIONS("-DSNAPCRAFT")
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
IF(NOT INSTALL_DIR_BIN)
|
IF(NOT INSTALL_DIR_BIN)
|
||||||
SET(INSTALL_DIR_BIN "${CMAKE_INSTALL_PREFIX}/games/" CACHE PATH "The installation path for binaries")
|
SET(INSTALL_DIR_BIN "${CMAKE_INSTALL_PREFIX}/games/" CACHE PATH "The installation path for binaries")
|
||||||
ENDIF()
|
ENDIF()
|
||||||
@@ -267,21 +273,21 @@ ENDIF()
|
|||||||
# where it is, and whether or not it has actually been installed
|
# where it is, and whether or not it has actually been installed
|
||||||
#
|
#
|
||||||
IF(EXISTS "${PROJECT_SOURCE_DIR}/../glest-data/CMakeLists.txt")
|
IF(EXISTS "${PROJECT_SOURCE_DIR}/../glest-data/CMakeLists.txt")
|
||||||
MESSAGE(STATUS "**Found game data.")
|
MESSAGE(STATUS "**Found game data.")
|
||||||
# using CMAKE_BINARY_DIR as last parameter will output cmake files into the same
|
# using CMAKE_BINARY_DIR as last parameter will output cmake files into the same
|
||||||
# directory as the source build.
|
# directory as the source build.
|
||||||
ADD_SUBDIRECTORY(${PROJECT_SOURCE_DIR}/../glest-data ${CMAKE_BINARY_DIR}/data)
|
ADD_SUBDIRECTORY(${PROJECT_SOURCE_DIR}/../glest-data ${CMAKE_BINARY_DIR}/data)
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||||
MESSAGE(WARNING ">> CLANG is NOT currently compatible as it does not support the following essential GCC compiler settings: -frounding-math -fsignaling-nans")
|
MESSAGE(WARNING ">> CLANG is NOT currently compatible as it does not support the following essential GCC compiler settings: -frounding-math -fsignaling-nans")
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
# FIXME: This should output all defines. For example, DATADIR is defined in
|
# FIXME: This should output all defines. For example, DATADIR is defined in
|
||||||
# the game source and sharedlib cmake file as well
|
# the game source and sharedlib cmake file as well
|
||||||
get_directory_property( DirDefs DIRECTORY ${CMAKE_SOURCE_DIR} COMPILE_DEFINITIONS )
|
get_directory_property( DirDefs DIRECTORY ${CMAKE_SOURCE_DIR} COMPILE_DEFINITIONS )
|
||||||
foreach( d ${DirDefs} )
|
foreach( d ${DirDefs} )
|
||||||
message( STATUS "=====> Found Define: " ${d} )
|
message( STATUS "=====> Found Define: " ${d} )
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
MARK_AS_ADVANCED(${SDL_VERSION_NAME}MAIN_LIBRARY)
|
MARK_AS_ADVANCED(${SDL_VERSION_NAME}MAIN_LIBRARY)
|
||||||
|
@@ -11,6 +11,9 @@ IF(BUILD_GLEST)
|
|||||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=gnu++11")
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=gnu++11")
|
||||||
add_definitions("-DDATADIR=${INSTALL_DIR_DATA}")
|
add_definitions("-DDATADIR=${INSTALL_DIR_DATA}")
|
||||||
|
|
||||||
|
# This is an environment var that pops up when building with snapcraft.
|
||||||
|
# Use this to activate snapcraft path...
|
||||||
|
|
||||||
FIND_PACKAGE(${SDL_VERSION_NAME} REQUIRED)
|
FIND_PACKAGE(${SDL_VERSION_NAME} REQUIRED)
|
||||||
INCLUDE_DIRECTORIES(${${SDL_VERSION_NAME}_INCLUDE_DIR})
|
INCLUDE_DIRECTORIES(${${SDL_VERSION_NAME}_INCLUDE_DIR})
|
||||||
IF(UNIX)
|
IF(UNIX)
|
||||||
@@ -23,13 +26,13 @@ IF(BUILD_GLEST)
|
|||||||
SET(EXTERNAL_LIBS ${EXTERNAL_LIBS} ${OPENGL_LIBRARY})
|
SET(EXTERNAL_LIBS ${EXTERNAL_LIBS} ${OPENGL_LIBRARY})
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
IF(WANT_USE_XercesC)
|
IF(WANT_USE_XercesC)
|
||||||
FIND_PACKAGE(XercesC REQUIRED)
|
FIND_PACKAGE(XercesC REQUIRED)
|
||||||
INCLUDE_DIRECTORIES(${XERCESC_INCLUDE})
|
INCLUDE_DIRECTORIES(${XERCESC_INCLUDE})
|
||||||
IF(UNIX)
|
IF(UNIX)
|
||||||
SET(EXTERNAL_LIBS ${EXTERNAL_LIBS} ${XERCESC_LIBRARY})
|
SET(EXTERNAL_LIBS ${EXTERNAL_LIBS} ${XERCESC_LIBRARY})
|
||||||
ENDIF()
|
ENDIF()
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
FIND_PACKAGE(OpenAL REQUIRED)
|
FIND_PACKAGE(OpenAL REQUIRED)
|
||||||
INCLUDE_DIRECTORIES(${OPENAL_INCLUDE_DIR})
|
INCLUDE_DIRECTORIES(${OPENAL_INCLUDE_DIR})
|
||||||
@@ -69,9 +72,9 @@ IF(BUILD_GLEST)
|
|||||||
set(OPENSSL_ROOT_DIR /usr/local/opt/openssl)
|
set(OPENSSL_ROOT_DIR /usr/local/opt/openssl)
|
||||||
include(FindOpenSSL)
|
include(FindOpenSSL)
|
||||||
IF(OPENSSL_FOUND)
|
IF(OPENSSL_FOUND)
|
||||||
INCLUDE_DIRECTORIES(${OPENSSL_INCLUDE_DIR})
|
INCLUDE_DIRECTORIES(${OPENSSL_INCLUDE_DIR})
|
||||||
ELSE()
|
ELSE()
|
||||||
MESSAGE(STATUS "**NOTE: OpenSSL is usually not required.")
|
MESSAGE(STATUS "**NOTE: OpenSSL is usually not required.")
|
||||||
ENDIF()
|
ENDIF()
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
@@ -289,7 +292,7 @@ IF(BUILD_GLEST)
|
|||||||
INSTALL(FILES
|
INSTALL(FILES
|
||||||
"${PROJECT_SOURCE_DIR}/mk/shared/glest.ini"
|
"${PROJECT_SOURCE_DIR}/mk/shared/glest.ini"
|
||||||
DESTINATION ${INSTALL_DIR_INI})
|
DESTINATION ${INSTALL_DIR_INI})
|
||||||
ELSEIF(UNIX AND NOT APPLE AND FLATPAK_INSTALL)
|
ELSEIF(UNIX AND NOT APPLE AND FLATPAK_INSTALL)
|
||||||
INSTALL(FILES
|
INSTALL(FILES
|
||||||
"${PROJECT_SOURCE_DIR}/mk/flatpak/glest.ini"
|
"${PROJECT_SOURCE_DIR}/mk/flatpak/glest.ini"
|
||||||
DESTINATION ${INSTALL_DIR_INI})
|
DESTINATION ${INSTALL_DIR_INI})
|
||||||
|
@@ -233,10 +233,12 @@ namespace Game {
|
|||||||
foundPath = tryCustomPath(cfgType, fileName, custom_path);
|
foundPath = tryCustomPath(cfgType, fileName, custom_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef SNAPCRAFT
|
||||||
if (foundPath == false) {
|
if (foundPath == false) {
|
||||||
currentpath = extractDirectoryPathFromFile(Properties::getApplicationPath());
|
currentpath = extractDirectoryPathFromFile(Properties::getApplicationPath());
|
||||||
foundPath = tryCustomPath(cfgType, fileName, currentpath);
|
foundPath = tryCustomPath(cfgType, fileName, currentpath);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
if (foundPath == false) {
|
if (foundPath == false) {
|
||||||
@@ -263,6 +265,13 @@ namespace Game {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef SNAPCRAFT
|
||||||
|
if (foundPath == false) {
|
||||||
|
foundPath = tryCustomPath(cfgType, fileName, std::getenv("SNAP") +
|
||||||
|
endPathWithSlash(formatPath(TOSTRING(DATADIR))));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef DATADIR
|
#ifdef DATADIR
|
||||||
if (foundPath == false) {
|
if (foundPath == false) {
|
||||||
foundPath = tryCustomPath(cfgType, fileName, endPathWithSlash(formatPath(TOSTRING(DATADIR))));
|
foundPath = tryCustomPath(cfgType, fileName, endPathWithSlash(formatPath(TOSTRING(DATADIR))));
|
||||||
|
@@ -53,8 +53,13 @@ namespace Shared {
|
|||||||
namespace Util {
|
namespace Util {
|
||||||
|
|
||||||
string Properties::applicationPath = "";
|
string Properties::applicationPath = "";
|
||||||
|
#ifdef SNAPCRAFT
|
||||||
|
string Properties::applicationDataPath = std::getenv("SNAP") + formatPath(TOSTRING(DATADIR));
|
||||||
|
#elif FLATPAK
|
||||||
|
string Properties::applicationDataPath = formatPath(TOSTRING(DATADIR));
|
||||||
|
#else
|
||||||
string Properties::applicationDataPath = "";
|
string Properties::applicationDataPath = "";
|
||||||
|
#endif
|
||||||
string Properties::techtreePath = "";
|
string Properties::techtreePath = "";
|
||||||
string Properties::scenarioPath = "";
|
string Properties::scenarioPath = "";
|
||||||
string Properties::tutorialPath = "";
|
string Properties::tutorialPath = "";
|
||||||
|
Reference in New Issue
Block a user