Skip to content

Commit

Permalink
Cmake: add copy target for wad files
Browse files Browse the repository at this point in the history
  • Loading branch information
Dasperal committed Oct 29, 2024
1 parent d551475 commit eee1751
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
32 changes: 32 additions & 0 deletions cmake/Utils.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,35 @@
# add_copy_target(<target_name> SOURCE <file> ... [DESTINATION <dir>])
# Copy given files to given dir at build time
function(add_copy_target target_name)
cmake_parse_arguments(PARSE_ARGV 1 "ARG"
"" # List of Options
"DESTINATION" # List of Values
"SOURCE" # List of Lists
)

if(NOT ARG_DESTINATION)
set(ARG_DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
endif()

set(output_dir "${ARG_DESTINATION}")

foreach(source_file ${ARG_SOURCE})
add_custom_command(OUTPUT "${output_dir}/${source_file}"
MAIN_DEPENDENCY "${CMAKE_CURRENT_SOURCE_DIR}/${source_file}"
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${CMAKE_CURRENT_SOURCE_DIR}/${source_file}"
"${output_dir}/${source_file}"
COMMENT "Copying ${output_dir}/${source_file}"
)
list(APPEND destination_files "${output_dir}/${source_file}")
endforeach()

add_custom_target(${target_name} DEPENDS ${destination_files})
set_target_properties(${target_name} PROPERTIES
OUT_FILES "${destination_files}"
)
endfunction()

# configure_empty_git_info(<Template> <Output>)
function(configure_empty_git_info Template Output)
set(Hash "<unknown>")
Expand Down
2 changes: 2 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ target_compile_options(rusdoom PRIVATE
-zastd=c99 # use C99 standard (Cmake fails to add this with target properties)
)

add_dependencies(rusdoom doom-wads)

if(NOT RD_GIT_NO_HASH)
add_dependencies(rusdoom revision_check)
endif()
Expand Down
7 changes: 6 additions & 1 deletion wads/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
install(FILES RUSDOOM.WAD
add_copy_target(doom-wads SOURCE
RUSDOOM.WAD
DESTINATION "${CMAKE_BINARY_DIR}/src"
)

install(FILES $<GENEX_EVAL:$<TARGET_PROPERTY:doom-wads,OUT_FILES>>
DESTINATION .
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
)

0 comments on commit eee1751

Please sign in to comment.