aboutsummaryrefslogtreecommitdiff
path: root/vcpkg/ports/juce/portfile.cmake
blob: 315ce76bdfe0d5ec38800b46c1ce63e1700a06c0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
set(VCPKG_BUILD_TYPE release)  # no libraries

vcpkg_from_github(
  OUT_SOURCE_PATH SOURCE_PATH
  REPO juce-framework/JUCE
  REF "${VERSION}"
  SHA512 ca404d94f8f79d9644f391342807dde279d1d313ef597a5d7fa88760e0459f2639cb98b6523c3ae71b2641357df63353c1f32e9b33dd9f050f5651fba470ec33
  HEAD_REF master
  PATCHES
    0001-build-allow-setting-JUCE_PLUGINHOST_LADSPA.patch
    0004-install-paths.patch
    gcc-has-builtin.diff
    devendor-oboe.diff
    install-extras.diff
    juceaide.diff
    prefer-cmake.diff
    vcpkg-compile-definitions.diff
    avoid-macos-15-deprecations.patch
)
file(REMOVE_RECURSE "${SOURCE_PATH}/modules/juce_audio_devices/native/oboe")

set(feature_compile_definitions
    "curl"        JUCE_USE_CURL
    "fontconfig"  JUCE_USE_FONTCONFIG
    "freetype"    JUCE_USE_FREETYPE
    "jack"        JUCE_JACK
    "ladspa"      JUCE_PLUGINHOST_LADSPA
    "web-browser" JUCE_WEB_BROWSER
    "xcursor"     JUCE_USE_XCURSOR
    "xinerama"    JUCE_USE_XINERAMA
    "xrandr"      JUCE_USE_XRANDR
    "xrender"     JUCE_USE_XRENDER
)
set(enforced_definitions "")
while(feature_compile_definitions)
  list(POP_FRONT feature_compile_definitions  feature compile_definition)
  if(NOT feature IN_LIST FEATURES)
    # Enforce controlled absence of dependency
    list(APPEND enforced_definitions "${compile_definition}=0")
  endif()
endwhile()
list(JOIN enforced_definitions "\n    " enforced_definitions)
file(WRITE "${SOURCE_PATH}/extras/Build/CMake/vcpkg-compile-definitions.cmake" "
function(vcpkg_juce_add_compile_definitions target)
  target_compile_definitions(\${target} INTERFACE
    ${enforced_definitions}
  )
endfunction()
")

vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
FEATURES
  "extras"      JUCE_BUILD_EXTRAS
  "ladspa"      JUCE_PLUGINHOST_LADSPA
)
# Based on https://github.com/juce-framework/JUCE/blob/master/docs/Linux%20Dependencies.md
if(VCPKG_TARGET_IS_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()

if(VCPKG_CROSSCOMPILING)
  # Constructed with CURRENT_INSTALLED_DIR, for vcpkg_cmake_config_fixup.
  list(APPEND FEATURE_OPTIONS "-DWITH_JUCEAIDE=${CURRENT_INSTALLED_DIR}/../${HOST_TRIPLET}/tools/${PORT}/juceaide${VCPKG_HOST_EXECUTABLE_SUFFIX}")
endif()

vcpkg_cmake_configure(
  SOURCE_PATH "${SOURCE_PATH}"
  OPTIONS
    -DJUCE_ENABLE_MODULE_SOURCE_GROUPS=ON
    -DJUCE_INSTALL_DESTINATION=share/juce
    -DJUCE_TOOL_INSTALL_DIR=bin
    ${FEATURE_OPTIONS}
  MAYBE_UNUSED_VARIABLES
    JUCE_TOOL_INSTALL_DIR
    JUCE_PLUGINHOST_LADSPA
)

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

file(GLOB icons "${CURRENT_PACKAGES_DIR}/bin/*.ico")
if(icons)
  file(REMOVE_RECURSE ${icons})
endif()

set(tool_names "")
file(GLOB tools "${CURRENT_PACKAGES_DIR}/bin/*")
set(name_component NAME_WE)
if(VCPKG_TARGET_EXECUTABLE_SUFFIX STREQUAL "")
  set(name_component NAME)
endif()
foreach(tool IN LISTS tools)
  get_filename_component(name "${tool}" ${name_component})
  list(APPEND tool_names "${name}")
endforeach()
if(tool_names)
  vcpkg_copy_tools(TOOL_NAMES ${tool_names} AUTO_CLEAN)
endif()

# Files not generated for Android or iOS
file(TOUCH "${CURRENT_PACKAGES_DIR}/share/juce/LV2_HELPER.cmake")
file(TOUCH "${CURRENT_PACKAGES_DIR}/share/juce/VST3_HELPER.cmake")

# Catch libs which must be de-vendored, e.g. oboe.
# This is to avoid ownership conflicts.
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/lib" "${CURRENT_PACKAGES_DIR}/include/oboe")
if(EXISTS "${CURRENT_PACKAGES_DIR}/lib")
  message(${Z_VCPKG_BACKCOMPAT_MESSAGE_LEVEL} "juce must not install files to ${CURRENT_PACKAGES_DIR}/lib.")
  file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/lib")
endif()

file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE.md")