From f77734e01c85aded92cf5fdc1e7038658e6aaf29 Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Thu, 20 Dec 2012 00:23:12 +0100 Subject: Installation path fixes and CMakeLists refactoring make && make install should now give a working installation. --- src/CBot/CMakeLists.txt | 2 +- src/CMakeLists.txt | 4 ++-- src/app/app.cpp | 16 ++++++---------- src/common/config.h.cmake | 4 ++-- src/common/global.h | 1 - src/po/CMakeLists.txt | 17 ++++++----------- 6 files changed, 17 insertions(+), 27 deletions(-) (limited to 'src') diff --git a/src/CBot/CMakeLists.txt b/src/CBot/CMakeLists.txt index e1c9b87..a347500 100644 --- a/src/CBot/CMakeLists.txt +++ b/src/CBot/CMakeLists.txt @@ -18,4 +18,4 @@ else() add_library(CBot SHARED ${SOURCES}) endif() -install(TARGETS CBot LIBRARY DESTINATION ${COLOBOT_LIB_DIR}) +install(TARGETS CBot LIBRARY DESTINATION ${COLOBOT_INSTALL_LIB_DIR}) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7096bff..be50e94 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -195,5 +195,5 @@ add_executable(colobot ${SOURCES}) target_link_libraries(colobot ${LIBS}) -install(TARGETS colobot RUNTIME DESTINATION games/) -set_target_properties(colobot PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${COLOBOT_LIB_DIR}") +install(TARGETS colobot RUNTIME DESTINATION ${COLOBOT_INSTALL_BIN_DIR}) +set_target_properties(colobot PROPERTIES INSTALL_RPATH ${COLOBOT_INSTALL_LIB_DIR}) diff --git a/src/app/app.cpp b/src/app/app.cpp index 04f8d2a..3073d77 100644 --- a/src/app/app.cpp +++ b/src/app/app.cpp @@ -30,12 +30,11 @@ #include "object/robotmain.h" +#include #include #include -#include - #include #include #include @@ -131,7 +130,7 @@ CApplication::CApplication() m_mouseButtonsState = 0; m_trackedKeys = 0; - m_dataPath = CBOT_DEFAULT_DATADIR; + m_dataPath = COLOBOT_DEFAULT_DATADIR; m_language = LANGUAGE_ENV; @@ -274,13 +273,10 @@ bool CApplication::Create() { GetLogger()->Info("Creating CApplication\n"); - // I know, a primitive way to check for dir, but works - std::string readmePath = m_dataPath + "/README.txt"; - std::ifstream testReadme; - testReadme.open(readmePath.c_str(), std::ios_base::in); - if (!testReadme.good()) + boost::filesystem::path dataPath(m_dataPath); + if (! (boost::filesystem::exists(dataPath) && boost::filesystem::is_directory(dataPath)) ) { - GetLogger()->Error("Could not open test file in data dir: '%s'\n", readmePath.c_str()); + GetLogger()->Error("Data directory '%s' doesn't exist or is not a directory\n", m_dataPath.c_str()); m_errorMessage = std::string("Could not read from data directory:\n") + std::string("'") + m_dataPath + std::string("'\n") + std::string("Please check your installation, or supply a valid data directory by -datadir option."); @@ -322,7 +318,7 @@ bool CApplication::Create() setlocale(LC_ALL, ""); GetLogger()->Debug("Set locale to '%s'\n", locale.c_str()); - bindtextdomain("colobot", CBOT_I18N_DIR); + bindtextdomain("colobot", COLOBOT_I18N_DIR); bind_textdomain_codeset("colobot", "UTF-8"); textdomain("colobot"); diff --git a/src/common/config.h.cmake b/src/common/config.h.cmake index 23b6de8..9b30720 100644 --- a/src/common/config.h.cmake +++ b/src/common/config.h.cmake @@ -8,5 +8,5 @@ #cmakedefine USE_GLEW @USE_GLEW@ #cmakedefine GLEW_STATIC -#define CBOT_DEFAULT_DATADIR "@COLOBOT_DATA_DIR@" -#define CBOT_I18N_DIR "@CMAKE_INSTALL_PREFIX@/share/locale/" +#define COLOBOT_DEFAULT_DATADIR "@COLOBOT_INSTALL_DATA_DIR@" +#define COLOBOT_I18N_DIR "@COLOBOT_INSTALL_I18N_DIR@" diff --git a/src/common/global.h b/src/common/global.h index 2d57ee0..0b2d8ec 100644 --- a/src/common/global.h +++ b/src/common/global.h @@ -181,7 +181,6 @@ enum DataDir DIR_AI, //! < ai scripts DIR_FONT, //! < fonts DIR_HELP, //! < help files - DIR_I18N, //! < translations DIR_ICON, //! < icons & images DIR_LEVEL, //! < levels DIR_MODEL, //! < models diff --git a/src/po/CMakeLists.txt b/src/po/CMakeLists.txt index 02a4d37..3b26571 100644 --- a/src/po/CMakeLists.txt +++ b/src/po/CMakeLists.txt @@ -1,13 +1,10 @@ cmake_minimum_required(VERSION 2.8) -SET(_potFile colobot.pot) +set(_potFile colobot.pot) -# TODO: Use a finder -SET(XGETTEXT_CMD /usr/bin/xgettext) +find_program(XGETTEXT_CMD xgettext) -find_package(Gettext REQUIRED) - -ADD_CUSTOM_COMMAND(OUTPUT ${_potFile} +add_custom_command(OUTPUT ${_potFile} COMMAND ${XGETTEXT_CMD} ../app/app.cpp --output=${_potFile} COMMAND ${XGETTEXT_CMD} ../common/restext_strings.c --output=${_potFile} --join-existing --extract-all --no-location @@ -15,10 +12,8 @@ ADD_CUSTOM_COMMAND(OUTPUT ${_potFile} COMMENT "Extract translatable messages to ${_potFile}" ) -ADD_CUSTOM_TARGET(_${potFile} ${_all} -DEPENDS ${_potFile} -) +add_custom_target(_${potFile} ${_all} DEPENDS ${_potFile}) -FILE(GLOB _poFiles *.po) +file(GLOB _poFiles *.po) -GETTEXT_CREATE_TRANSLATIONS(${_potFile} ALL ${_poFiles}) +gettext_create_translations(${_potFile} ALL ${_poFiles}) -- cgit v1.2.3-1-g7c22