Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
1,185 changes: 12 additions & 1,173 deletions cmake/yup.cmake

Large diffs are not rendered by default.

120 changes: 120 additions & 0 deletions cmake/yup_audio_plugin.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
# ==============================================================================
#
# This file is part of the YUP library.
# Copyright (c) 2024 - [email protected]
#
# YUP is an open source library subject to open-source licensing.
#
# The code included in this file is provided under the terms of the ISC license
# http://www.isc.org/downloads/software-support-policy/isc-license. Permission
# To use, copy, modify, and/or distribute this software for any purpose with or
# without fee is hereby granted provided that the above copyright notice and
# this permission notice appear in all copies.
#
# YUP IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
# EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
# DISCLAIMED.
#
# ==============================================================================

#==============================================================================

function (yup_audio_plugin)
# ==== Fetch options
set (options CONSOLE)
set (one_value_args TARGET_NAME TARGET_IDE_GROUP PLUGIN_CREATE_CLAP PLUGIN_CREATE_STANDALONE)
set (multi_value_args DEFINITIONS MODULES LINK_OPTIONS)

cmake_parse_arguments (YUP_ARG "${options}" "${one_value_args}" "${multi_value_args}" ${ARGN})

set (target_name "${YUP_ARG_TARGET_NAME}")
set (additional_definitions "")
set (additional_options "")
set (additional_libraries "yup_audio_plugin_client")
set (additional_link_options "")

# ==== Find dependencies
include (FetchContent)

if (NOT "${yup_platform}" MATCHES "^(emscripten)$")
_yup_fetch_glfw3()
list (APPEND additional_libraries glfw)

