-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[cmake] add basic packaging support. for testing reasons, tz_io_image…
…_test can now be built as a package via ninja tz_io_image_test.package. it works pretty well!
- Loading branch information
Showing
4 changed files
with
53 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
set(TOPAZ_PACKAGE_BASE_DIR "${PROJECT_BINARY_DIR}/packages") | ||
function(topaz_define_package) | ||
cmake_parse_arguments( | ||
TOPAZ_DEFINE_PACKAGE | ||
"" | ||
"TARGET" | ||
"" | ||
${ARGN} | ||
) | ||
|
||
set(dependency_list "") | ||
set(package_dir ${TOPAZ_PACKAGE_BASE_DIR}/${TOPAZ_DEFINE_PACKAGE_TARGET}.package) | ||
|
||
get_target_property(bundle_deps ${TOPAZ_DEFINE_PACKAGE_TARGET} TOPAZ_BUNDLE_DEPENDENCIES) | ||
# Create commands to copy all the bundled files to the package dir. | ||
if(NOT ${bundle_deps} STREQUAL "bundle_deps-NOTFOUND") | ||
foreach(bundle_file IN LISTS bundle_deps) | ||
set(bundle_file_path $<TARGET_FILE_DIR:${TOPAZ_DEFINE_PACKAGE_TARGET}>/${bundle_file}) | ||
add_custom_command( | ||
OUTPUT "${package_dir}/${bundle_file}" | ||
DEPENDS ${bundle_file_path} | ||
COMMAND ${CMAKE_COMMAND} -E copy "${bundle_file_path}" "${package_dir}/${bundle_file}" | ||
COMMENT "Copying bundled file ${bundle_file} into ${TOPAZ_DEFINE_PACKAGE_TARGET}.package" | ||
) | ||
list(APPEND dependency_list "${package_dir}/${bundle_file}") | ||
endforeach() | ||
endif() | ||
# Make tar.package which copies the bundled files | ||
add_custom_target(${TOPAZ_DEFINE_PACKAGE_TARGET}.package | ||
ALL | ||
COMMAND ${CMAKE_COMMAND} -E make_directory ${package_dir} | ||
DEPENDS ${TOPAZ_DEFINE_PACKAGE_TARGET} ${dependency_list} | ||
) | ||
# And also to copy over the executable/library. | ||
add_custom_command(TARGET ${TOPAZ_DEFINE_PACKAGE_TARGET}.package | ||
POST_BUILD | ||
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:${TOPAZ_DEFINE_PACKAGE_TARGET}> "${package_dir}" | ||
COMMAND_EXPAND_LISTS | ||
) | ||
# And finally, all dll dependencies | ||
# why use -t here when its not used anywhere else? | ||
# well TARGET_RUNTIME_DLLS could may well yield an empty list. copy without -t is malformed if you try to copy 0 things, but with -t its much better. | ||
add_custom_command(TARGET ${TOPAZ_DEFINE_PACKAGE_TARGET}.package | ||
POST_BUILD | ||
COMMAND ${CMAKE_COMMAND} -E copy -t "${package_dir}" $<TARGET_RUNTIME_DLLS:${TOPAZ_DEFINE_PACKAGE_TARGET}> | ||
COMMAND_EXPAND_LISTS | ||
) | ||
endfunction() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters