2011-06-19 17:12:07 -06:00
|
|
|
PROJECT (dfapi)
|
2018-03-08 01:28:28 -07:00
|
|
|
cmake_minimum_required(VERSION 2.8.12)
|
2010-05-26 04:24:45 -06:00
|
|
|
|
2015-09-27 02:05:28 -06:00
|
|
|
# prevent CMake warnings about INTERFACE_LINK_LIBRARIES vs LINK_INTERFACE_LIBRARIES
|
2018-03-08 01:28:28 -07:00
|
|
|
CMAKE_POLICY(SET CMP0022 NEW)
|
2015-09-27 02:05:28 -06:00
|
|
|
|
2011-06-19 17:12:07 -06:00
|
|
|
## build options
|
|
|
|
OPTION(BUILD_DEVEL "Install/package files required for development (For SDK)." OFF)
|
2011-08-18 14:09:30 -06:00
|
|
|
IF(UNIX)
|
|
|
|
OPTION(CONSOLE_NO_CATCH "Make the console not catch 'CTRL+C' events for easier debugging." OFF)
|
|
|
|
ENDIF()
|
2011-06-19 17:12:07 -06:00
|
|
|
|
2012-03-14 09:57:29 -06:00
|
|
|
include_directories (proto)
|
2012-07-02 09:02:48 -06:00
|
|
|
include_directories (include)
|
2009-09-13 18:02:46 -06:00
|
|
|
|
2012-03-13 07:46:48 -06:00
|
|
|
execute_process(COMMAND ${PERL_EXECUTABLE} xml/list.pl xml ${dfapi_SOURCE_DIR}/include/df ";"
|
2011-12-24 03:37:00 -07:00
|
|
|
WORKING_DIRECTORY ${dfapi_SOURCE_DIR}
|
|
|
|
OUTPUT_VARIABLE GENERATED_HDRS)
|
|
|
|
|
2012-03-13 07:46:48 -06:00
|
|
|
SET_SOURCE_FILES_PROPERTIES(${GENERATED_HDRS} PROPERTIES HEADER_FILE_ONLY TRUE GENERATED TRUE)
|
2010-08-30 21:32:40 -06:00
|
|
|
|
2012-03-13 07:46:48 -06:00
|
|
|
SET(MAIN_HEADERS
|
2011-12-31 04:48:42 -07:00
|
|
|
include/Internal.h
|
2010-08-30 21:32:40 -06:00
|
|
|
include/DFHack.h
|
2015-02-19 08:31:58 -07:00
|
|
|
include/DFHackVersion.h
|
2011-12-31 04:48:42 -07:00
|
|
|
include/Console.h
|
|
|
|
include/Core.h
|
2012-03-10 02:29:33 -07:00
|
|
|
include/ColorText.h
|
2011-12-31 04:48:42 -07:00
|
|
|
include/DataDefs.h
|
2012-03-24 03:25:10 -06:00
|
|
|
include/DataIdentity.h
|
2012-08-17 12:40:53 -06:00
|
|
|
include/VTableInterpose.h
|
2012-03-24 03:25:10 -06:00
|
|
|
include/LuaWrapper.h
|
2012-03-31 05:40:54 -06:00
|
|
|
include/LuaTools.h
|
2011-12-31 04:48:42 -07:00
|
|
|
include/Error.h
|
|
|
|
include/Export.h
|
|
|
|
include/Hooks.h
|
|
|
|
include/MiscUtils.h
|
|
|
|
include/Module.h
|
|
|
|
include/Pragma.h
|
|
|
|
include/MemAccess.h
|
|
|
|
include/TileTypes.h
|
|
|
|
include/Types.h
|
|
|
|
include/VersionInfo.h
|
|
|
|
include/VersionInfoFactory.h
|
2012-03-14 09:57:29 -06:00
|
|
|
include/RemoteClient.h
|
|
|
|
include/RemoteServer.h
|
2012-03-17 02:09:30 -06:00
|
|
|
include/RemoteTools.h
|
2012-03-13 07:46:48 -06:00
|
|
|
)
|
|
|
|
|
|
|
|
SET(MAIN_HEADERS_WINDOWS
|
|
|
|
include/wdirent.h
|
|
|
|
)
|
|
|
|
|
|
|
|
SET(MAIN_SOURCES
|
|
|
|
Core.cpp
|
|
|
|
ColorText.cpp
|
|
|
|
DataDefs.cpp
|
2018-02-05 17:18:35 -07:00
|
|
|
Error.cpp
|
2012-08-17 12:40:53 -06:00
|
|
|
VTableInterpose.cpp
|
2012-03-19 10:12:27 -06:00
|
|
|
LuaWrapper.cpp
|
2012-03-24 03:25:10 -06:00
|
|
|
LuaTypes.cpp
|
2012-03-31 05:40:54 -06:00
|
|
|
LuaTools.cpp
|
2012-04-06 08:00:54 -06:00
|
|
|
LuaApi.cpp
|
2012-03-13 07:46:48 -06:00
|
|
|
DataStatics.cpp
|
|
|
|
DataStaticsCtor.cpp
|
2012-03-19 06:59:11 -06:00
|
|
|
DataStaticsFields.cpp
|
2012-03-13 07:46:48 -06:00
|
|
|
MiscUtils.cpp
|
2012-05-05 11:07:18 -06:00
|
|
|
Types.cpp
|
2012-03-13 07:46:48 -06:00
|
|
|
PluginManager.cpp
|
|
|
|
TileTypes.cpp
|
|
|
|
VersionInfoFactory.cpp
|
2012-03-14 09:57:29 -06:00
|
|
|
RemoteClient.cpp
|
|
|
|
RemoteServer.cpp
|
2012-03-17 02:09:30 -06:00
|
|
|
RemoteTools.cpp
|
2012-03-13 07:46:48 -06:00
|
|
|
)
|
|
|
|
|
|
|
|
SET(MAIN_SOURCES_WINDOWS
|
|
|
|
Console-windows.cpp
|
|
|
|
Hooks-windows.cpp
|
|
|
|
PlugLoad-windows.cpp
|
|
|
|
Process-windows.cpp
|
|
|
|
)
|
|
|
|
|
|
|
|
IF(WIN32)
|
|
|
|
SOURCE_GROUP("Main\\Headers" FILES ${MAIN_HEADERS} ${MAIN_HEADERS_WINDOWS})
|
|
|
|
SOURCE_GROUP("Main\\Sources" FILES ${MAIN_SOURCES} ${MAIN_SOURCES_WINDOWS})
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
SET(MAIN_SOURCES_LINUX
|
2014-08-09 15:48:53 -06:00
|
|
|
Console-posix.cpp
|
2012-03-13 07:46:48 -06:00
|
|
|
Hooks-linux.cpp
|
2014-12-29 08:31:12 -07:00
|
|
|
PlugLoad-posix.cpp
|
2012-03-13 07:46:48 -06:00
|
|
|
Process-linux.cpp
|
|
|
|
)
|
|
|
|
|
2012-05-25 12:28:59 -06:00
|
|
|
SET(MAIN_SOURCES_DARWIN
|
2014-08-09 15:48:53 -06:00
|
|
|
Console-posix.cpp
|
2012-05-29 12:44:37 -06:00
|
|
|
Hooks-darwin.cpp
|
2014-12-29 08:31:12 -07:00
|
|
|
PlugLoad-posix.cpp
|
|
|
|
Process-darwin.cpp
|
2012-05-25 12:28:59 -06:00
|
|
|
)
|
|
|
|
|
2012-03-13 07:46:48 -06:00
|
|
|
SET(MAIN_SOURCES_LINUX_EGGY
|
|
|
|
Console-linux.cpp
|
|
|
|
Hooks-egg.cpp
|
|
|
|
PlugLoad-linux.cpp
|
|
|
|
Process-linux.cpp
|
|
|
|
)
|
|
|
|
|
|
|
|
SET(MODULE_HEADERS
|
2011-12-31 04:48:42 -07:00
|
|
|
include/modules/Buildings.h
|
2012-04-26 02:56:28 -06:00
|
|
|
include/modules/Burrows.h
|
2011-12-31 04:48:42 -07:00
|
|
|
include/modules/Constructions.h
|
2017-05-04 19:47:12 -06:00
|
|
|
include/modules/Designations.h
|
2011-12-31 04:48:42 -07:00
|
|
|
include/modules/Engravings.h
|
2012-12-14 19:05:38 -07:00
|
|
|
include/modules/EventManager.h
|
2017-05-04 19:47:12 -06:00
|
|
|
include/modules/Filesystem.h
|
|
|
|
include/modules/Graphic.h
|
2011-12-31 04:48:42 -07:00
|
|
|
include/modules/Gui.h
|
2015-11-13 18:10:29 -07:00
|
|
|
include/modules/GuiHooks.h
|
2011-12-31 04:48:42 -07:00
|
|
|
include/modules/Items.h
|
2012-01-07 08:21:07 -07:00
|
|
|
include/modules/Job.h
|
2011-12-31 04:48:42 -07:00
|
|
|
include/modules/kitchen.h
|
|
|
|
include/modules/MapCache.h
|
2017-05-04 19:47:12 -06:00
|
|
|
include/modules/Maps.h
|
2011-12-31 04:48:42 -07:00
|
|
|
include/modules/Materials.h
|
|
|
|
include/modules/Notes.h
|
2017-05-04 19:47:12 -06:00
|
|
|
include/modules/Once.h
|
2013-09-30 09:46:39 -06:00
|
|
|
include/modules/Random.h
|
2015-08-28 14:21:11 -06:00
|
|
|
include/modules/Renderer.h
|
2012-08-18 23:31:09 -06:00
|
|
|
include/modules/Screen.h
|
2011-12-31 04:48:42 -07:00
|
|
|
include/modules/Translation.h
|
2017-05-04 19:47:12 -06:00
|
|
|
include/modules/Units.h
|
2011-12-31 04:48:42 -07:00
|
|
|
include/modules/Vermin.h
|
|
|
|
include/modules/World.h
|
2009-10-26 15:50:08 -06:00
|
|
|
)
|
|
|
|
|
2012-03-13 07:46:48 -06:00
|
|
|
SET( MODULE_SOURCES
|
2010-05-26 04:24:45 -06:00
|
|
|
modules/Buildings.cpp
|
2012-04-26 02:56:28 -06:00
|
|
|
modules/Burrows.cpp
|
2010-05-26 04:24:45 -06:00
|
|
|
modules/Constructions.cpp
|
2017-05-04 19:47:12 -06:00
|
|
|
modules/Designations.cpp
|
2011-04-02 16:15:47 -06:00
|
|
|
modules/Engravings.cpp
|
2012-12-14 19:05:38 -07:00
|
|
|
modules/EventManager.cpp
|
2017-05-04 19:47:12 -06:00
|
|
|
modules/Filesystem.cpp
|
|
|
|
modules/Graphic.cpp
|
2010-04-02 19:52:46 -06:00
|
|
|
modules/Gui.cpp
|
2010-05-02 02:35:23 -06:00
|
|
|
modules/Items.cpp
|
2012-01-07 08:21:07 -07:00
|
|
|
modules/Job.cpp
|
2011-10-29 20:20:54 -06:00
|
|
|
modules/kitchen.cpp
|
2013-10-03 06:50:00 -06:00
|
|
|
modules/MapCache.cpp
|
2010-04-02 19:52:46 -06:00
|
|
|
modules/Maps.cpp
|
|
|
|
modules/Materials.cpp
|
2011-07-20 19:26:52 -06:00
|
|
|
modules/Notes.cpp
|
2017-05-04 19:47:12 -06:00
|
|
|
modules/Once.cpp
|
2013-09-30 09:46:39 -06:00
|
|
|
modules/Random.cpp
|
2015-08-28 14:21:11 -06:00
|
|
|
modules/Renderer.cpp
|
2012-08-18 23:31:09 -06:00
|
|
|
modules/Screen.cpp
|
2010-04-06 09:11:58 -06:00
|
|
|
modules/Translation.cpp
|
2017-05-04 19:47:12 -06:00
|
|
|
modules/Units.cpp
|
2011-07-13 00:17:51 -06:00
|
|
|
modules/Vermin.cpp
|
2012-03-04 17:34:04 -07:00
|
|
|
modules/Windows.cpp
|
2017-05-04 19:47:12 -06:00
|
|
|
modules/World.cpp
|
2010-08-12 18:35:10 -06:00
|
|
|
)
|
|
|
|
|
2016-03-18 21:11:11 -06:00
|
|
|
SET(STATIC_FIELDS_FILES)
|
|
|
|
FOREACH(GROUP other a b c d e f g h i j k l m n o p q r s t u v w x y z)
|
|
|
|
SET(STATIC_FIELDS_FILENAME ${dfhack_SOURCE_DIR}/library/DataStaticsFields/${GROUP}.cpp)
|
|
|
|
IF(${GROUP} STREQUAL "other")
|
|
|
|
SET(STATIC_FIELDS_INC_FILENAME "df/static.fields.inc")
|
|
|
|
ELSE()
|
|
|
|
SET(STATIC_FIELDS_INC_FILENAME "df/static.fields-${GROUP}.inc")
|
|
|
|
ENDIF()
|
|
|
|
FILE(WRITE ${STATIC_FIELDS_FILENAME}.tmp
|
|
|
|
"#define STATIC_FIELDS_GROUP\n"
|
|
|
|
"#include \"../DataStaticsFields.cpp\"\n"
|
|
|
|
"#include \"${STATIC_FIELDS_INC_FILENAME}\"\n"
|
|
|
|
)
|
|
|
|
EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
|
|
|
${STATIC_FIELDS_FILENAME}.tmp ${STATIC_FIELDS_FILENAME})
|
|
|
|
FILE(REMOVE ${STATIC_FIELDS_FILENAME}.tmp)
|
|
|
|
LIST(APPEND STATIC_FIELDS_FILES ${STATIC_FIELDS_FILENAME})
|
|
|
|
ENDFOREACH()
|
|
|
|
LIST(APPEND MAIN_SOURCES ${STATIC_FIELDS_FILES})
|
|
|
|
|
2012-03-13 07:46:48 -06:00
|
|
|
IF(WIN32)
|
|
|
|
SOURCE_GROUP("Modules\\Headers" FILES ${MODULE_HEADERS})
|
|
|
|
SOURCE_GROUP("Modules\\Sources" FILES ${MODULE_SOURCES})
|
|
|
|
SOURCE_GROUP("Generated" FILES ${GENERATED_HDRS})
|
|
|
|
ENDIF()
|
2009-11-16 20:19:13 -07:00
|
|
|
|
2012-03-13 07:46:48 -06:00
|
|
|
SET(PROJECT_HEADERS)
|
|
|
|
LIST(APPEND PROJECT_HEADERS ${MAIN_HEADERS})
|
|
|
|
LIST(APPEND PROJECT_HEADERS ${MODULE_HEADERS})
|
|
|
|
SET(PROJECT_SOURCES)
|
|
|
|
LIST(APPEND PROJECT_SOURCES ${MAIN_SOURCES})
|
|
|
|
LIST(APPEND PROJECT_SOURCES ${MODULE_SOURCES})
|
2012-02-27 19:37:56 -07:00
|
|
|
|
2009-11-16 20:19:13 -07:00
|
|
|
IF(UNIX)
|
2012-02-27 19:37:56 -07:00
|
|
|
OPTION(BUILD_EGGY "Make DFHack strangely egg-shaped." OFF)
|
|
|
|
IF(BUILD_EGGY)
|
2012-03-13 07:46:48 -06:00
|
|
|
LIST(APPEND PROJECT_SOURCES ${MAIN_SOURCES_LINUX_EGGY})
|
2012-05-25 12:28:59 -06:00
|
|
|
ELSEIF(APPLE)
|
2012-11-16 14:33:36 -07:00
|
|
|
LIST(APPEND PROJECT_SOURCES ${MAIN_SOURCES_DARWIN})
|
2012-02-27 19:37:56 -07:00
|
|
|
ELSE()
|
2012-03-13 07:46:48 -06:00
|
|
|
LIST(APPEND PROJECT_SOURCES ${MAIN_SOURCES_LINUX})
|
2012-02-27 19:37:56 -07:00
|
|
|
ENDIF()
|
2012-03-13 07:46:48 -06:00
|
|
|
ELSEIF(WIN32)
|
|
|
|
LIST(APPEND PROJECT_SOURCES ${MAIN_SOURCES_WINDOWS})
|
|
|
|
LIST(APPEND PROJECT_HEADERS ${MAIN_HEADERS_WINDOWS})
|
2011-03-16 00:35:08 -06:00
|
|
|
ENDIF()
|
2009-11-16 20:19:13 -07:00
|
|
|
|
2012-03-09 10:42:22 -07:00
|
|
|
# Protobuf
|
|
|
|
FILE(GLOB PROJECT_PROTOS ${CMAKE_CURRENT_SOURCE_DIR}/proto/*.proto)
|
|
|
|
|
2012-03-15 01:07:43 -06:00
|
|
|
STRING(REPLACE ".proto" ".pb.cc" PROJECT_PROTO_SRCS "${PROJECT_PROTOS}")
|
|
|
|
STRING(REPLACE ".proto" ".pb.h" PROJECT_PROTO_HDRS "${PROJECT_PROTOS}")
|
2016-10-24 20:28:51 -06:00
|
|
|
STRING(REPLACE "/proto/" "/proto/tmp/" PROJECT_PROTO_TMP_FILES "${PROJECT_PROTO_SRCS};${PROJECT_PROTO_HDRS}")
|
|
|
|
SET_SOURCE_FILES_PROPERTIES(${PROJECT_PROTO_SRCS} ${PROJECT_PROTO_HDRS}
|
|
|
|
PROPERTIES GENERATED TRUE)
|
|
|
|
|
|
|
|
# Force a re-gen if any *.pb.* files are missing
|
2016-10-24 20:51:27 -06:00
|
|
|
# (only runs when cmake is run, but better than nothing)
|
|
|
|
FOREACH(file IN LISTS PROJECT_PROTO_SRCS PROJECT_PROTO_HDRS)
|
|
|
|
IF(NOT EXISTS ${file})
|
|
|
|
# MESSAGE("Resetting generate_proto_core because '${file}' is missing")
|
|
|
|
FILE(REMOVE ${PROJECT_PROTO_TMP_FILES})
|
|
|
|
BREAK()
|
|
|
|
ENDIF()
|
|
|
|
ENDFOREACH()
|
2012-03-09 10:42:22 -07:00
|
|
|
|
2012-03-13 07:46:48 -06:00
|
|
|
LIST(APPEND PROJECT_HEADERS ${PROJECT_PROTO_HDRS})
|
2012-03-14 09:57:29 -06:00
|
|
|
LIST(APPEND PROJECT_SOURCES ${PROJECT_PROTO_SRCS})
|
2012-03-09 10:42:22 -07:00
|
|
|
|
|
|
|
ADD_CUSTOM_COMMAND(
|
2016-10-24 20:51:27 -06:00
|
|
|
OUTPUT ${PROJECT_PROTO_TMP_FILES}
|
2012-03-09 10:42:22 -07:00
|
|
|
COMMAND protoc-bin -I=${CMAKE_CURRENT_SOURCE_DIR}/proto/
|
2016-10-24 20:28:51 -06:00
|
|
|
--cpp_out=dllexport_decl=DFHACK_EXPORT:${CMAKE_CURRENT_SOURCE_DIR}/proto/tmp/
|
2012-03-09 10:42:22 -07:00
|
|
|
${PROJECT_PROTOS}
|
2016-11-02 14:23:32 -06:00
|
|
|
COMMAND ${PERL_EXECUTABLE} ${CMAKE_SOURCE_DIR}/depends/copy-if-different.pl
|
2016-10-24 20:28:51 -06:00
|
|
|
${PROJECT_PROTO_TMP_FILES}
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/proto/
|
|
|
|
COMMENT "Generating core protobufs"
|
2012-03-09 10:42:22 -07:00
|
|
|
DEPENDS protoc-bin ${PROJECT_PROTOS}
|
|
|
|
)
|
|
|
|
|
2018-04-05 15:46:04 -06:00
|
|
|
IF(UNIX)
|
|
|
|
SET_SOURCE_FILES_PROPERTIES(${PROJECT_PROTO_SRCS} PROPERTIES COMPILE_FLAGS "-Wno-misleading-indentation")
|
|
|
|
ENDIF()
|
|
|
|
|
2016-10-24 20:51:27 -06:00
|
|
|
ADD_CUSTOM_TARGET(generate_proto_core DEPENDS ${PROJECT_PROTO_TMP_FILES})
|
2016-10-24 20:28:51 -06:00
|
|
|
|
2012-03-13 07:46:48 -06:00
|
|
|
# Merge headers into sources
|
|
|
|
SET_SOURCE_FILES_PROPERTIES( ${PROJECT_HEADERS} PROPERTIES HEADER_FILE_ONLY TRUE )
|
|
|
|
LIST(APPEND PROJECT_SOURCES ${PROJECT_HEADERS})
|
2009-10-26 15:50:08 -06:00
|
|
|
|
2011-12-24 03:37:00 -07:00
|
|
|
# Generation
|
2012-03-13 07:46:48 -06:00
|
|
|
LIST(APPEND PROJECT_SOURCES ${GENERATED_HDRS})
|
2011-12-24 03:37:00 -07:00
|
|
|
|
2011-12-29 05:30:55 -07:00
|
|
|
FILE(GLOB GENERATE_INPUT_SCRIPTS ${dfapi_SOURCE_DIR}/xml/*.pm ${dfapi_SOURCE_DIR}/xml/*.xslt)
|
2018-04-04 09:52:18 -06:00
|
|
|
FILE(GLOB GENERATE_INPUT_XMLS ${dfapi_SOURCE_DIR}/xml/df.*.xml)
|
2011-12-24 03:37:00 -07:00
|
|
|
|
|
|
|
ADD_CUSTOM_COMMAND(
|
2012-03-29 00:59:54 -06:00
|
|
|
OUTPUT ${dfapi_SOURCE_DIR}/include/df/codegen.out.xml
|
2012-02-03 19:43:14 -07:00
|
|
|
COMMAND ${PERL_EXECUTABLE} xml/codegen.pl xml include/df
|
2011-12-24 03:37:00 -07:00
|
|
|
WORKING_DIRECTORY ${dfapi_SOURCE_DIR}
|
|
|
|
MAIN_DEPENDENCY ${dfapi_SOURCE_DIR}/xml/codegen.pl
|
2011-12-29 05:30:55 -07:00
|
|
|
DEPENDS ${GENERATE_INPUT_XMLS} ${GENERATE_INPUT_SCRIPTS}
|
2011-12-24 03:37:00 -07:00
|
|
|
)
|
|
|
|
|
2012-03-29 00:59:54 -06:00
|
|
|
ADD_CUSTOM_TARGET(generate_headers DEPENDS ${dfapi_SOURCE_DIR}/include/df/codegen.out.xml)
|
2011-12-24 03:37:00 -07:00
|
|
|
|
2012-03-19 06:59:11 -06:00
|
|
|
IF(UNIX)
|
|
|
|
# Don't produce debug info for generated stubs
|
2016-03-18 21:11:11 -06:00
|
|
|
SET_SOURCE_FILES_PROPERTIES(DataStatics.cpp DataStaticsCtor.cpp DataStaticsFields.cpp ${STATIC_FIELDS_FILES}
|
2012-03-20 11:34:27 -06:00
|
|
|
PROPERTIES COMPILE_FLAGS "-g0 -O1")
|
2012-03-19 06:59:11 -06:00
|
|
|
ELSE(WIN32)
|
2016-03-18 21:11:11 -06:00
|
|
|
SET_SOURCE_FILES_PROPERTIES(DataStatics.cpp DataStaticsCtor.cpp DataStaticsFields.cpp ${STATIC_FIELDS_FILES}
|
2012-05-23 12:38:16 -06:00
|
|
|
PROPERTIES COMPILE_FLAGS "/O1 /bigobj")
|
2012-03-19 06:59:11 -06:00
|
|
|
ENDIF()
|
|
|
|
|
2011-12-24 03:37:00 -07:00
|
|
|
# Compilation
|
|
|
|
|
2011-03-30 17:12:50 -06:00
|
|
|
ADD_DEFINITIONS(-DBUILD_DFHACK_LIB)
|
2009-10-29 18:56:40 -06:00
|
|
|
|
2011-08-18 14:09:30 -06:00
|
|
|
IF(UNIX)
|
|
|
|
IF(CONSOLE_NO_CATCH)
|
|
|
|
ADD_DEFINITIONS(-DCONSOLE_NO_CATCH)
|
|
|
|
ENDIF()
|
|
|
|
ENDIF()
|
|
|
|
|
2015-08-09 11:20:28 -06:00
|
|
|
IF(APPLE)
|
2016-06-26 17:48:55 -06:00
|
|
|
SET(PROJECT_LIBS dl dfhack-md5 ${DFHACK_TINYXML} dfhack-tinythread)
|
2015-08-09 11:20:28 -06:00
|
|
|
ELSEIF(UNIX)
|
2016-06-26 17:48:55 -06:00
|
|
|
SET(PROJECT_LIBS rt dl dfhack-md5 ${DFHACK_TINYXML} dfhack-tinythread)
|
2011-11-06 13:16:16 -07:00
|
|
|
ELSE(WIN32)
|
2012-03-13 07:46:48 -06:00
|
|
|
#FIXME: do we really need psapi?
|
2016-06-26 17:48:55 -06:00
|
|
|
SET(PROJECT_LIBS psapi dfhack-md5 ${DFHACK_TINYXML} dfhack-tinythread)
|
2011-03-16 00:35:08 -06:00
|
|
|
ENDIF()
|
2009-09-13 18:02:46 -06:00
|
|
|
|
2015-02-19 08:31:58 -07:00
|
|
|
ADD_LIBRARY(dfhack-version STATIC DFHackVersion.cpp)
|
2015-04-02 14:37:58 -06:00
|
|
|
SET_PROPERTY(TARGET dfhack-version APPEND PROPERTY COMPILE_DEFINITIONS
|
|
|
|
DFHACK_VERSION="${DFHACK_VERSION}"
|
|
|
|
DF_VERSION="${DF_VERSION}"
|
|
|
|
DFHACK_RELEASE="${DFHACK_RELEASE}"
|
2018-03-10 14:55:00 -07:00
|
|
|
DFHACK_ABI_VERSION=${DFHACK_ABI_VERSION}
|
2015-04-02 14:37:58 -06:00
|
|
|
)
|
2015-12-11 18:27:46 -07:00
|
|
|
IF(DFHACK_PRERELEASE)
|
|
|
|
SET_PROPERTY(TARGET dfhack-version APPEND PROPERTY COMPILE_DEFINITIONS
|
|
|
|
DFHACK_PRERELEASE=1
|
|
|
|
)
|
|
|
|
ENDIF()
|
2015-02-19 08:31:58 -07:00
|
|
|
|
2015-06-24 17:32:45 -06:00
|
|
|
ADD_CUSTOM_TARGET(git-describe
|
|
|
|
COMMAND ${CMAKE_COMMAND}
|
|
|
|
-D dfhack_SOURCE_DIR:STRING=${dfhack_SOURCE_DIR}
|
2015-06-25 09:43:54 -06:00
|
|
|
-D GIT_EXECUTABLE:STRING=${GIT_EXECUTABLE}
|
2015-06-24 17:32:45 -06:00
|
|
|
-P ${CMAKE_CURRENT_SOURCE_DIR}/git-describe.cmake
|
|
|
|
COMMENT "Obtaining git commit information"
|
|
|
|
)
|
|
|
|
ADD_DEPENDENCIES(dfhack-version git-describe)
|
|
|
|
|
2012-03-13 07:46:48 -06:00
|
|
|
ADD_LIBRARY(dfhack SHARED ${PROJECT_SOURCES})
|
2016-10-24 20:28:51 -06:00
|
|
|
ADD_DEPENDENCIES(dfhack generate_headers generate_proto_core)
|
2009-10-23 12:05:42 -06:00
|
|
|
|
2018-02-07 13:32:27 -07:00
|
|
|
ADD_LIBRARY(dfhack-client SHARED RemoteClient.cpp ColorText.cpp MiscUtils.cpp Error.cpp ${PROJECT_PROTO_SRCS})
|
2012-03-15 04:06:50 -06:00
|
|
|
ADD_DEPENDENCIES(dfhack-client dfhack)
|
|
|
|
|
|
|
|
ADD_EXECUTABLE(dfhack-run dfhack-run.cpp)
|
2012-10-08 06:47:52 -06:00
|
|
|
|
2012-10-08 02:10:02 -06:00
|
|
|
ADD_EXECUTABLE(binpatch binpatch.cpp)
|
2012-10-08 06:47:52 -06:00
|
|
|
TARGET_LINK_LIBRARIES(binpatch dfhack-md5)
|
2012-03-14 09:57:29 -06:00
|
|
|
|
2012-02-27 19:37:56 -07:00
|
|
|
IF(BUILD_EGGY)
|
|
|
|
SET_TARGET_PROPERTIES(dfhack PROPERTIES OUTPUT_NAME "egg" )
|
|
|
|
else()
|
|
|
|
IF(WIN32)
|
|
|
|
SET_TARGET_PROPERTIES(dfhack PROPERTIES OUTPUT_NAME "SDL" )
|
|
|
|
ENDIF()
|
|
|
|
endif()
|
2011-06-19 20:29:38 -06:00
|
|
|
|
2012-03-09 10:42:22 -07:00
|
|
|
IF(WIN32)
|
|
|
|
SET_TARGET_PROPERTIES(dfhack PROPERTIES COMPILE_FLAGS "/FI\"Export.h\"" )
|
2012-03-15 04:06:50 -06:00
|
|
|
SET_TARGET_PROPERTIES(dfhack-client PROPERTIES COMPILE_FLAGS "/FI\"Export.h\"" )
|
2012-03-09 10:42:22 -07:00
|
|
|
ELSE()
|
|
|
|
SET_TARGET_PROPERTIES(dfhack PROPERTIES COMPILE_FLAGS "-include Export.h" )
|
2012-03-15 04:06:50 -06:00
|
|
|
SET_TARGET_PROPERTIES(dfhack-client PROPERTIES COMPILE_FLAGS "-include Export.h" )
|
2012-03-09 10:42:22 -07:00
|
|
|
ENDIF()
|
|
|
|
|
2011-08-14 00:42:21 -06:00
|
|
|
#effectively disables debug builds...
|
2009-12-12 12:52:30 -07:00
|
|
|
SET_TARGET_PROPERTIES(dfhack PROPERTIES DEBUG_POSTFIX "-debug" )
|
2009-10-23 12:05:42 -06:00
|
|
|
|
2012-05-24 09:31:20 -06:00
|
|
|
IF(APPLE)
|
2015-12-01 15:32:59 -07:00
|
|
|
SET(DF_SDL_LIBRARY ${CMAKE_INSTALL_PREFIX}/libs/SDL.framework/Versions/A/SDL)
|
|
|
|
IF(NOT EXISTS ${DF_SDL_LIBRARY})
|
2015-09-26 08:46:29 -06:00
|
|
|
MESSAGE(SEND_ERROR "SDL framework not found. Make sure CMAKE_INSTALL_PREFIX is specified and correct.")
|
2015-07-21 14:26:41 -06:00
|
|
|
ENDIF()
|
2015-12-01 15:32:59 -07:00
|
|
|
SET(SDL_LIBRARY ${CMAKE_BINARY_DIR}/SDL)
|
|
|
|
EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E copy_if_different ${DF_SDL_LIBRARY} ${SDL_LIBRARY})
|
2012-11-16 14:33:36 -07:00
|
|
|
SET(CXX_LIBRARY ${CMAKE_INSTALL_PREFIX}/libs/libstdc++.6.dylib)
|
|
|
|
SET(ZIP_LIBRARY /usr/lib/libz.dylib)
|
|
|
|
TARGET_LINK_LIBRARIES(dfhack ${SDL_LIBRARY})
|
|
|
|
TARGET_LINK_LIBRARIES(dfhack ${CXX_LIBRARY})
|
|
|
|
TARGET_LINK_LIBRARIES(dfhack ${ZIP_LIBRARY})
|
2017-06-08 11:05:12 -06:00
|
|
|
TARGET_LINK_LIBRARIES(dfhack ncurses)
|
2012-11-16 14:33:36 -07:00
|
|
|
SET_TARGET_PROPERTIES(dfhack PROPERTIES VERSION 1.0.0)
|
|
|
|
SET_TARGET_PROPERTIES(dfhack PROPERTIES SOVERSION 1.0.0)
|
2012-05-24 09:31:20 -06:00
|
|
|
ENDIF()
|
|
|
|
|
2015-07-29 12:47:55 -06:00
|
|
|
TARGET_LINK_LIBRARIES(dfhack protobuf-lite clsocket lua jsoncpp dfhack-version ${PROJECT_LIBS})
|
2018-03-08 01:28:28 -07:00
|
|
|
SET_TARGET_PROPERTIES(dfhack PROPERTIES INTERFACE_LINK_LIBRARIES "")
|
2009-10-29 18:56:40 -06:00
|
|
|
|
2012-03-15 04:06:50 -06:00
|
|
|
TARGET_LINK_LIBRARIES(dfhack-client protobuf-lite clsocket)
|
|
|
|
TARGET_LINK_LIBRARIES(dfhack-run dfhack-client)
|
2012-03-14 09:57:29 -06:00
|
|
|
|
2012-09-13 12:58:52 -06:00
|
|
|
if(APPLE)
|
2012-11-16 14:33:36 -07:00
|
|
|
add_custom_command(TARGET dfhack-run COMMAND ${dfhack_SOURCE_DIR}/package/darwin/fix-libs.sh WORKING_DIRECTORY ../ COMMENT "Fixing library dependencies...")
|
2012-09-13 12:58:52 -06:00
|
|
|
endif()
|
|
|
|
|
2011-07-12 18:25:27 -06:00
|
|
|
IF(UNIX)
|
2012-11-16 14:33:36 -07:00
|
|
|
if (APPLE)
|
|
|
|
install(PROGRAMS ${dfhack_SOURCE_DIR}/package/darwin/dfhack
|
|
|
|
DESTINATION .)
|
|
|
|
install(PROGRAMS ${dfhack_SOURCE_DIR}/package/darwin/dfhack-run
|
|
|
|
DESTINATION .)
|
2012-05-29 14:12:35 -06:00
|
|
|
else()
|
2012-11-16 14:33:36 -07:00
|
|
|
# On linux, copy our version of the df launch script which sets LD_PRELOAD
|
|
|
|
install(PROGRAMS ${dfhack_SOURCE_DIR}/package/linux/dfhack
|
2011-08-14 00:42:21 -06:00
|
|
|
DESTINATION .)
|
2012-11-16 14:33:36 -07:00
|
|
|
install(PROGRAMS ${dfhack_SOURCE_DIR}/package/linux/dfhack-run
|
2012-03-15 01:07:43 -06:00
|
|
|
DESTINATION .)
|
2012-05-29 14:12:35 -06:00
|
|
|
endif()
|
2011-07-16 02:32:18 -06:00
|
|
|
ELSE()
|
2012-02-27 19:37:56 -07:00
|
|
|
if(NOT BUILD_EGGY)
|
|
|
|
# On windows, copy the renamed SDL so DF can still run.
|
2016-07-27 19:08:24 -06:00
|
|
|
install(PROGRAMS ${dfhack_SOURCE_DIR}/package/windows/win${DFHACK_BUILD_ARCH}/SDLreal.dll
|
2012-02-27 19:37:56 -07:00
|
|
|
DESTINATION ${DFHACK_LIBRARY_DESTINATION})
|
|
|
|
endif()
|
2011-07-12 18:25:27 -06:00
|
|
|
ENDIF()
|
2011-08-14 00:42:21 -06:00
|
|
|
|
|
|
|
#install the main lib
|
2012-02-27 19:37:56 -07:00
|
|
|
if(NOT BUILD_EGGY)
|
|
|
|
install(TARGETS dfhack
|
|
|
|
LIBRARY DESTINATION ${DFHACK_LIBRARY_DESTINATION}
|
|
|
|
RUNTIME DESTINATION ${DFHACK_LIBRARY_DESTINATION})
|
|
|
|
else()
|
|
|
|
install(TARGETS dfhack
|
|
|
|
LIBRARY DESTINATION ${DFHACK_EGGY_DESTINATION}
|
|
|
|
RUNTIME DESTINATION ${DFHACK_EGGY_DESTINATION})
|
|
|
|
endif()
|
2012-03-14 09:57:29 -06:00
|
|
|
|
2011-08-14 00:42:21 -06:00
|
|
|
#install the offset file
|
2012-02-11 11:24:44 -07:00
|
|
|
install(FILES xml/symbols.xml
|
2011-03-17 17:07:40 -06:00
|
|
|
DESTINATION ${DFHACK_DATA_DESTINATION}) #linux: share/dfhack
|
2012-02-23 00:57:11 -07:00
|
|
|
#install the example autoexec file
|
2017-07-12 14:30:49 -06:00
|
|
|
install(FILES ../dfhack.init-example ../onLoad.init-example
|
2012-02-23 00:57:11 -07:00
|
|
|
DESTINATION ${DFHACK_BINARY_DESTINATION})
|
2011-03-18 09:47:55 -06:00
|
|
|
|
2012-10-08 02:10:02 -06:00
|
|
|
install(TARGETS dfhack-run dfhack-client binpatch
|
2012-03-14 09:57:29 -06:00
|
|
|
LIBRARY DESTINATION ${DFHACK_LIBRARY_DESTINATION}
|
|
|
|
RUNTIME DESTINATION ${DFHACK_LIBRARY_DESTINATION})
|
|
|
|
|
2012-03-31 05:40:54 -06:00
|
|
|
install(DIRECTORY lua/
|
|
|
|
DESTINATION ${DFHACK_LUA_DESTINATION}
|
|
|
|
FILES_MATCHING PATTERN "*.lua")
|
|
|
|
|
2012-11-11 06:24:13 -07:00
|
|
|
install(DIRECTORY ${dfhack_SOURCE_DIR}/patches
|
|
|
|
DESTINATION ${DFHACK_DATA_DESTINATION}
|
|
|
|
FILES_MATCHING PATTERN "*.dif")
|
|
|
|
|
2012-02-27 19:37:56 -07:00
|
|
|
# Unused for so long that it's not even relevant now...
|
2011-06-19 17:12:07 -06:00
|
|
|
if(BUILD_DEVEL)
|
2011-03-19 19:06:50 -06:00
|
|
|
if(WIN32)
|
|
|
|
install(TARGETS dfhack
|
|
|
|
ARCHIVE DESTINATION ${DFHACK_DEVLIB_DESTINATION})
|
|
|
|
endif()
|
2011-06-16 15:53:39 -06:00
|
|
|
# note the ending '/'. This means *contents* of the directory are installed
|
2011-03-20 10:24:34 -06:00
|
|
|
# without the '/', the directory itself is installed
|
|
|
|
install(DIRECTORY include/
|
2011-03-18 09:47:55 -06:00
|
|
|
DESTINATION ${DFHACK_INCLUDES_DESTINATION}
|
2013-10-01 08:58:04 -06:00
|
|
|
FILES_MATCHING PATTERN "*.h" PATTERN "*.inc" ) #linux: include
|
2011-03-17 17:07:40 -06:00
|
|
|
endif()
|