mirror of
https://gitee.com/openharmony/third_party_vulkan-loader
synced 2024-11-23 07:10:23 +00:00
build: Use Vulkan::Headers target to determine include paths
Change-Id: I73b9b2bfd5e33a9da861937510029cb71f3b2648
This commit is contained in:
parent
210ca44cd2
commit
7c4909fbb3
@ -27,14 +27,24 @@ add_definitions(-DAPI_NAME="Vulkan")
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
||||
find_package(PythonInterp 3 REQUIRED)
|
||||
|
||||
find_package(VulkanHeaders)
|
||||
if(NOT ${VulkanHeaders_FOUND})
|
||||
message(FATAL_ERROR "Could not find Vulkan headers path. This can be fixed by setting VULKAN_HEADERS_INSTALL_DIR to an "
|
||||
"installation of the Vulkan-Headers repository.")
|
||||
endif()
|
||||
if(NOT ${VulkanRegistry_FOUND})
|
||||
message(FATAL_ERROR "Could not find Vulkan registry path. This can be fixed by setting VULKAN_HEADERS_INSTALL_DIR to an "
|
||||
"installation of the Vulkan-Headers repository.")
|
||||
if (TARGET Vulkan::Headers)
|
||||
message(STATUS "Using Vulkan headers from Vulkan::Headers target")
|
||||
get_target_property(VulkanRegistry_DIR Vulkan::Registry INTERFACE_INCLUDE_DIRECTORIES)
|
||||
else()
|
||||
find_package(VulkanHeaders)
|
||||
if(NOT ${VulkanHeaders_FOUND})
|
||||
message(FATAL_ERROR "Could not find Vulkan headers path. This can be fixed by setting VULKAN_HEADERS_INSTALL_DIR to an "
|
||||
"installation of the Vulkan-Headers repository.")
|
||||
endif()
|
||||
if(NOT ${VulkanRegistry_FOUND})
|
||||
message(FATAL_ERROR "Could not find Vulkan registry path. This can be fixed by setting VULKAN_HEADERS_INSTALL_DIR to an "
|
||||
"installation of the Vulkan-Headers repository.")
|
||||
endif()
|
||||
|
||||
# set up the Vulkan::Headers target for consistency
|
||||
add_library(vulkan-headers INTERFACE)
|
||||
target_include_directories(vulkan-headers INTERFACE "${VulkanHeaders_INCLUDE_DIRS}")
|
||||
add_library(Vulkan::Headers ALIAS vulkan-headers)
|
||||
endif()
|
||||
|
||||
option(USE_CCACHE "Use ccache" OFF)
|
||||
@ -112,9 +122,6 @@ else()
|
||||
option(BUILD_TESTS "Build Tests" OFF)
|
||||
endif()
|
||||
|
||||
# Add location of Vulkan header files to include search path
|
||||
include_directories(${VulkanHeaders_INCLUDE_DIRS})
|
||||
|
||||
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
|
||||
set(COMMON_COMPILE_FLAGS "-Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wno-stringop-truncation -Wno-stringop-overflow")
|
||||
set(COMMON_COMPILE_FLAGS "${COMMON_COMPILE_FLAGS} -fno-strict-aliasing -fno-builtin-memcmp")
|
||||
|
@ -128,6 +128,7 @@ if(WIN32)
|
||||
|
||||
add_executable(asm_offset asm_offset.c)
|
||||
add_dependencies(asm_offset generate_helper_files loader_gen_files)
|
||||
target_link_libraries(asm_offset Vulkan::Headers)
|
||||
add_custom_command(OUTPUT gen_defines.asm DEPENDS asm_offset COMMAND asm_offset MASM)
|
||||
add_custom_target(loader_asm_gen_files DEPENDS gen_defines.asm)
|
||||
set_target_properties(loader_asm_gen_files PROPERTIES FOLDER ${LOADER_HELPER_FOLDER})
|
||||
@ -165,6 +166,7 @@ else(UNIX AND NOT APPLE) # i.e.: Linux
|
||||
set(OPT_LOADER_SRCS ${OPT_LOADER_SRCS} unknown_ext_chain_gas.asm)
|
||||
add_executable(asm_offset asm_offset.c)
|
||||
add_dependencies(asm_offset generate_helper_files loader_gen_files)
|
||||
target_link_libraries(asm_offset Vulkan::Headers)
|
||||
add_custom_command(OUTPUT gen_defines.asm DEPENDS asm_offset COMMAND asm_offset GAS)
|
||||
add_custom_target(loader_asm_gen_files DEPENDS gen_defines.asm)
|
||||
else()
|
||||
@ -184,11 +186,13 @@ if(WIN32)
|
||||
add_dependencies(loader-norm generate_helper_files loader_gen_files)
|
||||
target_compile_options(loader-norm PUBLIC "$<$<CONFIG:DEBUG>:${LOCAL_C_FLAGS_DBG}>")
|
||||
target_compile_options(loader-norm PUBLIC ${MSVC_LOADER_COMPILE_OPTIONS})
|
||||
target_include_directories(loader-norm PRIVATE "$<TARGET_PROPERTY:Vulkan::Headers,INTERFACE_INCLUDE_DIRECTORIES>")
|
||||
|
||||
add_library(loader-opt OBJECT ${OPT_LOADER_SRCS})
|
||||
add_dependencies(loader-opt generate_helper_files loader_gen_files loader_asm_gen_files)
|
||||
target_compile_options(loader-opt PUBLIC "$<$<CONFIG:DEBUG>:${LOCAL_C_FLAGS_REL}>")
|
||||
target_compile_options(loader-opt PUBLIC ${MSVC_LOADER_COMPILE_OPTIONS})
|
||||
target_include_directories(loader-opt PRIVATE "$<TARGET_PROPERTY:Vulkan::Headers,INTERFACE_INCLUDE_DIRECTORIES>")
|
||||
|
||||
if(NOT ENABLE_STATIC_LOADER)
|
||||
target_compile_definitions(loader-norm PUBLIC LOADER_DYNAMIC_LIB)
|
||||
@ -206,6 +210,7 @@ if(WIN32)
|
||||
"/ignore:4098"
|
||||
OUTPUT_NAME
|
||||
vulkan-1)
|
||||
target_link_libraries(vulkan Vulkan::Headers)
|
||||
else()
|
||||
add_library(vulkan
|
||||
STATIC
|
||||
@ -243,6 +248,7 @@ else()
|
||||
VERSION
|
||||
"${VulkanHeaders_VERSION_MAJOR}.${VulkanHeaders_VERSION_MINOR}.${VulkanHeaders_VERSION_PATCH}")
|
||||
target_link_libraries(vulkan -ldl -lpthread -lm)
|
||||
target_link_libraries(vulkan Vulkan::Headers)
|
||||
|
||||
if(APPLE)
|
||||
find_library(COREFOUNDATION_LIBRARY NAMES CoreFoundation)
|
||||
@ -270,6 +276,7 @@ else()
|
||||
add_dependencies(vulkan-framework generate_helper_files loader_gen_files loader_asm_gen_files)
|
||||
target_compile_definitions(vulkan-framework PUBLIC -DLOADER_DYNAMIC_LIB)
|
||||
target_link_libraries(vulkan-framework -ldl -lpthread -lm "-framework CoreFoundation")
|
||||
target_link_libraries(vulkan-framework Vulkan::Headers)
|
||||
|
||||
# The FRAMEWORK_VERSION needs to be "A" here so that Xcode code-signing works when a user adds their framework to an Xcode
|
||||
# project and does "Sign on Copy". It would have been nicer to use "1" to denote Vulkan 1. Although Apple docs say that a
|
||||
@ -307,6 +314,9 @@ else()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
target_link_libraries(vulkan Vulkan::Headers)
|
||||
add_library(Vulkan::Vulkan ALIAS vulkan)
|
||||
|
||||
install(TARGETS vulkan
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
|
@ -27,24 +27,26 @@ if(WIN32)
|
||||
add_library(VkLayer_${target} SHARED ${ARGN} VkLayer_${target}.def)
|
||||
target_compile_options(VkLayer_${target} PUBLIC ${MSVC_LOADER_COMPILE_OPTIONS})
|
||||
add_dependencies(VkLayer_${target} generate_helper_files)
|
||||
target_link_libraries(VkLayer_${target} Vulkan::Headers)
|
||||
endmacro()
|
||||
elseif(APPLE)
|
||||
macro(AddVkLayer target)
|
||||
add_library(VkLayer_${target} SHARED ${ARGN})
|
||||
add_dependencies(VkLayer_${target} generate_helper_files)
|
||||
set_target_properties(VkLayer_${target} PROPERTIES LINK_FLAGS "-Wl")
|
||||
target_link_libraries(VkLayer_${target} Vulkan::Headers)
|
||||
endmacro()
|
||||
else(UNIX AND NOT APPLE) # i.e.: Linux
|
||||
macro(AddVkLayer target)
|
||||
add_library(VkLayer_${target} SHARED ${ARGN})
|
||||
add_dependencies(VkLayer_${target} generate_helper_files)
|
||||
set_target_properties(VkLayer_${target} PROPERTIES LINK_FLAGS "-Wl,-Bsymbolic")
|
||||
target_link_libraries(VkLayer_${target} Vulkan::Headers)
|
||||
endmacro()
|
||||
endif()
|
||||
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../loader
|
||||
${PROJECT_SOURCE_DIR}/Vulkan-Headers/include
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${PROJECT_BINARY_DIR}
|
||||
${CMAKE_BINARY_DIR})
|
||||
|
Loading…
Reference in New Issue
Block a user