2009-09-13 18:02:46 -06:00
# main project file. use it from a build sub-folder, see COMPILE for details
2011-03-16 00:35:08 -06:00
## some generic CMake magic
cmake_minimum_required ( VERSION 2.8.0 FATAL_ERROR )
2010-01-03 22:20:28 -07:00
PROJECT ( dfhack )
2009-09-13 18:02:46 -06:00
2011-03-16 00:35:08 -06:00
SET ( CMAKE_MODULE_PATH ${ CMAKE_SOURCE_DIR } /CMake/Modules )
2010-08-16 01:09:33 -06:00
# 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 } )
2010-05-26 04:24:45 -06:00
if ( "${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}" )
2011-03-17 17:07:40 -06:00
message ( FATAL_ERROR "In-source builds are not allowed." )
2011-03-16 00:35:08 -06:00
endif ( )
2009-09-13 18:02:46 -06:00
2011-03-17 23:07:13 -06:00
2011-03-17 17:07:40 -06:00
set ( DEVEL_RELEASE "-dev" )
set ( CPACK_PACKAGE_VERSION_MAJOR "0" )
set ( CPACK_PACKAGE_VERSION_MINOR "5" )
set ( CPACK_PACKAGE_VERSION_PATCH "8" )
2011-03-17 23:07:13 -06:00
set ( DFHACK_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}" )
2011-03-17 17:07:40 -06:00
set ( CPACK_PACKAGE_NAME "dfhack" )
2011-03-16 00:35:08 -06:00
## setting the build type
2009-09-13 18:02:46 -06:00
IF ( NOT DEFINED CMAKE_BUILD_TYPE )
2011-03-16 00:35:08 -06:00
SET ( CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." )
ENDIF ( )
2009-09-13 18:02:46 -06:00
2011-03-17 17:07:40 -06:00
## put everything in one big ugly directory to make MSVC and KDevelop debuggers happy
2011-03-16 00:35:08 -06:00
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" )
2009-09-13 18:02:46 -06:00
2011-03-17 23:07:13 -06:00
IF ( WIN32 )
set ( DFHACK_INST_DEFAULT "portable" )
ELSE ( )
set ( DFHACK_INST_DEFAULT "linux" )
ENDIF ( )
SET ( DFHACK_INSTALL ${ DFHACK_INST_DEFAULT } CACHE STRING "Choose the install type: 'portable' for a portable zip or tar.gz package (windows default), 'linux' for packaging and system installs on linux (linux default)." )
2011-03-17 17:07:40 -06:00
SET ( MEMXML_DATA_PATH . CACHE PATH "Path to a valid Memory.xml file. This is baked into the library, so when you package DFHack for linux, set it to the right path." )
IF ( ${ DFHACK_INSTALL } STREQUAL "portable" )
# the dfhack libraries will be installed here:
SET ( DFHACK_LIBRARY_DESTINATION . )
# the dfhack tools will be installed here:
SET ( DFHACK_BINARY_DESTINATION . )
# Memory.xml goes here:
SET ( DFHACK_DATA_DESTINATION . )
# Includes go here:
SET ( DFHACK_INCLUDES_DESTINATION dev/include )
# the Windows .lib files go here:
IF ( WIN32 )
SET ( DFHACK_DEVLIB_DESTINATION dev )
SET ( CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION . )
ENDIF ( )
2011-03-17 23:07:13 -06:00
# documentation goes here:
SET ( DFHACK_USERDOC_DESTINATION . )
SET ( DFHACK_DEVDOC_DESTINATION dev )
SET ( DFHACK_DOXYGEN_DESTINATION dev/doxygen )
2011-03-17 17:07:40 -06:00
ENDIF ( )
IF ( ${ DFHACK_INSTALL } STREQUAL "linux" )
# the dfhack libraries will be installed here:
SET ( DFHACK_LIBRARY_DESTINATION lib )
# the dfhack tools will be installed here:
SET ( DFHACK_BINARY_DESTINATION bin )
# Memory.xml goes here:
SET ( DFHACK_DATA_DESTINATION share/dfhack )
# Includes go here:
SET ( DFHACK_INCLUDES_DESTINATION include )
2011-03-17 23:07:13 -06:00
# documentation goes here:
SET ( DFHACK_USERDOC_DESTINATION share/dfhack/doc )
SET ( DFHACK_DEVDOC_DESTINATION share/dfhack/doc )
SET ( DFHACK_DOXYGEN_DESTINATION share/dfhack/doc/doxygen )
2011-03-17 17:07:40 -06:00
ENDIF ( )
## some options for the user/developer to play with
OPTION ( BUILD_DFHACK_SUPPORTED "Build the supported tools." ON )
OPTION ( BUILD_DFHACK_C_BINDINGS "Build the C portion of the library" ON )
2011-03-16 00:35:08 -06:00
OPTION ( BUILD_DFHACK_DOXYGEN "Create doxygen documentation for developers" ON )
2010-07-08 14:58:01 -06:00
OPTION ( BUILD_DFHACK_EXAMPLES "Build example tools" OFF )
OPTION ( BUILD_DFHACK_PLAYGROUND "Build tools from the playground folder" OFF )
2010-06-23 16:34:35 -06:00
2010-05-25 22:48:23 -06:00
include_directories ( ${ CMAKE_SOURCE_DIR } /library/include/ )
include_directories ( ${ CMAKE_SOURCE_DIR } /library/shm/ )
2011-03-06 14:20:08 -07:00
include_directories ( ${ CMAKE_SOURCE_DIR } /library/depends/argstream/ )
2009-09-13 18:02:46 -06:00
2010-05-25 22:48:23 -06:00
add_subdirectory ( library )
2010-08-14 12:22:59 -06:00
2011-03-17 23:07:13 -06:00
## install the default documentation files
install ( FILES Readme.html Compile.html DESTINATION ${ DFHACK_USERDOC_DESTINATION } )
2011-03-16 00:35:08 -06:00
# macro to save on typing in the tool subdirs
2011-03-17 17:07:40 -06:00
# builds a tool, links it to the dfhack lib and makes sure the dependency
# LOCAL_DEPNAME is built first, in case there is one
2011-03-16 00:35:08 -06:00
MACRO ( DFHACK_TOOL TOOL_NAME TOOL_SOURCES )
ADD_EXECUTABLE ( ${ TOOL_NAME } ${ TOOL_SOURCES } )
TARGET_LINK_LIBRARIES ( ${ TOOL_NAME } dfhack )
if ( DEFINED LOCAL_DEPNAME )
ADD_DEPENDENCIES ( ${ TOOL_NAME } ${ LOCAL_DEPNAME } )
endif ( )
install ( TARGETS
$ { T O O L _ N A M E }
2011-03-17 17:07:40 -06:00
R U N T I M E D E S T I N A T I O N $ { D F H A C K _ B I N A R Y _ D E S T I N A T I O N } )
2011-03-16 00:35:08 -06:00
ENDMACRO ( )
2010-08-15 16:45:02 -06:00
IF ( BUILD_DFHACK_SUPPORTED )
add_subdirectory ( tools/supported )
2011-03-16 00:35:08 -06:00
ENDIF ( )
2010-08-15 16:45:02 -06:00
IF ( BUILD_DFHACK_EXAMPLES )
add_subdirectory ( tools/examples )
2011-03-16 00:35:08 -06:00
ENDIF ( )
2010-08-15 16:45:02 -06:00
IF ( BUILD_DFHACK_PLAYGROUND )
add_subdirectory ( tools/playground )
2011-03-16 00:35:08 -06:00
ENDIF ( )
2010-08-15 16:45:02 -06:00
2011-03-16 00:35:08 -06:00
IF ( BUILD_DFHACK_DOXYGEN )
2010-08-15 16:45:02 -06:00
add_subdirectory ( doc )
2011-03-16 00:35:08 -06:00
ENDIF ( )
2011-03-17 17:07:40 -06:00
IF ( ${ DFHACK_INSTALL } STREQUAL "portable" )
IF ( UNIX )
SET ( CPACK_GENERATOR "TGZ" )
ENDIF ( )
IF ( WIN32 )
SET ( CPACK_GENERATOR "ZIP" )
# this includes the MSVC C++ DLLs in the package. Doesn't work with Express versions in general.
INCLUDE ( InstallRequiredSystemLibraries )
ENDIF ( )
set ( CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${DFHACK_VERSION}-${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}" )
INCLUDE ( CPack )
ENDIF ( )