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
|
|
|
|
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
|
|
|
|
2012-03-13 14:16:30 -06:00
|
|
|
## some generic CMake magic
|
|
|
|
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
|
|
|
|
project(dfhack)
|
|
|
|
|
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
|
|
|
|
${dfhack_SOURCE_DIR}/CMake/Modules
|
|
|
|
${CMAKE_MODULE_PATH}
|
|
|
|
)
|
2010-08-16 01:09:33 -06:00
|
|
|
|
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
|
|
|
|
2011-08-14 00:42:21 -06:00
|
|
|
# set up versioning.
|
|
|
|
set(DF_VERSION_MAJOR "0")
|
2012-02-21 10:19:17 -07:00
|
|
|
set(DF_VERSION_MINOR "34")
|
2012-03-28 03:56:46 -06:00
|
|
|
set(DF_VERSION_PATCH "06")
|
2011-08-14 00:42:21 -06:00
|
|
|
set(DF_VERSION "${DF_VERSION_MAJOR}.${DF_VERSION_MINOR}.${DF_VERSION_PATCH}")
|
2011-06-19 17:12:07 -06:00
|
|
|
|
2012-03-28 03:56:46 -06:00
|
|
|
set(DFHACK_RELEASE "1")
|
2012-02-21 10:19:17 -07:00
|
|
|
|
|
|
|
set(DFHACK_VERSION "${DF_VERSION_MAJOR}.${DF_VERSION_MINOR}.${DF_VERSION_PATCH}-r${DFHACK_RELEASE}")
|
|
|
|
add_definitions(-DDFHACK_VERSION="${DFHACK_VERSION}")
|
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)
|
|
|
|
# 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
|
|
|
|
2011-11-06 13:16:16 -07:00
|
|
|
## flags for GCC
|
|
|
|
# default to hidden symbols
|
|
|
|
# build 32bit
|
|
|
|
# ensure compatibility with older CPUs
|
|
|
|
# enable C++11 features
|
|
|
|
IF(UNIX)
|
|
|
|
add_definitions(-DLINUX_BUILD)
|
|
|
|
SET(CMAKE_CXX_FLAGS_DEBUG "-g -Wall")
|
2012-02-01 21:43:43 -07:00
|
|
|
SET(CMAKE_CXX_FLAGS "-fvisibility=hidden -m32 -march=i686 -mtune=generic -std=c++0x")
|
|
|
|
SET(CMAKE_C_FLAGS "-fvisibility=hidden -m32 -march=i686 -mtune=generic")
|
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-03-14 09:57:29 -06:00
|
|
|
if(UNIX)
|
|
|
|
add_definitions(-D_LINUX)
|
|
|
|
elseif(WIN32)
|
|
|
|
add_definitions(-DWIN32)
|
|
|
|
endif()
|
|
|
|
|
2012-03-13 07:46:48 -06:00
|
|
|
#### expose depends ####
|
|
|
|
|
2012-03-10 07:31:46 -07:00
|
|
|
# find and make available libz
|
|
|
|
if(NOT UNIX)
|
2012-03-13 07:46:48 -06:00
|
|
|
SET(ZLIB_ROOT depends/zlib/)
|
2012-03-10 07:31:46 -07:00
|
|
|
endif()
|
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)
|
|
|
|
include_directories(depends/tinyxml)
|
|
|
|
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
|
|
|
|
2011-10-29 19:50:29 -06:00
|
|
|
|
2011-08-08 15:19:44 -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)
|
|
|
|
## install the default documentation files
|
2011-08-14 00:42:21 -06:00
|
|
|
install(FILES LICENSE Readme.html Compile.html DESTINATION ${DFHACK_USERDOC_DESTINATION})
|
2011-03-18 09:47:55 -06:00
|
|
|
endif()
|
2010-08-15 16:45:02 -06:00
|
|
|
|
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
|
|
|
|
2011-06-19 17:12:07 -06:00
|
|
|
# Packaging with CPack!
|
|
|
|
IF(UNIX)
|
|
|
|
SET(CPACK_GENERATOR "TGZ")
|
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)
|
2012-02-21 10:19:17 -07:00
|
|
|
set(CPACK_PACKAGE_FILE_NAME "dfhack-${DFHACK_VERSION}-${CMAKE_SYSTEM_NAME}")
|
2011-06-19 17:12:07 -06:00
|
|
|
INCLUDE(CPack)
|