From 21f7f8e7038286d550a7a61a3e1ea83f46e01286 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Fri, 13 Aug 2010 02:23:38 +0200 Subject: [PATCH] Moved memory defs to /data. Memory.xml is copied into the right folder at build time (works even with MSVC). --- CMakeLists.txt | 2 ++ {output => data}/Memory-40d.xml | 0 {offsetedit => data}/Memory-ng.xml | 0 {output => data}/Memory.xml | 0 library/CMakeLists.txt | 14 ++++++++++++++ library/DFMemInfoManager.cpp | 6 +++--- 6 files changed, 19 insertions(+), 3 deletions(-) rename {output => data}/Memory-40d.xml (100%) rename {offsetedit => data}/Memory-ng.xml (100%) mode change 100755 => 100644 rename {output => data}/Memory.xml (100%) mode change 100755 => 100644 diff --git a/CMakeLists.txt b/CMakeLists.txt index 50072ab9b..160b71a6f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,10 +19,12 @@ ENDIF(NOT DEFINED CMAKE_BUILD_TYPE) SET( LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/output CACHE PATH "Output directory for the dfhack library" ) SET( EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/output CACHE PATH "Output directory for the dfhack tools" ) +SET( DATA_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/output CACHE PATH "Output directory for the dfhack data (offset files)" ) OPTION(BUILD_DFHACK_DOCUMENTATION "Create doxygen documentation for developers" OFF) OPTION(BUILD_DFHACK_EXAMPLES "Build example tools" OFF) OPTION(BUILD_DFHACK_PLAYGROUND "Build tools from the playground folder" OFF) +OPTION(BUILD_DFHACK_C_BINDIGS "Build the C portion of the library" ON) include_directories (${CMAKE_SOURCE_DIR}/library/include/) include_directories (${CMAKE_SOURCE_DIR}/library/shm/) diff --git a/output/Memory-40d.xml b/data/Memory-40d.xml similarity index 100% rename from output/Memory-40d.xml rename to data/Memory-40d.xml diff --git a/offsetedit/Memory-ng.xml b/data/Memory-ng.xml old mode 100755 new mode 100644 similarity index 100% rename from offsetedit/Memory-ng.xml rename to data/Memory-ng.xml diff --git a/output/Memory.xml b/data/Memory.xml old mode 100755 new mode 100644 similarity index 100% rename from output/Memory.xml rename to data/Memory.xml diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt index f036a7a44..9442a4cc7 100644 --- a/library/CMakeLists.txt +++ b/library/CMakeLists.txt @@ -164,6 +164,20 @@ SET_TARGET_PROPERTIES(dfhack PROPERTIES DEBUG_POSTFIX "-debug" ) TARGET_LINK_LIBRARIES(dfhack ${PROJECT_LIBS}) +if(MSVC) + # This is a MSVC hack used for copying files into the target directory + # of build target set in MSVC. + # It exploits the fact that MSVC has some variables in .vcproj files, much like cmake does here. + # + # So, $(TargetDir) is ignored by cmake, and replaced with the actual output directory by MSVC + ADD_CUSTOM_COMMAND(TARGET dfhack POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/data/Memory.xml $(TargetDir)/Memory.xml + ) +else(MSVC) + # Just put the file in the output directory on Linux and Mac + configure_file(${CMAKE_SOURCE_DIR}/data/Memory-ng.xml ${DATA_OUTPUT_PATH}/Memory.xml COPYONLY) +endif(MSVC) + IF(UNIX) install(TARGETS dfhack LIBRARY DESTINATION lib) install(FILES ${CMAKE_SOURCE_DIR}/output/Memory.xml DESTINATION share/dfhack) diff --git a/library/DFMemInfoManager.cpp b/library/DFMemInfoManager.cpp index 48ea3f8a2..cc4c5de4a 100644 --- a/library/DFMemInfoManager.cpp +++ b/library/DFMemInfoManager.cpp @@ -154,9 +154,9 @@ void MemInfoManager::ParseEntry (TiXmlElement* entry, memory_info* mem, map Value(); const char *cstr_name = pMemEntry->Attribute("name"); const char *cstr_value = pMemEntry->GetText(); - - if(!cstr_value) - cstr_value = pMemEntry->Attribute("id"); + + if(!cstr_value) + cstr_value = pMemEntry->Attribute("id"); // check for missing parts string type, name, value;