@ -1,22 +1,5 @@
# 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
# 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 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 )
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}" )
else ( NOT CMAKE_BUILD_TYPE )
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
# # 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 )
cmake_minimum_required ( VERSION 2.8.12 FATAL_ERROR )
project ( dfhack )
project ( dfhack )
@ -27,12 +10,29 @@ if("${CMAKE_GENERATOR}" STREQUAL Ninja)
endif ( )
endif ( )
endif ( )
endif ( )
macro ( CHECK_GCC COMPILER_PATH )
# S e t u p b u i l d t y p e s
execute_process ( COMMAND ${ COMPILER_PATH } -dumpversion OUTPUT_VARIABLE GCC_VERSION_OUT )
if ( CMAKE_CONFIGURATION_TYPES )
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}" )
else ( NOT CMAKE_BUILD_TYPE )
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 )
macro ( CHECK_GCC compiler_path )
execute_process ( COMMAND ${ compiler_path } -dumpversion OUTPUT_VARIABLE GCC_VERSION_OUT )
string ( STRIP "${GCC_VERSION_OUT}" GCC_VERSION_OUT )
string ( STRIP "${GCC_VERSION_OUT}" GCC_VERSION_OUT )
if ( ${ GCC_VERSION_OUT } VERSION_LESS "4.8" )
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" )
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 .
# 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 .
# 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 .
# h t t p : / / d e v e l o p e r b l o g . r e d h a t . c o m / 2 0 1 5 / 0 2 / 0 5 / g c c 5 - a n d - t h e - c 1 1 - a b i /
# h t t p : / / d e v e l o p e r b l o g . r e d h a t . c o m / 2 0 1 5 / 0 2 / 0 5 / g c c 5 - a n d - t h e - c 1 1 - a b i /
@ -42,12 +42,12 @@ endmacro()
if ( UNIX )
if ( UNIX )
if ( CMAKE_COMPILER_IS_GNUCC )
if ( CMAKE_COMPILER_IS_GNUCC )
CHECK_GCC ( ${ CMAKE_C_COMPILER } )
check_gcc ( ${ CMAKE_C_COMPILER } )
else ( )
else ( )
message ( SEND_ERROR "C compiler is not GCC" )
message ( SEND_ERROR "C compiler is not GCC" )
endif ( )
endif ( )
if ( CMAKE_COMPILER_IS_GNUCXX )
if ( CMAKE_COMPILER_IS_GNUCXX )
CHECK_GCC ( ${ CMAKE_CXX_COMPILER } )
check_gcc ( ${ CMAKE_CXX_COMPILER } )
else ( )
else ( )
message ( SEND_ERROR "C++ compiler is not GCC" )
message ( SEND_ERROR "C++ compiler is not GCC" )
endif ( )
endif ( )
@ -68,51 +68,51 @@ set(CMAKE_CXX_EXTENSIONS OFF)
if ( MSVC )
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
# 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" )
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" )
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
# 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
# w e i r d a n d m y s t e r i o u s l i n k i n g e r r o r s , y o u c a n d i s a b l e t h i s , b u t y o u ' l l h a v e t o
# w e i r d a n d m y s t e r i o u s l i n k i n g e r r o r s , y o u c a n d i s a b l e t h i s , b u t y o u ' l l h a v e t o
# d e a l w i t h a L O T o f c o m p i l e r n o i s e o v e r i t
# d e a l w i t h a L O T o f c o m p i l e r n o i s e o v e r i t
# s e e h t t p s : / / m s d n . m i c r o s o f t . c o m / e n - u s / l i b r a r y / 0 7 4 a f 4 b 6 . a s p x
# s e e h t t p s : / / m s d n . m i c r o s o f t . c o m / e n - u s / l i b r a r y / 0 7 4 a f 4 b 6 . a s p x
add_definitions ( "/wd4503" )
add_definitions ( "/wd4503" )
# s u p p r e s s C 4 2 6 7 - V C + + c o m p l a i n s w h e n e v e r w e i m p l i c i t l y c o n v e r t a n i n t e g e r t o
# s u p p r e s s C 4 2 6 7 - V C + + c o m p l a i n s w h e n e v e r w e i m p l i c i t l y c o n v e r t a n i n t e g e r t o
# a s m a l l e r t y p e , a n d m o s t o f t h e t i m e t h i s i s j u s t c o n v e r s i o n f r o m 6 4 t o 3 2 b i t s
# a s m a l l e r t y p e , a n d m o s t o f t h e t i m e t h i s i s j u s t c o n v e r s i o n f r o m 6 4 t o 3 2 b i t s
# f o r t h i n g s l i k e v e c t o r s i z e s , w h i c h a r e n e v e r t h a t b i g a n y w a y .
# f o r t h i n g s l i k e v e c t o r s i z e s , w h i c h a r e n e v e r t h a t b i g a n y w a y .
add_definitions ( "/wd4267" )
add_definitions ( "/wd4267" )
endif ( )
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
# 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 ( MSVC AND NOT DEFINED DFHACK_BUILD_ARCH )
IF ( ${ CMAKE_GENERATOR } MATCHES "Win64" )
if ( ${ CMAKE_GENERATOR } MATCHES "Win64" )
SET ( DFHACK_BUILD_ARCH "64" )
set ( DFHACK_BUILD_ARCH "64" )
ELSE ( )
else ( )
SET ( DFHACK_BUILD_ARCH "32" )
set ( DFHACK_BUILD_ARCH "32" )
ENDIF ( )
endif ( )
ELSE ( )
else ( )
SET ( DFHACK_BUILD_ARCH "64" CACHE STRING "Architecture to build ('32' or '64')" )
set ( DFHACK_BUILD_ARCH "64" CACHE STRING "Architecture to build ('32' or '64')" )
ENDIF ( )
endif ( )
IF ( "${DFHACK_BUILD_ARCH}" STREQUAL "32" )
if ( "${DFHACK_BUILD_ARCH}" STREQUAL "32" )
SET ( DFHACK_BUILD_32 1 )
set ( DFHACK_BUILD_32 1 )
SET ( DFHACK_BUILD_64 0 )
set ( DFHACK_BUILD_64 0 )
set ( DFHACK_SETARCH "i386" )
set ( DFHACK_SETARCH "i386" )
ELSEIF ( "${DFHACK_BUILD_ARCH}" STREQUAL "64" )
elseif ( "${DFHACK_BUILD_ARCH}" STREQUAL "64" )
SET ( DFHACK_BUILD_32 0 )
set ( DFHACK_BUILD_32 0 )
SET ( DFHACK_BUILD_64 1 )
set ( DFHACK_BUILD_64 1 )
set ( DFHACK_SETARCH "x86_64" )
set ( DFHACK_SETARCH "x86_64" )
ADD_DEFINITIONS ( -DDFHACK64 )
add_definitions ( -DDFHACK64 )
ELSE ( )
else ( )
MESSAGE ( SEND_ERROR "Invalid build architecture (should be 32/64): ${DFHACK_BUILD_ARCH}" )
message ( SEND_ERROR "Invalid build architecture (should be 32/64): ${DFHACK_BUILD_ARCH}" )
ENDIF ( )
endif ( )
IF ( CMAKE_CROSSCOMPILING )
if ( CMAKE_CROSSCOMPILING )
SET ( DFHACK_NATIVE_BUILD_DIR "DFHACK_NATIVE_BUILD_DIR-NOTFOUND" CACHE FILEPATH "Path to a native build directory" )
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" )
include ( "${DFHACK_NATIVE_BUILD_DIR}/ImportExecutables.cmake" )
ENDIF ( )
endif ( )
find_package ( Perl REQUIRED )
find_package ( Perl REQUIRED )
@ -121,34 +121,34 @@ find_package(Perl REQUIRED)
# C h e c k f o r M F C !
# C h e c k f o r M F C !
find_package ( MFC QUIET )
find_package ( MFC QUIET )
if ( MFC_FOUND OR ( NOT MSVC ) )
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 ( )
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 ( )
endif ( )
if ( CMAKE_USE_FOLDERS )
if ( CMAKE_USE_FOLDERS )
SET_PROPERTY ( GLOBAL PROPERTY USE_FOLDERS ON )
set_property ( GLOBAL PROPERTY USE_FOLDERS ON )
else ( )
else ( )
SET_PROPERTY ( GLOBAL PROPERTY USE_FOLDERS OFF )
set_property ( GLOBAL PROPERTY USE_FOLDERS OFF )
endif ( )
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
# 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 )
macro ( IDE_FOLDER target folder )
if ( CMAKE_USE_FOLDERS )
if ( CMAKE_USE_FOLDERS )
SET_PROPERTY ( TARGET ${ target } PROPERTY FOLDER ${ folder } )
set_property ( TARGET ${ target } PROPERTY FOLDER ${ folder } )
endif ( )
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
$ { 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 }
$ { 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
# 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 )
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 s t d l i b >
# i n c l u d e < c u c h a r >
# i n c l u d e < c u c h a r >
i n t main ( void ) {
i n t main ( void ) {
@ -168,7 +168,7 @@ if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
endif ( )
endif ( )
# m a k e s u r e a l l t h e n e c e s s a r y s u b m o d u l e s h a v e b e e n s e t u p
# m a k e s u r e a l l t h e n e c e s s a r y s u b m o d u l e s h a v e b e e n s e t u p
if ( NOT EXISTS ${ dfhack_SOURCE_DIR } /library/xml/codegen.pl OR NOT EXISTS ${ dfhack_SOURCE_DIR } /depends/clsocket/CMakeLists.txt )
if ( NOT EXISTS ${ dfhack_SOURCE_DIR } /library/xml/codegen.pl OR NOT EXISTS ${ dfhack_SOURCE_DIR } /depends/clsocket/CMakeLists.txt )
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/Compile.rst)" )
endif ( )
endif ( )
@ -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 )
# # 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 :
# 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
# 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 hack )
SET ( DFHACK_EGGY_DESTINATION libs )
set ( DFHACK_EGGY_DESTINATION libs )
ELSE ( )
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 . . .
# 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_LIBRARY_DESTINATION . )
SET ( DFHACK_EGGY_DESTINATION . )
set ( DFHACK_EGGY_DESTINATION . )
ENDIF ( )
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 :
# 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 :
# 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 :
# 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 :
# 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 :
# 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 :
# 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 :
# 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 :
# 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
# 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_LIBRARY "Build the library that goes into DF." ON )
OPTION ( BUILD_PLUGINS "Build the plugins." ON )
option ( BUILD_PLUGINS "Build the plugins." ON )
SET ( CMAKE_POSITION_INDEPENDENT_CODE TRUE )
set ( CMAKE_POSITION_INDEPENDENT_CODE TRUE )
IF ( UNIX )
if ( UNIX )
# # f l a g s f o r G C C
# # 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
# 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
# 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
# e n a b l e C + + 1 1 f e a t u r e s
add_definitions ( -DLINUX_BUILD )
add_definitions ( -DLINUX_BUILD )
add_definitions ( -D_GLIBCXX_USE_C99 )
add_definitions ( -D_GLIBCXX_USE_C99 )
SET ( CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -g -Wall -Wno-unused-variable" )
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_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden -mtune=generic" )
SET ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden -mtune=generic" )
set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden -mtune=generic" )
IF ( DFHACK_BUILD_64 )
if ( DFHACK_BUILD_64 )
SET ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64 -mno-avx" )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64 -mno-avx" )
SET ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m64 -mno-avx" )
set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m64 -mno-avx" )
ELSE ( )
else ( )
SET ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32 -march=i686" )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32 -march=i686" )
SET ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32 -march=i686" )
set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32 -march=i686" )
ENDIF ( )
endif ( )
STRING ( REPLACE "-DNDEBUG" "" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}" )
string ( REPLACE "-DNDEBUG" "" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}" )
ELSEIF ( MSVC )
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
# 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 "${CMAKE_CXX_FLAGS} /vmg /vmm /MP" )
SET ( CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /Od" )
set ( CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /Od" )
STRING ( REPLACE "/O2" "" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}" )
string ( REPLACE "/O2" "" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}" )
STRING ( REPLACE "/DNDEBUG" "" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}" )
string ( REPLACE "/DNDEBUG" "" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}" )
ENDIF ( )
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
# 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 ( -DPROTOBUF_USE_DLLS )
ADD_DEFINITIONS ( -DLUA_BUILD_AS_DLL )
add_definitions ( -DLUA_BUILD_AS_DLL )
if ( APPLE )
if ( APPLE )
add_definitions ( -D_DARWIN )
add_definitions ( -D_DARWIN )
@ -281,7 +282,6 @@ if(WIN32)
file ( COPY ${ ZLIB_DOWNLOAD_DIR } /zlib.lib
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 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 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 )
# ( 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 } )
set ( SDLREAL_DOWNLOAD_DIR ${ CMAKE_SOURCE_DIR } /package/windows/win ${ DFHACK_BUILD_ARCH } )
@ -296,7 +296,6 @@ if(WIN32)
endif ( )
endif ( )
endif ( )
endif ( )
option ( EXTERNAL_LIBSTDCXX "macOS only: Avoid installing the DFHack-provided libstdc++." OFF )
if ( APPLE )
if ( APPLE )
# l i b s t d c + + ( G C C 4 . 8 . 5 f o r O S X 1 0 . 6 )
# l i b s t d c + + ( G C C 4 . 8 . 5 f o r O S X 1 0 . 6 )
# f i x e s c r a s h - o n - u n w i n d b u g i n D F ' s l i b s t d c + +
# f i x e s c r a s h - o n - u n w i n d b u g i n D F ' s l i b s t d c + +
@ -388,10 +387,10 @@ if(EXTERNAL_TINYXML)
if ( NOT TinyXML_FOUND )
if ( NOT TinyXML_FOUND )
message ( SEND_ERROR "Could not find an external TinyXML, consider setting EXTERNAL_TINYXML to OFF." )
message ( SEND_ERROR "Could not find an external TinyXML, consider setting EXTERNAL_TINYXML to OFF." )
endif ( )
endif ( )
SET ( DFHACK_TINYXML "tinyxml" )
set ( DFHACK_TINYXML "tinyxml" )
else ( )
else ( )
include_directories ( depends/tinyxml )
include_directories ( depends/tinyxml )
SET ( DFHACK_TINYXML "dfhack-tinyxml" )
set ( DFHACK_TINYXML "dfhack-tinyxml" )
endif ( )
endif ( )
include_directories ( depends/tthread )
include_directories ( depends/tthread )
@ -405,8 +404,8 @@ if(NOT GIT_FOUND)
endif ( )
endif ( )
# b u i l d t h e l i b i t s e l f
# 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 )
add_subdirectory ( library )
install ( FILES LICENSE.rst docs/changelog.txt DESTINATION ${ DFHACK_USERDOC_DESTINATION } )
install ( FILES LICENSE.rst docs/changelog.txt DESTINATION ${ DFHACK_USERDOC_DESTINATION } )
endif ( )
endif ( )
@ -416,16 +415,16 @@ install(FILES "${CMAKE_BINARY_DIR}/dfhack_setarch.txt" DESTINATION "${DFHACK_DAT
install ( DIRECTORY dfhack-config/ DESTINATION dfhack-config/default )
install ( DIRECTORY dfhack-config/ DESTINATION dfhack-config/default )
install ( DIRECTORY test DESTINATION "${DFHACK_DATA_DESTINATION}" )
install ( DIRECTORY test DESTINATION "${DFHACK_DATA_DESTINATION}" )
# b u i l d t h e p l u g i n s
# b u i l d t h e p l u g i n s
IF ( BUILD_PLUGINS )
if ( BUILD_PLUGINS )
add_subdirectory ( plugins )
add_subdirectory ( plugins )
endif ( )
endif ( )
add_subdirectory ( scripts )
add_subdirectory ( scripts )
find_package ( Sphinx QUIET )
find_package ( Sphinx QUIET )
if ( BUILD_DOCS )
if ( BUILD_DOCS )
if ( NOT SPHINX_FOUND )
if ( NOT SPHINX_FOUND )
message ( SEND_ERROR "Sphinx not found but BUILD_DOCS enabled" )
message ( SEND_ERROR "Sphinx not found but BUILD_DOCS enabled" )
endif ( )
endif ( )
@ -470,28 +469,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 } )
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/
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 docs/_auto/news.rst docs/_auto/news-dev.rst DESTINATION ${ DFHACK_USERDOC_DESTINATION } )
install ( FILES "README.html" DESTINATION "${DFHACK_DATA_DESTINATION}" )
install ( FILES "README.html" DESTINATION "${DFHACK_DATA_DESTINATION}" )
endif ( )
endif ( )
# P a c k a g i n g w i t h C P a c k !
# P a c k a g i n g w i t h C P a c k !
SET ( DFHACK_PACKAGE_SUFFIX "" )
set ( DFHACK_PACKAGE_SUFFIX "" )
IF ( UNIX )
if ( UNIX )
execute_process ( COMMAND ${ CMAKE_CXX_COMPILER } -dumpversion OUTPUT_VARIABLE GCC_VERSION )
execute_process ( COMMAND ${ CMAKE_CXX_COMPILER } -dumpversion OUTPUT_VARIABLE GCC_VERSION )
string ( STRIP ${ GCC_VERSION } GCC_VERSION )
string ( STRIP ${ GCC_VERSION } GCC_VERSION )
SET ( DFHACK_PACKAGE_SUFFIX "-gcc-${GCC_VERSION}" )
set ( DFHACK_PACKAGE_SUFFIX "-gcc-${GCC_VERSION}" )
SET ( CPACK_GENERATOR "TBZ2" )
set ( CPACK_GENERATOR "TBZ2" )
ELSEIF ( WIN32 )
elseif ( WIN32 )
SET ( CPACK_GENERATOR "ZIP" )
set ( CPACK_GENERATOR "ZIP" )
ENDIF ( )
endif ( )
set ( CPACK_INCLUDE_TOPLEVEL_DIRECTORY 0 )
set ( CPACK_INCLUDE_TOPLEVEL_DIRECTORY 0 )
IF ( APPLE )
if ( APPLE )
set ( DFHACK_PACKAGE_PLATFORM_NAME OSX )
set ( DFHACK_PACKAGE_PLATFORM_NAME OSX )
ELSE ( )
else ( )
set ( DFHACK_PACKAGE_PLATFORM_NAME ${ CMAKE_SYSTEM_NAME } )
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
# s e t o n c o m m a n d l i n e
if ( DFHACK_BUILD_ID STREQUAL "" )
if ( DFHACK_BUILD_ID STREQUAL "" )
set ( DFHACK_BUILD_ID_PACKAGE "" )
set ( DFHACK_BUILD_ID_PACKAGE "" )
@ -499,48 +497,46 @@ else()
set ( DFHACK_BUILD_ID_PACKAGE "${DFHACK_BUILD_ID}-" )
set ( DFHACK_BUILD_ID_PACKAGE "${DFHACK_BUILD_ID}-" )
endif ( )
endif ( )
set ( CPACK_PACKAGE_FILE_NAME "dfhack-${DFHACK_VERSION}-${DFHACK_BUILD_ID_PACKAGE}${DFHACK_PACKAGE_PLATFORM_NAME}-${DFHACK_BUILD_ARCH}${DFHACK_PACKAGE_SUFFIX}" )
set ( CPACK_PACKAGE_FILE_NAME "dfhack-${DFHACK_VERSION}-${DFHACK_BUILD_ID_PACKAGE}${DFHACK_PACKAGE_PLATFORM_NAME}-${DFHACK_BUILD_ARCH}${DFHACK_PACKAGE_SUFFIX}" )
INCLUDE ( CPack )
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 )
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 )
if ( DFHACK_INCLUDE_CORE )
STRING ( REPLACE "." "_" DF_CORE_FILENAME "${DF_VERSION}" )
string ( REPLACE "." "_" DF_CORE_FILENAME "${DF_VERSION}" )
STRING ( REGEX REPLACE "^0_" "df_" DF_CORE_FILENAME "${DF_CORE_FILENAME}" )
string ( REGEX REPLACE "^0_" "df_" DF_CORE_FILENAME "${DF_CORE_FILENAME}" )
IF ( UNIX )
if ( UNIX )
IF ( APPLE )
if ( APPLE )
STRING ( APPEND DF_CORE_FILENAME "_osx" )
string ( APPEND DF_CORE_FILENAME "_osx" )
ELSE ( )
else ( )
STRING ( APPEND DF_CORE_FILENAME "_linux" )
string ( APPEND DF_CORE_FILENAME "_linux" )
ENDIF ( )
endif ( )
IF ( DFHACK_BUILD_32 )
if ( DFHACK_BUILD_32 )
STRING ( APPEND DF_CORE_FILENAME "32" )
string ( APPEND DF_CORE_FILENAME "32" )
ENDIF ( )
endif ( )
STRING ( APPEND DF_CORE_FILENAME ".tar.bz2" )
string ( APPEND DF_CORE_FILENAME ".tar.bz2" )
ELSE ( )
else ( )
STRING ( APPEND DF_CORE_FILENAME "_win" )
string ( APPEND DF_CORE_FILENAME "_win" )
IF ( DFHACK_BUILD_32 )
if ( DFHACK_BUILD_32 )
STRING ( APPEND DF_CORE_FILENAME "32" )
string ( APPEND DF_CORE_FILENAME "32" )
ENDIF ( )
endif ( )
STRING ( APPEND DF_CORE_FILENAME ".zip" )
string ( APPEND DF_CORE_FILENAME ".zip" )
ENDIF ( )
endif ( )
SET ( DF_CORE_URL "http://bay12games.com/dwarves/${DF_CORE_FILENAME}" )
set ( DF_CORE_URL "http://bay12games.com/dwarves/${DF_CORE_FILENAME}" )
IF ( NOT EXISTS "${CMAKE_BINARY_DIR}/${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 )
file ( DOWNLOAD "${DF_CORE_URL}" "${CMAKE_BINARY_DIR}/${DF_CORE_FILENAME}" SHOW_PROGRESS )
ENDIF ( )
endif ( )
FILE ( REMOVE_RECURSE "${CMAKE_BINARY_DIR}/df-core" )
file ( REMOVE_RECURSE "${CMAKE_BINARY_DIR}/df-core" )
FILE ( MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/df-core" )
file ( MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/df-core" )
IF ( UNIX )
if ( UNIX )
execute_process ( COMMAND ${ CMAKE_COMMAND } -E tar xjf "../${DF_CORE_FILENAME}" --strip-components=1
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 " )
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
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 " )
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" )
file ( REMOVE "${CMAKE_BINARY_DIR}/df-core/SDL.dll" )
ENDIF ( )
endif ( )
INSTALL ( DIRECTORY "${CMAKE_BINARY_DIR}/df-core/"
install ( DIRECTORY "${CMAKE_BINARY_DIR}/df-core/"
D E S T I N A T I O N . )
D E S T I N A T I O N . )
ENDIF ( )
endif ( )
# INCLUDE ( FindSphinx.cmake )
# S t o r e o l d b u i l d a r c h
# 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 )