Fix some stuff in Cmake

This commit is contained in:
Gregory Wells
2025-06-10 14:59:18 -04:00
parent 292187b494
commit 92ba48005f
7 changed files with 41 additions and 39 deletions

View File

@@ -6,18 +6,17 @@ file(GLOB_RECURSE SOURCE_FILES CONFIGURE_DEPENDS
"src/*.c" "src/*.h"
)
if(APPLE)
file(GLOB_RECURSE METAL_FILES CONFIGURE_DEPENDS
"src/*.m")
file(GLOB_RECURSE METAL_FILES CONFIGURE_DEPENDS "src/*.m")
endif()
add_library(Gryphn ${SOURCE_FILES} ${METAL_FILES})
target_include_directories(Gryphn PUBLIC ${CMAKE_SOURCE_DIR}/gryphn/src/)
target_include_directories(Gryphn PUBLIC ${CMAKE_SOURCE_DIR}/gryphn/include/)
target_include_directories(Gryphn PUBLIC ${CMAKE_SOURCE_DIR}/gryphn/src/utils)
target_include_directories(Gryphn PUBLIC ${CMAKE_SOURCE_DIR}/gryphn/src/utils/utils)
target_include_directories(Gryphn PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src/)
target_include_directories(Gryphn PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include/)
target_include_directories(Gryphn PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src/utils)
target_include_directories(Gryphn PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src/utils/utils)
add_compile_definitions(GN_REVEAL_IMPL)
make_directory(${CMAKE_BINARY_DIR}/gryphn/rendering_apis/)
if(WIN32)
add_compile_definitions(GN_PLATFORM_WIN32)
# add_subdirectory(rendering_api/dirctx/)
@@ -41,7 +40,6 @@ endif()
if(UNIX AND NOT APPLE)
add_compile_definitions(GN_PLATFORM_LINUX)
add_subdirectory(rendering_api/vulkan/)
target_include_directories(Gryphn PUBLIC ${CMAKE_SOURCE_DIR/Gryphn/rendering_api/metal/depends/metal-cpp/)
endif()
target_link_libraries(Gryphn)

View File

@@ -13,20 +13,17 @@ if (APPLE)
)
endif()
find_package(Vulkan REQUIRED)
add_library(GryphnVulkanImpl SHARED ${SOURCE_FILES} ${METAL_FILES})
target_include_directories(GryphnVulkanImpl PUBLIC
${CMAKE_SOURCE_DIR}/gryphn/include/
${CMAKE_SOURCE_DIR}/gryphn/src/
${CMAKE_SOURCE_DIR}/gryphn/src/utils/
${Vulkan_INCLUDE_DIRS}
${CMAKE_CURRENT_SOURCE_DIR}/../../include/
${CMAKE_CURRENT_SOURCE_DIR}/../../src/
${CMAKE_CURRENT_SOURCE_DIR}/../../src/utils/
src/
/Applications/vulkansdk/macOS/include/
)
add_compile_definitions(GN_REVEAL_IMPL)
add_library(libvulkan SHARED IMPORTED)
set_target_properties(libvulkan PROPERTIES IMPORTED_LOCATION /Applications/vulkansdk/macOS/lib/libvulkan.dylib)
target_link_libraries(GryphnVulkanImpl libvulkan)
target_link_libraries(GryphnVulkanImpl ${Vulkan_LIBRARY})
if(WIN32)
add_compile_definitions(GN_PLATFORM_WIN32)
@@ -48,7 +45,15 @@ if(UNIX AND NOT APPLE)
add_compile_definitions(GN_PLATFORM_LINUX)
endif()
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/gryphn/rendering_apis)
if (APPLE)
add_custom_command(TARGET GryphnVulkanImpl POST_BUILD
COMMAND mv libGryphnVulkanImpl.dylib ../../rendering_apis/GryphnVulkanImpl.dylib
COMMAND mv libGryphnVulkanImpl.dylib
${CMAKE_BINARY_DIR}/gryphn/rendering_apis/GryphnVulkanImpl.dylib
)
endif()
if (UNIX AND NOT APPLE)
add_custom_command(TARGET GryphnVulkanImpl POST_BUILD
COMMAND mv libGryphnVulkanImpl.so
${CMAKE_BINARY_DIR}/gryphn/rendering_apis/GryphnVulkanImpl.so
)
endif()

View File

@@ -56,23 +56,20 @@ static VKAPI_ATTR VkBool32 VKAPI_CALL vk_debuggerDebugCallback(
gnReturnCode gnCreateInstanceFn(gnInstanceHandle instance, gnInstanceInfo instanceInfo) {
instance->instance = malloc(sizeof(gnPlatformInstance));
#ifdef GN_PLATFORM_LINUX
#ifdef GN_WINDOW_X11
gnBool isX11 = gnFalse;
uint32_t extensionCount = 3;
const char* extensions[] = {
"VK_KHR_xlib_surface",
"VK_KHR_surface",
VK_EXT_DEBUG_UTILS_EXTENSION_NAME
};
#endif
#ifdef GN_WINFDOW_WAYLAND
uint32_t extensionCount = 3;
const char* extensions[] = {
"VK_KHR_wayland_surface",
"VK_KHR_surface",
VK_EXT_DEBUG_UTILS_EXTENSION_NAME
};
#endif
const char* extensions[3];
if (isX11) {
extensions[0] = "VK_KHR_xlib_surface";
extensions[1] = "VK_KHR_surface";
extensions[2] = VK_EXT_DEBUG_UTILS_EXTENSION_NAME;
} else {
extensions[0] = "VK_KHR_wayland_surface";
extensions[1] = "VK_KHR_surface";
extensions[2] = VK_EXT_DEBUG_UTILS_EXTENSION_NAME;
}
#endif
#ifdef GN_PLATFORM_WINDOWS
uint32_t extensionCount = 3;

View File

@@ -50,7 +50,7 @@ gnPhysicalDevice* gnGetPhysicalDevicesFn(gnInstanceHandle instance, uint32_t* de
}
gnBool gnQueueCanPresentToSurfaceFn(const struct gnPhysicalDevice_t device, uint32_t queueIndex, gnWindowSurfaceHandle windowSurface) {
VkBool32 supportsPresent = false;
VkBool32 supportsPresent = VK_FALSE;
vkGetPhysicalDeviceSurfaceSupportKHR(device.physicalDevice->device, queueIndex, windowSurface->windowSurface->surface, &supportsPresent);
if (supportsPresent)
return gnTrue;

View File

@@ -12,7 +12,7 @@ void gnBufferData(gnBufferHandle buffer, size_t dataSize, void* data) {
buffer->device->deviceFunctions->_gnBufferData(buffer, dataSize, data);
}
void* gnMapBuffer(gnBufferHandle buffer) {
if (buffer->info.type == GN_STATIC_DRAW) {
if (buffer->info.usage == GN_STATIC_DRAW) {
gnDebuggerSetErrorMessage(buffer->device->instance->debugger, (gnMessageData){
.message = gnCreateString("Cannot map static draw buffers")
});

View File

@@ -3,6 +3,7 @@
#include <platform/gryphn_platform_include.h>
#include "gryphn_dynamic_library.h"
// #include <dlfcn.h>
#include "stdbool.h"
#include "stdio.h"
gnBool gnIsAPISupported(gnRenderingAPI api) {

View File

@@ -1,4 +1,5 @@
#pragma once
#include "stdint.h"
#include "utils/gryphn_string.h"
#include "core/gryphn_handles.h"