linux install target for dfhack, ability to set data path

develop
Petr Mrázek 2009-10-30 00:56:40 +00:00
parent 851e105556
commit 759783e501
3 changed files with 50 additions and 17 deletions

@ -44,8 +44,19 @@ SET_SOURCE_FILES_PROPERTIES( ${PROJECT_HDRS} PROPERTIES HEADER_FILE_ONLY TRUE )
LIST(APPEND PROJECT_SRCS ${PROJECT_HDRS}) 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) IF(UNIX)
add_definitions(-DLINUX_BUILD) add_definitions(-DLINUX_BUILD)
add_definitions(-DUSE_CONFIG_H)
ELSE(UNIX) ELSE(UNIX)
SET(PROJECT_LIBS psapi) SET(PROJECT_LIBS psapi)
ENDIF(UNIX) ENDIF(UNIX)
@ -55,3 +66,10 @@ ADD_LIBRARY(dfhack SHARED ${PROJECT_SRCS})
SET_TARGET_PROPERTIES( dfhack PROPERTIES DEBUG_POSTFIX "-debug" ) SET_TARGET_PROPERTIES( dfhack PROPERTIES DEBUG_POSTFIX "-debug" )
TARGET_LINK_LIBRARIES(dfhack ${PROJECT_LIBS}) 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)

@ -31,10 +31,19 @@ distribution.
#include "DFHackAPI.h" #include "DFHackAPI.h"
#include "DFMemInfo.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 #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 #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 #endif
/* TODO: Test these /* TODO: Test these
@ -54,7 +63,9 @@ DFHackAPIImpl::DFHackAPIImpl(const string path_to_xml)
, pm(NULL), p(NULL), dm(NULL), offset_descriptor(NULL) , pm(NULL), p(NULL), dm(NULL), offset_descriptor(NULL)
, p_cons(NULL), p_bld(NULL), p_veg(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; constructionsInited = false;
creaturesInited = false; creaturesInited = false;
buildingsInited = false; buildingsInited = false;

@ -6,25 +6,29 @@ add_definitions(-DLINUX_BUILD)
ENDIF(UNIX) ENDIF(UNIX)
# a benchmark program, reads the map 1000x # a benchmark program, reads the map 1000x
ADD_EXECUTABLE(expbench expbench.cpp) ADD_EXECUTABLE(dfexpbench expbench.cpp)
TARGET_LINK_LIBRARIES(expbench dfhack) TARGET_LINK_LIBRARIES(dfexpbench dfhack)
# a reveal clone # a reveal clone
ADD_EXECUTABLE(reveal reveal.cpp) ADD_EXECUTABLE(dfreveal reveal.cpp)
TARGET_LINK_LIBRARIES(reveal dfhack) TARGET_LINK_LIBRARIES(dfreveal dfhack)
# prospector - produces a list of available materials and their quantities # prospector - produces a list of available materials and their quantities
ADD_EXECUTABLE(prospector prospector.cpp) ADD_EXECUTABLE(dfprospector prospector.cpp)
TARGET_LINK_LIBRARIES(prospector dfhack) TARGET_LINK_LIBRARIES(dfprospector dfhack)
# cleanmap - removes mud, snow, blood and similar stuff from a map. farmers beware # cleanmap - removes mud, snow, blood and similar stuff from a map. farmers beware
ADD_EXECUTABLE(cleanmap cleanmap.cpp) ADD_EXECUTABLE(dfcleanmap cleanmap.cpp)
TARGET_LINK_LIBRARIES(cleanmap dfhack) TARGET_LINK_LIBRARIES(dfcleanmap dfhack)
# creaturedump - basic creature dump - a test of the creature related exports # creaturedump - basic creature dump - a test of the creature related exports
ADD_EXECUTABLE(creaturedump creaturedump.cpp) ADD_EXECUTABLE(dfcreaturedump creaturedump.cpp)
TARGET_LINK_LIBRARIES(creaturedump dfhack) TARGET_LINK_LIBRARIES(dfcreaturedump dfhack)
# attachtest - 100x attach/detach, 100x reads, 100x writes # attachtest - 100x attach/detach, 100x reads, 100x writes
ADD_EXECUTABLE(attachtest attachtest.cpp) ADD_EXECUTABLE(dfattachtest attachtest.cpp)
TARGET_LINK_LIBRARIES(attachtest dfhack) TARGET_LINK_LIBRARIES(dfattachtest dfhack)
IF(UNIX)
install(TARGETS dfexpbench dfreveal dfreveal dfprospector dfcleanmap dfcreaturedump dfattachtest RUNTIME DESTINATION bin)
ENDIF(UNIX)