Skip to content
Open
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
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,19 @@ create_jucer_clap_target(
post-build step triggered from the Projucer:

```bash
cmake -Bbuild-clap -G<generator> -DCMAKE_BUILD_TYPE=<Debug|Release>
# multi-config generators (Visual Studio, Xcode, Ninja Multi-Config)
cmake -Bbuild-clap -G<generator>
cmake --build build-clap --config <Debug|Release>

# single-config generators (Unix Makefiles, Ninja)
cmake -Bbuild-clap -G<generator> -DCMAKE_BUILD_TYPE=<Debug|Release>
cmake --build build-clap
```

The configuration is selected at build time, so one configure step can serve both `Debug` and
`Release` builds on a multi-config generator. Make sure the matching Projucer configuration has
been built, since the CLAP links against its "Shared Code" library.

The resulting builds will be located in `build-clap/MyPlugin_artefacts`.

If you would like to use the [CLAP extensions API](#the-extensions-api), the necessary source
Expand Down
2 changes: 1 addition & 1 deletion cmake/ClapTargetHelpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ function(clap_juce_extensions_plugin_internal)
# the plugin with the extensions... however, we still need to compile
# the extensions, since we'll get a linker error otherwise.
target_link_libraries(${claptarget} PUBLIC clap_juce_extensions)
target_link_libraries(${claptarget} PUBLIC ${CJA_TARGET_PATH})
target_link_libraries(${claptarget} PUBLIC "${CJA_TARGET_PATH}")
else()
target_link_libraries(${target} PUBLIC clap_juce_extensions)
target_link_libraries(${claptarget} PUBLIC ${target})
Expand Down
43 changes: 15 additions & 28 deletions cmake/JucerClap.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,21 @@ function(create_jucer_clap_target)
set(CJA_BINARY_NAME "${CJA_TARGET}")
endif()

if ("${CMAKE_BUILD_TYPE}" STREQUAL "")
get_property(is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if(NOT is_multi_config AND "${CMAKE_BUILD_TYPE}" STREQUAL "")
message(WARNING "CMAKE_BUILD_TYPE not set... using Release by default")
set(CMAKE_BUILD_TYPE "Release")
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build" FORCE)
endif()

if("${JUCER_GENERATOR}" STREQUAL "VisualStudio2019")
find_library(PLUGIN_LIBRARY_PATH ${CJA_TARGET} "Builds/VisualStudio2019/x64/${CMAKE_BUILD_TYPE}/Shared Code")
elseif("${JUCER_GENERATOR}" STREQUAL "VisualStudio2017")
find_library(PLUGIN_LIBRARY_PATH ${CJA_TARGET} "Builds/VisualStudio2017/x64/${CMAKE_BUILD_TYPE}/Shared Code")
elseif("${JUCER_GENERATOR}" STREQUAL "VisualStudio2015")
find_library(PLUGIN_LIBRARY_PATH ${CJA_TARGET} "Builds/VisualStudio2015/x64/${CMAKE_BUILD_TYPE}/Shared Code")
elseif("${JUCER_GENERATOR}" STREQUAL "VisualStudio2022")
find_library(PLUGIN_LIBRARY_PATH ${CJA_TARGET} "Builds/VisualStudio2022/x64/${CMAKE_BUILD_TYPE}/Shared Code")
# multi-config support by using $<CONFIG> in the library names
set(jucer_builds_dir "${CMAKE_CURRENT_SOURCE_DIR}/Builds")
if("${JUCER_GENERATOR}" MATCHES "^VisualStudio(2015|2017|2019|2022)$")
set(PLUGIN_LIBRARY_PATH "${jucer_builds_dir}/${JUCER_GENERATOR}/x64/$<CONFIG>/Shared Code/${CJA_TARGET}.lib")
elseif("${JUCER_GENERATOR}" STREQUAL "Xcode")
find_library(PLUGIN_LIBRARY_PATH ${CJA_TARGET} "Builds/MacOSX/build/${CMAKE_BUILD_TYPE}")
set(PLUGIN_LIBRARY_PATH "${jucer_builds_dir}/MacOSX/build/$<CONFIG>/lib${CJA_TARGET}.a")
elseif("${JUCER_GENERATOR}" STREQUAL "LinuxMakefile")
# for some reason Projucer makes a lib called "PluginName.a", but find_library needs "libPluginName.a"
set(LINUX_LIB_PATH "${CMAKE_CURRENT_SOURCE_DIR}/Builds/LinuxMakefile/build")
configure_file("${LINUX_LIB_PATH}/${CJA_TARGET}.a" "${LINUX_LIB_PATH}/lib${CJA_TARGET}.a" COPYONLY)
find_library(PLUGIN_LIBRARY_PATH ${CJA_TARGET} "${LINUX_LIB_PATH}")
# the Makefile exporter is single-config, and makes a lib called "PluginName.a"
set(PLUGIN_LIBRARY_PATH "${jucer_builds_dir}/LinuxMakefile/build/${CJA_TARGET}.a")
elseif("${JUCER_GENERATOR}" STREQUAL "")
message(FATAL_ERROR "JUCER_GENERATOR variable must be set!")
else()
Expand Down Expand Up @@ -66,19 +61,11 @@ function(create_jucer_clap_target)
JucePlugin_Desc=""
)

if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
target_compile_definitions(${clap_target}
PRIVATE
DEBUG=1
_DEBUG=1
)
else()
target_compile_definitions(${clap_target}
PRIVATE
NDEBUG=1
_NDEBUG=1
)
endif()
target_compile_definitions(${clap_target}
PRIVATE
"$<$<CONFIG:Debug>:DEBUG=1;_DEBUG=1>"
"$<$<NOT:$<CONFIG:Debug>>:NDEBUG=1;_NDEBUG=1>"
)

if("${CJA_CLAP_FEATURES}" MATCHES "^instrument.*")
message(STATUS "Detected plugin category: instrument")
Expand Down
Loading