Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 1 addition & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -320,14 +320,12 @@ else()
endif()
endif()
find_package(ZLIB REQUIRED)
include_directories(${ZLIB_INCLUDE_DIRS})

set(USE_SYSTEM_SDL2 OFF CACHE BOOL "Set to ON to use the system SDL2 headers.")

if(BUILD_LIBRARY)
if(USE_SYSTEM_SDL2)
find_package(SDL2 REQUIRED CONFIG REQUIRED COMPONENTS SDL2)
include_directories(${SDL2_INCLUDE_DIRS})
else()
# Download SDL release and extract into depends in the build dir
# all we need are the header files (including generated headers), so the same release package
Expand All @@ -342,7 +340,7 @@ if(BUILD_LIBRARY)
${SDL_ZIP_MD5})
file(ARCHIVE_EXTRACT INPUT ${SDL_ZIP_PATH}${SDL_ZIP_FILE}
DESTINATION ${SDL_ZIP_PATH})
include_directories(${SDL_ZIP_PATH}/SDL2-${SDL_VERSION}/include)
set(SDL2_INCLUDE_DIRS ${SDL_ZIP_PATH}/SDL2-${SDL_VERSION}/include)
endif()
endif()

Expand Down Expand Up @@ -404,10 +402,6 @@ endif()

#### expose depends ####

include_directories(depends/protobuf)
include_directories(depends/lua/include)
include_directories(depends/md5)

# Support linking against external tinyxml
# If we find an external tinyxml, set the DFHACK_TINYXML variable to "tinyxml"
# Otherwise, set it to "dfhack-tinyxml"
Expand All @@ -419,14 +413,9 @@ if(EXTERNAL_TINYXML)
endif()
set(DFHACK_TINYXML "tinyxml")
else()
include_directories(depends/tinyxml)
set(DFHACK_TINYXML "dfhack-tinyxml")
endif()

include_directories(depends/lodepng)
include_directories(depends/clsocket/src)
include_directories(depends/xlsxio/include)

if(BUILD_LIBRARY)
add_subdirectory(depends)
endif()
Expand Down
4 changes: 4 additions & 0 deletions depends/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ add_subdirectory(lodepng)
add_subdirectory(lua)
add_subdirectory(md5)
add_subdirectory(protobuf)
target_include_directories(protobuf-lite INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/protobuf)

if(UNIX)
set_target_properties(lua PROPERTIES COMPILE_FLAGS "-Wno-deprecated-declarations -Wno-deprecated-enum-enum-conversion")
Expand All @@ -21,6 +22,7 @@ add_subdirectory(googletest)
# Don't build tinyxml if it's being externally linked against.
if(NOT TinyXML_FOUND)
add_subdirectory(tinyxml)
target_include_directories(dfhack-tinyxml INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/tinyxml)
endif()

option(JSONCPP_WITH_TESTS "Compile and (for jsoncpp_check) run JsonCpp test executables" OFF)
Expand Down Expand Up @@ -87,3 +89,5 @@ if(MSVC)
target_compile_options(xlsxio_read_STATIC PRIVATE /wd4013 /wd4244)
target_compile_options(xlsxio_write_STATIC PRIVATE /wd4013 /wd4244)
endif()
target_include_directories(xlsxio_read_STATIC INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/xlsxio/include)
target_include_directories(xlsxio_write_STATIC INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/xlsxio/include)
1 change: 1 addition & 0 deletions depends/lua/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ list(APPEND SRC_LIBLUA ${HDR_LIBLUA})
add_library(lua SHARED ${SRC_LIBLUA})
set_target_properties(lua PROPERTIES OUTPUT_NAME lua53)
target_link_libraries(lua ${LIBS})
target_include_directories(lua INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include)

