From 759783e50140a3e1299923d8efbcc06fe1a12188 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Fri, 30 Oct 2009 00:56:40 +0000 Subject: [PATCH] linux install target for dfhack, ability to set data path --- library/CMakeLists.txt | 20 +++++++++++++++++++- library/DFHackAPI.cpp | 19 +++++++++++++++---- tools/CMakeLists.txt | 28 ++++++++++++++++------------ 3 files changed, 50 insertions(+), 17 deletions(-) diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt index 56be12574..e2b718d51 100644 --- a/library/CMakeLists.txt +++ b/library/CMakeLists.txt @@ -44,8 +44,19 @@ SET_SOURCE_FILES_PROPERTIES( ${PROJECT_HDRS} PROPERTIES HEADER_FILE_ONLY TRUE ) LIST(APPEND PROJECT_SRCS ${PROJECT_HDRS}) +SET( MEMXML_DATA_PATH ${CMAKE_INSTALL_PREFIX} CACHE PATH "search path for Memory.xml") +# OPTION( VARIABLE "Description" Initial state) +#OPTION( WITH_FOO "Enable FOO support" ON ) +#OPTION( WITH_BAR "Enable BAR component" OFF ) + + +CONFIGURE_FILE( ${CMAKE_SOURCE_DIR}/library/config.h.cmake ${CMAKE_SOURCE_DIR}/library/config.h ) + + + IF(UNIX) add_definitions(-DLINUX_BUILD) + add_definitions(-DUSE_CONFIG_H) ELSE(UNIX) SET(PROJECT_LIBS psapi) ENDIF(UNIX) @@ -54,4 +65,11 @@ ADD_LIBRARY(dfhack SHARED ${PROJECT_SRCS}) SET_TARGET_PROPERTIES( dfhack PROPERTIES DEBUG_POSTFIX "-debug" ) -TARGET_LINK_LIBRARIES(dfhack ${PROJECT_LIBS}) \ No newline at end of file +TARGET_LINK_LIBRARIES(dfhack ${PROJECT_LIBS}) + +IF(UNIX) + install(TARGETS dfhack LIBRARY DESTINATION lib) + install(FILES ${CMAKE_SOURCE_DIR}/output/Memory.xml DESTINATION share/dfhack) +ENDIF(UNIX) + +#install(TARGETS mySharedLib DESTINATION /some/full/path) \ No newline at end of file diff --git a/library/DFHackAPI.cpp b/library/DFHackAPI.cpp index dd181a611..9e912ecaf 100644 --- a/library/DFHackAPI.cpp +++ b/library/DFHackAPI.cpp @@ -31,10 +31,19 @@ distribution. #include "DFHackAPI.h" #include "DFMemInfo.h" +#define _QUOTEME(x) #x +#define QUOT(x) _QUOTEME(x) + +#ifdef USE_CONFIG_H + #include "config.h" +#else + #define MEMXML_DATA_PATH . +#endif + #if defined(_MSC_VER) && _MSC_VER >= 1400 -# define fill_char_buf(buf, str) strcpy_s((buf), sizeof(buf) / sizeof((buf)[0]), (str).c_str()) + #define fill_char_buf(buf, str) strcpy_s((buf), sizeof(buf) / sizeof((buf)[0]), (str).c_str()) #else -# define fill_char_buf(buf, str) strncpy((buf), (str).c_str(), sizeof(buf) / sizeof((buf)[0])) + #define fill_char_buf(buf, str) strncpy((buf), (str).c_str(), sizeof(buf) / sizeof((buf)[0])) #endif /* TODO: Test these @@ -43,7 +52,7 @@ distribution. DFHACKAPI DFHackAPI *CreateDFHackAPI0(const char *path_to_xml) { - return new DFHackAPIImpl(path_to_xml); + return new DFHackAPIImpl(path_to_xml); } // TODO: templating for vectors, simple copy constructor for stl vectors @@ -54,7 +63,9 @@ DFHackAPIImpl::DFHackAPIImpl(const string path_to_xml) , pm(NULL), p(NULL), dm(NULL), offset_descriptor(NULL) , p_cons(NULL), p_bld(NULL), p_veg(NULL) { - xml = path_to_xml; + xml = QUOT(MEMXML_DATA_PATH); + xml += "/"; + xml += path_to_xml; constructionsInited = false; creaturesInited = false; buildingsInited = false; diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 9240a566e..74a295e33 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -6,25 +6,29 @@ add_definitions(-DLINUX_BUILD) ENDIF(UNIX) # a benchmark program, reads the map 1000x -ADD_EXECUTABLE(expbench expbench.cpp) -TARGET_LINK_LIBRARIES(expbench dfhack) +ADD_EXECUTABLE(dfexpbench expbench.cpp) +TARGET_LINK_LIBRARIES(dfexpbench dfhack) # a reveal clone -ADD_EXECUTABLE(reveal reveal.cpp) -TARGET_LINK_LIBRARIES(reveal dfhack) +ADD_EXECUTABLE(dfreveal reveal.cpp) +TARGET_LINK_LIBRARIES(dfreveal dfhack) # prospector - produces a list of available materials and their quantities -ADD_EXECUTABLE(prospector prospector.cpp) -TARGET_LINK_LIBRARIES(prospector dfhack) +ADD_EXECUTABLE(dfprospector prospector.cpp) +TARGET_LINK_LIBRARIES(dfprospector dfhack) # cleanmap - removes mud, snow, blood and similar stuff from a map. farmers beware -ADD_EXECUTABLE(cleanmap cleanmap.cpp) -TARGET_LINK_LIBRARIES(cleanmap dfhack) +ADD_EXECUTABLE(dfcleanmap cleanmap.cpp) +TARGET_LINK_LIBRARIES(dfcleanmap dfhack) # creaturedump - basic creature dump - a test of the creature related exports -ADD_EXECUTABLE(creaturedump creaturedump.cpp) -TARGET_LINK_LIBRARIES(creaturedump dfhack) +ADD_EXECUTABLE(dfcreaturedump creaturedump.cpp) +TARGET_LINK_LIBRARIES(dfcreaturedump dfhack) # attachtest - 100x attach/detach, 100x reads, 100x writes -ADD_EXECUTABLE(attachtest attachtest.cpp) -TARGET_LINK_LIBRARIES(attachtest dfhack) \ No newline at end of file +ADD_EXECUTABLE(dfattachtest attachtest.cpp) +TARGET_LINK_LIBRARIES(dfattachtest dfhack) + +IF(UNIX) + install(TARGETS dfexpbench dfreveal dfreveal dfprospector dfcleanmap dfcreaturedump dfattachtest RUNTIME DESTINATION bin) +ENDIF(UNIX) \ No newline at end of file