From 3f892ec2aa4e72955ccc339fc32dee13f5dbebb7 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Wed, 31 Dec 2014 14:07:34 +0000 Subject: [PATCH] Move maps to /usr/local and allow these settings to get defaults from the cmakelists --- source/client/CMakeLists.txt | 8 ++++++++ source/client/main.cpp | 7 +++++-- source/gen/CMakeLists.txt | 2 +- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/source/client/CMakeLists.txt b/source/client/CMakeLists.txt index 7d12cef..6549943 100644 --- a/source/client/CMakeLists.txt +++ b/source/client/CMakeLists.txt @@ -13,6 +13,14 @@ set( SOURCES main.cpp ) +# Set defaults for ttrts maps and games +set( TTRTS_MAPS "/usr/local/share/ttrts/maps/" ) +set( TTRTS_GAMES "/tmp/" ) + +# define these defaults in code +set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DTTRTS_MAPS=${TTRTS_MAPS}" ) +set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DTTRTS_GAMES=${TTRTS_GAMES}" ) + # Add the executable add_executable( ${PROJECT_NAME} ${SOURCES} ) diff --git a/source/client/main.cpp b/source/client/main.cpp index 76ce858..35bf5de 100644 --- a/source/client/main.cpp +++ b/source/client/main.cpp @@ -12,6 +12,9 @@ #include "game.h" +#define STRINGIFY(x) _STRINGIFY(x) +#define _STRINGIFY(x) #x + static const char* sk_usage = #include "usage.h" ; @@ -69,7 +72,7 @@ int main(int argc, char* argv[]) std::string gameFile = argv[1]; // Default for maps - std::string ttrts_maps_dir = "/usr/share/ttrts/maps/"; + std::string ttrts_maps_dir = STRINGIFY(TTRTS_MAPS); if( getenv("TTRTS_MAPS") ) { ttrts_maps_dir = getenv("TTRTS_MAPS"); @@ -80,7 +83,7 @@ int main(int argc, char* argv[]) } // Default for games - std::string ttrts_games_dir = "/tmp/"; + std::string ttrts_games_dir = STRINGIFY(TTRTS_GAMES); if( getenv("TTRTS_GAMES") ) { ttrts_games_dir = getenv("TTRTS_GAMES"); diff --git a/source/gen/CMakeLists.txt b/source/gen/CMakeLists.txt index 7d0a030..466e233 100644 --- a/source/gen/CMakeLists.txt +++ b/source/gen/CMakeLists.txt @@ -25,4 +25,4 @@ add_custom_target( add_dependencies(ttrts-gen-maps ${PROJECT_NAME}) # Installation target -install( DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/maps DESTINATION /usr/share/ttrts ) \ No newline at end of file +install( DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/maps DESTINATION /usr/local/share/ttrts ) \ No newline at end of file