mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Compatibility with older CMake
Copy each file individually, only pass --type parameter for creating zips.
This commit is contained in:
parent
45d944162a
commit
8b2e31620f
|
@ -1059,14 +1059,6 @@ if(TARGET_OS STREQUAL "windows")
|
||||||
list(APPEND CPACK_FILES other/config_directory.bat)
|
list(APPEND CPACK_FILES other/config_directory.bat)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
function(array_add_prefix VAR PREFIX) # ...
|
|
||||||
set(RESULT)
|
|
||||||
foreach(element ${ARGN})
|
|
||||||
list(APPEND RESULT "${PREFIX}${element}")
|
|
||||||
endforeach()
|
|
||||||
set(${VAR} ${RESULT} PARENT_SCOPE)
|
|
||||||
endfunction()
|
|
||||||
|
|
||||||
if(CMAKE_VERSION VERSION_GREATER 3.6 OR CMAKE_VERSION VERSION_EQUAL 3.6)
|
if(CMAKE_VERSION VERSION_GREATER 3.6 OR CMAKE_VERSION VERSION_EQUAL 3.6)
|
||||||
set(EXTRA_ARGS DESTINATION ${CPACK_PACKAGE_FILE_NAME} COMPONENT portable)
|
set(EXTRA_ARGS DESTINATION ${CPACK_PACKAGE_FILE_NAME} COMPONENT portable)
|
||||||
install(TARGETS ${CPACK_TARGETS} ${EXTRA_ARGS})
|
install(TARGETS ${CPACK_TARGETS} ${EXTRA_ARGS})
|
||||||
|
@ -1076,22 +1068,25 @@ else()
|
||||||
message(WARNING "Cannot create CPack targets, CMake version too old. Use CMake 3.6 or newer.")
|
message(WARNING "Cannot create CPack targets, CMake version too old. Use CMake 3.6 or newer.")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
array_add_prefix(PACKAGE_FILES_SOURCE ${PROJECT_SOURCE_DIR}/ ${CPACK_FILES})
|
set(COPY_FILE_COMMANDS)
|
||||||
set(COPY_DIRS_COMMAND)
|
set(COPY_DIR_COMMANDS)
|
||||||
foreach(dir ${CPACK_DIRS})
|
set(COPY_TARGET_COMMANDS)
|
||||||
list(APPEND COPY_DIRS_COMMAND COMMAND cmake -E copy_directory ${PROJECT_SOURCE_DIR}/${dir} ${CPACK_PACKAGE_FILE_NAME}/${dir})
|
foreach(file ${CPACK_FILES})
|
||||||
|
list(APPEND COPY_FILE_COMMANDS COMMAND cmake -E copy ${PROJECT_SOURCE_DIR}/${file} ${CPACK_PACKAGE_FILE_NAME}/)
|
||||||
|
endforeach()
|
||||||
|
foreach(dir ${CPACK_DIRS})
|
||||||
|
list(APPEND COPY_DIR_COMMAND COMMAND cmake -E copy_directory ${PROJECT_SOURCE_DIR}/${dir} ${CPACK_PACKAGE_FILE_NAME}/${dir})
|
||||||
endforeach()
|
endforeach()
|
||||||
set(PACKAGE_TARGETS_EXPRESSIONS)
|
|
||||||
foreach(target ${CPACK_TARGETS})
|
foreach(target ${CPACK_TARGETS})
|
||||||
list(APPEND PACKAGE_TARGETS_EXPRESSIONS $<TARGET_FILE:${target}>)
|
list(APPEND COPY_TARGET_COMMANDS COMMAND cmake -E copy $<TARGET_FILE:${target}> ${CPACK_PACKAGE_FILE_NAME}/)
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
foreach(ext zip tar.gz tar.xz)
|
foreach(ext zip tar.gz tar.xz)
|
||||||
set(TAR_MODE c)
|
set(TAR_MODE c)
|
||||||
set(TAR_FORMAT paxr)
|
set(TAR_EXTRA_ARGS)
|
||||||
string(REPLACE . _ EXT_SLUG ${ext})
|
string(REPLACE . _ EXT_SLUG ${ext})
|
||||||
if(ext STREQUAL zip)
|
if(ext STREQUAL zip)
|
||||||
set(TAR_FORMAT zip)
|
set(TAR_EXTRA_ARGS --format=zip)
|
||||||
elseif(ext STREQUAL tar.gz)
|
elseif(ext STREQUAL tar.gz)
|
||||||
set(TAR_MODE cz)
|
set(TAR_MODE cz)
|
||||||
elseif(ext STREQUAL tar.xz)
|
elseif(ext STREQUAL tar.xz)
|
||||||
|
@ -1099,10 +1094,10 @@ foreach(ext zip tar.gz tar.xz)
|
||||||
endif()
|
endif()
|
||||||
add_custom_command(OUTPUT ${CPACK_PACKAGE_FILE_NAME}.${ext}
|
add_custom_command(OUTPUT ${CPACK_PACKAGE_FILE_NAME}.${ext}
|
||||||
COMMAND cmake -E make_directory ${CPACK_PACKAGE_FILE_NAME}
|
COMMAND cmake -E make_directory ${CPACK_PACKAGE_FILE_NAME}
|
||||||
COMMAND cmake -E copy ${PACKAGE_FILES_SOURCE} ${CPACK_PACKAGE_FILE_NAME}/
|
${COPY_FILE_COMMANDS}
|
||||||
${COPY_DIRS_COMMAND}
|
${COPY_DIR_COMMANDS}
|
||||||
COMMAND cmake -E copy ${PACKAGE_TARGETS_EXPRESSIONS} ${CPACK_PACKAGE_FILE_NAME}/
|
${COPY_TARGET_COMMANDS}
|
||||||
COMMAND cmake -E tar ${TAR_MODE} ${CPACK_PACKAGE_FILE_NAME}.${ext} --format=${TAR_FORMAT} -- ${CPACK_PACKAGE_FILE_NAME}/
|
COMMAND cmake -E tar ${TAR_MODE} ${CPACK_PACKAGE_FILE_NAME}.${ext} ${TAR_EXTRA_ARGS} -- ${CPACK_PACKAGE_FILE_NAME}/
|
||||||
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
|
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
|
||||||
)
|
)
|
||||||
add_custom_target(package_${EXT_SLUG} DEPENDS ${CPACK_PACKAGE_FILE_NAME}.${ext})
|
add_custom_target(package_${EXT_SLUG} DEPENDS ${CPACK_PACKAGE_FILE_NAME}.${ext})
|
||||||
|
|
Loading…
Reference in a new issue