加入volk 和 wma 后 编译不通过, 先保存代码
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
project(volk_test LANGUAGES C)
|
||||
|
||||
# Include volk from a CMake package config.
|
||||
# CMAKE_PREFIX_PATH or volk_DIR must be set properly.
|
||||
find_package(volk CONFIG REQUIRED)
|
||||
|
||||
add_executable(volk_test main.c)
|
||||
target_link_libraries(volk_test PRIVATE volk::volk_headers)
|
||||
@@ -0,0 +1,54 @@
|
||||
/* Set platform defines at build time for volk to pick up. */
|
||||
#if defined(_WIN32)
|
||||
# define VK_USE_PLATFORM_WIN32_KHR
|
||||
#elif defined(__linux__) || defined(__unix__)
|
||||
# define VK_USE_PLATFORM_XLIB_KHR
|
||||
#elif defined(__APPLE__)
|
||||
# define VK_USE_PLATFORM_MACOS_MVK
|
||||
#else
|
||||
# error "Platform not supported by this example."
|
||||
#endif
|
||||
|
||||
#define VOLK_IMPLEMENTATION
|
||||
#include "volk.h"
|
||||
|
||||
#include "stdio.h"
|
||||
#include "stdlib.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
VkResult r;
|
||||
uint32_t version;
|
||||
void* ptr;
|
||||
|
||||
/* This won't compile if the appropriate Vulkan platform define isn't set. */
|
||||
ptr =
|
||||
#if defined(_WIN32)
|
||||
&vkCreateWin32SurfaceKHR;
|
||||
#elif defined(__linux__) || defined(__unix__)
|
||||
&vkCreateXlibSurfaceKHR;
|
||||
#elif defined(__APPLE__)
|
||||
&vkCreateMacOSSurfaceMVK;
|
||||
#else
|
||||
/* Platform not recogized for testing. */
|
||||
NULL;
|
||||
#endif
|
||||
|
||||
/* Try to initialize volk. This might not work on CI builds, but the
|
||||
* above should have compiled at least. */
|
||||
r = volkInitialize();
|
||||
if (r != VK_SUCCESS) {
|
||||
printf("volkInitialize failed!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
version = volkGetInstanceVersion();
|
||||
printf("Vulkan version %d.%d.%d initialized.\n",
|
||||
VK_VERSION_MAJOR(version),
|
||||
VK_VERSION_MINOR(version),
|
||||
VK_VERSION_PATCH(version));
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
# Compiles the volk sources as part of a user project.
|
||||
# Volk comes with a volk.c for this purpose.
|
||||
# Note that for volk to properly handle platform defines,
|
||||
# those have to be set at build time.
|
||||
# Also note that this way the Vulkan headers must
|
||||
# handled by the user project as well as linking to dl on
|
||||
# non-Windows platforms.
|
||||
# For these reasons it's recommended to use one of
|
||||
# the other ways to include volk (see the other examples).
|
||||
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
project(volk_test LANGUAGES C)
|
||||
|
||||
add_executable(volk_test main.c ../../volk.c)
|
||||
|
||||
# Set include path for volk.h
|
||||
target_include_directories(volk_test PRIVATE ../..)
|
||||
|
||||
# Set suitable platform defines
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL Windows)
|
||||
target_compile_definitions(volk_test PRIVATE VK_USE_PLATFORM_WIN32_KHR)
|
||||
elseif(CMAKE_SYSTEM_NAME STREQUAL Linux)
|
||||
target_compile_definitions(volk_test PRIVATE VK_USE_PLATFORM_XLIB_KHR)
|
||||
elseif(CMAKE_SYSTEM_NAME STREQUAL Darwin)
|
||||
target_compile_definitions(volk_test PRIVATE VK_USE_PLATFORM_MACOS_MVK)
|
||||
endif()
|
||||
|
||||
# Link requires libraries
|
||||
if(NOT WIN32)
|
||||
target_link_libraries(volk_test PRIVATE dl)
|
||||
endif()
|
||||
|
||||
# Get Vulkan dependency
|
||||
find_package(Vulkan QUIET)
|
||||
if(TARGET Vulkan::Vulkan)
|
||||
# Note: We don't use target_link_libraries for Vulkan::Vulkan to avoid a static dependency on libvulkan1
|
||||
target_include_directories(volk_test PRIVATE ${Vulkan_INCLUDE_DIRS})
|
||||
elseif(DEFINED ENV{VULKAN_SDK})
|
||||
target_include_directories(volk_test PRIVATE "$ENV{VULKAN_SDK}/include")
|
||||
endif()
|
||||
@@ -0,0 +1,41 @@
|
||||
#include "volk.h"
|
||||
|
||||
#include "stdio.h"
|
||||
#include "stdlib.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
VkResult r;
|
||||
uint32_t version;
|
||||
void* ptr;
|
||||
|
||||
/* This won't compile if the appropriate Vulkan platform define isn't set. */
|
||||
ptr =
|
||||
#if defined(_WIN32)
|
||||
&vkCreateWin32SurfaceKHR;
|
||||
#elif defined(__linux__) || defined(__unix__)
|
||||
&vkCreateXlibSurfaceKHR;
|
||||
#elif defined(__APPLE__)
|
||||
&vkCreateMacOSSurfaceMVK;
|
||||
#else
|
||||
/* Platform not recogized for testing. */
|
||||
NULL;
|
||||
#endif
|
||||
|
||||
/* Try to initialize volk. This might not work on CI builds, but the
|
||||
* above should have compiled at least. */
|
||||
r = volkInitialize();
|
||||
if (r != VK_SUCCESS) {
|
||||
printf("volkInitialize failed!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
version = volkGetInstanceVersion();
|
||||
printf("Vulkan version %d.%d.%d initialized.\n",
|
||||
VK_VERSION_MAJOR(version),
|
||||
VK_VERSION_MINOR(version),
|
||||
VK_VERSION_PATCH(version));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
# Include the volk target through add_subdirectory.
|
||||
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
project(volk_test LANGUAGES C)
|
||||
|
||||
# Include volk as part of the build tree to make the target known.
|
||||
# The two-argument version of add_subdirectory allows adding non-subdirs.
|
||||
add_subdirectory(../.. volk)
|
||||
|
||||
add_executable(volk_test main.c)
|
||||
target_link_libraries(volk_test PRIVATE volk_headers)
|
||||
@@ -0,0 +1,53 @@
|
||||
/* Set platform defines at build time for volk to pick up. */
|
||||
#if defined(_WIN32)
|
||||
# define VK_USE_PLATFORM_WIN32_KHR
|
||||
#elif defined(__linux__) || defined(__unix__)
|
||||
# define VK_USE_PLATFORM_XLIB_KHR
|
||||
#elif defined(__APPLE__)
|
||||
# define VK_USE_PLATFORM_MACOS_MVK
|
||||
#else
|
||||
# error "Platform not supported by this example."
|
||||
#endif
|
||||
|
||||
#define VOLK_IMPLEMENTATION
|
||||
#include "volk.h"
|
||||
|
||||
#include "stdio.h"
|
||||
#include "stdlib.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
VkResult r;
|
||||
uint32_t version;
|
||||
void* ptr;
|
||||
|
||||
/* This won't compile if the appropriate Vulkan platform define isn't set. */
|
||||
ptr =
|
||||
#if defined(_WIN32)
|
||||
&vkCreateWin32SurfaceKHR;
|
||||
#elif defined(__linux__) || defined(__unix__)
|
||||
&vkCreateXlibSurfaceKHR;
|
||||
#elif defined(__APPLE__)
|
||||
&vkCreateMacOSSurfaceMVK;
|
||||
#else
|
||||
/* Platform not recogized for testing. */
|
||||
NULL;
|
||||
#endif
|
||||
|
||||
/* Try to initialize volk. This might not work on CI builds, but the
|
||||
* above should have compiled at least. */
|
||||
r = volkInitialize();
|
||||
if (r != VK_SUCCESS) {
|
||||
printf("volkInitialize failed!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
version = volkGetInstanceVersion();
|
||||
printf("Vulkan version %d.%d.%d initialized.\n",
|
||||
VK_VERSION_MAJOR(version),
|
||||
VK_VERSION_MINOR(version),
|
||||
VK_VERSION_PATCH(version));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
# Include the volk target through add_subdirectory, use the static lib target.
|
||||
# We must set platform defines.
|
||||
# By default, Vulkan is pulled in as transitive dependency if found.
|
||||
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
project(volk_test LANGUAGES C)
|
||||
|
||||
# Set a suitable platform define to compile volk with.
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL Windows)
|
||||
set(VOLK_STATIC_DEFINES VK_USE_PLATFORM_WIN32_KHR)
|
||||
elseif(CMAKE_SYSTEM_NAME STREQUAL Linux)
|
||||
set(VOLK_STATIC_DEFINES VK_USE_PLATFORM_XLIB_KHR)
|
||||
elseif(CMAKE_SYSTEM_NAME STREQUAL Darwin)
|
||||
set(VOLK_STATIC_DEFINES VK_USE_PLATFORM_MACOS_MVK)
|
||||
endif()
|
||||
|
||||
# Include volk as part of the build tree to make the target known.
|
||||
# The two-argument version of add_subdirectory allows adding non-subdirs.
|
||||
add_subdirectory(../.. volk)
|
||||
|
||||
add_executable(volk_test main.c)
|
||||
target_link_libraries(volk_test PRIVATE volk)
|
||||
@@ -0,0 +1,41 @@
|
||||
#include "volk.h"
|
||||
|
||||
#include "stdio.h"
|
||||
#include "stdlib.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
VkResult r;
|
||||
uint32_t version;
|
||||
void* ptr;
|
||||
|
||||
/* This won't compile if the appropriate Vulkan platform define isn't set. */
|
||||
ptr =
|
||||
#if defined(_WIN32)
|
||||
&vkCreateWin32SurfaceKHR;
|
||||
#elif defined(__linux__) || defined(__unix__)
|
||||
&vkCreateXlibSurfaceKHR;
|
||||
#elif defined(__APPLE__)
|
||||
&vkCreateMacOSSurfaceMVK;
|
||||
#else
|
||||
/* Platform not recogized for testing. */
|
||||
NULL;
|
||||
#endif
|
||||
|
||||
/* Try to initialize volk. This might not work on CI builds, but the
|
||||
* above should have compiled at least. */
|
||||
r = volkInitialize();
|
||||
if (r != VK_SUCCESS) {
|
||||
printf("volkInitialize failed!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
version = volkGetInstanceVersion();
|
||||
printf("Vulkan version %d.%d.%d initialized.\n",
|
||||
VK_VERSION_MAJOR(version),
|
||||
VK_VERSION_MINOR(version),
|
||||
VK_VERSION_PATCH(version));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Vendored
+87
@@ -0,0 +1,87 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
function reset_build {
|
||||
for DIR in "_build" "_installed"
|
||||
do
|
||||
if [ -d $DIR ]; then
|
||||
rm -rf $DIR
|
||||
fi
|
||||
mkdir -p $DIR
|
||||
done
|
||||
}
|
||||
function run_volk_test {
|
||||
for FILE in "./volk_test" "./volk_test.exe" "Debug/volk_test.exe" "Release/volk_test.exe"
|
||||
do
|
||||
if [ -f $FILE ]; then
|
||||
echo "Running test:"
|
||||
$FILE
|
||||
RC=$?
|
||||
break
|
||||
fi
|
||||
done
|
||||
echo "volk_test return code: $RC"
|
||||
}
|
||||
|
||||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||
pushd $SCRIPT_DIR/..
|
||||
|
||||
reset_build
|
||||
pushd _build
|
||||
cmake -DCMAKE_INSTALL_PREFIX=../_installed -DVOLK_INSTALL=ON .. || exit 1
|
||||
cmake --build . --target install || exit 1
|
||||
popd
|
||||
|
||||
echo
|
||||
echo "cmake_using_source_directly =======================================>"
|
||||
echo
|
||||
|
||||
pushd test/cmake_using_source_directly
|
||||
reset_build
|
||||
pushd _build
|
||||
cmake .. || exit 1
|
||||
cmake --build . || exit 1
|
||||
run_volk_test
|
||||
popd
|
||||
popd
|
||||
|
||||
echo
|
||||
echo "cmake_using_subdir_static =======================================>"
|
||||
echo
|
||||
|
||||
pushd test/cmake_using_subdir_static
|
||||
reset_build
|
||||
pushd _build
|
||||
cmake .. || exit 1
|
||||
cmake --build . || exit 1
|
||||
run_volk_test
|
||||
popd
|
||||
popd
|
||||
|
||||
echo
|
||||
echo "cmake_using_subdir_headers =======================================>"
|
||||
echo
|
||||
|
||||
pushd test/cmake_using_subdir_headers
|
||||
reset_build
|
||||
pushd _build
|
||||
cmake .. || exit 1
|
||||
cmake --build . || exit 1
|
||||
run_volk_test
|
||||
popd
|
||||
popd
|
||||
|
||||
echo
|
||||
echo "cmake_using_installed_headers =======================================>"
|
||||
echo
|
||||
|
||||
pushd test/cmake_using_installed_headers
|
||||
reset_build
|
||||
pushd _build
|
||||
cmake -DCMAKE_INSTALL_PREFIX=../../../_installed/lib/cmake .. || exit 1
|
||||
cmake --build . || exit 1
|
||||
run_volk_test
|
||||
popd
|
||||
popd
|
||||
|
||||
popd
|
||||
|
||||
Reference in New Issue
Block a user