2019-07-16 20:19:11 -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
|
2019-07-16 20:19:11 -06:00
|
|
|
cmake_policy(SET CMP0022 NEW)
|
2015-09-27 02:05:28 -06:00
|
|
|
|
2019-07-16 20:19:11 -06:00
|
|
|
# build options
|
|
|
|
option(BUILD_DEVEL "Install/package files required for development(For SDK)." OFF)
|
|
|
|
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
|
|
|
|
2019-07-16 20:19:11 -06:00
|
|
|
include_directories(proto)
|
|
|
|
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 ";"
|
2019-07-16 20:19:11 -06:00
|
|
|
WORKING_DIRECTORY ${dfapi_SOURCE_DIR}
|
|
|
|
OUTPUT_VARIABLE GENERATED_HDRS)
|
|
|
|
|
|
|
|
set_source_files_properties(${GENERATED_HDRS} PROPERTIES HEADER_FILE_ONLY TRUE GENERATED TRUE)
|
|
|
|
|
|
|
|
set(MAIN_HEADERS
|
|
|
|
include/Internal.h
|
|
|
|
include/DFHack.h
|
|
|
|
include/DFHackVersion.h
|
|
|
|
include/Console.h
|
|
|
|
include/Core.h
|
|
|
|
include/ColorText.h
|
|
|
|
include/DataDefs.h
|
|
|
|
include/DataIdentity.h
|
|
|
|
include/Debug.h
|
|
|
|
include/DebugManager.h
|
|
|
|
include/VTableInterpose.h
|
|
|
|
include/LuaWrapper.h
|
|
|
|
include/LuaTools.h
|
|
|
|
include/Error.h
|
|
|
|
include/Export.h
|
|
|
|
include/Hooks.h
|
|
|
|
include/MiscUtils.h
|
|
|
|
include/Module.h
|
|
|
|
include/Pragma.h
|
|
|
|
include/MemAccess.h
|
|
|
|
include/Signal.hpp
|
|
|
|
include/TileTypes.h
|
|
|
|
include/Types.h
|
|
|
|
include/VersionInfo.h
|
|
|
|
include/VersionInfoFactory.h
|
|
|
|
include/RemoteClient.h
|
|
|
|
include/RemoteServer.h
|
|
|
|
include/RemoteTools.h
|
2012-03-13 07:46:48 -06:00
|
|
|
)
|
|
|
|
|
2019-07-16 20:19:11 -06:00
|
|
|
set(MAIN_HEADERS_WINDOWS
|
|
|
|
include/wdirent.h
|
2012-03-13 07:46:48 -06:00
|
|
|
)
|
|
|
|
|
2019-07-16 20:19:11 -06:00
|
|
|
set(MAIN_SOURCES
|
|
|
|
Core.cpp
|
|
|
|
ColorText.cpp
|
|
|
|
CompilerWorkAround.cpp
|
|
|
|
DataDefs.cpp
|
|
|
|
Debug.cpp
|
|
|
|
Error.cpp
|
|
|
|
VTableInterpose.cpp
|
|
|
|
LuaWrapper.cpp
|
|
|
|
LuaTypes.cpp
|
|
|
|
LuaTools.cpp
|
|
|
|
LuaApi.cpp
|
|
|
|
DataStatics.cpp
|
|
|
|
DataStaticsCtor.cpp
|
|
|
|
DataStaticsFields.cpp
|
|
|
|
MiscUtils.cpp
|
|
|
|
Types.cpp
|
|
|
|
PluginManager.cpp
|
|
|
|
TileTypes.cpp
|
|
|
|
VersionInfoFactory.cpp
|
|
|
|
RemoteClient.cpp
|
|
|
|
RemoteServer.cpp
|
|
|
|
RemoteTools.cpp
|
2012-03-13 07:46:48 -06:00
|
|
|
)
|
|
|
|
|
2020-03-06 14:02:03 -07:00
|
|
|
if(WIN32)
|
|
|
|
set(CONSOLE_SOURCES Console-windows.cpp)
|
|
|
|
else()
|
|
|
|
set(CONSOLE_SOURCES Console-posix.cpp)
|
|
|
|
endif()
|
|
|
|
|
2019-07-16 20:19:11 -06:00
|
|
|
set(MAIN_SOURCES_WINDOWS
|
2020-03-06 14:02:03 -07:00
|
|
|
${CONSOLE_SOURCES}
|
2019-07-16 20:19:11 -06:00
|
|
|
Hooks-windows.cpp
|
|
|
|
PlugLoad-windows.cpp
|
|
|
|
Process-windows.cpp
|
2012-03-13 07:46:48 -06:00
|
|
|
)
|
|
|
|
|
2019-07-16 20:19:11 -06:00
|
|
|
if(WIN32)
|
|
|
|
source_group("Main\\Headers" FILES ${MAIN_HEADERS} ${MAIN_HEADERS_WINDOWS})
|
|
|
|
source_group("Main\\Sources" FILES ${MAIN_SOURCES} ${MAIN_SOURCES_WINDOWS})
|
|
|
|
endif()
|
2012-03-13 07:46:48 -06:00
|
|
|
|
2019-07-16 20:19:11 -06:00
|
|
|
set(MAIN_SOURCES_LINUX
|
2020-03-06 14:02:03 -07:00
|
|
|
${CONSOLE_SOURCES}
|
2019-07-16 20:19:11 -06:00
|
|
|
Hooks-linux.cpp
|
|
|
|
PlugLoad-posix.cpp
|
|
|
|
Process-linux.cpp
|
2012-03-13 07:46:48 -06:00
|
|
|
)
|
|
|
|
|
2019-07-16 20:19:11 -06:00
|
|
|
set(MAIN_SOURCES_DARWIN
|
2020-03-06 14:02:03 -07:00
|
|
|
${CONSOLE_SOURCES}
|
2019-07-16 20:19:11 -06:00
|
|
|
Hooks-darwin.cpp
|
|
|
|
PlugLoad-posix.cpp
|
|
|
|
Process-darwin.cpp
|
2012-05-25 12:28:59 -06:00
|
|
|
)
|
|
|
|
|
2019-07-16 20:19:11 -06:00
|
|
|
set(MAIN_SOURCES_LINUX_EGGY
|
2020-03-06 14:02:03 -07:00
|
|
|
${CONSOLE_SOURCES}
|
2019-07-16 20:19:11 -06:00
|
|
|
Hooks-egg.cpp
|
|
|
|
PlugLoad-linux.cpp
|
|
|
|
Process-linux.cpp
|
2012-03-13 07:46:48 -06:00
|
|
|
)
|
|
|
|
|
2019-07-16 20:19:11 -06:00
|
|
|
set(MODULE_HEADERS
|
|
|
|
include/modules/Buildings.h
|
|
|
|
include/modules/Burrows.h
|
|
|
|
include/modules/Constructions.h
|
|
|
|
include/modules/Designations.h
|
|
|
|
include/modules/Engravings.h
|
|
|
|
include/modules/EventManager.h
|
|
|
|
include/modules/Filesystem.h
|
|
|
|
include/modules/Graphic.h
|
|
|
|
include/modules/Gui.h
|
|
|
|
include/modules/GuiHooks.h
|
|
|
|
include/modules/Items.h
|
|
|
|
include/modules/Job.h
|
|
|
|
include/modules/Kitchen.h
|
|
|
|
include/modules/MapCache.h
|
|
|
|
include/modules/Maps.h
|
|
|
|
include/modules/Materials.h
|
|
|
|
include/modules/Notes.h
|
|
|
|
include/modules/Once.h
|
2019-08-23 21:58:00 -06:00
|
|
|
include/modules/Persistence.h
|
2019-07-16 20:19:11 -06:00
|
|
|
include/modules/Random.h
|
|
|
|
include/modules/Renderer.h
|
|
|
|
include/modules/Screen.h
|
|
|
|
include/modules/Translation.h
|
|
|
|
include/modules/Units.h
|
|
|
|
include/modules/World.h
|
2009-10-26 15:50:08 -06:00
|
|
|
)
|
|
|
|
|
2019-07-16 20:19:11 -06:00
|
|
|
set(MODULE_SOURCES
|
|
|
|
modules/Buildings.cpp
|
|
|
|
modules/Burrows.cpp
|
|
|
|
modules/Constructions.cpp
|
|
|
|
modules/Designations.cpp
|
|
|
|
modules/Engravings.cpp
|
|
|
|
modules/EventManager.cpp
|
|
|
|
modules/Filesystem.cpp
|
|
|
|
modules/Graphic.cpp
|
|
|
|
modules/Gui.cpp
|
|
|
|
modules/Items.cpp
|
|
|
|
modules/Job.cpp
|
|
|
|
modules/Kitchen.cpp
|
|
|
|
modules/MapCache.cpp
|
|
|
|
modules/Maps.cpp
|
|
|
|
modules/Materials.cpp
|
|
|
|
modules/Notes.cpp
|
|
|
|
modules/Once.cpp
|
2019-08-23 21:58:00 -06:00
|
|
|
modules/Persistence.cpp
|
2019-07-16 20:19:11 -06:00
|
|
|
modules/Random.cpp
|
|
|
|
modules/Renderer.cpp
|
|
|
|
modules/Screen.cpp
|
|
|
|
modules/Translation.cpp
|
|
|
|
modules/Units.cpp
|
|
|
|
modules/Windows.cpp
|
|
|
|
modules/World.cpp
|
2010-08-12 18:35:10 -06:00
|
|
|
)
|
|
|
|
|
2019-07-16 20:19: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
|
2016-03-18 21:11:11 -06:00
|
|
|
"#define STATIC_FIELDS_GROUP\n"
|
|
|
|
"#include \"../DataStaticsFields.cpp\"\n"
|
|
|
|
"#include \"${STATIC_FIELDS_INC_FILENAME}\"\n"
|
|
|
|
)
|
2019-07-16 20:19:11 -06:00
|
|
|
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
2016-03-18 21:11:11 -06:00
|
|
|
${STATIC_FIELDS_FILENAME}.tmp ${STATIC_FIELDS_FILENAME})
|
2019-07-16 20:19:11 -06:00
|
|
|
file(REMOVE ${STATIC_FIELDS_FILENAME}.tmp)
|
|
|
|
list(APPEND STATIC_FIELDS_FILES ${STATIC_FIELDS_FILENAME})
|
|
|
|
endforeach()
|
|
|
|
list(APPEND MAIN_SOURCES ${STATIC_FIELDS_FILES})
|
|
|
|
|
|
|
|
if(WIN32)
|
|
|
|
source_group("Modules\\Headers" FILES ${MODULE_HEADERS})
|
|
|
|
source_group("Modules\\Sources" FILES ${MODULE_SOURCES})
|
|
|
|
source_group("Generated" FILES ${GENERATED_HDRS})
|
|
|
|
endif()
|
|
|
|
|
|
|
|
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})
|
|
|
|
|
|
|
|
if(UNIX)
|
|
|
|
option(BUILD_EGGY "Make DFHack strangely egg-shaped." OFF)
|
|
|
|
if(BUILD_EGGY)
|
|
|
|
list(APPEND PROJECT_SOURCES ${MAIN_SOURCES_LINUX_EGGY})
|
|
|
|
elseif(APPLE)
|
|
|
|
list(APPEND PROJECT_SOURCES ${MAIN_SOURCES_DARWIN})
|
|
|
|
else()
|
|
|
|
list(APPEND PROJECT_SOURCES ${MAIN_SOURCES_LINUX})
|
|
|
|
endif()
|
|
|
|
elseif(WIN32)
|
|
|
|
list(APPEND PROJECT_SOURCES ${MAIN_SOURCES_WINDOWS})
|
|
|
|
list(APPEND PROJECT_HEADERS ${MAIN_HEADERS_WINDOWS})
|
|
|
|
endif()
|
2009-11-16 20:19:13 -07:00
|
|
|
|
2012-03-09 10:42:22 -07:00
|
|
|
# Protobuf
|
2019-07-16 20:19:11 -06:00
|
|
|
file(GLOB PROJECT_PROTOS ${CMAKE_CURRENT_SOURCE_DIR}/proto/*.proto)
|
2012-03-09 10:42:22 -07:00
|
|
|
|
2019-07-16 20:19:11 -06:00
|
|
|
string(REPLACE ".proto" ".pb.cc" PROJECT_PROTO_SRCS "${PROJECT_PROTOS}")
|
|
|
|
string(REPLACE ".proto" ".pb.h" PROJECT_PROTO_HDRS "${PROJECT_PROTOS}")
|
|
|
|
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}
|
2016-10-24 20:28:51 -06:00
|
|
|
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)
|
2019-07-16 20:19:11 -06:00
|
|
|
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()
|
|
|
|
|
|
|
|
list(APPEND PROJECT_HEADERS ${PROJECT_PROTO_HDRS})
|
|
|
|
list(APPEND PROJECT_SOURCES ${PROJECT_PROTO_SRCS})
|
|
|
|
|
|
|
|
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/
|
2019-07-16 20:19:11 -06:00
|
|
|
--cpp_out=dllexport_decl=DFHACK_EXPORT:${CMAKE_CURRENT_SOURCE_DIR}/proto/tmp/
|
|
|
|
${PROJECT_PROTOS}
|
2016-11-02 14:23:32 -06:00
|
|
|
COMMAND ${PERL_EXECUTABLE} ${CMAKE_SOURCE_DIR}/depends/copy-if-different.pl
|
2019-07-16 20:19:11 -06:00
|
|
|
${PROJECT_PROTO_TMP_FILES}
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/proto/
|
2016-10-24 20:28:51 -06:00
|
|
|
COMMENT "Generating core protobufs"
|
2012-03-09 10:42:22 -07:00
|
|
|
DEPENDS protoc-bin ${PROJECT_PROTOS}
|
|
|
|
)
|
|
|
|
|
2019-07-16 20:19:11 -06:00
|
|
|
if(UNIX)
|
|
|
|
set_source_files_properties(${PROJECT_PROTO_SRCS} PROPERTIES COMPILE_FLAGS "-Wno-misleading-indentation")
|
|
|
|
endif()
|
2018-04-05 15:46:04 -06:00
|
|
|
|
2019-07-16 20:19:11 -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
|
2019-07-16 20:19:11 -06:00
|
|
|
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
|
2019-07-16 20:19:11 -06:00
|
|
|
list(APPEND PROJECT_SOURCES ${GENERATED_HDRS})
|
2011-12-24 03:37:00 -07:00
|
|
|
|
2019-07-16 20:19:11 -06:00
|
|
|
file(GLOB GENERATE_INPUT_SCRIPTS ${dfapi_SOURCE_DIR}/xml/*.pm ${dfapi_SOURCE_DIR}/xml/*.xslt)
|
|
|
|
file(GLOB GENERATE_INPUT_XMLS ${dfapi_SOURCE_DIR}/xml/df.*.xml)
|
2011-12-24 03:37:00 -07:00
|
|
|
|
2018-07-13 08:01:36 -06:00
|
|
|
set(CODEGEN_OUT ${dfapi_SOURCE_DIR}/include/df/codegen.out.xml)
|
2019-07-16 20:19:11 -06:00
|
|
|
if(NOT("${CMAKE_GENERATOR}" STREQUAL Ninja))
|
2019-05-13 17:38:24 -06:00
|
|
|
# use BYPRODUCTS instead under Ninja to avoid rebuilds
|
2019-07-16 20:19:11 -06:00
|
|
|
list(APPEND CODEGEN_OUT ${GENERATED_HDRS})
|
|
|
|
endif()
|
2018-07-13 08:01:36 -06:00
|
|
|
|
2019-07-16 20:19:11 -06:00
|
|
|
add_custom_command(
|
2018-07-13 08:01:36 -06:00
|
|
|
OUTPUT ${CODEGEN_OUT}
|
2019-05-13 17:38:24 -06:00
|
|
|
BYPRODUCTS ${GENERATED_HDRS}
|
2018-06-25 06:31:51 -06:00
|
|
|
COMMAND ${PERL_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/xml/codegen.pl
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/xml
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/include/df
|
2011-12-24 03:37:00 -07:00
|
|
|
MAIN_DEPENDENCY ${dfapi_SOURCE_DIR}/xml/codegen.pl
|
2018-06-28 12:09:42 -06:00
|
|
|
COMMENT "Generating codegen.out.xml and df/headers"
|
2011-12-29 05:30:55 -07:00
|
|
|
DEPENDS ${GENERATE_INPUT_XMLS} ${GENERATE_INPUT_SCRIPTS}
|
2011-12-24 03:37:00 -07:00
|
|
|
)
|
|
|
|
|
2019-07-16 20:19:11 -06:00
|
|
|
add_custom_target(generate_headers
|
2018-07-08 04:32:04 -06:00
|
|
|
DEPENDS ${dfapi_SOURCE_DIR}/include/df/codegen.out.xml)
|
2018-06-25 06:39:26 -06:00
|
|
|
|
2019-07-16 20:19:11 -06:00
|
|
|
if(REMOVE_SYMBOLS_FROM_DF_STUBS)
|
|
|
|
if(UNIX)
|
|
|
|
# Don't produce debug info for generated stubs
|
|
|
|
set_source_files_properties(DataStatics.cpp DataStaticsCtor.cpp DataStaticsFields.cpp ${STATIC_FIELDS_FILES}
|
|
|
|
PROPERTIES COMPILE_FLAGS "-g0 -O1")
|
|
|
|
else(WIN32)
|
|
|
|
set_source_files_properties(DataStatics.cpp DataStaticsCtor.cpp DataStaticsFields.cpp ${STATIC_FIELDS_FILES}
|
|
|
|
PROPERTIES COMPILE_FLAGS "/O1 /bigobj")
|
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
if(WIN32)
|
|
|
|
set_source_files_properties(DataStatics.cpp DataStaticsCtor.cpp DataStaticsFields.cpp ${STATIC_FIELDS_FILES}
|
|
|
|
PROPERTIES COMPILE_FLAGS "/Od /bigobj")
|
|
|
|
endif()
|
|
|
|
endif()
|
2012-03-19 06:59:11 -06:00
|
|
|
|
2011-12-24 03:37:00 -07:00
|
|
|
# Compilation
|
|
|
|
|
2019-07-16 20:19:11 -06:00
|
|
|
add_definitions(-DBUILD_DFHACK_LIB)
|
2009-10-29 18:56:40 -06:00
|
|
|
|
2019-07-16 20:19:11 -06:00
|
|
|
if(UNIX)
|
|
|
|
if(CONSOLE_NO_CATCH)
|
|
|
|
add_definitions(-DCONSOLE_NO_CATCH)
|
|
|
|
endif()
|
|
|
|
endif()
|
2011-08-18 14:09:30 -06:00
|
|
|
|
2019-07-16 20:19:11 -06:00
|
|
|
if(APPLE)
|
|
|
|
set(PROJECT_LIBS dl dfhack-md5 ${DFHACK_TINYXML} dfhack-tinythread)
|
|
|
|
elseif(UNIX)
|
|
|
|
set(PROJECT_LIBS rt dl dfhack-md5 ${DFHACK_TINYXML} dfhack-tinythread)
|
|
|
|
else(WIN32)
|
|
|
|
# FIXME: do we really need psapi?
|
|
|
|
set(PROJECT_LIBS psapi dfhack-md5 ${DFHACK_TINYXML} dfhack-tinythread)
|
|
|
|
endif()
|
2009-09-13 18:02:46 -06:00
|
|
|
|
2018-06-25 06:25:13 -06:00
|
|
|
set(VERSION_SRCS DFHackVersion.cpp)
|
2018-07-07 15:05:32 -06:00
|
|
|
set(VERSION_HDRS include/git-describe.h)
|
2018-06-25 06:25:13 -06:00
|
|
|
|
2019-07-16 20:19:11 -06:00
|
|
|
set_source_files_properties(${VERSION_HDRS} PROPERTIES HEADER_FILE_ONLY TRUE)
|
2018-06-25 06:25:13 -06:00
|
|
|
|
2019-07-16 20:19:11 -06:00
|
|
|
list(APPEND VERSION_SRCS ${VERSION_HDRS})
|
2018-06-25 06:25:13 -06:00
|
|
|
|
2019-07-16 20:19:11 -06:00
|
|
|
add_library(dfhack-version STATIC ${VERSION_SRCS})
|
|
|
|
set_property(TARGET dfhack-version APPEND PROPERTY COMPILE_DEFINITIONS
|
2015-04-02 14:37:58 -06:00
|
|
|
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
|
|
|
)
|
2019-07-16 20:19:11 -06:00
|
|
|
if(DFHACK_PRERELEASE)
|
|
|
|
set_property(TARGET dfhack-version APPEND PROPERTY COMPILE_DEFINITIONS
|
2015-12-11 18:27:46 -07:00
|
|
|
DFHACK_PRERELEASE=1
|
|
|
|
)
|
2019-07-16 20:19:11 -06:00
|
|
|
endif()
|
2015-02-19 08:31:58 -07:00
|
|
|
|
2018-07-13 06:22:00 -06:00
|
|
|
configure_file(git-describe.cmake.in ${CMAKE_CURRENT_SOURCE_DIR}/git-describe.cmake @ONLY)
|
2019-07-16 20:19:11 -06:00
|
|
|
if(EXISTS ${CMAKE_SOURCE_DIR}/.git/index AND EXISTS ${CMAKE_SOURCE_DIR}/.git/modules/library/xml/index)
|
|
|
|
add_custom_command(OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/include/git-describe.h
|
|
|
|
COMMAND ${CMAKE_COMMAND}
|
|
|
|
-D dfhack_SOURCE_DIR:STRING=${dfhack_SOURCE_DIR}
|
|
|
|
-D GIT_EXECUTABLE:STRING=${GIT_EXECUTABLE}
|
|
|
|
-P ${CMAKE_CURRENT_SOURCE_DIR}/git-describe.cmake
|
|
|
|
COMMENT "Obtaining git commit information"
|
|
|
|
DEPENDS ${CMAKE_SOURCE_DIR}/.git/index
|
|
|
|
${CMAKE_SOURCE_DIR}/.git/modules/library/xml/index
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/git-describe.cmake
|
|
|
|
include/git-describe.h.in
|
2018-07-08 04:32:04 -06:00
|
|
|
)
|
2019-07-16 20:19:11 -06:00
|
|
|
endif()
|
2015-06-24 17:32:45 -06:00
|
|
|
|
2019-07-16 20:19:11 -06:00
|
|
|
add_library(dfhack SHARED ${PROJECT_SOURCES})
|
|
|
|
add_dependencies(dfhack generate_proto_core)
|
|
|
|
add_dependencies(dfhack generate_headers)
|
2009-10-23 12:05:42 -06:00
|
|
|
|
2020-03-06 14:02:03 -07:00
|
|
|
add_library(dfhack-client SHARED RemoteClient.cpp ColorText.cpp MiscUtils.cpp Error.cpp ${PROJECT_PROTO_SRCS} ${CONSOLE_SOURCES})
|
2019-07-16 20:19:11 -06:00
|
|
|
add_dependencies(dfhack-client dfhack)
|
2012-03-15 04:06:50 -06:00
|
|
|
|
2019-07-16 20:19:11 -06:00
|
|
|
add_executable(dfhack-run dfhack-run.cpp)
|
2012-10-08 06:47:52 -06:00
|
|
|
|
2019-07-16 20:19:11 -06:00
|
|
|
add_executable(binpatch binpatch.cpp)
|
|
|
|
target_link_libraries(binpatch dfhack-md5)
|
2012-03-14 09:57:29 -06:00
|
|
|
|
2019-07-16 20:19:11 -06:00
|
|
|
if(BUILD_EGGY)
|
|
|
|
set_target_properties(dfhack PROPERTIES OUTPUT_NAME "egg" )
|
2012-02-27 19:37:56 -07:00
|
|
|
else()
|
2019-07-16 20:19:11 -06:00
|
|
|
if(WIN32)
|
|
|
|
set_target_properties(dfhack PROPERTIES OUTPUT_NAME "SDL" )
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(WIN32)
|
|
|
|
set_target_properties(dfhack PROPERTIES COMPILE_FLAGS "/FI\"Export.h\"" )
|
|
|
|
set_target_properties(dfhack-client PROPERTIES COMPILE_FLAGS "/FI\"Export.h\"" )
|
|
|
|
else()
|
|
|
|
set_target_properties(dfhack PROPERTIES COMPILE_FLAGS "-include Export.h" )
|
|
|
|
set_target_properties(dfhack-client PROPERTIES COMPILE_FLAGS "-include Export.h" )
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# effectively disables debug builds...
|
|
|
|
set_target_properties(dfhack PROPERTIES DEBUG_POSTFIX "-debug" )
|
|
|
|
|
|
|
|
if(APPLE)
|
|
|
|
set(DF_SDL_LIBRARY ${CMAKE_INSTALL_PREFIX}/libs/SDL.framework/Versions/A/SDL)
|
|
|
|
if(NOT EXISTS ${DF_SDL_LIBRARY})
|
|
|
|
message(SEND_ERROR "SDL framework not found. Make sure CMAKE_INSTALL_PREFIX is specified and correct.")
|
|
|
|
endif()
|
|
|
|
set(SDL_LIBRARY ${CMAKE_BINARY_DIR}/SDL)
|
|
|
|
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different ${DF_SDL_LIBRARY} ${SDL_LIBRARY})
|
|
|
|
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})
|
|
|
|
target_link_libraries(dfhack ncurses)
|
|
|
|
set_target_properties(dfhack PROPERTIES VERSION 1.0.0)
|
|
|
|
set_target_properties(dfhack PROPERTIES SOVERSION 1.0.0)
|
2012-02-27 19:37:56 -07:00
|
|
|
endif()
|
2011-06-19 20:29:38 -06:00
|
|
|
|
2020-08-09 09:54:42 -06:00
|
|
|
target_link_libraries(dfhack protobuf-lite clsocket lua jsoncpp_lib_static dfhack-version ${PROJECT_LIBS})
|
2019-07-16 20:19:11 -06:00
|
|
|
set_target_properties(dfhack PROPERTIES INTERFACE_LINK_LIBRARIES "")
|
|
|
|
|
|
|
|
target_link_libraries(dfhack-client protobuf-lite clsocket jsoncpp_lib_static)
|
|
|
|
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()
|
|
|
|
|
2019-07-16 20:19:11 -06:00
|
|
|
if(UNIX)
|
|
|
|
if(APPLE)
|
2012-11-16 14:33:36 -07:00
|
|
|
install(PROGRAMS ${dfhack_SOURCE_DIR}/package/darwin/dfhack
|
2019-07-16 20:19:11 -06:00
|
|
|
DESTINATION .)
|
2012-11-16 14:33:36 -07:00
|
|
|
install(PROGRAMS ${dfhack_SOURCE_DIR}/package/darwin/dfhack-run
|
2019-07-16 20:19:11 -06:00
|
|
|
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()
|
2019-07-16 20:19:11 -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
|
2019-07-16 20:19:11 -06:00
|
|
|
DESTINATION ${DFHACK_LIBRARY_DESTINATION})
|
2012-02-27 19:37:56 -07:00
|
|
|
endif()
|
2019-07-16 20:19:11 -06:00
|
|
|
endif()
|
2011-08-14 00:42:21 -06:00
|
|
|
|
2019-07-16 20:19:11 -06:00
|
|
|
# install the main lib
|
2012-02-27 19:37:56 -07:00
|
|
|
if(NOT BUILD_EGGY)
|
|
|
|
install(TARGETS dfhack
|
2019-07-16 20:19:11 -06:00
|
|
|
LIBRARY DESTINATION ${DFHACK_LIBRARY_DESTINATION}
|
|
|
|
RUNTIME DESTINATION ${DFHACK_LIBRARY_DESTINATION})
|
2012-02-27 19:37:56 -07:00
|
|
|
else()
|
|
|
|
install(TARGETS dfhack
|
2019-07-16 20:19:11 -06:00
|
|
|
LIBRARY DESTINATION ${DFHACK_EGGY_DESTINATION}
|
|
|
|
RUNTIME DESTINATION ${DFHACK_EGGY_DESTINATION})
|
2012-02-27 19:37:56 -07:00
|
|
|
endif()
|
2012-03-14 09:57:29 -06:00
|
|
|
|
2019-07-16 20:19:11 -06:00
|
|
|
# install the offset file
|
2012-02-11 11:24:44 -07:00
|
|
|
install(FILES xml/symbols.xml
|
2019-07-16 20:19:11 -06:00
|
|
|
DESTINATION ${DFHACK_DATA_DESTINATION})
|
|
|
|
# install the example autoexec file
|
2017-07-12 14:30:49 -06:00
|
|
|
install(FILES ../dfhack.init-example ../onLoad.init-example
|
2019-07-16 20:19:11 -06: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
|
2019-07-16 20:19:11 -06:00
|
|
|
LIBRARY DESTINATION ${DFHACK_LIBRARY_DESTINATION}
|
|
|
|
RUNTIME DESTINATION ${DFHACK_LIBRARY_DESTINATION})
|
2012-03-14 09:57:29 -06:00
|
|
|
|
2012-03-31 05:40:54 -06:00
|
|
|
install(DIRECTORY lua/
|
2019-07-16 20:19:11 -06:00
|
|
|
DESTINATION ${DFHACK_LUA_DESTINATION}
|
|
|
|
FILES_MATCHING PATTERN "*.lua")
|
2012-03-31 05:40:54 -06:00
|
|
|
|
2012-11-11 06:24:13 -07:00
|
|
|
install(DIRECTORY ${dfhack_SOURCE_DIR}/patches
|
2019-07-16 20:19:11 -06:00
|
|
|
DESTINATION ${DFHACK_DATA_DESTINATION}
|
|
|
|
FILES_MATCHING PATTERN "*.dif")
|
2012-11-11 06:24:13 -07:00
|
|
|
|
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
|
2019-07-16 20:19:11 -06:00
|
|
|
ARCHIVE DESTINATION ${DFHACK_DEVLIB_DESTINATION})
|
2011-03-19 19:06:50 -06:00
|
|
|
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/
|
2019-07-16 20:19:11 -06:00
|
|
|
DESTINATION ${DFHACK_INCLUDES_DESTINATION}
|
|
|
|
FILES_MATCHING PATTERN "*.h" PATTERN "*.inc" )
|
2011-03-17 17:07:40 -06:00
|
|
|
endif()
|