# ==== Fetch plugins SDKS
if (YUP_ARG_PLUGIN_CREATE_CLAP)
FetchContent_Declare (clap GIT_REPOSITORY https://github.com/free-audio/clap.git GIT_TAG main)
FetchContent_MakeAvailable (clap)
set_target_properties (clap-tests PROPERTIES FOLDER "Tests")

_yup_module_setup_plugin_client_clap (${target_name} yup_audio_plugin_client ${YUP_ARG_TARGET_IDE_GROUP} ${YUP_ARG_UNPARSED_ARGUMENTS})

list (APPEND additional_libraries clap ${target_name}_clap)
endif()

if (NOT YUP_ARG_PLUGIN_CREATE_CLAP AND NOT PLUGIN_CREATE_STANDALONE) # AND NOT YUP_ARG_PLUGIN_CREATE_VST3 ...
_yup_message (FATAL_ERROR "Cannot enable audio plugins on WASM targets yet")
endif()
endif()

if (YUP_ARG_PLUGIN_CREATE_STANDALONE)
list (APPEND additional_definitions YUP_AUDIO_PLUGIN_ENABLE_STANDALONE=1)
endif()

# ==== Prepare shared binary
add_library (${target_name} SHARED)
target_compile_features (${target_name} PRIVATE cxx_std_17)

# ==== Per platform configuration
if ("${yup_platform}" MATCHES "^(osx)$")
#if (NOT YUP_ARG_CONSOLE)
# set_target_properties (${target_name} PROPERTIES
# BUNDLE ON
# CXX_EXTENSIONS OFF
# MACOSX_BUNDLE_GUI_IDENTIFIER "org.kunitoki.yup.${target_name}"
# MACOSX_BUNDLE_NAME "${target_name}"
# MACOSX_BUNDLE_VERSION "1.0.0"
# #MACOSX_BUNDLE_ICON_FILE "Icon.icns"
# MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/cmake/platforms/${yup_platform}/Info.plist"
# #RESOURCE "${RESOURCE_FILES}"
# #XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY ""
# XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED OFF
# XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT dwarf
# XCODE_ATTRIBUTE_GCC_INLINES_ARE_PRIVATE_EXTERN ON
# XCODE_ATTRIBUTE_CLANG_LINK_OBJC_RUNTIME OFF)
#endif()

set_target_properties (${target_name} PROPERTIES
XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC OFF)

endif()

if (YUP_ARG_PLUGIN_CREATE_CLAP)
set_target_properties (${target_name} PROPERTIES SUFFIX ".clap")
endif()

if (YUP_ARG_TARGET_IDE_GROUP)
set_target_properties (${target_name} PROPERTIES FOLDER "${YUP_ARG_TARGET_IDE_GROUP}")
endif()

# ==== Definitions and link libraries
target_compile_options (${target_name} PRIVATE
${additional_options}
${YUP_ARG_OPTIONS})

target_compile_definitions (${target_name} PRIVATE
$<IF:$<CONFIG:Debug>,DEBUG=1,NDEBUG=1>
JUCE_GLOBAL_MODULE_SETTINGS_INCLUDED=1
JUCE_STANDALONE_APPLICATION=0
JUCE_MODAL_LOOPS_PERMITTED=1
${additional_definitions}
${YUP_ARG_DEFINITIONS})

target_link_options (${target_name} PRIVATE
${additional_link_options}
${YUP_ARG_LINK_OPTIONS})

target_link_libraries (${target_name} PRIVATE
${additional_libraries}
${YUP_ARG_MODULES})

endfunction()
73 changes: 73 additions & 0 deletions cmake/yup_dependencies.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# ==============================================================================
#
# This file is part of the YUP library.
# Copyright (c) 2024 - [email protected]
#
# YUP is an open source library subject to open-source licensing.
#
# The code included in this file is provided under the terms of the ISC license
# http://www.isc.org/downloads/software-support-policy/isc-license. Permission
# To use, copy, modify, and/or distribute this software for any purpose with or
# without fee is hereby granted provided that the above copyright notice and
# this permission notice appear in all copies.
#
# YUP IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
# EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
# DISCLAIMED.
#
# ==============================================================================

#==============================================================================

function (_yup_fetch_glfw3)
FetchContent_Declare (glfw
GIT_REPOSITORY https://github.com/kunitoki/glfw.git
GIT_TAG dev/android_support
GIT_SHALLOW TRUE
GIT_PROGRESS TRUE)

set (GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE)
set (GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set (GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
set (GLFW_BUILD_WAYLAND OFF CACHE BOOL "" FORCE)
set (GLFW_INSTALL OFF CACHE STRING "" FORCE)

FetchContent_MakeAvailable (glfw)

set_target_properties (glfw PROPERTIES FOLDER "Thirdparty")
endfunction()

#==============================================================================

function (_yup_fetch_perfetto)
FetchContent_Declare (Perfetto
GIT_REPOSITORY https://android.googlesource.com/platform/external/perfetto
GIT_TAG v42.0
GIT_SHALLOW TRUE
GIT_PROGRESS TRUE)

FetchContent_MakeAvailable (Perfetto)

add_library (perfetto STATIC)
target_compile_features (perfetto PUBLIC cxx_std_17)

target_sources (perfetto
PRIVATE "$<BUILD_INTERFACE:${perfetto_SOURCE_DIR}/sdk/perfetto.cc>"
PUBLIC "$<BUILD_INTERFACE:${perfetto_SOURCE_DIR}/sdk/perfetto.h>")

target_include_directories (perfetto PUBLIC
"$<BUILD_INTERFACE:${perfetto_SOURCE_DIR}/sdk>")

set_target_properties (perfetto PROPERTIES
POSITION_INDEPENDENT_CODE TRUE
FOLDER "Thirdparty")

if (WIN32)
target_compile_definitions (perfetto PUBLIC NOMINMAX=1 WIN32_LEAN_AND_MEAN=1)
if (MSVC)
target_compile_options (perfetto PRIVATE /bigobj PUBLIC /Zc:__cplusplus /permissive-)
endif()
endif()

add_library (perfetto::perfetto ALIAS perfetto)
endfunction()
114 changes: 114 additions & 0 deletions cmake/yup_embed_binary.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
# ==============================================================================
#
# This file is part of the YUP library.
# Copyright (c) 2024 - [email protected]
#
# YUP is an open source library subject to open-source licensing.
#
# The code included in this file is provided under the terms of the ISC license
# http://www.isc.org/downloads/software-support-policy/isc-license. Permission
# To use, copy, modify, and/or distribute this software for any purpose with or
# without fee is hereby granted provided that the above copyright notice and
# this permission notice appear in all copies.
#
# YUP IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
# EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
# DISCLAIMED.
#
# ==============================================================================

#==============================================================================

function (yup_add_embedded_binary_resources library_name)
set (options "")
set (one_value_args OUT_DIR HEADER NAMESPACE)
set (multi_value_args RESOURCE_NAMES RESOURCES)

cmake_parse_arguments (YUP_ARG "${options}" "${one_value_args}" "${multi_value_args}" ${ARGN})

set (binary_path "${CMAKE_CURRENT_BINARY_DIR}/${YUP_ARG_OUT_DIR}")
set (binary_header_path "${binary_path}/${YUP_ARG_HEADER}")
set (binary_sources "")

add_library (${library_name} OBJECT)

target_include_directories (${library_name} PUBLIC "${CMAKE_CURRENT_BINARY_DIR}")
target_compile_features (${library_name} PUBLIC cxx_std_17)

set_target_properties (${library_name} PROPERTIES POSITION_INDEPENDENT_CODE ON)

file (WRITE "${binary_header_path}"
"#pragma once\n"
"\n"
"#include <cstddef>\n"
"#include <cstdint>\n"
"\n")

if (DEFINED YUP_ARG_NAMESPACE)
file (APPEND "${binary_header_path}"
"namespace ${YUP_ARG_NAMESPACE}\n"
"{\n"
"\n")
endif()

foreach (resource_name resource IN ZIP_LISTS YUP_ARG_RESOURCE_NAMES YUP_ARG_RESOURCES)
set (full_resource_unit_path "${CMAKE_CURRENT_BINARY_DIR}/${YUP_ARG_OUT_DIR}/${resource_name}.cpp")
set (full_resource_hex_path "${CMAKE_CURRENT_BINARY_DIR}/${YUP_ARG_OUT_DIR}/${resource_name}.inc")

# Add symbol to header
file (APPEND "${binary_header_path}"
"extern const uint8_t ${resource_name}_data[];\n"
"extern const std::size_t ${resource_name}_size;\n"
"\n")

# Write .cpp
file (WRITE "${full_resource_unit_path}"
"#include \"${YUP_ARG_HEADER}\"\n"
"\n"
"#include <cstdint>\n"
"\n")

if (DEFINED YUP_ARG_NAMESPACE)
file (APPEND "${full_resource_unit_path}"
"namespace ${YUP_ARG_NAMESPACE}\n"
"{\n"
"\n")
endif()

file (APPEND "${full_resource_unit_path}"
"const uint8_t ${resource_name}_data[] = \n"
"{\n"
"#include \"${resource_name}.inc\"\n"
"};\n"
"\n"
"const std::size_t ${resource_name}_size = sizeof (${resource_name}_data);\n"
"\n")

if (DEFINED YUP_ARG_NAMESPACE)
file (APPEND "${full_resource_unit_path}"
"\n"
"} // namespace ${YUP_ARG_NAMESPACE}\n")
endif()

_yup_file_to_byte_array (${resource} resource_byte_array)
file (WRITE "${full_resource_hex_path}" "${resource_byte_array}")

list (APPEND binary_sources "${full_resource_unit_path}")
list (APPEND resources_hex_files "${full_resource_hex_path}")
endforeach()

if (DEFINED YUP_ARG_NAMESPACE)
file (APPEND "${binary_header_path}"
"} // namespace ${YUP_ARG_NAMESPACE}\n")
endif()

target_sources (${library_name}
PUBLIC "${binary_header_path}"
PRIVATE "${binary_sources}")

target_include_directories (${library_name} PUBLIC "${binary_path}")

add_custom_target ("${library_name}_content" DEPENDS "${resources_hex_files}")
add_dependencies (${library_name} "${library_name}_content")

endfunction()
Loading
Loading