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
2015-09-27 02:05:28 -06:00
# prevent CMake warnings about INTERFACE_LINK_LIBRARIES vs LINK_INTERFACE_LIBRARIES
IF ( CMAKE_VERSION VERSION_GREATER "2.8.12" )
CMAKE_POLICY ( SET CMP0022 OLD )
ENDIF ( )
2012-02-13 09:43:41 -07:00
# Set up build types
if ( CMAKE_CONFIGURATION_TYPES )
2012-02-16 07:07:10 -07:00
SET ( CMAKE_CONFIGURATION_TYPES Release RelWithDebInfo )
SET ( CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING "List of supported configuration types" FORCE )
2012-02-13 09:43:41 -07:00
else ( CMAKE_CONFIGURATION_TYPES )
if ( NOT CMAKE_BUILD_TYPE )
SET ( CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: Release RelWithDebInfo." )
endif ( NOT CMAKE_BUILD_TYPE )
endif ( CMAKE_CONFIGURATION_TYPES )
2011-08-26 21:50:14 -06:00
2015-11-26 15:09:53 -07:00
OPTION ( BUILD_DOCS "Choose whether to build the documentation (requires python and Sphinx)." OFF )
2015-09-24 00:04:09 -06:00
2012-03-13 14:16:30 -06:00
## some generic CMake magic
cmake_minimum_required ( VERSION 2.8 FATAL_ERROR )
project ( dfhack )
2015-09-26 08:46:29 -06:00
macro ( CHECK_GCC COMPILER_PATH )
execute_process ( COMMAND ${ COMPILER_PATH } -dumpversion OUTPUT_VARIABLE GCC_VERSION_OUT )
string ( STRIP "${GCC_VERSION_OUT}" GCC_VERSION_OUT )
2016-12-10 22:23:16 -07:00
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" )
2015-11-29 07:26:11 -07:00
elseif ( ${ GCC_VERSION_OUT } VERSION_GREATER "4.9.9" )
# GCC 5 changes ABI name mangling to enable C++11 changes.
# This must be disabled to enable linking against DF.
# http://developerblog.redhat.com/2015/02/05/gcc5-and-the-c11-abi/
add_definitions ( -D_GLIBCXX_USE_CXX11_ABI=0 )
2015-09-26 08:46:29 -06:00
endif ( )
endmacro ( )
if ( UNIX )
if ( CMAKE_COMPILER_IS_GNUCC )
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 } )
else ( )
message ( SEND_ERROR "C++ compiler is not GCC" )
endif ( )
endif ( )
if ( WIN32 )
2016-07-27 17:46:49 -06:00
if ( ( NOT MSVC ) OR ( NOT MSVC_VERSION STREQUAL 1900 ) )
message ( SEND_ERROR "MSVC 2015 is required" )
2015-09-26 08:46:29 -06:00
endif ( )
endif ( )
2012-04-14 16:27:02 -06:00
if ( MSVC )
2012-04-14 16:20:59 -06:00
# disable C4819 code-page warning
add_definitions ( "/wd4819" )
2016-06-28 07:34:11 -06:00
# Disable use of POSIX name warnings
add_definitions ( "/D_CRT_NONSTDC_NO_WARNINGS" )
# supress C4503 - VC++ dislikes if a name is too long. If you get
# weird and mysterious linking errors, you can disable this, but you'll have to
# deal with a LOT of compiler noise over it
# see https://msdn.microsoft.com/en-us/library/074af4b6.aspx
add_definitions ( "/wd4503" )
2012-04-14 16:27:02 -06:00
endif ( )
2012-04-14 16:20:59 -06:00
2016-07-31 18:01:47 -06:00
# Automatically detect architecture based on Visual Studio generator
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 "32" CACHE STRING "Architecture to build ('32' or '64')" )
ENDIF ( )
2016-07-03 21:32:43 -06:00
IF ( "${DFHACK_BUILD_ARCH}" STREQUAL "32" )
SET ( DFHACK_BUILD_32 1 )
SET ( DFHACK_BUILD_64 0 )
2017-08-21 17:34:46 -06:00
set ( DFHACK_SETARCH "i386" )
2016-07-03 21:32:43 -06:00
ELSEIF ( "${DFHACK_BUILD_ARCH}" STREQUAL "64" )
SET ( DFHACK_BUILD_32 0 )
SET ( DFHACK_BUILD_64 1 )
2017-08-21 17:34:46 -06:00
set ( DFHACK_SETARCH "x86_64" )
2016-07-03 21:32:43 -06:00
ADD_DEFINITIONS ( -DDFHACK64 )
ELSE ( )
MESSAGE ( SEND_ERROR "Invalid build architecture (should be 32/64): ${DFHACK_BUILD_ARCH}" )
ENDIF ( )
2016-01-08 19:08:26 -07:00
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 ( )
2017-04-30 15:36:42 -06:00
find_package ( Perl REQUIRED )
2012-03-13 07:46:48 -06:00
# set up folder structures for IDE solutions
2012-03-13 13:00:20 -06:00
# MSVC Express won't load solutions that use this. It also doesn't include MFC supported
# Check for MFC!
find_package ( MFC QUIET )
if ( MFC_FOUND OR ( NOT MSVC ) )
2012-03-13 07:46:48 -06:00
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 )
endif ( )
2012-03-13 14:05:25 -06:00
if ( CMAKE_USE_FOLDERS )
SET_PROPERTY ( GLOBAL PROPERTY USE_FOLDERS ON )
else ( )
SET_PROPERTY ( GLOBAL PROPERTY USE_FOLDERS OFF )
endif ( )
2012-03-13 07:46:48 -06:00
# macro for setting up IDE folders without nasty IF()s everywhere
MACRO ( IDE_FOLDER target folder )
if ( CMAKE_USE_FOLDERS )
SET_PROPERTY ( TARGET ${ target } PROPERTY FOLDER ${ folder } )
endif ( )
ENDMACRO ( )
2011-03-20 10:17:33 -06:00
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 }
)
2010-08-16 01:09:33 -06:00
2016-01-26 18:37:27 -07:00
# generates compile_commands.json, used for autocompletion by some editors
SET ( CMAKE_EXPORT_COMPILE_COMMANDS ON )
2011-08-14 00:42:21 -06:00
# mixing the build system with the source code is ugly and stupid. enforce the opposite :)
2011-06-19 17:12:07 -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
2012-03-26 17:37:37 -06:00
# make sure all the necessary submodules have been set up
2015-07-29 12:47:55 -06:00
if ( NOT EXISTS ${ dfhack_SOURCE_DIR } /library/xml/codegen.pl OR NOT EXISTS ${ dfhack_SOURCE_DIR } /depends/clsocket/CMakeLists.txt )
2016-01-18 08:55:21 -07:00
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)" )
2012-03-26 17:37:37 -06:00
endif ( )
2011-08-14 00:42:21 -06:00
# set up versioning.
2018-01-14 16:09:18 -07:00
set ( DF_VERSION "0.44.05" )
2018-02-21 21:07:53 -07:00
set ( DFHACK_RELEASE "r2" )
2018-02-03 20:17:28 -07:00
set ( DFHACK_PRERELEASE FALSE )
2011-06-19 17:12:07 -06:00
2013-01-09 09:19:43 -07:00
set ( DFHACK_VERSION "${DF_VERSION}-${DFHACK_RELEASE}" )
2011-06-19 17:12:07 -06:00
## where to install things (after the build is done, classic 'make install' or package structure)
# the dfhack libraries will be installed here:
2011-03-18 09:47:55 -06:00
IF ( UNIX )
2011-08-14 00:42:21 -06:00
# put the lib into DF/hack
SET ( DFHACK_LIBRARY_DESTINATION hack )
2012-02-27 19:37:56 -07:00
SET ( DFHACK_EGGY_DESTINATION libs )
2011-08-14 00:42:21 -06:00
ELSE ( )
# windows is crap, therefore we can't do nice things with it. leave the libs on a nasty pile...
SET ( DFHACK_LIBRARY_DESTINATION . )
2012-02-27 19:37:56 -07:00
SET ( DFHACK_EGGY_DESTINATION . )
2011-03-18 09:47:55 -06:00
ENDIF ( )
2011-08-14 00:42:21 -06:00
# external tools will be installed here:
SET ( DFHACK_BINARY_DESTINATION . )
# dfhack data goes here:
SET ( DFHACK_DATA_DESTINATION hack )
# plugin libs go here:
SET ( DFHACK_PLUGIN_DESTINATION hack/plugins )
# dfhack header files go here:
SET ( DFHACK_INCLUDES_DESTINATION hack/include )
2012-03-31 05:40:54 -06:00
# dfhack lua files go here:
SET ( DFHACK_LUA_DESTINATION hack/lua )
2011-08-14 00:42:21 -06:00
# the windows .lib file goes here:
SET ( DFHACK_DEVLIB_DESTINATION hack )
# user documentation goes here:
SET ( DFHACK_USERDOC_DESTINATION hack )
# developer documentation goes here:
SET ( DFHACK_DEVDOC_DESTINATION hack )
2011-05-21 12:32:53 -06:00
2011-06-19 17:12:07 -06:00
## some options for the user/developer to play with
OPTION ( BUILD_LIBRARY "Build the library that goes into DF." ON )
2011-07-11 16:07:59 -06:00
OPTION ( BUILD_PLUGINS "Build the plugins." ON )
2010-08-15 16:45:02 -06:00
2016-08-10 13:48:47 -06:00
SET ( CMAKE_POSITION_INDEPENDENT_CODE TRUE )
2011-11-06 13:16:16 -07:00
IF ( UNIX )
2015-09-26 11:16:05 -06:00
## flags for GCC
# default to hidden symbols
# build 32bit
# ensure compatibility with older CPUs
# enable C++11 features
2011-11-06 13:16:16 -07:00
add_definitions ( -DLINUX_BUILD )
2013-09-30 12:51:29 -06:00
SET ( CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -g -Wall -Wno-unused-variable" )
2016-07-03 21:32:43 -06:00
SET ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden -mtune=generic -std=c++0x" )
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 ( )
2017-06-27 11:58:29 -06:00
STRING ( REPLACE "-DNDEBUG" "" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}" )
2012-08-17 12:40:53 -06:00
ELSEIF ( MSVC )
# for msvc, tell it to always use 8-byte pointers to member functions to avoid confusion
2013-01-18 15:05:41 -07:00
SET ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /vmg /vmm /MP" )
2013-01-18 16:21:57 -07:00
SET ( CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /Od" )
2017-06-27 11:58:29 -06:00
STRING ( REPLACE "/DNDEBUG" "" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}" )
2011-11-06 13:16:16 -07:00
ENDIF ( )
2012-03-13 07:46:48 -06:00
# use shared libraries for protobuf
ADD_DEFINITIONS ( -DPROTOBUF_USE_DLLS )
2012-03-19 10:12:27 -06:00
ADD_DEFINITIONS ( -DLUA_BUILD_AS_DLL )
2012-03-13 07:46:48 -06:00
2012-05-24 09:31:20 -06:00
if ( APPLE )
2012-11-16 14:33:36 -07:00
add_definitions ( -D_DARWIN )
2015-04-18 09:40:20 -06:00
set ( CMAKE_MACOSX_RPATH 1 )
2012-05-24 09:31:20 -06:00
elseif ( UNIX )
2012-03-14 09:57:29 -06:00
add_definitions ( -D_LINUX )
elseif ( WIN32 )
add_definitions ( -DWIN32 )
endif ( )
2016-07-27 19:43:38 -06:00
#### download depends ####
2012-03-13 07:46:48 -06:00
2016-08-08 14:49:22 -06:00
include ( CMake/DownloadFile.cmake )
2016-07-27 19:08:24 -06:00
if ( WIN32 )
2016-08-08 14:49:22 -06:00
# Download zlib on Windows
set ( ZLIB_DOWNLOAD_DIR ${ CMAKE_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.43.05/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.43.05/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 " )
endif ( )
# Move zlib to the build folder so possible 32 and 64-bit builds
# in the same source tree don't conflict
file ( COPY ${ CMAKE_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 / )
# Do the same for SDLreal.dll
# (DFHack doesn't require this at build time, so no need to move it to the build folder)
set ( SDLREAL_DOWNLOAD_DIR ${ CMAKE_SOURCE_DIR } /package/windows/win ${ DFHACK_BUILD_ARCH } )
if ( ${ DFHACK_BUILD_ARCH } STREQUAL "64" )
download_file ( "https://github.com/DFHack/dfhack-bin/releases/download/0.43.05/win64-SDL.dll"
$ { S D L R E A L _ D O W N L O A D _ D I R } / S D L r e a l . d l l
" 1 a e 2 4 2 c 4 b 9 4 c b 0 3 7 5 6 a 1 2 8 8 1 2 2 a 6 6 f a f " )
else ( )
download_file ( "https://github.com/DFHack/dfhack-bin/releases/download/0.43.05/win32-SDL.dll"
$ { S D L R E A L _ D O W N L O A D _ D I R } / S D L r e a 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 ( )
2016-07-27 19:08:24 -06:00
endif ( )
2016-07-27 19:43:38 -06:00
if ( APPLE )
2016-08-08 14:49:22 -06:00
# libstdc++ (GCC 4.8.5 for OS X 10.6)
# fixes crash-on-unwind bug in DF's libstdc++
set ( LIBSTDCXX_DOWNLOAD_DIR ${ CMAKE_SOURCE_DIR } /package/darwin/osx ${ DFHACK_BUILD_ARCH } )
if ( ${ DFHACK_BUILD_ARCH } STREQUAL "64" )
download_file_unzip ( "https://github.com/DFHack/dfhack-bin/releases/download/0.43.05/osx64-libstdcxx.6.dylib.gz"
" g z "
$ { L I B S T D C X X _ D O W N L O A D _ D I R } / l i b s t d c + + . 6 . d y l i b . g z
" c f 2 6 e d 5 8 8 b e 8 e 8 3 c 8 e 3 a 4 9 9 1 9 7 9 3 b 4 1 6 "
$ { L I B S T D C X X _ D O W N L O A D _ D I R } / l i b s t d c + + . 6 . d y l i b
" 1 6 d c 6 d b d 4 e c d e 7 f 9 b 9 5 b b 6 d c 9 1 f 0 7 4 0 4 " )
else ( )
download_file_unzip ( "https://github.com/DFHack/dfhack-bin/releases/download/0.43.05/osx32-libstdcxx.6.dylib.gz"
" g z "
$ { L I B S T D C X X _ D O W N L O A D _ D I R } / l i b s t d c + + . 6 . d y l i b . g z
" 4 0 f 3 d 8 3 8 7 1 b 1 1 4 f 0 2 7 9 2 4 0 6 2 6 3 1 1 6 2 1 b "
$ { L I B S T D C X X _ D O W N L O A D _ D I R } / l i b s t d c + + . 6 . d y l i b
" c 3 f 5 6 7 8 b 8 2 0 4 9 1 7 e 0 3 8 7 0 8 3 4 9 0 2 c 3 e 8 b " )
endif ( )
2016-07-27 19:43:38 -06:00
endif ( )
#### expose depends ####
2016-09-15 08:24:57 -06:00
if ( UNIX )
# Rescan for pthread and zlib if the build arch changed
if ( NOT "${DFHACK_BUILD_ARCH}" STREQUAL "${DFHACK_BUILD_ARCH_PREV}" )
unset ( ZLIB_LIBRARY CACHE )
unset ( CMAKE_HAVE_PTHREAD_H CACHE )
endif ( )
endif ( )
2016-07-27 19:43:38 -06:00
2012-03-10 07:31:46 -07:00
# find and make available libz
2016-07-27 19:08:24 -06:00
if ( NOT UNIX ) # Windows
# zlib is in here so 32-bit and 64-bit builds in the same source tree are possible
2016-08-09 17:10:38 -06:00
set ( ZLIB_ROOT ${ CMAKE_BINARY_DIR } /depends/zlib/ )
2016-01-17 21:04:08 -07:00
else ( )
2016-08-09 17:10:38 -06:00
if ( NOT APPLE AND DFHACK_BUILD_32 )
# 32-bit Linux
set ( ZLIB_ROOT /usr/lib/i386-linux-gnu )
endif ( )
2012-03-10 07:31:46 -07:00
endif ( )
2016-07-27 19:08:24 -06:00
2012-03-13 07:46:48 -06:00
find_package ( ZLIB REQUIRED )
include_directories ( depends/protobuf )
include_directories ( depends/lua/include )
include_directories ( depends/md5 )
2015-07-29 12:47:55 -06:00
include_directories ( depends/jsoncpp )
2016-06-26 17:48:55 -06:00
# Support linking against external tinyxml
# If we find an external tinyxml, set the DFHACK_TINYXML variable to "tinyxml"
# Otherwise, set it to "dfhack-tinyxml"
option ( EXTERNAL_TINYXML "Choose to link against external TinyXML" OFF )
if ( EXTERNAL_TINYXML )
find_package ( TinyXML REQUIRED )
if ( NOT TinyXML_FOUND )
message ( SEND_ERROR "Could not find an external TinyXML, consider setting EXTERNAL_TINYXML to OFF." )
endif ( )
SET ( DFHACK_TINYXML "tinyxml" )
else ( )
include_directories ( depends/tinyxml )
SET ( DFHACK_TINYXML "dfhack-tinyxml" )
endif ( )
2012-03-13 07:46:48 -06:00
include_directories ( depends/tthread )
2012-03-10 07:31:46 -07:00
include_directories ( ${ ZLIB_INCLUDE_DIRS } )
2012-03-13 10:10:46 -06:00
include_directories ( depends/clsocket/src )
2012-03-13 07:46:48 -06:00
add_subdirectory ( depends )
2012-03-10 07:31:46 -07:00
2015-11-10 15:00:49 -07:00
find_package ( Git REQUIRED )
2015-06-25 09:43:54 -06:00
if ( NOT GIT_FOUND )
2015-11-10 15:00:49 -07:00
message ( SEND_ERROR "could not find git" )
2015-06-25 09:43:54 -06:00
endif ( )
2011-10-29 19:50:29 -06:00
2011-08-14 00:42:21 -06:00
# build the lib itself
2011-06-19 17:12:07 -06:00
IF ( BUILD_LIBRARY )
2011-03-18 09:47:55 -06:00
add_subdirectory ( library )
2015-10-22 19:34:54 -06:00
install ( FILES LICENSE.rst NEWS.rst DESTINATION ${ DFHACK_USERDOC_DESTINATION } )
2011-03-18 09:47:55 -06:00
endif ( )
2010-08-15 16:45:02 -06:00
2017-08-21 17:34:46 -06:00
file ( WRITE "${CMAKE_BINARY_DIR}/dfhack_setarch.txt" ${ DFHACK_SETARCH } )
install ( FILES "${CMAKE_BINARY_DIR}/dfhack_setarch.txt" DESTINATION "${DFHACK_DATA_DESTINATION}" )
2015-06-18 06:59:01 -06:00
install ( DIRECTORY dfhack-config/ DESTINATION dfhack-config/default )
2011-08-14 00:42:21 -06:00
#build the plugins
2011-06-19 20:29:38 -06:00
IF ( BUILD_PLUGINS )
add_subdirectory ( plugins )
endif ( )
2011-03-17 17:07:40 -06:00
2016-06-29 17:38:15 -06:00
add_subdirectory ( scripts )
2015-11-10 15:00:49 -07:00
find_package ( Sphinx QUIET )
2015-09-24 00:04:09 -06:00
if ( BUILD_DOCS )
2015-09-26 11:28:06 -06:00
if ( NOT SPHINX_FOUND )
message ( SEND_ERROR "Sphinx not found but BUILD_DOCS enabled" )
endif ( )
2015-09-26 15:52:06 -06:00
file ( GLOB SPHINX_DEPS
" $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / d o c s / * . r s t "
" $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / d o c s / i m a g e s / * . p n g "
2015-10-24 05:19:52 -06:00
" $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / d o c s / s t y l e s / * "
2015-11-05 20:57:09 -07:00
" $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / c o n f . p y "
2016-06-29 17:38:15 -06:00
" $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / s c r i p t s / a b o u t . t x t "
" $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / s c r i p t s / * / a b o u t . t x t "
2015-10-24 05:19:52 -06:00
)
2015-11-04 17:53:46 -07:00
file ( GLOB_RECURSE SPHINX_SCRIPT_DEPS
2016-06-29 17:38:15 -06:00
" $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / s c r i p t s / * . l u a "
" $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / s c r i p t s / * . r b "
2015-09-26 15:52:06 -06:00
)
2015-11-07 16:07:12 -07:00
set ( SPHINX_DEPS ${ SPHINX_DEPS } ${ SPHINX_SCRIPT_DEPS }
" $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / L I C E N S E . r s t "
" $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / N E W S . r s t "
" $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / C M a k e L i s t s . t x t "
)
2015-09-26 15:52:06 -06:00
set ( SPHINX_OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/docs/html/.buildinfo" )
set_source_files_properties ( ${ SPHINX_OUTPUT } PROPERTIES GENERATED TRUE )
add_custom_command ( OUTPUT ${ SPHINX_OUTPUT }
C O M M A N D $ { S P H I N X _ E X E C U T A B L E }
2015-09-27 02:05:28 -06:00
- a - E - q - b h t m l
2015-09-26 11:28:06 -06:00
" $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } "
2015-10-24 05:19:52 -06:00
" $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / d o c s / h t m l "
2015-10-24 17:14:09 -06:00
- w " $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / d o c s / _ s p h i n x - w a r n i n g s . t x t "
2015-11-05 20:57:09 -07:00
- j 2
2015-09-26 15:52:06 -06:00
D E P E N D S $ { S P H I N X _ D E P S }
C O M M E N T " B u i l d i n g H T M L d o c u m e n t a t i o n w i t h S p h i n x "
)
add_custom_target ( dfhack_docs ALL
D E P E N D S $ { S P H I N X _ O U T P U T }
)
# Sphinx doesn't touch this file if it didn't make changes,
# which makes CMake think it didn't complete
add_custom_command ( TARGET dfhack_docs POST_BUILD
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 } )
2015-11-05 17:37:37 -07:00
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
2015-09-26 15:52:06 -06:00
)
2015-10-24 05:19:52 -06:00
install ( FILES "README.html" DESTINATION "${DFHACK_DATA_DESTINATION}" )
2015-09-24 00:04:09 -06:00
endif ( )
2011-06-19 17:12:07 -06:00
# Packaging with CPack!
2015-11-07 16:07:48 -07:00
SET ( DFHACK_PACKAGE_SUFFIX "" )
2011-06-19 17:12:07 -06:00
IF ( UNIX )
2015-11-07 18:27:48 -07:00
execute_process ( COMMAND ${ CMAKE_CXX_COMPILER } -dumpversion OUTPUT_VARIABLE GCC_VERSION )
string ( STRIP ${ GCC_VERSION } GCC_VERSION )
SET ( DFHACK_PACKAGE_SUFFIX "-gcc-${GCC_VERSION}" )
2016-10-31 00:06:06 -06:00
SET ( CPACK_GENERATOR "TBZ2" )
2011-08-14 00:42:21 -06:00
ELSEIF ( WIN32 )
2011-06-19 17:12:07 -06:00
SET ( CPACK_GENERATOR "ZIP" )
2011-03-19 16:26:32 -06:00
ENDIF ( )
2011-08-14 17:30:15 -06:00
set ( CPACK_INCLUDE_TOPLEVEL_DIRECTORY 0 )
2015-01-07 14:03:24 -07:00
IF ( APPLE )
set ( DFHACK_PACKAGE_PLATFORM_NAME OSX )
ELSE ( )
set ( DFHACK_PACKAGE_PLATFORM_NAME ${ CMAKE_SYSTEM_NAME } )
ENDIF ( )
2016-10-31 00:05:46 -06:00
set ( CPACK_PACKAGE_FILE_NAME "dfhack-${DFHACK_VERSION}-${DFHACK_PACKAGE_PLATFORM_NAME}-${DFHACK_BUILD_ARCH}${DFHACK_PACKAGE_SUFFIX}" )
2011-06-19 17:12:07 -06:00
INCLUDE ( CPack )
2015-09-24 00:04:09 -06:00
#INCLUDE(FindSphinx.cmake)
2016-09-15 08:24:57 -06:00
# Store old build arch
SET ( DFHACK_BUILD_ARCH_PREV "${DFHACK_BUILD_ARCH}" CACHE STRING "Previous build architecture" FORCE )