Make snapcraft build work.

This commit is contained in:
Jammyjamjamman
2019-04-07 19:45:21 +01:00
parent ddb1259cbe
commit 4c0914fff1
4 changed files with 76 additions and 53 deletions

View File

@@ -10,6 +10,9 @@ IF(BUILD_GLEST)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=gnu++11")
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)
INCLUDE_DIRECTORIES(${${SDL_VERSION_NAME}_INCLUDE_DIR})
@@ -23,13 +26,13 @@ IF(BUILD_GLEST)
SET(EXTERNAL_LIBS ${EXTERNAL_LIBS} ${OPENGL_LIBRARY})
ENDIF()
IF(WANT_USE_XercesC)
FIND_PACKAGE(XercesC REQUIRED)
INCLUDE_DIRECTORIES(${XERCESC_INCLUDE})
IF(UNIX)
SET(EXTERNAL_LIBS ${EXTERNAL_LIBS} ${XERCESC_LIBRARY})
ENDIF()
ENDIF()
IF(WANT_USE_XercesC)
FIND_PACKAGE(XercesC REQUIRED)
INCLUDE_DIRECTORIES(${XERCESC_INCLUDE})
IF(UNIX)
SET(EXTERNAL_LIBS ${EXTERNAL_LIBS} ${XERCESC_LIBRARY})
ENDIF()
ENDIF()
FIND_PACKAGE(OpenAL REQUIRED)
INCLUDE_DIRECTORIES(${OPENAL_INCLUDE_DIR})
@@ -69,9 +72,9 @@ IF(BUILD_GLEST)
set(OPENSSL_ROOT_DIR /usr/local/opt/openssl)
include(FindOpenSSL)
IF(OPENSSL_FOUND)
INCLUDE_DIRECTORIES(${OPENSSL_INCLUDE_DIR})
INCLUDE_DIRECTORIES(${OPENSSL_INCLUDE_DIR})
ELSE()
MESSAGE(STATUS "**NOTE: OpenSSL is usually not required.")
MESSAGE(STATUS "**NOTE: OpenSSL is usually not required.")
ENDIF()
ENDIF()
@@ -289,7 +292,7 @@ IF(BUILD_GLEST)
INSTALL(FILES
"${PROJECT_SOURCE_DIR}/mk/shared/glest.ini"
DESTINATION ${INSTALL_DIR_INI})
ELSEIF(UNIX AND NOT APPLE AND FLATPAK_INSTALL)
ELSEIF(UNIX AND NOT APPLE AND FLATPAK_INSTALL)
INSTALL(FILES
"${PROJECT_SOURCE_DIR}/mk/flatpak/glest.ini"
DESTINATION ${INSTALL_DIR_INI})

View File

@@ -233,10 +233,12 @@ namespace Game {
foundPath = tryCustomPath(cfgType, fileName, custom_path);
}
#ifndef SNAPCRAFT
if (foundPath == false) {
currentpath = extractDirectoryPathFromFile(Properties::getApplicationPath());
foundPath = tryCustomPath(cfgType, fileName, currentpath);
}
#endif
#ifdef _WIN32
if (foundPath == false) {
@@ -263,6 +265,13 @@ namespace Game {
}
#endif
#ifdef SNAPCRAFT
if (foundPath == false) {
foundPath = tryCustomPath(cfgType, fileName, std::getenv("SNAP") +
endPathWithSlash(formatPath(TOSTRING(DATADIR))));
}
#endif
#ifdef DATADIR
if (foundPath == false) {
foundPath = tryCustomPath(cfgType, fileName, endPathWithSlash(formatPath(TOSTRING(DATADIR))));

View File

@@ -53,8 +53,13 @@ namespace Shared {
namespace Util {
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 = "";
#endif
string Properties::techtreePath = "";
string Properties::scenarioPath = "";
string Properties::tutorialPath = "";