if(MSVC)
# need no space to prevent /FI from being stripped: https://github.com/DFHack/dfhack/issues/1455
Expand Down
1 change: 1 addition & 0 deletions depends/md5/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
project(dfhack-md5)
add_library(dfhack-md5 STATIC EXCLUDE_FROM_ALL md5.cpp md5wrapper.cpp)
target_include_directories(dfhack-md5 INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
ide_folder(dfhack-md5 "Depends")
if(UNIX)
set_target_properties(dfhack-md5 PROPERTIES COMPILE_FLAGS "-Wno-strict-aliasing")
Expand Down
11 changes: 7 additions & 4 deletions library/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,10 @@ endif()

add_custom_target(generate_headers DEPENDS ${CODEGEN_OUT})

include_directories(include)

add_subdirectory(xml)

if(BUILD_LIBRARY)

include_directories(proto)

set(MAIN_HEADERS
include/Internal.h
include/DFHack.h
Expand Down Expand Up @@ -347,6 +343,7 @@ set_property(TARGET dfhack-version APPEND PROPERTY COMPILE_DEFINITIONS
DFHACK_ABI_VERSION=${DFHACK_ABI_VERSION}
DFHACK_RUN_URL="${DFHACK_RUN_URL}"
)
target_include_directories(dfhack-version PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)
if(DFHACK_PRERELEASE)
set_property(TARGET dfhack-version APPEND PROPERTY COMPILE_DEFINITIONS
DFHACK_PRERELEASE=1
Expand All @@ -369,13 +366,19 @@ if(EXISTS ${dfhack_SOURCE_DIR}/.git/index AND EXISTS ${dfhack_SOURCE_DIR}/.git/m
endif()

add_library(dfhack SHARED ${PROJECT_SOURCES})
target_include_directories(dfhack PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR}/proto)

get_target_property(xlsxio_INCLUDES xlsxio_read_STATIC INTERFACE_INCLUDE_DIRECTORIES)
target_include_directories(dfhack PRIVATE ${xlsxio_INCLUDES} ${SDL2_INCLUDE_DIRS})
add_dependencies(dfhack generate_proto_core)
add_dependencies(dfhack generate_headers)

add_library(dfhack-client SHARED RemoteClient.cpp ColorText.cpp MiscUtils.cpp Error.cpp ${PROJECT_PROTO_SRCS} ${CONSOLE_SOURCES})
target_include_directories(dfhack-client PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR}/proto)
add_dependencies(dfhack-client dfhack)

add_executable(dfhack-run dfhack-run.cpp)
target_include_directories(dfhack-run PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR}/proto)

add_executable(binpatch binpatch.cpp)
target_link_libraries(binpatch dfhack-md5)
Expand Down
2 changes: 1 addition & 1 deletion package/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ if(BUILD_DFLAUNCH)
set(STEAMAPI_SHARED_LIBRARY "${STEAMAPI_LIBRARY}")
endif()

include_directories(${STEAMAPI_SOURCE_DIR})
link_libraries(${STEAMAPI_LIBRARY})
if(WIN32)
add_executable(launchdf WIN32 launchdf.cpp)
else()
add_executable(launchdf launchdf.cpp)
endif()
target_include_directories(launchdf PRIVATE ${STEAMAPI_SOURCE_DIR})
install(TARGETS launchdf DESTINATION ${DFHACK_DATA_DESTINATION})
install(FILES ${STEAMAPI_SHARED_LIBRARY} DESTINATION ${DFHACK_DATA_DESTINATION})
endif()
18 changes: 6 additions & 12 deletions plugins/Plugins.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -119,22 +119,16 @@ macro(dfhack_plugin)
add_library(${PLUGIN_NAME} MODULE ${PLUGIN_SOURCES})
ide_folder(${PLUGIN_NAME} "Plugins")

target_include_directories(${PLUGIN_NAME} PRIVATE "${dfhack_SOURCE_DIR}/library/include")
target_include_directories(${PLUGIN_NAME} PRIVATE "${dfhack_SOURCE_DIR}/library/proto")
target_include_directories(${PLUGIN_NAME} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/proto")
target_include_directories(${PLUGIN_NAME} PRIVATE "${dfhack_SOURCE_DIR}/library/depends/xgetopt")

if(NUM_PROTO)
add_dependencies(${PLUGIN_NAME} generate_proto_${PLUGIN_NAME})
target_link_libraries(${PLUGIN_NAME} dfhack protobuf-lite dfhack-version ${PLUGIN_LINK_LIBRARIES})
else()
target_link_libraries(${PLUGIN_NAME} dfhack dfhack-version ${PLUGIN_LINK_LIBRARIES})
target_include_directories(${PLUGIN_NAME} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/proto")
target_link_libraries(${PLUGIN_NAME} protobuf-lite)
endif()
target_link_libraries(${PLUGIN_NAME} dfhack dfhack-version ${PLUGIN_LINK_LIBRARIES})

add_dependencies(${PLUGIN_NAME} dfhack-version)

# Make sure the source is generated before the executable builds.
add_dependencies(${PLUGIN_NAME} generate_proto)
# since PluginManager currently uses Lua headers, even when Lua is not used
get_target_property(lua_INCLUDES lua INTERFACE_INCLUDE_DIRECTORIES)
target_include_directories(${PLUGIN_NAME} PRIVATE ${lua_INCLUDES})

if(UNIX)
set(PLUGIN_COMPILE_FLAGS "${PLUGIN_COMPILE_FLAGS} ${PLUGIN_COMPILE_FLAGS_GCC}")
Expand Down
1 change: 0 additions & 1 deletion plugins/channel-safely/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
project(channel-safely)

include_directories(include)
SET(SOURCES
channel-groups.cpp
channel-manager.cpp
Expand Down
3 changes: 3 additions & 0 deletions plugins/remotefortressreader/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,6 @@ endif()

# this makes sure all the stuff is put in proper places and linked to dfhack
dfhack_plugin(RemoteFortressReader ${PROJECT_SRCS} LINK_LIBRARIES ${PROJECT_LIBS} PROTOBUFS ${PROJECT_PROTO})
if(BUILD_PLUGINS)
target_include_directories(RemoteFortressReader PRIVATE ${SDL2_INCLUDE_DIRS})
endif()
Loading