Improves support for dfhack as a sub-project (#2058)

Replaces CMAKE_SOURCE_DIR with dfhack_SOURCE_DIR so it can be included in other cmake projects that have a different top-level CMAKE_SOURCE_DIR
develop
Josh Cooper 2022-03-29 10:28:52 -07:00 committed by GitHub
parent b18eff9ce2
commit 69ca0d8a28
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 13 additions and 13 deletions

@ -11,7 +11,7 @@ endfunction()
function(search_downloads FILE_MD5 VAR) function(search_downloads FILE_MD5 VAR)
set(${VAR} "" PARENT_SCOPE) set(${VAR} "" PARENT_SCOPE)
file(GLOB FILES ${CMAKE_SOURCE_DIR}/CMake/downloads/*) file(GLOB FILES ${dfhack_SOURCE_DIR}/CMake/downloads/*)
foreach(FILE ${FILES}) foreach(FILE ${FILES})
file(MD5 "${FILE}" CUR_MD5) file(MD5 "${FILE}" CUR_MD5)
if("${CUR_MD5}" STREQUAL "${FILE_MD5}") if("${CUR_MD5}" STREQUAL "${FILE_MD5}")
@ -53,7 +53,7 @@ function(download_file_unzip URL ZIP_TYPE ZIP_DEST ZIP_MD5 UNZIP_DEST UNZIP_MD5)
message("* Decompressing ${FILENAME}") message("* Decompressing ${FILENAME}")
if("${ZIP_TYPE}" STREQUAL "gz") if("${ZIP_TYPE}" STREQUAL "gz")
execute_process(COMMAND execute_process(COMMAND
"${PERL_EXECUTABLE}" "${CMAKE_SOURCE_DIR}/depends/gunzip.pl" "${PERL_EXECUTABLE}" "${dfhack_SOURCE_DIR}/depends/gunzip.pl"
"${ZIP_DEST}" --force) "${ZIP_DEST}" --force)
else() else()
message(SEND_ERROR "Unknown ZIP_TYPE: ${ZIP_TYPE}") message(SEND_ERROR "Unknown ZIP_TYPE: ${ZIP_TYPE}")

@ -174,7 +174,7 @@ if(HAVE_CUCHAR2)
endif() endif()
# mixing the build system with the source code is ugly and stupid. enforce the opposite :) # mixing the build system with the source code is ugly and stupid. enforce the opposite :)
if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}") if("${dfhack_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
message(FATAL_ERROR "In-source builds are not allowed.") message(FATAL_ERROR "In-source builds are not allowed.")
endif() endif()
@ -283,7 +283,7 @@ include(CMake/DownloadFile.cmake)
if(WIN32) if(WIN32)
# Download zlib on Windows # Download zlib on Windows
set(ZLIB_DOWNLOAD_DIR ${CMAKE_SOURCE_DIR}/depends/zlib/lib/win${DFHACK_BUILD_ARCH}) set(ZLIB_DOWNLOAD_DIR ${dfhack_SOURCE_DIR}/depends/zlib/lib/win${DFHACK_BUILD_ARCH})
if(${DFHACK_BUILD_ARCH} STREQUAL "64") if(${DFHACK_BUILD_ARCH} STREQUAL "64")
download_file("https://github.com/DFHack/dfhack-bin/releases/download/0.44.09/win64-zlib.lib" download_file("https://github.com/DFHack/dfhack-bin/releases/download/0.44.09/win64-zlib.lib"
${ZLIB_DOWNLOAD_DIR}/zlib.lib ${ZLIB_DOWNLOAD_DIR}/zlib.lib
@ -296,14 +296,14 @@ if(WIN32)
# Move zlib to the build folder so possible 32 and 64-bit builds # Move zlib to the build folder so possible 32 and 64-bit builds
# in the same source tree don't conflict # in the same source tree don't conflict
file(COPY ${CMAKE_SOURCE_DIR}/depends/zlib file(COPY ${dfhack_SOURCE_DIR}/depends/zlib
DESTINATION ${CMAKE_BINARY_DIR}/depends/) DESTINATION ${CMAKE_BINARY_DIR}/depends/)
file(COPY ${ZLIB_DOWNLOAD_DIR}/zlib.lib file(COPY ${ZLIB_DOWNLOAD_DIR}/zlib.lib
DESTINATION ${CMAKE_BINARY_DIR}/depends/zlib/lib/) DESTINATION ${CMAKE_BINARY_DIR}/depends/zlib/lib/)
# Do the same for SDLreal.dll # Do the same for SDLreal.dll
# (DFHack doesn't require this at build time, so no need to move it to the build folder) # (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}) set(SDLREAL_DOWNLOAD_DIR ${dfhack_SOURCE_DIR}/package/windows/win${DFHACK_BUILD_ARCH})
if(${DFHACK_BUILD_ARCH} STREQUAL "64") if(${DFHACK_BUILD_ARCH} STREQUAL "64")
download_file("https://github.com/DFHack/dfhack-bin/releases/download/0.44.09/win64-SDL.dll" download_file("https://github.com/DFHack/dfhack-bin/releases/download/0.44.09/win64-SDL.dll"
${SDLREAL_DOWNLOAD_DIR}/SDLreal.dll ${SDLREAL_DOWNLOAD_DIR}/SDLreal.dll
@ -318,7 +318,7 @@ endif()
if(APPLE) if(APPLE)
# libstdc++ (GCC 4.8.5 for OS X 10.6) # libstdc++ (GCC 4.8.5 for OS X 10.6)
# fixes crash-on-unwind bug in DF's libstdc++ # fixes crash-on-unwind bug in DF's libstdc++
set(LIBSTDCXX_DOWNLOAD_DIR ${CMAKE_SOURCE_DIR}/package/darwin/osx${DFHACK_BUILD_ARCH}) set(LIBSTDCXX_DOWNLOAD_DIR ${dfhack_SOURCE_DIR}/package/darwin/osx${DFHACK_BUILD_ARCH})
if(${GCC_VERSION_OUT} VERSION_LESS "4.9") if(${GCC_VERSION_OUT} VERSION_LESS "4.9")
set(LIBSTDCXX_GCC_VER "48") set(LIBSTDCXX_GCC_VER "48")

@ -251,7 +251,7 @@ add_custom_command(
COMMAND protoc-bin -I=${CMAKE_CURRENT_SOURCE_DIR}/proto/ COMMAND protoc-bin -I=${CMAKE_CURRENT_SOURCE_DIR}/proto/
--cpp_out=dllexport_decl=DFHACK_EXPORT:${CMAKE_CURRENT_SOURCE_DIR}/proto/tmp/ --cpp_out=dllexport_decl=DFHACK_EXPORT:${CMAKE_CURRENT_SOURCE_DIR}/proto/tmp/
${PROJECT_PROTOS} ${PROJECT_PROTOS}
COMMAND ${PERL_EXECUTABLE} ${CMAKE_SOURCE_DIR}/depends/copy-if-different.pl COMMAND ${PERL_EXECUTABLE} ${dfhack_SOURCE_DIR}/depends/copy-if-different.pl
${PROJECT_PROTO_TMP_FILES} ${PROJECT_PROTO_TMP_FILES}
${CMAKE_CURRENT_SOURCE_DIR}/proto/ ${CMAKE_CURRENT_SOURCE_DIR}/proto/
COMMENT "Generating core protobufs" COMMENT "Generating core protobufs"
@ -350,15 +350,15 @@ if(DFHACK_PRERELEASE)
endif() endif()
configure_file(git-describe.cmake.in ${CMAKE_CURRENT_SOURCE_DIR}/git-describe.cmake @ONLY) configure_file(git-describe.cmake.in ${CMAKE_CURRENT_SOURCE_DIR}/git-describe.cmake @ONLY)
if(EXISTS ${CMAKE_SOURCE_DIR}/.git/index AND EXISTS ${CMAKE_SOURCE_DIR}/.git/modules/library/xml/index) if(EXISTS ${dfhack_SOURCE_DIR}/.git/index AND EXISTS ${dfhack_SOURCE_DIR}/.git/modules/library/xml/index)
add_custom_command(OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/include/git-describe.h add_custom_command(OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/include/git-describe.h
COMMAND ${CMAKE_COMMAND} COMMAND ${CMAKE_COMMAND}
-D dfhack_SOURCE_DIR:STRING=${dfhack_SOURCE_DIR} -D dfhack_SOURCE_DIR:STRING=${dfhack_SOURCE_DIR}
-D GIT_EXECUTABLE:STRING=${GIT_EXECUTABLE} -D GIT_EXECUTABLE:STRING=${GIT_EXECUTABLE}
-P ${CMAKE_CURRENT_SOURCE_DIR}/git-describe.cmake -P ${CMAKE_CURRENT_SOURCE_DIR}/git-describe.cmake
COMMENT "Obtaining git commit information" COMMENT "Obtaining git commit information"
DEPENDS ${CMAKE_SOURCE_DIR}/.git/index DEPENDS ${dfhack_SOURCE_DIR}/.git/index
${CMAKE_SOURCE_DIR}/.git/modules/library/xml/index ${dfhack_SOURCE_DIR}/.git/modules/library/xml/index
${CMAKE_CURRENT_SOURCE_DIR}/git-describe.cmake ${CMAKE_CURRENT_SOURCE_DIR}/git-describe.cmake
include/git-describe.h.in include/git-describe.h.in
) )

@ -64,7 +64,7 @@ add_custom_command(
-I=${CMAKE_CURRENT_SOURCE_DIR}/proto/ -I=${CMAKE_CURRENT_SOURCE_DIR}/proto/
--cpp_out=${CMAKE_CURRENT_SOURCE_DIR}/proto/tmp/ --cpp_out=${CMAKE_CURRENT_SOURCE_DIR}/proto/tmp/
${PROJECT_PROTOS} ${PROJECT_PROTOS}
COMMAND ${PERL_EXECUTABLE} ${CMAKE_SOURCE_DIR}/depends/copy-if-different.pl COMMAND ${PERL_EXECUTABLE} ${dfhack_SOURCE_DIR}/depends/copy-if-different.pl
${PROJECT_PROTO_TMP_FILES} ${PROJECT_PROTO_TMP_FILES}
${CMAKE_CURRENT_SOURCE_DIR}/proto/ ${CMAKE_CURRENT_SOURCE_DIR}/proto/
COMMENT "Generating plugin protobufs" COMMENT "Generating plugin protobufs"

@ -94,7 +94,7 @@ macro(dfhack_plugin)
COMMAND protoc-bin -I=${CMAKE_CURRENT_SOURCE_DIR}/proto/ COMMAND protoc-bin -I=${CMAKE_CURRENT_SOURCE_DIR}/proto/
--cpp_out=${CMAKE_CURRENT_SOURCE_DIR}/proto/tmp/ --cpp_out=${CMAKE_CURRENT_SOURCE_DIR}/proto/tmp/
${PLUGIN_PROTOS} ${PLUGIN_PROTOS}
COMMAND ${PERL_EXECUTABLE} ${CMAKE_SOURCE_DIR}/depends/copy-if-different.pl COMMAND ${PERL_EXECUTABLE} ${dfhack_SOURCE_DIR}/depends/copy-if-different.pl
${PLUGIN_PROTO_TMP_FILES} ${PLUGIN_PROTO_TMP_FILES}
${CMAKE_CURRENT_SOURCE_DIR}/proto/ ${CMAKE_CURRENT_SOURCE_DIR}/proto/
COMMENT "Generating plugin ${PLUGIN_NAME} protobufs" COMMENT "Generating plugin ${PLUGIN_NAME} protobufs"