Skip to content

Commit

Permalink
[juce] add port for JUCE (microsoft#35439)
Browse files Browse the repository at this point in the history
* [juce] add port for JUCE

* [juce] install linux dependencies in ci

* [juce] fix tool installation and cleaning

* [juce] fix freetype includes for juce graphics

* [juce] fix freetype includes for juceaide

* [juce] simplify the freetype find check

* [juce] use find_path in addition for freetype

* [juce] allow setting freetype usage for juceaide

* [juce] forward freetype setting + guard with option

* [juce] do not use freetype for console apps

* [juce] freetype is needed for console apps on Linux

* [juce] link freetype on Linux for juce_build_tools

* [juce] forward-vcpkg-toolchain for Builder

* [juce] fix linux dependencies + forward vcpkg args

* [juce] fix installation of juce tools and juce extra tools

* [juce] use jack2 only on Linux

* [juce] add docs for targets and descriptions

* [juce] fix installation path references in CMake

* [juce] do not move Cmake files + fix tool install dir

* [juce] remove libwebkit2gtk-4.0-dev from ci

* [juce] add ONLY_STATIC_LIBRARY to the port for windows

* [juce] fix the CMake path installation paths

* Revert "[juce] add ONLY_STATIC_LIBRARY to the port for windows"

This reverts commit 0eb5c6f.

* [juce] improve linux dependencies find/linkage

* [juce] remove libxcomposite-dev from vm
  • Loading branch information
aminya authored Jan 8, 2024
1 parent d64c5e8 commit 3bc5ff7
Show file tree
Hide file tree
Showing 9 changed files with 435 additions and 0 deletions.
15 changes: 15 additions & 0 deletions ports/juce/0001-build-allow-setting-JUCE_PLUGINHOST_LADSPA.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
diff --git a/extras/AudioPluginHost/CMakeLists.txt b/extras/AudioPluginHost/CMakeLists.txt
index 852796383..37a5306c9 100644
--- a/extras/AudioPluginHost/CMakeLists.txt
+++ b/extras/AudioPluginHost/CMakeLists.txt
@@ -51,7 +51,7 @@ target_compile_definitions(AudioPluginHost PRIVATE
JUCE_CONTENT_SHARING=1
JUCE_DIRECTSOUND=1
JUCE_DISABLE_CAUTIOUS_PARAMETER_ID_CHECKING=1
- JUCE_PLUGINHOST_LADSPA=1
+ JUCE_PLUGINHOST_LADSPA=${JUCE_PLUGINHOST_LADSPA}
JUCE_PLUGINHOST_LV2=1
JUCE_PLUGINHOST_VST3=1
JUCE_PLUGINHOST_VST=0
--
2.34.1
36 changes: 36 additions & 0 deletions ports/juce/0002-build-linux-find_packages.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
diff --git a/extras/Build/CMake/JUCEModuleSupport.cmake b/extras/Build/CMake/JUCEModuleSupport.cmake
index e18dd5e08..45cc9245f 100644
--- a/extras/Build/CMake/JUCEModuleSupport.cmake
+++ b/extras/Build/CMake/JUCEModuleSupport.cmake
@@ -353,6 +353,29 @@ function(_juce_create_pkgconfig_target name)
return()
endif()

+ # The package that can be found via find_package instead of pkg-config
+ if("${name}" STREQUAL "freetype2")
+ find_package(Freetype REQUIRED)
+ add_library(juce::pkgconfig_${name} INTERFACE)
+ target_link_libraries(juce::pkgconfig_${name} INTERFACE Freetype::Freetype)
+ return()
+ elseif("${name}" STREQUAL "libcurl")
+ find_package(CURL REQUIRED)
+ add_library(juce::pkgconfig_${name} INTERFACE)
+ target_link_libraries(juce::pkgconfig_${name} INTERFACE CURL::libcurl)
+ return()
+ elseif("${name}" STREQUAL "alsa")
+ find_package(ALSA REQUIRED)
+ add_library(juce::pkgconfig_${name} INTERFACE)
+ target_link_libraries(juce::pkgconfig_${name} INTERFACE ALSA::ALSA)
+ return()
+ elseif("${name}" STREQUAL "gl")
+ find_package(OpenGL REQUIRED)
+ add_library(juce::pkgconfig_${name} INTERFACE)
+ target_link_libraries(juce::pkgconfig_${name} INTERFACE OpenGL::GL)
+ return()
+ endif()
+
find_package(PkgConfig REQUIRED)
pkg_check_modules(${name} ${ARGN})

--
2.34.1
32 changes: 32 additions & 0 deletions ports/juce/0003-build-forward-vcpkg-toolchain.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
diff --git a/extras/Build/juceaide/CMakeLists.txt b/extras/Build/juceaide/CMakeLists.txt
index 163f203cc..f4cdba7f7 100644
--- a/extras/Build/juceaide/CMakeLists.txt
+++ b/extras/Build/juceaide/CMakeLists.txt
@@ -111,6 +111,25 @@ else()
"-DCMAKE_BUILD_TYPE=Debug"
"-DJUCE_BUILD_HELPER_TOOLS=ON"
"-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}"
+ # forward vcpkg flags
+ "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}"
+ "-DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}"
+ "-DCMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION=${CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION}"
+ "-DCMAKE_EXPORT_NO_PACKAGE_REGISTRY=${CMAKE_EXPORT_NO_PACKAGE_REGISTRY}"
+ "-DCMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY=${CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY}"
+ "-DCMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY=${CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY}"
+ "-DCMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP=${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP}"
+ "-DCMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE_MAKEFILE}"
+ "-DVCPKG_APPLOCAL_DEPS=${VCPKG_APPLOCAL_DEPS}"
+ "-DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=${VCPKG_CHAINLOAD_TOOLCHAIN_FILE}"
+ "-DVCPKG_CRT_LINKAGE=${VCPKG_CRT_LINKAGE}"
+ "-DVCPKG_MANIFEST_INSTALL=${VCPKG_MANIFEST_INSTALL}"
+ "-DVCPKG_PLATFORM_TOOLSET=${VCPKG_PLATFORM_TOOLSET}"
+ "-DVCPKG_SET_CHARSET_FLAG=${VCPKG_SET_CHARSET_FLAG}"
+ "-DVCPKG_TARGET_ARCHITECTURE=${VCPKG_TARGET_ARCHITECTURE}"
+ "-DVCPKG_TARGET_TRIPLET=${VCPKG_TARGET_TRIPLET}"
+ "-D_VCPKG_INSTALLED_DIR=${_VCPKG_INSTALLED_DIR}"
+ "-D_VCPKG_ROOT_DIR=${_VCPKG_ROOT_DIR}"
${extra_compiler_flag_arguments}
WORKING_DIRECTORY "${JUCE_SOURCE_DIR}"
OUTPUT_VARIABLE command_output
--
2.34.1
49 changes: 49 additions & 0 deletions ports/juce/0004-install-paths.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4262a9852..a46b51f1a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -167,14 +167,14 @@ if(("${CMAKE_SOURCE_DIR}" STREQUAL "${JUCE_SOURCE_DIR}") AND (NOT JUCE_BUILD_HEL
_juce_add_lv2_manifest_helper_target()

if(TARGET juce_lv2_helper)
- install(TARGETS juce_lv2_helper EXPORT LV2_HELPER DESTINATION "bin/JUCE-${JUCE_VERSION}")
+ install(TARGETS juce_lv2_helper EXPORT LV2_HELPER DESTINATION "${JUCE_TOOL_INSTALL_DIR}")
install(EXPORT LV2_HELPER NAMESPACE juce:: DESTINATION "${JUCE_INSTALL_DESTINATION}")
endif()

_juce_add_vst3_manifest_helper_target()

if(TARGET juce_vst3_helper)
- install(TARGETS juce_vst3_helper EXPORT VST3_HELPER DESTINATION "bin/JUCE-${JUCE_VERSION}")
+ install(TARGETS juce_vst3_helper EXPORT VST3_HELPER DESTINATION "${JUCE_TOOL_INSTALL_DIR}")
install(EXPORT VST3_HELPER NAMESPACE juce:: DESTINATION "${JUCE_INSTALL_DESTINATION}")
endif()
endif()
diff --git a/extras/Build/juceaide/CMakeLists.txt b/extras/Build/juceaide/CMakeLists.txt
index f4cdba7f7..fab57fdb4 100644
--- a/extras/Build/juceaide/CMakeLists.txt
+++ b/extras/Build/juceaide/CMakeLists.txt
@@ -164,7 +164,7 @@ else()

add_executable(juce::juceaide ALIAS juceaide)

- set(JUCE_TOOL_INSTALL_DIR "bin/JUCE-${JUCE_VERSION}" CACHE STRING
+ set(JUCE_TOOL_INSTALL_DIR "tools/juce" CACHE STRING
"The location, relative to the install prefix, where juceaide will be installed")

install(PROGRAMS "${imported_location}" DESTINATION "${JUCE_TOOL_INSTALL_DIR}")
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a46b51f1a..38f863a3e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -123,7 +123,7 @@ write_basic_package_version_file("${JUCE_BINARY_DIR}/JUCEConfigVersion.cmake"
COMPATIBILITY ExactVersion
${extra_version_arg})

-set(JUCE_INSTALL_DESTINATION "lib/cmake/JUCE-${JUCE_VERSION}" CACHE STRING
+set(JUCE_INSTALL_DESTINATION "share/juce" CACHE STRING
"The location, relative to the install prefix, where the JUCE config file will be installed")

set(JUCE_MODULE_PATH "include/JUCE-${JUCE_VERSION}/modules")
--
2.34.1
155 changes: 155 additions & 0 deletions ports/juce/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO juce-framework/JUCE
REF "${VERSION}"
SHA512 e8519ca4ee55f126e14d7c927e2f36e7c30117a34da84f2b4e730afcea4a864b07455ad3f89d751fa47c8c155548b0c3150a667f1a9d199e582eadd146b6c697
HEAD_REF master
PATCHES
"0001-build-allow-setting-JUCE_PLUGINHOST_LADSPA.patch"
"0002-build-linux-find_packages.patch"
"0003-build-forward-vcpkg-toolchain.patch"
"0004-install-paths.patch"
)

vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
FEATURES
"extras" JUCE_BUILD_EXTRAS
"ladspa" JUCE_PLUGINHOST_LADSPA
"jack" JUCE_JACK
"curl" JUCE_USE_CURL
"freetype" JUCE_USE_FREETYPE
"xcursor" JUCE_USE_XCURSOR
"xinerama" JUCE_USE_XINERAMA
"xrandr" JUCE_USE_XRANDR
"xrender" JUCE_USE_XRENDER
"web-browser" JUCE_WEB_BROWSER
"opengl" JUCE_OPENGL
)
# Based on https://github.com/juce-framework/JUCE/blob/master/docs/Linux%20Dependencies.md
if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux")
message("juce currently requires the following programs from the system package manager:
libx11-dev libxcomposite-dev libxext-dev
On Ubuntu derivatives:
sudo apt install libx11-dev libxcomposite-dev libxext-dev
")
if(JUCE_OPENGL)
message("juce with opengl feature requires the following packages via the system package manager:
libglu1-mesa-dev mesa-common-dev
On Ubuntu derivatives:
sudo apt install libglu1-mesa-dev mesa-common-dev
")
endif()

if(${JUCE_PLUGINHOST_LADSPA})
message("juce with ladspa feature requires the following packages via the system package manager:
ladspa-sdk
On Ubuntu derivatives:
sudo apt install ladspa-sdk
")
endif()

if(JUCE_USE_XCURSOR)
message("juce with xcursor feature requires the following packages via the system package manager:
libxcursor-dev
On Ubuntu derivatives:
sudo apt install libxcursor-dev
")
endif()

if(JUCE_USE_XINERAMA)
message("juce with xinerama feature requires the following packages via the system package manager:
libxinerama-dev
On Ubuntu derivatives:
sudo apt install libxinerama-dev
")
endif()

if(JUCE_USE_XRANDR)
message("juce with xrandr feature requires the following packages via the system package manager:
libxrandr-dev
On Ubuntu derivatives:
sudo apt install libxrandr-dev
")
endif()

if(JUCE_USE_XRENDER)
message("juce with xrender feature requires the following packages via the system package manager:
libxrender-dev
On Ubuntu derivatives:
sudo apt install libxrender-dev
")
endif()

if(JUCE_WEB_BROWSER)
message("juce with web-browser feature requires the following packages via the system package manager:
libwebkit2gtk-4.0-dev
On Ubuntu derivatives:
sudo apt install libwebkit2gtk-4.0-dev
")
endif()
endif()

vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
-DJUCE_ENABLE_MODULE_SOURCE_GROUPS=ON
${FEATURE_OPTIONS}
MAYBE_UNUSED_VARIABLES
JUCE_PLUGINHOST_LADSPA
JUCE_JACK
JUCE_OPENGL
JUCE_USE_CURL
JUCE_USE_FREETYPE
JUCE_USE_XCURSOR
JUCE_USE_XINERAMA
JUCE_USE_XRANDR
JUCE_USE_XRENDER
JUCE_WEB_BROWSER
)

vcpkg_cmake_install()
vcpkg_cmake_config_fixup()
vcpkg_fixup_pkgconfig()
vcpkg_copy_pdbs()

# Copy tools
file(GLOB JUCE_TOOLS "${CURRENT_PACKAGES_DIR}/bin/JUCE-${VERSION}/*")
foreach(JUCE_TOOL_PATH IN LISTS JUCE_TOOLS)
get_filename_component(JUCE_TOOL "${JUCE_TOOL_PATH}" NAME_WLE)
get_filename_component(JUCE_TOOL_DIR "${JUCE_TOOL_PATH}" DIRECTORY)
vcpkg_copy_tools(TOOL_NAMES ${JUCE_TOOL} SEARCH_DIR "${JUCE_TOOL_DIR}")
endforeach()

# Copy extras tools
if(JUCE_BUILD_EXTRAS)
file(GLOB JUCE_EXTRA_TOOLS "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/extras/*/*_artefacts/Release/*")
foreach(JUCE_EXTRA_TOOL_PATH IN LISTS JUCE_EXTRA_TOOLS)
get_filename_component(JUCE_EXTRA_TOOL "${JUCE_EXTRA_TOOL_PATH}" NAME_WLE)
get_filename_component(JUCE_EXTRA_TOOL_DIR "${JUCE_EXTRA_TOOL_PATH}" DIRECTORY)
vcpkg_copy_tools(TOOL_NAMES ${JUCE_EXTRA_TOOL} SEARCH_DIR "${JUCE_EXTRA_TOOL_DIR}")
endforeach()
endif()

# Copy JUCE modules including the cpp/cmake files
file(GLOB JUCE_MODULES_FOLDERS "${CURRENT_PACKAGES_DIR}/include/JUCE-${VERSION}/modules/*")
foreach(JUCE_MODULE_FOLDER IN LISTS JUCE_MODULES_FOLDERS)
file(COPY "${JUCE_MODULE_FOLDER}" DESTINATION "${CURRENT_PACKAGES_DIR}/include")
endforeach()

# Remove duplicate tools directories
file(REMOVE_RECURSE
"${CURRENT_PACKAGES_DIR}/bin"
"${CURRENT_PACKAGES_DIR}/debug/bin"
)

# Remove duplicate debug files
file(REMOVE_RECURSE
"${CURRENT_PACKAGES_DIR}/debug/"
)

# Copy license
vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE.md")

# Copy usage examples
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage"
DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
30 changes: 30 additions & 0 deletions ports/juce/usage
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
juce provides the following common CMake targets:

find_package(JUCE CONFIG REQUIRED)
target_link_libraries(main PRIVATE
juce::juce_core
juce::juce_audio_basics
juce::juce_events
juce::juce_audio_devices
juce::juce_recommended_config_flags
juce::juce_recommended_lto_flags
juce::juce_recommended_warning_flags)

See the Juce CMake API documentation and the License for details on how to create targets. Here are other available targets:

juce::juce_graphics
juce::juce_gui_basics
juce::juce_gui_extra
juce::juce_opengl
juce::juce_analytics
juce::juce_audio_formats
juce::juce_audio_plugin_client
juce::juce_audio_processors
juce::juce_audio_utils
juce::juce_box2d
juce::juce_cryptography
juce::juce_data_structures
juce::juce_dsp
juce::juce_osc
juce::juce_product_unlocking
juce::juce_video
Loading

0 comments on commit 3bc5ff7

Please sign in to comment.