@ -1,21 +1,19 @@
# 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 3. 6 FATAL_ERROR )
cmake_minimum_required ( VERSION 3. 18 FATAL_ERROR )
cmake_policy ( SET CMP0048 NEW )
cmake_policy ( SET CMP0074 NEW )
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 v e r s i o n i n g .
set ( DF_VERSION "50.08" )
set ( DFHACK_RELEASE "r2rc1" )
set ( DFHACK_PRERELEASE TRUE )
if ( NOT( "${CMAKE_VERSION}" VERSION_LESS 3.12 ) )
# m a k e Z L I B _ R O O T w o r k i n C M a k e > = 3 . 1 2
# h t t p s : / / c m a k e . o r g / c m a k e / h e l p / g i t - s t a g e / p o l i c y / C M P 0 0 7 4 . h t m l
cmake_policy ( SET CMP0074 NEW )
endif ( )
set ( DFHACK_VERSION "${DF_VERSION}-${DFHACK_RELEASE}" )
set ( DFHACK_ABI_VERSION 1 )
set ( DFHACK_BUILD_ID "" CACHE STRING "Build ID (should be specified on command line)" )
# S e t u p b u i l d t y p e s
if ( CMAKE_CONFIGURATION_TYPES )
@ -123,7 +121,7 @@ elseif("${DFHACK_BUILD_ARCH}" STREQUAL "64")
set ( DFHACK_SETARCH "x86_64" )
add_definitions ( -DDFHACK64 )
else ( )
message ( SEND_ERROR "Invalid build architecture (should be 32 / 64): ${DFHACK_BUILD_ARCH}")
message ( SEND_ERROR "Invalid build architecture (should be 32 or 64): ${DFHACK_BUILD_ARCH}")
endif ( )
if ( CMAKE_CROSSCOMPILING )
@ -182,30 +180,24 @@ endif()
if ( NOT EXISTS ${ dfhack_SOURCE_DIR } /library/xml/codegen.pl
O R N O T E X I S T S $ { d f h a c k _ S O U R C E _ D I R } / s c r i p t s / C M a k e L i s t s . t x t
O R N O T E X I S T S $ { d f h a c k _ S O U R C E _ D I R } / d e p e n d s / c l s o c k e t / C M a k e L i s t s . t x t
O R N O T E X I S T S $ { d f h a c k _ S O U R C E _ D I R } / d e p e n d s / j s o n c p p - s u b / C M a k e L i s t s . t x t
O R N O T E X I S T S $ { d f h a c k _ S O U R C E _ D I R } / d e p e n d s / l i b e x p a t / e x p a t / C M a k e L i s t s . t x t
O R N O T E X I S T S $ { d f h a c k _ S O U R C E _ D I R } / d e p e n d s / l i b z i p / C M a k e L i s t s . t x t
O R N O T E X I S T S $ { d f h a c k _ S O U R C E _ D I R } / d e p e n d s / x l s x i o / C M a k e L i s t s . t x t
O R N O T E X I S T S $ { d f h a c k _ S O U R C E _ D I R } / d e p e n d s / g o o g l e t e s t / C M a k e L i s t s . t x t
O R N O T E X I S T S $ { d f h a c k _ S O U R C E _ D I R } / d e p e n d s / l u a c o v / s r c
)
message ( SEND_ERROR "One or more required submodules could not be found! Run 'git submodule update --init' from the root DFHack directory. (See the section 'Getting the Code' in docs/ Compile.rst)")
message ( SEND_ERROR "One or more required submodules could not be found! Run 'git submodule update --init' from the root DFHack directory. (See the section 'Getting the Code' in docs/ dev/compile/ Compile.rst)")
endif ( )
# s e t u p v e r s i o n i n g .
set ( DF_VERSION "50.08" )
set ( DFHACK_RELEASE "r3" )
set ( DFHACK_PRERELEASE FALSE )
set ( DFHACK_VERSION "${DF_VERSION}-${DFHACK_RELEASE}" )
set ( DFHACK_ABI_VERSION 1 )
set ( DFHACK_BUILD_ID "" CACHE STRING "Build ID (should be specified on command line)" )
# d f h a c k d a t a g o e s h e r e :
set ( DFHACK_DATA_DESTINATION hack )
# # 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 )
# 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_LIBRARY_DESTINATION ${ DFHACK_DATA_DESTINATION } )
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 . )
@ -213,31 +205,26 @@ 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 . )
# d f h a c k d a t a g o e s h e r e :
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 )
# 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_PLUGIN_DESTINATION ${ DFHACK_DATA_DESTINATION } /plugins )
# 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 ${ DFHACK_DATA_DESTINATION } /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 ${ DFHACK_DATA_DESTINATION } )
# 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 ${ DFHACK_DATA_DESTINATION } )
# 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 ${ DFHACK_DATA_DESTINATION } )
# 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 )
option ( BUILD_LIBRARY "Build the DFHack library." ON )
option ( BUILD_PLUGINS "Build the DFHack plugins." ON )
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
# e n s u r e c o m p a t i b i l i t y w i t h o l d e r C P U s
# e n a b l e C + + 1 1 f e a t u r e s
add_definitions ( -DLINUX_BUILD )
@ -254,7 +241,7 @@ if(UNIX)
set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32 -march=i686" )
endif ( )
string ( REPLACE "-DNDEBUG" "" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}" )
set ( CMAKE_INSTALL_RPATH "hack" )
set ( CMAKE_INSTALL_RPATH ${ DFHACK_LIBRARY_DESTINATION } )
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" )
@ -276,30 +263,37 @@ elseif(WIN32)
add_definitions ( -DWIN32 )
endif ( )
# # # # d o w n l o a d d e p e n d s # # # #
# # # # d e p e n d e n c i e s # # # #
# f i x f o r p y e n v : d e f a u l t t o ` p y t h o n 3 ` b e f o r e ` p y t h o n 3 . x `
set ( Python_FIND_UNVERSIONED_NAMES FIRST )
include ( CMake/DownloadFile.cmake )
if ( WIN32 )
# D o w n l o a d z l i b o n W i n d o w s
set ( ZLIB_DOWNLOAD_DIR ${ dfhack_SOURCE_DIR } /depends/zlib/lib/win ${ DFHACK_BUILD_ARCH } )
if ( ${ DFHACK_BUILD_ARCH } STREQUAL "64" )
download_file ( "https://github.com/DFHack/dfhack-bin/releases/download/0.44.09/win64-zlib.lib"
$ { Z L I B _ D O W N L O A D _ D I R } / z l i b . l i b
" a 3 b 2 f c 6 b 6 8 e f a f a 8 9 b 0 8 8 2 e 3 5 4 f c 8 4 1 8 " )
else ( )
download_file ( "https://github.com/DFHack/dfhack-bin/releases/download/0.44.09/win32-zlib.lib"
$ { Z L I B _ D O W N L O A D _ D I R } / z l i b . l i b
" f 4 e b a a 2 1 d 9 d e 2 8 5 6 6 e 8 8 b 1 e d f c d f f 9 0 1 " )
set ( ZLIB_FILE win64-zlib.lib )
set ( ZLIB_PATH ${ CMAKE_BINARY_DIR } /depends/zlib/ )
set ( ZLIB_MD5 a3b2fc6b68efafa89b0882e354fc8418 )
file ( COPY ${ dfhack_SOURCE_DIR } /depends/zlib/ DESTINATION ${ ZLIB_PATH } )
download_file ( "https://github.com/DFHack/dfhack-bin/releases/download/0.44.09/${ZLIB_FILE}"
$ { Z L I B _ P A T H } $ { Z L I B _ F I L E }
$ { Z L I B _ M D 5 } )
set ( ZLIB_ROOT ${ ZLIB_PATH } )
else ( )
# R e s c a n f o r p t h r e a d a n d z l i b i f t h e b u i l d a r c h c h a n g e d
if ( NOT "${DFHACK_BUILD_ARCH}" STREQUAL "${DFHACK_BUILD_ARCH_PREV}" )
unset ( ZLIB_LIBRARY CACHE )
unset ( CMAKE_HAVE_PTHREAD_H CACHE )
endif ( )
# M o v e z l i b t o t h e b u i l d f o l d e r s o p o s s i b l e 3 2 a n d 6 4 - b i t b u i l d s
# i n t h e s a m e s o u r c e t r e e d o n ' t c o n f l i c t
file( COPY ${ dfhack_SOURCE_DIR } /depends/zlib
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 / )
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 / )
if ( NOT APPLE AND DFHACK_BUILD_32 )
set ( ZLIB_ROOT /usr/lib/i386-linux-gnu )
endif( )
endif ( )
find_package ( ZLIB REQUIRED )
include_directories ( ${ ZLIB_INCLUDE_DIRS } )
if ( WIN32 )
# D o t h e s a m e f o r S D 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 )
# T O D O : r e m o v e S D L . d l l f r o m o u r d i s t r i b u t i o n o n c e D F m o v e s t o S D L 2 . w e o n l y
@ -315,7 +309,6 @@ if(WIN32)
$ { S D L _ D O W N L O A D _ D I R } / S D L . d l l
" 5 a 0 9 6 0 4 d a c a 6 b 2 b 5 c e 0 4 9 d 7 9 a f 9 3 5 d 6 a " )
endif ( )
endif ( )
if ( APPLE )
@ -376,29 +369,6 @@ endif()
# # # # e x p o s e d e p e n d s # # # #
# f i x f o r p y e n v : d e f a u l t t o ` p y t h o n 3 ` b e f o r e ` p y t h o n 3 . x `
set ( Python_FIND_UNVERSIONED_NAMES FIRST )
if ( UNIX )
# R e s c a n f o r p t h r e a d a n d z l i b i f t h e b u i l d a r c h c h a n g e d
if ( NOT "${DFHACK_BUILD_ARCH}" STREQUAL "${DFHACK_BUILD_ARCH_PREV}" )
unset ( ZLIB_LIBRARY CACHE )
unset ( CMAKE_HAVE_PTHREAD_H CACHE )
endif ( )
endif ( )
# f i n d a n d m a k e a v a i l a b l e l i b z
if ( NOT UNIX ) # W i n d o w s
# z l i b i s i n h e r e s o 3 2 - b i t a n d 6 4 - b i t b u i l d s i n t h e s a m e s o u r c e t r e e a r e p o s s i b l e
set ( ZLIB_ROOT ${ CMAKE_BINARY_DIR } /depends/zlib/ )
else ( )
if ( NOT APPLE AND DFHACK_BUILD_32 )
# 3 2 - b i t L i n u x
set ( ZLIB_ROOT /usr/lib/i386-linux-gnu )
endif ( )
endif ( )
find_package ( ZLIB REQUIRED )
include_directories ( depends/protobuf )
include_directories ( depends/lua/include )
include_directories ( depends/md5 )
@ -420,7 +390,6 @@ endif()
include_directories ( depends/lodepng )
include_directories ( depends/tthread )
include_directories ( ${ ZLIB_INCLUDE_DIRS } )
include_directories ( depends/clsocket/src )
include_directories ( depends/xlsxio/include )
add_subdirectory ( depends )