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})
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})
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 "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;

@ -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)
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)