From 0a35afb16a884e02008aa23d4028d501f55c4618 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Sun, 20 Mar 2011 17:17:33 +0100 Subject: [PATCH] Use proper paths in build system. --- CMakeLists.txt | 25 +++++++++--------- doc/CMakeLists.txt | 16 +++++------- library/CMakeLists.txt | 34 ++++++++++--------------- tools/examples/CMakeLists.txt | 8 +++--- tools/playground/CMakeLists.txt | 8 +++--- tools/supported/CMakeLists.txt | 11 +++++--- {output => tools/supported}/dfXvdig.bat | 0 tools/supported/prospector.cpp | 6 +---- 8 files changed, 51 insertions(+), 57 deletions(-) rename {output => tools/supported}/dfXvdig.bat (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9c3b2d5da..e10fbe580 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,16 +4,17 @@ cmake_minimum_required(VERSION 2.8.0 FATAL_ERROR) PROJECT (dfhack) -SET(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/CMake/Modules) -# Set this to project source dir. When dfhack is used -# as a submodule, CMAKE_SOURCE_DIR is not pointing to -# the root where this particular CMakeLists.txt file sits. -SET(CMAKE_SOURCE_DIR ${PROJECT_SOURCE_DIR}) +SET(CMAKE_MODULE_PATH +${dfhack_SOURCE_DIR}/CMake/Modules +${CMAKE_MODULE_PATH} +) -if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}") +if("${dfhack_SOURCE_DIR}" STREQUAL "${dfhack_BINARY_DIR}") message(FATAL_ERROR "In-source builds are not allowed.") endif() +SET(DFHACK_CONSISTENCY 1) + set(CPACK_PACKAGE_VERSION_MAJOR "0") set(CPACK_PACKAGE_VERSION_MINOR "5") set(CPACK_PACKAGE_VERSION_PATCH "8") @@ -41,9 +42,9 @@ IF(NOT DEFINED CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE STREQUAL "") ENDIF() ## put everything in one big ugly directory to make MSVC and KDevelop debuggers happy -SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") -SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") -SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") +SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${dfhack_BINARY_DIR}/bin") +SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${dfhack_BINARY_DIR}/bin") +SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${dfhack_BINARY_DIR}/bin") IF(WIN32) set (DFHACK_INST_DEFAULT "portable") @@ -143,9 +144,9 @@ OPTION(BUILD_DFHACK_SUPPORTED "Build the supported tools." ON) OPTION(BUILD_DFHACK_EXAMPLES "Build example tools" OFF) OPTION(BUILD_DFHACK_PLAYGROUND "Build tools from the playground folder" OFF) -include_directories (${CMAKE_SOURCE_DIR}/library/include/) -include_directories (${CMAKE_SOURCE_DIR}/library/shm/) -include_directories (${CMAKE_SOURCE_DIR}/library/depends/argstream/) +include_directories (${dfhack_SOURCE_DIR}/library/include/) +include_directories (${dfhack_SOURCE_DIR}/library/shm/) +include_directories (${dfhack_SOURCE_DIR}/library/depends/argstream/) # macro to save on typing in the tool subdirs # builds a tool, links it to the dfhack lib and makes sure the dependency diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt index 31c456a20..aad02a203 100644 --- a/doc/CMakeLists.txt +++ b/doc/CMakeLists.txt @@ -35,16 +35,12 @@ IF(DOXYGEN_FOUND) # with DOXYGEN_SOURCE_DIR we fill a list of directories and later we write it into # the Doxyfile with a REGEX REPLACE (see below) SET( DOXYGEN_SOURCE_DIR - # "${CMAKE_SOURCE_DIR}/library" - "${CMAKE_SOURCE_DIR}/doc/index.dxgen" - "${CMAKE_SOURCE_DIR}/library/include" - "${CMAKE_SOURCE_DIR}/library/include/dfhack" - "${CMAKE_SOURCE_DIR}/library/include/dfhack/modules" - "${CMAKE_SOURCE_DIR}/library/include/dfhack-c" - "${CMAKE_SOURCE_DIR}/library/include/dfhack-c/modules" -# "${CMAKE_SOURCE_DIR}/library/modules" -# "${CMAKE_SOURCE_DIR}/library/shm" -# "${CMAKE_SOURCE_DIR}/library/private" + "${dfhack_SOURCE_DIR}/doc/index.dxgen" + "${dfhack_SOURCE_DIR}/library/include" + "${dfhack_SOURCE_DIR}/library/include/dfhack" + "${dfhack_SOURCE_DIR}/library/include/dfhack/modules" + "${dfhack_SOURCE_DIR}/library/include/dfhack-c" + "${dfhack_SOURCE_DIR}/library/include/dfhack-c/modules" ) STRING(REGEX REPLACE ";" " " CMAKE_DOXYGEN_INPUT_LIST "${DOXYGEN_SOURCE_DIR}") diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt index 4a04466fa..4e5be3402 100644 --- a/library/CMakeLists.txt +++ b/library/CMakeLists.txt @@ -1,22 +1,15 @@ -# don't use this file directly. use the one in the root folder of the project +if(NOT DEFINED DFHACK_CONSISTENCY) + MESSAGE(FATAL_ERROR "Please build the whole thing, not parts. You can turn parts on/off using options.") +ENDIF() + PROJECT (dfhack-library) cmake_minimum_required(VERSION 2.8) -SET(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/CMake/Modules) - -if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}") - message(FATAL_ERROR "In-source builds are not allowed.") -endif() - -IF(NOT DEFINED CMAKE_BUILD_TYPE) - SET(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel.") -ENDIF() -include_directories (${CMAKE_SOURCE_DIR}/library/include/) -include_directories (${CMAKE_SOURCE_DIR}/library/shm/) -include_directories (${CMAKE_SOURCE_DIR}/library/depends/md5/) -include_directories (${CMAKE_SOURCE_DIR}/library/depends/tinyxml/) -include_directories (${CMAKE_SOURCE_DIR}/library/depends/argstream/) -include_directories (${CMAKE_SOURCE_DIR}/library/private/) +include_directories (include) +include_directories (depends/md5) +include_directories (depends/tinyxml) +include_directories (depends/argstream) +include_directories (private) SET(PROJECT_HDRS_INTERNAL private/ContextShared.h @@ -167,7 +160,6 @@ IF( CMAKE_SIZEOF_VOID_P MATCHES 8 ) ADD_DEFINITIONS(-DHAVE_64_BIT) ENDIF() -#CONFIGURE_FILE( ${CMAKE_SOURCE_DIR}/library/config.h.cmake ${CMAKE_SOURCE_DIR}/library/private/config.h ) ADD_DEFINITIONS(-DMEMXML_DATA_PATH="${MEMXML_DATA_PATH}") ADD_DEFINITIONS(-DBUILD_DFHACK_LIB -DTIXML_USE_STL) @@ -180,7 +172,7 @@ IF(UNIX) SET(PROJECT_LIBS ${X11_LIBRARY} rt ) ELSE() IF(MSVC) - SET(PROJECT_LIBS psapi ${CMAKE_SOURCE_DIR}/library/depends/ntdll/ntdll.lib) + SET(PROJECT_LIBS psapi ${dfhack_SOURCE_DIR}/library/depends/ntdll/ntdll.lib) ELSE() SET(PROJECT_LIBS psapi ntdll) ENDIF() @@ -193,12 +185,12 @@ SET_TARGET_PROPERTIES(dfhack PROPERTIES DEBUG_POSTFIX "-debug" ) TARGET_LINK_LIBRARIES(dfhack ${PROJECT_LIBS}) ADD_CUSTOM_COMMAND( TARGET dfhack POST_BUILD -COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/Memory.xml ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/) +COMMAND ${CMAKE_COMMAND} -E copy ${dfhack_SOURCE_DIR}/Memory.xml ${dfhack_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/) install(TARGETS dfhack LIBRARY DESTINATION ${DFHACK_LIBRARY_DESTINATION} RUNTIME DESTINATION ${DFHACK_LIBRARY_DESTINATION}) #linux: lib -install(FILES ${CMAKE_SOURCE_DIR}/Memory.xml +install(FILES ${dfhack_SOURCE_DIR}/Memory.xml DESTINATION ${DFHACK_DATA_DESTINATION}) #linux: share/dfhack if(BUILD_DFHACK_DEVEL) @@ -206,7 +198,7 @@ if(BUILD_DFHACK_DEVEL) install(TARGETS dfhack ARCHIVE DESTINATION ${DFHACK_DEVLIB_DESTINATION}) endif() - install(DIRECTORY ${CMAKE_SOURCE_DIR}/library/include/ + install(DIRECTORY include DESTINATION ${DFHACK_INCLUDES_DESTINATION} FILES_MATCHING PATTERN "*.h" ) #linux: include endif() diff --git a/tools/examples/CMakeLists.txt b/tools/examples/CMakeLists.txt index 0c0f66660..81c14bb23 100644 --- a/tools/examples/CMakeLists.txt +++ b/tools/examples/CMakeLists.txt @@ -1,13 +1,15 @@ -# don't use this file directly. use the one in the root folder of the project +if(NOT DEFINED DFHACK_CONSISTENCY) + MESSAGE(FATAL_ERROR "Please build the whole thing, not parts. You can turn parts on/off using options.") +ENDIF() # this is required to ensure we use the right configuration for the system. IF(UNIX) -add_definitions(-DLINUX_BUILD) + add_definitions(-DLINUX_BUILD) ENDIF(UNIX) IF(MSVC) ADD_CUSTOM_TARGET( memxml-for-examples - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/Memory.xml ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${CMAKE_COMMAND} -E copy ${dfhack_SOURCE_DIR}/Memory.xml ${CMAKE_CURRENT_BINARY_DIR} COMMENT "Copying Memory.xml to ${CMAKE_CURRENT_BINARY_DIR}" ) set(LOCAL_DEPNAME memxml-for-examples) diff --git a/tools/playground/CMakeLists.txt b/tools/playground/CMakeLists.txt index 117f9601d..db2e80c4c 100644 --- a/tools/playground/CMakeLists.txt +++ b/tools/playground/CMakeLists.txt @@ -1,14 +1,16 @@ -# don't use this file directly. use the one in the root folder of the project +if(NOT DEFINED DFHACK_CONSISTENCY) + MESSAGE(FATAL_ERROR "Please build the whole thing, not parts. You can turn parts on/off using options.") +ENDIF() # this is required to ensure we use the right configuration for the system. IF(UNIX) -add_definitions(-DLINUX_BUILD) + add_definitions(-DLINUX_BUILD) ENDIF(UNIX) # deep magic. make sure it runs to be able to do debug runs for MSVC projects out of the box IF(MSVC) ADD_CUSTOM_TARGET( memxml-for-playground - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/Memory.xml ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${CMAKE_COMMAND} -E copy ${dfhack_SOURCE_DIR}/Memory.xml ${CMAKE_CURRENT_BINARY_DIR} COMMENT "Copying Memory.xml to ${CMAKE_CURRENT_BINARY_DIR}" ) set(LOCAL_DEPNAME memxml-for-playground) diff --git a/tools/supported/CMakeLists.txt b/tools/supported/CMakeLists.txt index 96b59301c..e7c81d986 100644 --- a/tools/supported/CMakeLists.txt +++ b/tools/supported/CMakeLists.txt @@ -1,13 +1,15 @@ -# don't use this file directly. use the one in the root folder of the project +if(NOT DEFINED DFHACK_CONSISTENCY) + MESSAGE(FATAL_ERROR "Please build the whole thing, not parts. You can turn parts on/off using options.") +ENDIF() # this is required to ensure we use the right configuration for the system. IF(UNIX) -add_definitions(-DLINUX_BUILD) + add_definitions(-DLINUX_BUILD) ENDIF() IF(MSVC) ADD_CUSTOM_TARGET( memxml-for-supported - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/Memory.xml ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${CMAKE_COMMAND} -E copy ${dfhack_SOURCE_DIR}/Memory.xml ${CMAKE_CURRENT_BINARY_DIR} COMMENT "Copying Memory.xml to ${CMAKE_CURRENT_BINARY_DIR}") set(LOCAL_DEPNAME memxml-for-supported) ENDIF() @@ -23,6 +25,9 @@ DFHACK_TOOL(dfprospector prospector.cpp) # vdig - dig the vein under the cursor DFHACK_TOOL(dfvdig vdig.cpp) +IF(WIN32) + INSTALL(PROGRAMS dfXvdig.bat DESTINATION ${DFHACK_BINARY_DESTINATION}) +ENDIF() # cleanmap - removes mud, snow, blood and similar stuff from a map. farmers beware DFHACK_TOOL(dfcleanmap cleanmap.cpp) diff --git a/output/dfXvdig.bat b/tools/supported/dfXvdig.bat similarity index 100% rename from output/dfXvdig.bat rename to tools/supported/dfXvdig.bat diff --git a/tools/supported/prospector.cpp b/tools/supported/prospector.cpp index df0d3e852..fc19d7bec 100644 --- a/tools/supported/prospector.cpp +++ b/tools/supported/prospector.cpp @@ -65,11 +65,7 @@ int main (int argc, const char* argv[]) showhidden = true; #endif uint32_t x_max,y_max,z_max; - /* - DFHack::tiletypes40d tiletypes; - DFHack::designations40d designations; - DFHack::biome_indices40d regionoffsets; - */ + DFHack::mapblock40d Block; map materials; materials.clear();