Skip to content

"Could not implement aligned_alloc..." when linking VMA as a CMake target #344

@starcatter

Description

@starcatter

[...]/vk_mem_alloc.h:2791: void* vma_aligned_alloc(size_t, size_t): Assertion 0 && "Could not implement aligned_alloc automatically. Please enable C++17 or later in your compiler or provide custom implementation of macro VMA_SYSTEM_ALIGNED_MALLOC (and VMA_SYSTEM_ALIGNED_FREE if needed) using the API of your system."' failed.

This seems to happen because the CMake project for VMA is setup for C++14, and when using GCC on Linux it needs C++17 for the aligned_alloc() function. The project I'm using VMA for is using C++20, but the setting is not propagated back to VMA's CMake project.

As an example, VulkanMemoryAllocator-Hpp links VMA this way.

My solution to this problem is overriding VMA's C++ standard after including it:


add_subdirectory(vma)

set_target_properties(VulkanMemoryAllocator PROPERTIES CXX_STANDARD 17)

I don't know how desirable it is for the VMA's CMake project to stay at C++14, if it's not a big deal then I suggest simply bumping the standard in the src/CMakeLists.txt file.

Metadata

Metadata

Assignees

No one assigned

    Labels

    compatibilityCompatibility with some platformsnext releaseTo be done as soon as possible

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions