90d013695d
- Replace window class with cbt::opengl::context - Add buffer resource (VBO, EBO, UBO, SSBO) with move semantics - Add texture resource with format/type enums and filtering - Add descriptor_set for Vulkan-style resource binding - All resources use RAII with proper cleanup
106 lines
3.4 KiB
CMake
106 lines
3.4 KiB
CMake
# ==============================================================================
|
|
# Find kfr
|
|
# ==============================================================================
|
|
# This module fetches the KFR DSP library.
|
|
#
|
|
# Targets provided:
|
|
# kfr::kfr - The kfr library target
|
|
#
|
|
# Variables set:
|
|
# kfr_FOUND - TRUE if kfr is available
|
|
# kfr_LIBRARIES - The kfr library target (kfr::kfr)
|
|
# kfr_INCLUDE_DIR - Include directories for kfr
|
|
# kfr_VERSION - Version of kfr (if available)
|
|
# ==============================================================================
|
|
|
|
if (DEFINED _FINDKFR_INCLUDED)
|
|
return()
|
|
endif()
|
|
set(_FINDKFR_INCLUDED TRUE)
|
|
|
|
# Use the version passed to find_package(), or default to 7.0.1
|
|
if (DEFINED kfr_FIND_VERSION AND NOT kfr_FIND_VERSION STREQUAL "")
|
|
set(KFR_VERSION "${kfr_FIND_VERSION}")
|
|
else()
|
|
set(KFR_VERSION "7.0.1")
|
|
endif()
|
|
|
|
message(STATUS "Fetching kfr ${KFR_VERSION}")
|
|
|
|
include(FetchContent)
|
|
|
|
find_program(GIT_EXECUTABLE git)
|
|
if (GIT_EXECUTABLE)
|
|
set(KFR_FETCH_METHOD "GIT")
|
|
else()
|
|
set(KFR_FETCH_METHOD "ZIP")
|
|
endif()
|
|
|
|
# Disable tests, examples, and other unnecessary components
|
|
set(ENABLE_TESTS OFF CACHE BOOL "" FORCE)
|
|
set(ENABLE_EXAMPLES OFF CACHE BOOL "" FORCE)
|
|
set(KFR_ENABLE_ASMTEST OFF CACHE BOOL "" FORCE)
|
|
set(KFR_ENABLE_CAPI_BUILD OFF CACHE BOOL "" FORCE)
|
|
set(KFR_INSTALL_HEADERS OFF CACHE BOOL "" FORCE)
|
|
set(KFR_INSTALL_LIBRARIES OFF CACHE BOOL "" FORCE)
|
|
|
|
# Create dummy uninstall target to prevent KFR from creating one
|
|
if (NOT TARGET uninstall)
|
|
add_custom_target(uninstall)
|
|
endif()
|
|
|
|
if (KFR_FETCH_METHOD STREQUAL "GIT")
|
|
FetchContent_Declare(
|
|
kfr
|
|
GIT_REPOSITORY https://github.com/kfrlib/kfr.git
|
|
GIT_TAG ${KFR_VERSION}
|
|
)
|
|
else()
|
|
FetchContent_Declare(
|
|
kfr
|
|
URL https://github.com/kfrlib/kfr/archive/refs/tags/${KFR_VERSION}.zip
|
|
)
|
|
endif()
|
|
|
|
FetchContent_MakeAvailable(kfr)
|
|
|
|
# Fix KFR's redundant standard library linking
|
|
# KFR explicitly links stdc++/pthread/m, but these are already linked by the compiler
|
|
# On Windows with Clang: these Unix libraries don't exist
|
|
# On macOS: stdc++ becomes c++ which duplicates the automatic libc++ linking
|
|
if (TARGET kfr)
|
|
get_target_property(_kfr_link_libs kfr INTERFACE_LINK_LIBRARIES)
|
|
if (_kfr_link_libs)
|
|
list(REMOVE_ITEM _kfr_link_libs "stdc++" "c++" "pthread" "m")
|
|
set_target_properties(kfr PROPERTIES INTERFACE_LINK_LIBRARIES "${_kfr_link_libs}")
|
|
endif()
|
|
endif()
|
|
|
|
# Remove KFR's uninstall target
|
|
if (TARGET uninstall)
|
|
set_target_properties(uninstall PROPERTIES EXCLUDE_FROM_ALL TRUE)
|
|
endif()
|
|
|
|
if (NOT TARGET kfr::kfr)
|
|
if (TARGET kfr)
|
|
add_library(kfr::kfr ALIAS kfr)
|
|
else()
|
|
message(FATAL_ERROR "Could not fetch kfr; no target kfr or kfr::kfr available")
|
|
endif()
|
|
endif()
|
|
|
|
set(kfr_FOUND TRUE)
|
|
set(kfr_LIBRARIES kfr::kfr)
|
|
set(kfr_VERSION "${KFR_VERSION}")
|
|
get_target_property(_kfr_inc kfr::kfr INTERFACE_INCLUDE_DIRECTORIES)
|
|
set(kfr_INCLUDE_DIR "${_kfr_inc}")
|
|
|
|
# Mark kfr includes as SYSTEM to suppress warnings from its headers
|
|
if (_kfr_inc AND TARGET kfr)
|
|
set_target_properties(kfr PROPERTIES
|
|
INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${_kfr_inc}"
|
|
)
|
|
endif()
|
|
|
|
set(KFR_LICENSE_FILE "${kfr_SOURCE_DIR}/LICENSE.txt" CACHE FILEPATH "Path to KFR license file")
|