From 6e5e9463d2f9673637aa7622368678fab6e74e23 Mon Sep 17 00:00:00 2001 From: Mike Stroyan Date: Fri, 16 Sep 2016 09:45:14 -0600 Subject: [PATCH] build: Fix parallel build of layers Change layer dependencies to prevent collisions of scripts creating headers. Use dependency on one custom target for each group of headers built by a custom command. The layers json targets need to depend on the layers targets. They expect to copy into a directory created by those targets. Make dependency of vk_safe_struct.cpp indirect through generate_vk_layer_helpers. That will wait for a single build of the generated files. --- layers/CMakeLists.txt | 39 +++++++++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/layers/CMakeLists.txt b/layers/CMakeLists.txt index 456844f..a5f38f0 100644 --- a/layers/CMakeLists.txt +++ b/layers/CMakeLists.txt @@ -40,6 +40,7 @@ if (WIN32) COMMAND copy ${src_json} ${dst_json} VERBATIM ) + add_dependencies(${config_file}-json ${config_file}) endforeach(config_file) else() foreach (config_file ${LAYER_JSON_FILES}) @@ -49,6 +50,7 @@ if (WIN32) COMMAND copy ${src_json} ${dst_json} VERBATIM ) + add_dependencies(${config_file}-json ${config_file}) endforeach(config_file) endif() endif() @@ -60,6 +62,7 @@ else() COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/linux/${config_file}.json VERBATIM ) + add_dependencies(${config_file}-json ${config_file}) endforeach(config_file) endif() endif() @@ -72,14 +75,14 @@ if (WIN32) ) add_library(VkLayer_${target} SHARED ${ARGN} VkLayer_${target}.def) target_link_Libraries(VkLayer_${target} VkLayer_utils) - add_dependencies(VkLayer_${target} generate_vk_layer_helpers) + add_dependencies(VkLayer_${target} generate_dispatch_table_helper generate_vk_layer_helpers generate_enum_string_helper VkLayer_utils) set_target_properties(VkLayer_${target} PROPERTIES LINK_FLAGS "/DEF:${CMAKE_CURRENT_BINARY_DIR}/VkLayer_${target}.def") endmacro() else() macro(add_vk_layer target) add_library(VkLayer_${target} SHARED ${ARGN}) target_link_Libraries(VkLayer_${target} VkLayer_utils) - add_dependencies(VkLayer_${target} generate_vk_layer_helpers) + add_dependencies(VkLayer_${target} generate_dispatch_table_helper generate_vk_layer_helpers generate_enum_string_helper VkLayer_utils) set_target_properties(VkLayer_${target} PROPERTIES LINK_FLAGS "-Wl,-Bsymbolic") install(TARGETS VkLayer_${target} DESTINATION ${PROJECT_BINARY_DIR}/install_staging) endmacro() @@ -117,12 +120,40 @@ run_vk_helper(gen_struct_wrappers vk_struct_wrappers.h vk_struct_wrappers.cpp vk_safe_struct.h +# Don't list vk_safe_struct.cpp as OUTPUT to avoid duplicate builds. +# If listed here use of it for add_library will cause it to be created +# independently of custom target generate_vk_layer_helpers . +# That breaks parallel builds. +# vk_safe_struct.cpp +) + +# Let gen_struct_wrappers really create vk_safe_struct.cpp +add_custom_command(OUTPUT vk_safe_struct.cpp + COMMAND echo defer making vk_safe_struct.cpp +) + +set_source_files_properties( + vk_struct_string_helper.h + vk_struct_string_helper_cpp.h + vk_struct_string_helper_no_addr.h + vk_struct_string_helper_no_addr_cpp.h + vk_struct_size_helper.h + vk_struct_size_helper.c + vk_struct_wrappers.h + vk_struct_wrappers.cpp + vk_safe_struct.h vk_safe_struct.cpp + PROPERTIES GENERATED TRUE) + +add_custom_target(generate_enum_string_helper DEPENDS + vk_enum_string_helper.h ) -add_custom_target(generate_vk_layer_helpers DEPENDS +add_custom_target(generate_dispatch_table_helper DEPENDS vk_dispatch_table_helper.h - vk_enum_string_helper.h +) + +add_custom_target(generate_vk_layer_helpers DEPENDS vk_struct_string_helper.h vk_struct_string_helper_no_addr.h vk_struct_string_helper_cpp.h -- 2.7.4