diff --git a/CMakeLists.txt b/CMakeLists.txt index 3cb58479..bbeab4eb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -677,19 +677,7 @@ else() PATTERN "*.a" EXCLUDE) endif() -# Define a custom target to generate the dispatch table files -add_custom_target(GenerateDispatchTables - DEPENDS ${VK_VIDEO_COMMON_LIBS_SOURCE_ROOT}/VkCodecUtils/HelpersDispatchTable.h - ${VK_VIDEO_COMMON_LIBS_SOURCE_ROOT}/VkCodecUtils/HelpersDispatchTable.cpp -) - -# Add the custom command to generate the dispatch tables -macro(generate_dispatch_table out) - add_custom_command(OUTPUT ${out} - COMMAND ${PYTHON_EXECUTABLE} ${SCRIPTS_DIR}/generate-dispatch-table.py ${out} - DEPENDS ${SCRIPTS_DIR}/generate-dispatch-table.py - ) -endmacro() +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/common/libs/VkCodecUtils) if(BUILD_DECODER) add_subdirectory(vk_video_decoder) diff --git a/common/libs/VkCodecUtils/CMakeLists.txt b/common/libs/VkCodecUtils/CMakeLists.txt new file mode 100644 index 00000000..51d2b970 --- /dev/null +++ b/common/libs/VkCodecUtils/CMakeLists.txt @@ -0,0 +1,25 @@ +# Define a custom target to generate the dispatch table files +add_custom_target(GenerateDispatchTables + DEPENDS ${VK_VIDEO_COMMON_LIBS_SOURCE_ROOT}/VkCodecUtils/HelpersDispatchTable.h + ${VK_VIDEO_COMMON_LIBS_SOURCE_ROOT}/VkCodecUtils/HelpersDispatchTable.cpp +) + +# Add the custom command to generate the dispatch tables +macro(generate_dispatch_table out) + add_custom_command(OUTPUT ${out} + COMMAND ${PYTHON_EXECUTABLE} ${SCRIPTS_DIR}/generate-dispatch-table.py ${out} + DEPENDS ${SCRIPTS_DIR}/generate-dispatch-table.py + ) +endmacro() + +set (gen_codec_utils_sources + ${VK_VIDEO_COMMON_LIBS_SOURCE_ROOT}/VkCodecUtils/HelpersDispatchTable.cpp + ${VK_VIDEO_COMMON_LIBS_SOURCE_ROOT}/VkCodecUtils/HelpersDispatchTable.h +) + +generate_dispatch_table(${VK_VIDEO_COMMON_LIBS_SOURCE_ROOT}/VkCodecUtils/HelpersDispatchTable.h) +generate_dispatch_table(${VK_VIDEO_COMMON_LIBS_SOURCE_ROOT}/VkCodecUtils/HelpersDispatchTable.cpp) + + +# Create a static library from the generated file +add_library(GenCodecUtilsLib STATIC ${gen_codec_utils_sources}) \ No newline at end of file diff --git a/vk_video_decoder/CMakeLists.txt b/vk_video_decoder/CMakeLists.txt index 6b33e70f..5a9a7000 100644 --- a/vk_video_decoder/CMakeLists.txt +++ b/vk_video_decoder/CMakeLists.txt @@ -5,12 +5,6 @@ cmake_minimum_required(VERSION 3.0) include(CheckCXXCompilerFlag) - - - - - - add_dependencies(VkVideoUtils generate_helper_files) target_include_directories( VkVideoUtils PUBLIC diff --git a/vk_video_decoder/demos/vk-video-dec/CMakeLists.txt b/vk_video_decoder/demos/vk-video-dec/CMakeLists.txt index 8e53772d..e526c828 100644 --- a/vk_video_decoder/demos/vk-video-dec/CMakeLists.txt +++ b/vk_video_decoder/demos/vk-video-dec/CMakeLists.txt @@ -14,8 +14,6 @@ macro(compile_cuda src) ) endmacro() -generate_dispatch_table(${VK_VIDEO_COMMON_LIBS_SOURCE_ROOT}/VkCodecUtils/HelpersDispatchTable.h) -generate_dispatch_table(${VK_VIDEO_COMMON_LIBS_SOURCE_ROOT}/VkCodecUtils/HelpersDispatchTable.cpp) set(sources Main.cpp @@ -23,8 +21,6 @@ set(sources ${VK_VIDEO_COMMON_LIBS_SOURCE_ROOT}/VkShell/ShellDirect.cpp ${VK_VIDEO_COMMON_LIBS_SOURCE_ROOT}/VkShell/Shell.h ${VK_VIDEO_COMMON_LIBS_SOURCE_ROOT}/VkCodecUtils/Helpers.h - ${VK_VIDEO_COMMON_LIBS_SOURCE_ROOT}/VkCodecUtils/HelpersDispatchTable.cpp - ${VK_VIDEO_COMMON_LIBS_SOURCE_ROOT}/VkCodecUtils/HelpersDispatchTable.h ${VK_VIDEO_COMMON_LIBS_SOURCE_ROOT}/VkCodecUtils/VulkanDeviceContext.cpp ${VK_VIDEO_COMMON_LIBS_SOURCE_ROOT}/VkCodecUtils/VulkanDeviceContext.h ${VK_VIDEO_COMMON_LIBS_SOURCE_ROOT}/VkCodecUtils/VulkanShaderCompiler.cpp @@ -139,6 +135,8 @@ elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Linux") endif() endif() +list(APPEND libraries GenCodecUtilsLib) + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/..) list(APPEND includes PRIVATE ${VK_VIDEO_DECODER_LIBS_INCLUDE_ROOT}) diff --git a/vk_video_encoder/demos/vk-video-enc/CMakeLists.txt b/vk_video_encoder/demos/vk-video-enc/CMakeLists.txt index b3cd43d8..205a471d 100644 --- a/vk_video_encoder/demos/vk-video-enc/CMakeLists.txt +++ b/vk_video_encoder/demos/vk-video-enc/CMakeLists.txt @@ -14,9 +14,6 @@ macro(compile_cuda src) ) endmacro() -generate_dispatch_table(${VK_VIDEO_COMMON_LIBS_SOURCE_ROOT}/VkCodecUtils/HelpersDispatchTable.h) -generate_dispatch_table(${VK_VIDEO_COMMON_LIBS_SOURCE_ROOT}/VkCodecUtils/HelpersDispatchTable.cpp) - set(sources Main.cpp ${VK_VIDEO_ENCODER_LIBS_SOURCE_ROOT}/VkVideoEncoder/VkEncoderConfigH264.cpp @@ -42,8 +39,6 @@ set(sources ${VK_VIDEO_COMMON_LIBS_SOURCE_ROOT}/VkShell/ShellDirect.cpp ${VK_VIDEO_COMMON_LIBS_SOURCE_ROOT}/VkShell/Shell.h ${VK_VIDEO_COMMON_LIBS_SOURCE_ROOT}/VkCodecUtils/Helpers.h - ${VK_VIDEO_COMMON_LIBS_SOURCE_ROOT}/VkCodecUtils/HelpersDispatchTable.cpp - ${VK_VIDEO_COMMON_LIBS_SOURCE_ROOT}/VkCodecUtils/HelpersDispatchTable.h ${VK_VIDEO_COMMON_LIBS_SOURCE_ROOT}/VkCodecUtils/VulkanDeviceContext.cpp ${VK_VIDEO_COMMON_LIBS_SOURCE_ROOT}/VkCodecUtils/VulkanDeviceContext.h ${VK_VIDEO_COMMON_LIBS_SOURCE_ROOT}/VkCodecUtils/VulkanShaderCompiler.cpp @@ -170,6 +165,8 @@ elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Linux") endif() endif() +list(APPEND libraries GenCodecUtilsLib) + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/..) list(APPEND includes PRIVATE ${VK_VIDEO_DECODER_LIBS_INCLUDE_ROOT}) diff --git a/vk_video_encoder/libs/CMakeLists.txt b/vk_video_encoder/libs/CMakeLists.txt index 20a15ee4..ae7344ca 100644 --- a/vk_video_encoder/libs/CMakeLists.txt +++ b/vk_video_encoder/libs/CMakeLists.txt @@ -25,9 +25,6 @@ if(WIN32) add_definitions(-DVK_USE_PLATFORM_WIN32_KHR) endif() -generate_dispatch_table(${VK_VIDEO_COMMON_LIBS_SOURCE_ROOT}/VkCodecUtils/HelpersDispatchTable.h) -generate_dispatch_table(${VK_VIDEO_COMMON_LIBS_SOURCE_ROOT}/VkCodecUtils/HelpersDispatchTable.cpp) - # Even though shaderc.hpp is a headers-only library, adding # a dependency here will force clients of the library to rebuild # when it changes. @@ -53,8 +50,6 @@ set(LIBVKVIDEOENCODER ${VK_VIDEO_COMMON_LIBS_SOURCE_ROOT}/VkCodecUtils/YCbCrConvUtilsCpu.cpp ${VK_VIDEO_COMMON_LIBS_SOURCE_ROOT}/VkCodecUtils/YCbCrConvUtilsCpu.h ${VK_VIDEO_COMMON_LIBS_SOURCE_ROOT}/VkCodecUtils/Helpers.h - ${VK_VIDEO_COMMON_LIBS_SOURCE_ROOT}/VkCodecUtils/HelpersDispatchTable.cpp - ${VK_VIDEO_COMMON_LIBS_SOURCE_ROOT}/VkCodecUtils/HelpersDispatchTable.h ${VK_VIDEO_COMMON_LIBS_SOURCE_ROOT}/VkCodecUtils/VulkanDeviceContext.cpp ${VK_VIDEO_COMMON_LIBS_SOURCE_ROOT}/VkCodecUtils/VulkanDeviceContext.h ${VK_VIDEO_COMMON_LIBS_SOURCE_ROOT}/VkCodecUtils/VulkanDeviceMemoryImpl.h @@ -97,8 +92,7 @@ include_directories(BEFORE ${VULKAN_VIDEO_ENCODER_INCLUDE}) include_directories(BEFORE ${VK_VIDEO_COMMON_LIBS_SOURCE_ROOT}) add_library(${VULKAN_VIDEO_ENCODER_LIB} SHARED ${LIBVKVIDEOENCODER}) -# Ensure the library depends on the generation of these files -add_dependencies(${VULKAN_VIDEO_ENCODER_LIB} GenerateDispatchTables) +target_link_libraries(${VULKAN_VIDEO_ENCODER_LIB} GenCodecUtilsLib) target_include_directories(${VULKAN_VIDEO_ENCODER_LIB} PUBLIC ${VULKAN_VIDEO_ENCODER_INCLUDE} ${VULKAN_VIDEO_ENCODER_INCLUDE}/../NvVideoParser PRIVATE include) target_compile_definitions(${VULKAN_VIDEO_ENCODER_LIB} @@ -121,8 +115,7 @@ if(WIN32) endif() add_library(${VULKAN_VIDEO_ENCODER_STATIC_LIB} STATIC ${LIBVKVIDEOENCODER}) -# Ensure the library depends on the generation of these files -add_dependencies(${VULKAN_VIDEO_ENCODER_STATIC_LIB} GenerateDispatchTables) + target_include_directories(${VULKAN_VIDEO_ENCODER_STATIC_LIB} PUBLIC ${VULKAN_VIDEO_ENCODER_INCLUDE} ${VULKAN_VIDEO_ENCODER_INCLUDE}/../NvVideoParser PRIVATE include) install(TARGETS ${VULKAN_VIDEO_ENCODER_LIB} ${VULKAN_VIDEO_ENCODER_STATIC_LIB} diff --git a/vk_video_encoder/test/vulkan-video-enc/CMakeLists.txt b/vk_video_encoder/test/vulkan-video-enc/CMakeLists.txt index b58f1f00..4d07bd21 100644 --- a/vk_video_encoder/test/vulkan-video-enc/CMakeLists.txt +++ b/vk_video_encoder/test/vulkan-video-enc/CMakeLists.txt @@ -41,6 +41,8 @@ elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Linux") list(APPEND VULKAN_VIDEO_ENC_LIBRARIES PRIVATE -ldl -lrt -lpthread) endif() +list(APPEND VULKAN_VIDEO_ENC_LIBRARIES GenCodecUtilsLib) + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/..) list(APPEND VULKAN_VIDEO_ENC_INCLUDES PRIVATE ${VK_VIDEO_COMMON_LIBS_SOURCE_ROOT})