@ -1,37 +1,37 @@
# m a i n p r o j e c t f i l e . u s e i t f r o m a b u i l d s u b - f o l d e r , s e e C O M P I L E f o r d e t a i l s
# # s o m e g e n e r i c C M a k e m a g i c
cmake_minimum_required ( VERSION 2.8.12 FATAL_ERROR )
project ( dfhack )
if ( "${CMAKE_GENERATOR}" STREQUAL Ninja )
if ( "${CMAKE_VERSION}" VERSION_LESS 3.9 )
message ( WARNING "You are using an old version of CMake (${CMAKE_VERSION}) with Ninja. This may result in ninja errors - see docs/Compile.rst for more details. Upgrading your CMake version is recommended." )
endif ( )
endif ( )
# S e t u p b u i l d t y p e s
if ( CMAKE_CONFIGURATION_TYPES )
SET ( CMAKE_CONFIGURATION_TYPES "Release;RelWithDebInfo" CACHE STRING "List of supported configuration types" FORCE )
set ( CMAKE_CONFIGURATION_TYPES "Release;RelWithDebInfo" CACHE STRING "List of supported configuration types" FORCE )
else ( CMAKE_CONFIGURATION_TYPES )
set ( DFHACK_TYPE_HELP "Choose the type of build, options are: Release and RelWithDebInfo" )
# P r e v e n t c m a k e C m o d u l e a t t e m p t s t o o v e r w r i t e o u r h e l p s t r i n g
if ( NOT CMAKE_BUILD_TYPE )
SET ( CMAKE_BUILD_TYPE "Release" CACHE STRING "${DFHACK_TYPE_HELP}" )
set ( CMAKE_BUILD_TYPE "Release" CACHE STRING "${DFHACK_TYPE_HELP}" )
else ( NOT CMAKE_BUILD_TYPE )
SET ( CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING "${DFHACK_TYPE_HELP}" )
set ( CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING "${DFHACK_TYPE_HELP}" )
endif ( NOT CMAKE_BUILD_TYPE )
set_property ( CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Release;RelWithDebInfo" )
endif ( CMAKE_CONFIGURATION_TYPES )
OPTION ( BUILD_DOCS "Choose whether to build the documentation (requires python and Sphinx)." OFF )
OPTION ( REMOVE_SYMBOLS_FROM_DF_STUBS "Remove debug symbols from DF stubs. (Reduces libdfhack size to about half but removes a few useful symbols)" ON )
# # s o m e g e n e r i c C M a k e m a g i c
cmake_minimum_required ( VERSION 2.8.12 FATAL_ERROR )
project ( dfhack )
if ( "${CMAKE_GENERATOR}" STREQUAL Ninja )
if ( "${CMAKE_VERSION}" VERSION_LESS 3.9 )
message ( WARNING "You are using an old version of CMake (${CMAKE_VERSION}) with Ninja. This may result in ninja errors - see docs/Compile.rst for more details. Upgrading your CMake version is recommended." )
endif ( )
endif ( )
option ( BUILD_DOCS "Choose whether to build the documentation (requires python and Sphinx)." OFF )
option ( REMOVE_SYMBOLS_FROM_DF_STUBS "Remove debug symbols from DF stubs. (Reduces libdfhack size to about half but removes a few useful symbols)" ON )
macro ( CHECK_GCC COMPILER_PATH )
execute_process ( COMMAND ${ COMPILER_PATH } -dumpversion OUTPUT_VARIABLE GCC_VERSION_OUT )
macro ( CHECK_GCC compiler_path )
execute_process ( COMMAND ${ compiler_path } -dumpversion OUTPUT_VARIABLE GCC_VERSION_OUT )
string ( STRIP "${GCC_VERSION_OUT}" GCC_VERSION_OUT )
if ( ${ GCC_VERSION_OUT } VERSION_LESS "4.8" )
message ( SEND_ERROR "${ COMPILER_PATH } version ${GCC_VERSION_OUT} cannot be used - use GCC 4.8 or later")
message ( SEND_ERROR "${compiler_path} version ${GCC_VERSION_OUT} cannot be used - use GCC 4.8 or later" )
elseif ( ${ GCC_VERSION_OUT } VERSION_GREATER "4.9.9" )
# G C C 5 c h a n g e s A B I n a m e m a n g l i n g t o e n a b l e C + + 1 1 c h a n g e s .
# T h i s m u s t b e d i s a b l e d t o e n a b l e l i n k i n g a g a i n s t D F .
@ -42,12 +42,12 @@ endmacro()
if ( UNIX )
if ( CMAKE_COMPILER_IS_GNUCC )
CHECK_GCC ( ${ CMAKE_C_COMPILER } )
check_gcc ( ${ CMAKE_C_COMPILER } )
else ( )
message ( SEND_ERROR "C compiler is not GCC" )
endif ( )
if ( CMAKE_COMPILER_IS_GNUCXX )
CHECK_GCC ( ${ CMAKE_CXX_COMPILER } )
check_gcc ( ${ CMAKE_CXX_COMPILER } )
else ( )
message ( SEND_ERROR "C++ compiler is not GCC" )
endif ( )
@ -70,7 +70,7 @@ if(MSVC)
# d i s a b l e C 4 8 1 9 c o d e - p a g e w a r n i n g
add_definitions ( "/wd4819" )
# D i s a b l e u s e o f P O S I X n a m e w a r n i n g s
# d i s a b l e u s e o f P O S I X n a m e w a r n i n g s
add_definitions ( "/D_CRT_NONSTDC_NO_WARNINGS /D_CRT_SECURE_NO_WARNINGS" )
# s u p r e s s C 4 5 0 3 - V C + + d i s l i k e s i f a n a m e i s t o o l o n g . I f y o u g e t
@ -86,33 +86,33 @@ if(MSVC)
endif ( )
# A u t o m a t i c a l l y d e t e c t a r c h i t e c t u r e b a s e d o n V i s u a l S t u d i o g e n e r a t o r
IF ( MSVC AND NOT DEFINED DFHACK_BUILD_ARCH )
IF ( ${ CMAKE_GENERATOR } MATCHES "Win64" )
SET ( DFHACK_BUILD_ARCH "64" )
ELSE ( )
SET ( DFHACK_BUILD_ARCH "32" )
ENDIF ( )
ELSE ( )
SET ( DFHACK_BUILD_ARCH "64" CACHE STRING "Architecture to build ('32' or '64')" )
ENDIF ( )
IF ( "${DFHACK_BUILD_ARCH}" STREQUAL "32" )
SET ( DFHACK_BUILD_32 1 )
SET ( DFHACK_BUILD_64 0 )
if ( MSVC AND NOT DEFINED DFHACK_BUILD_ARCH )
if ( ${ CMAKE_GENERATOR } MATCHES "Win64" )
set ( DFHACK_BUILD_ARCH "64" )
else ( )
set ( DFHACK_BUILD_ARCH "32" )
endif ( )
else ( )
set ( DFHACK_BUILD_ARCH "64" CACHE STRING "Architecture to build ('32' or '64')" )
endif ( )
if ( "${DFHACK_BUILD_ARCH}" STREQUAL "32" )
set ( DFHACK_BUILD_32 1 )
set ( DFHACK_BUILD_64 0 )
set ( DFHACK_SETARCH "i386" )
ELSEIF ( "${DFHACK_BUILD_ARCH}" STREQUAL "64" )
SET ( DFHACK_BUILD_32 0 )
SET ( DFHACK_BUILD_64 1 )
elseif ( "${DFHACK_BUILD_ARCH}" STREQUAL "64" )
set ( DFHACK_BUILD_32 0 )
set ( DFHACK_BUILD_64 1 )
set ( DFHACK_SETARCH "x86_64" )
ADD_DEFINITIONS ( -DDFHACK64 )
ELSE ( )
MESSAGE ( SEND_ERROR "Invalid build architecture (should be 32/64): ${DFHACK_BUILD_ARCH}" )
ENDIF ( )
add_definitions ( -DDFHACK64 )
else ( )
message ( SEND_ERROR "Invalid build architecture (should be 32/64): ${DFHACK_BUILD_ARCH}" )
endif ( )
IF ( CMAKE_CROSSCOMPILING )
SET ( DFHACK_NATIVE_BUILD_DIR "DFHACK_NATIVE_BUILD_DIR-NOTFOUND" CACHE FILEPATH "Path to a native build directory" )
INCLUDE ( "${DFHACK_NATIVE_BUILD_DIR}/ImportExecutables.cmake" )
ENDIF ( )
if ( CMAKE_CROSSCOMPILING )
set ( DFHACK_NATIVE_BUILD_DIR "DFHACK_NATIVE_BUILD_DIR-NOTFOUND" CACHE FILEPATH "Path to a native build directory" )
include ( "${DFHACK_NATIVE_BUILD_DIR}/ImportExecutables.cmake" )
endif ( )
find_package ( Perl REQUIRED )
@ -121,34 +121,34 @@ find_package(Perl REQUIRED)
# C h e c k f o r M F C !
find_package ( MFC QUIET )
if ( MFC_FOUND OR ( NOT MSVC ) )
OPTION ( CMAKE_USE_FOLDERS "Enable folder grouping of projects in IDEs." ON )
option ( CMAKE_USE_FOLDERS "Enable folder grouping of projects in IDEs." ON )
else ( )
OPTION ( CMAKE_USE_FOLDERS "Enable folder grouping of projects in IDEs." OFF )
option ( CMAKE_USE_FOLDERS "Enable folder grouping of projects in IDEs." OFF )
endif ( )
if ( CMAKE_USE_FOLDERS )
SET_PROPERTY ( GLOBAL PROPERTY USE_FOLDERS ON )
set_property ( GLOBAL PROPERTY USE_FOLDERS ON )
else ( )
SET_PROPERTY ( GLOBAL PROPERTY USE_FOLDERS OFF )
set_property ( GLOBAL PROPERTY USE_FOLDERS OFF )
endif ( )
# m a c r o f o r s e t t i n g u p I D E f o l d e r s w i t h o u t n a s t y IF ( ) s e v e r y w h e r e
MACRO ( IDE_FOLDER target folder )
# m a c r o f o r s e t t i n g u p I D E f o l d e r s w i t h o u t n a s t y if ( ) s e v e r y w h e r e
macro ( IDE_FOLDER target folder )
if ( CMAKE_USE_FOLDERS )
SET_PROPERTY ( TARGET ${ target } PROPERTY FOLDER ${ folder } )
set_property ( TARGET ${ target } PROPERTY FOLDER ${ folder } )
endif ( )
ENDMACRO ( )
endmacro ( )
SET ( CMAKE_MODULE_PATH
set ( CMAKE_MODULE_PATH
$ { d f h a c k _ S O U R C E _ D I R } / C M a k e / M o d u l e s
$ { C M A K E _ M O D U L E _ P A T H }
)
# g e n e r a t e s c o m p i l e _ c o m m a n d s . j s o n , u s e d f o r a u t o c o m p l e t i o n b y s o m e e d i t o r s
SET ( CMAKE_EXPORT_COMPILE_COMMANDS ON )
set ( CMAKE_EXPORT_COMPILE_COMMANDS ON )
include ( CheckCXXSourceCompiles )
CHECK_CXX_SOURCE_COMPILES ( "
check_cxx_source_compiles ( "
# i n c l u d e < c s t d l i b >
# i n c l u d e < c u c h a r >
i n t main ( void ) {
@ -185,39 +185,40 @@ set(DFHACK_BUILD_ID "" CACHE STRING "Build ID (should be specified on command li
# # w h e r e t o i n s t a l l things ( after the build is done, classic 'make install' or package structure )
# t h e d f h a c k l i b r a r i e s w i l l b e i n s t a l l e d h e r e :
IF ( UNIX )
if ( UNIX )
# p u t t h e l i b i n t o D F / h a c k
SET ( DFHACK_LIBRARY_DESTINATION hack )
SET ( DFHACK_EGGY_DESTINATION libs )
ELSE ( )
set ( DFHACK_LIBRARY_DESTINATION hack )
set ( DFHACK_EGGY_DESTINATION libs )
else ( )
# w i n d o w s i s c r a p , t h e r e f o r e w e c a n ' t d o n i c e t h i n g s w i t h i t . l e a v e t h e l i b s o n a n a s t y p i l e . . .
SET ( DFHACK_LIBRARY_DESTINATION . )
SET ( DFHACK_EGGY_DESTINATION . )
ENDIF ( )
set ( DFHACK_LIBRARY_DESTINATION . )
set ( DFHACK_EGGY_DESTINATION . )
endif ( )
# e x t e r n a l t o o l s w i l l b e i n s t a l l e d h e r e :
SET ( DFHACK_BINARY_DESTINATION . )
set ( DFHACK_BINARY_DESTINATION . )
# d f h a c k d a t a g o e s h e r e :
SET ( DFHACK_DATA_DESTINATION hack )
set ( DFHACK_DATA_DESTINATION hack )
# p l u g i n l i b s g o h e r e :
SET ( DFHACK_PLUGIN_DESTINATION hack/plugins )
set ( DFHACK_PLUGIN_DESTINATION hack/plugins )
# d f h a c k h e a d e r f i l e s g o h e r e :
SET ( DFHACK_INCLUDES_DESTINATION hack/include )
set ( DFHACK_INCLUDES_DESTINATION hack/include )
# d f h a c k l u a f i l e s g o h e r e :
SET ( DFHACK_LUA_DESTINATION hack/lua )
set ( DFHACK_LUA_DESTINATION hack/lua )
# t h e w i n d o w s . l i b f i l e g o e s h e r e :
SET ( DFHACK_DEVLIB_DESTINATION hack )
set ( DFHACK_DEVLIB_DESTINATION hack )
# u s e r d o c u m e n t a t i o n g o e s h e r e :
SET ( DFHACK_USERDOC_DESTINATION hack )
set ( DFHACK_USERDOC_DESTINATION hack )
# d e v e l o p e r d o c u m e n t a t i o n g o e s h e r e :
SET ( DFHACK_DEVDOC_DESTINATION hack )
set ( DFHACK_DEVDOC_DESTINATION hack )
# # s o m e o p t i o n s f o r t h e u s e r / d e v e l o p e r t o p l a y w i t h
OPTION ( BUILD_LIBRARY "Build the library that goes into DF." ON )
OPTION ( BUILD_PLUGINS "Build the plugins." ON )
# s o m e o p t i o n s f o r t h e u s e r / d e v e l o p e r t o p l a y w i t h
option ( BUILD_LIBRARY "Build the library that goes into DF." ON )
option ( BUILD_PLUGINS "Build the plugins." ON )
SET ( CMAKE_POSITION_INDEPENDENT_CODE TRUE )
IF ( UNIX )
set ( CMAKE_POSITION_INDEPENDENT_CODE TRUE )
if ( UNIX )
# # f l a g s f o r G C C
# d e f a u l t t o h i d d e n s y m b o l s
# b u i l d 3 2 b i t
@ -225,28 +226,28 @@ IF(UNIX)
# e n a b l e C + + 1 1 f e a t u r e s
add_definitions ( -DLINUX_BUILD )
add_definitions ( -D_GLIBCXX_USE_C99 )
SET ( CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -g -Wall -Wno-unused-variable" )
SET ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden -mtune=generic" )
SET ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden -mtune=generic" )
IF ( DFHACK_BUILD_64 )
SET ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64 -mno-avx" )
SET ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m64 -mno-avx" )
ELSE ( )
SET ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32 -march=i686" )
SET ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32 -march=i686" )
ENDIF ( )
STRING ( REPLACE "-DNDEBUG" "" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}" )
ELSEIF ( MSVC )
set ( CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -g -Wall -Wno-unused-variable" )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden -mtune=generic" )
set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden -mtune=generic" )
if ( DFHACK_BUILD_64 )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64 -mno-avx" )
set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m64 -mno-avx" )
else ( )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32 -march=i686" )
set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32 -march=i686" )
endif ( )
string ( REPLACE "-DNDEBUG" "" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}" )
elseif ( MSVC )
# f o r m s v c , t e l l i t t o a l w a y s u s e 8 - b y t e p o i n t e r s t o m e m b e r f u n c t i o n s t o a v o i d c o n f u s i o n
SET ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /vmg /vmm /MP" )
SET ( CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /Od" )
STRING ( REPLACE "/O2" "" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}" )
STRING ( REPLACE "/DNDEBUG" "" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}" )
ENDIF ( )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /vmg /vmm /MP" )
set ( CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /Od" )
string ( REPLACE "/O2" "" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}" )
string ( REPLACE "/DNDEBUG" "" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}" )
endif ( )
# u s e s h a r e d l i b r a r i e s f o r p r o t o b u f
ADD_DEFINITIONS ( -DPROTOBUF_USE_DLLS )
ADD_DEFINITIONS ( -DLUA_BUILD_AS_DLL )
add_definitions ( -DPROTOBUF_USE_DLLS )
add_definitions ( -DLUA_BUILD_AS_DLL )
if ( APPLE )
add_definitions ( -D_DARWIN )
@ -281,7 +282,6 @@ if(WIN32)
file ( COPY ${ ZLIB_DOWNLOAD_DIR } /zlib.lib
D E S T I N A T I O N $ { C M A K E _ B I N A R Y _ D I R } / d e p e n d s / z l i b / l i b / )
# D o t h e s a m e f o r S D L r e a l . d l l
# ( D F H a c k d o e s n ' t r e q u i r e t h i s a t b u i l d t i m e , s o n o n e e d t o m o v e i t t o t h e b u i l d f o l d e r )
set ( SDLREAL_DOWNLOAD_DIR ${ CMAKE_SOURCE_DIR } /package/windows/win ${ DFHACK_BUILD_ARCH } )
@ -386,10 +386,10 @@ if(EXTERNAL_TINYXML)
if ( NOT TinyXML_FOUND )
message ( SEND_ERROR "Could not find an external TinyXML, consider setting EXTERNAL_TINYXML to OFF." )
endif ( )
SET ( DFHACK_TINYXML "tinyxml" )
set ( DFHACK_TINYXML "tinyxml" )
else ( )
include_directories ( depends/tinyxml )
SET ( DFHACK_TINYXML "dfhack-tinyxml" )
set ( DFHACK_TINYXML "dfhack-tinyxml" )
endif ( )
include_directories ( depends/tthread )
@ -403,7 +403,7 @@ if(NOT GIT_FOUND)
endif ( )
# b u i l d t h e l i b i t s e l f
IF ( BUILD_LIBRARY )
if ( BUILD_LIBRARY )
add_subdirectory ( library )
install ( FILES LICENSE.rst docs/changelog.txt DESTINATION ${ DFHACK_USERDOC_DESTINATION } )
endif ( )
@ -415,7 +415,7 @@ install(DIRECTORY dfhack-config/ DESTINATION dfhack-config/default)
install ( DIRECTORY test DESTINATION "${DFHACK_DATA_DESTINATION}" )
# b u i l d t h e p l u g i n s
IF ( BUILD_PLUGINS )
if ( BUILD_PLUGINS )
add_subdirectory ( plugins )
endif ( )
@ -468,28 +468,27 @@ if (BUILD_DOCS)
C O M M A N D $ { C M A K E _ C O M M A N D } - E t o u c h $ { S P H I N X _ O U T P U T } )
install ( DIRECTORY ${ dfhack_SOURCE_DIR } /docs/html/
D E S T I N A T I O N $ { D F H A C K _ U S E R D O C _ D E S T I N A T I O N } / d o c s
)
D E S T I N A T I O N $ { D F H A C K _ U S E R D O C _ D E S T I N A T I O N } / d o c s )
install ( FILES docs/_auto/news.rst docs/_auto/news-dev.rst DESTINATION ${ DFHACK_USERDOC_DESTINATION } )
install ( FILES "README.html" DESTINATION "${DFHACK_DATA_DESTINATION}" )
endif ( )
# P a c k a g i n g w i t h C P a c k !
SET ( DFHACK_PACKAGE_SUFFIX "" )
IF ( UNIX )
set ( DFHACK_PACKAGE_SUFFIX "" )
if ( UNIX )
execute_process ( COMMAND ${ CMAKE_CXX_COMPILER } -dumpversion OUTPUT_VARIABLE GCC_VERSION )
string ( STRIP ${ GCC_VERSION } GCC_VERSION )
SET ( DFHACK_PACKAGE_SUFFIX "-gcc-${GCC_VERSION}" )
SET ( CPACK_GENERATOR "TBZ2" )
ELSEIF ( WIN32 )
SET ( CPACK_GENERATOR "ZIP" )
ENDIF ( )
set ( DFHACK_PACKAGE_SUFFIX "-gcc-${GCC_VERSION}" )
set ( CPACK_GENERATOR "TBZ2" )
elseif ( WIN32 )
set ( CPACK_GENERATOR "ZIP" )
endif ( )
set ( CPACK_INCLUDE_TOPLEVEL_DIRECTORY 0 )
IF ( APPLE )
if ( APPLE )
set ( DFHACK_PACKAGE_PLATFORM_NAME OSX )
ELSE ( )
else ( )
set ( DFHACK_PACKAGE_PLATFORM_NAME ${ CMAKE_SYSTEM_NAME } )
ENDIF ( )
endif ( )
# s e t o n c o m m a n d l i n e
if ( DFHACK_BUILD_ID STREQUAL "" )
set ( DFHACK_BUILD_ID_PACKAGE "" )
@ -497,48 +496,46 @@ else()
set ( DFHACK_BUILD_ID_PACKAGE "${DFHACK_BUILD_ID}-" )
endif ( )
set ( CPACK_PACKAGE_FILE_NAME "dfhack-${DFHACK_VERSION}-${DFHACK_BUILD_ID_PACKAGE}${DFHACK_PACKAGE_PLATFORM_NAME}-${DFHACK_BUILD_ARCH}${DFHACK_PACKAGE_SUFFIX}" )
INCLUDE ( CPack )
OPTION ( DFHACK_INCLUDE_CORE "Download and include Dwarf Fortress core files in DFHack. Useful for local testing, but should not be used in releases." OFF )
IF ( DFHACK_INCLUDE_CORE )
STRING ( REPLACE "." "_" DF_CORE_FILENAME "${DF_VERSION}" )
STRING ( REGEX REPLACE "^0_" "df_" DF_CORE_FILENAME "${DF_CORE_FILENAME}" )
IF ( UNIX )
IF ( APPLE )
STRING ( APPEND DF_CORE_FILENAME "_osx" )
ELSE ( )
STRING ( APPEND DF_CORE_FILENAME "_linux" )
ENDIF ( )
IF ( DFHACK_BUILD_32 )
STRING ( APPEND DF_CORE_FILENAME "32" )
ENDIF ( )
STRING ( APPEND DF_CORE_FILENAME ".tar.bz2" )
ELSE ( )
STRING ( APPEND DF_CORE_FILENAME "_win" )
IF ( DFHACK_BUILD_32 )
STRING ( APPEND DF_CORE_FILENAME "32" )
ENDIF ( )
STRING ( APPEND DF_CORE_FILENAME ".zip" )
ENDIF ( )
SET ( DF_CORE_URL "http://bay12games.com/dwarves/${DF_CORE_FILENAME}" )
IF ( NOT EXISTS "${CMAKE_BINARY_DIR}/${DF_CORE_FILENAME}" )
FILE ( DOWNLOAD "${DF_CORE_URL}" "${CMAKE_BINARY_DIR}/${DF_CORE_FILENAME}" SHOW_PROGRESS )
ENDIF ( )
FILE ( REMOVE_RECURSE "${CMAKE_BINARY_DIR}/df-core" )
FILE ( MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/df-core" )
IF ( UNIX )
include ( CPack )
option ( DFHACK_INCLUDE_CORE "Download and include Dwarf Fortress core files in DFHack. Useful for local testing, but should not be used in releases." OFF )
if ( DFHACK_INCLUDE_CORE )
string ( REPLACE "." "_" DF_CORE_FILENAME "${DF_VERSION}" )
string ( REGEX REPLACE "^0_" "df_" DF_CORE_FILENAME "${DF_CORE_FILENAME}" )
if ( UNIX )
if ( APPLE )
string ( APPEND DF_CORE_FILENAME "_osx" )
else ( )
string ( APPEND DF_CORE_FILENAME "_linux" )
endif ( )
if ( DFHACK_BUILD_32 )
string ( APPEND DF_CORE_FILENAME "32" )
endif ( )
string ( APPEND DF_CORE_FILENAME ".tar.bz2" )
else ( )
string ( APPEND DF_CORE_FILENAME "_win" )
if ( DFHACK_BUILD_32 )
string ( APPEND DF_CORE_FILENAME "32" )
endif ( )
string ( APPEND DF_CORE_FILENAME ".zip" )
endif ( )
set ( DF_CORE_URL "http://bay12games.com/dwarves/${DF_CORE_FILENAME}" )
if ( NOT EXISTS "${CMAKE_BINARY_DIR}/${DF_CORE_FILENAME}" )
file ( DOWNLOAD "${DF_CORE_URL}" "${CMAKE_BINARY_DIR}/${DF_CORE_FILENAME}" SHOW_PROGRESS )
endif ( )
file ( REMOVE_RECURSE "${CMAKE_BINARY_DIR}/df-core" )
file ( MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/df-core" )
if ( UNIX )
execute_process ( COMMAND ${ CMAKE_COMMAND } -E tar xjf "../${DF_CORE_FILENAME}" --strip-components=1
W O R K I N G _ D I R E C T O R Y " $ { C M A K E _ B I N A R Y _ D I R } / d f - c o r e " )
ELSE ( )
else ( )
execute_process ( COMMAND ${ CMAKE_COMMAND } -E tar xf "../${DF_CORE_FILENAME}" --format=zip
W O R K I N G _ D I R E C T O R Y " $ { C M A K E _ B I N A R Y _ D I R } / d f - c o r e " )
FILE ( REMOVE "${CMAKE_BINARY_DIR}/df-core/SDL.dll" )
ENDIF ( )
INSTALL ( DIRECTORY "${CMAKE_BINARY_DIR}/df-core/"
file ( REMOVE "${CMAKE_BINARY_DIR}/df-core/SDL.dll" )
endif ( )
install ( DIRECTORY "${CMAKE_BINARY_DIR}/df-core/"
D E S T I N A T I O N . )
ENDIF ( )
# INCLUDE ( FindSphinx.cmake )
endif ( )
# S t o r e o l d b u i l d a r c h
SET ( DFHACK_BUILD_ARCH_PREV "${DFHACK_BUILD_ARCH}" CACHE STRING "Previous build architecture" FORCE )
set ( DFHACK_BUILD_ARCH_PREV "${DFHACK_BUILD_ARCH}" CACHE STRING "Previous build architecture" FORCE )