Skip to content

Commit

Permalink
Upgrade RackSDK.cmake (#97)
Browse files Browse the repository at this point in the history
  • Loading branch information
baconpaul authored Jan 5, 2023
1 parent 435d146 commit 60f366d
Showing 1 changed file with 16 additions and 19 deletions.
35 changes: 16 additions & 19 deletions RackSDK.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Mapping of plugin build definitions from the Rack-SDK arch.mk, compile.mk, dep.mk and plugin.mk to CMake.

set(RACK_SDK_VERSION 2.2.1)
set(RACK_SDK_VERSION 2.2.2)
message(STATUS "Load RackSDK.cmake (mapping based on Rack-SDK-${RACK_SDK_VERSION})")

if ("${RACK_SDK_DIR}" STREQUAL "")
Expand All @@ -9,6 +9,12 @@ else ()
message(STATUS "Using Rack-SDK in '${RACK_SDK_DIR}'")
endif ()

if (EXISTS "${RACK_SDK_DIR}/include/rack.hpp")
message(STATUS "Found include/rack.hpp")
else()
message(FATAL_ERROR "Rack SDK in ${RACK_SDK_DIR} missing include/rack.hpp")
endif()

if ("${PLUGIN_NAME}" STREQUAL "")
message(FATAL_ERROR "PLUGIN_NAME variable not set! Add PLUGIN_NAME variable to the project CMakeLists.txt before including RackSDK.cmake.\
The PLUGIN_NAME must correspond to the plugin slug, as defined in plugin.json.")
Expand All @@ -22,15 +28,10 @@ if ("${ADDITIONAL_PLUGIN_DISTRIBUTABLES}" STREQUAL "")
endif ()

# Do not change the RACK_PLUGIN_LIB!
if (APPLE)
if (${CMAKE_OSX_ARCHITECTURES} MATCHES "arm64")
set(RACK_PLUGIN_LIB plugin-arm64)
else()
set(RACK_PLUGIN_LIB plugin)
endif()
else()
set(RACK_PLUGIN_LIB plugin)
endif()
if (${CMAKE_OSX_ARCHITECTURES} MATCHES "arm64")
set(RACK_PLUGIN_ARCH -arm64)
endif ()
set(RACK_PLUGIN_LIB plugin${RACK_PLUGIN_ARCH})

file(GLOB LICENSE LICENSE*)
set(PLUGIN_DISTRIBUTABLES plugin.json res ${LICENSE} ${ADDITIONAL_PLUGIN_DISTRIBUTABLES})
Expand Down Expand Up @@ -112,17 +113,13 @@ install(TARGETS ${RACK_PLUGIN_LIB} LIBRARY DESTINATION ${PROJECT_BINARY_DIR}/${P
install(DIRECTORY ${PROJECT_BINARY_DIR}/${PLUGIN_NAME}/ DESTINATION ${PLUGIN_NAME})
file(COPY ${PLUGIN_DISTRIBUTABLES} DESTINATION ${PLUGIN_NAME})

# Since the name of RACK_PLUGIN_LIB is no longer stable in SDK 2.2.1 add a stable
# named target
set(RACK_BUILD_TARGET build_plugin)
add_custom_target(${RACK_BUILD_TARGET})
add_dependencies(${RACK_BUILD_TARGET} ${RACK_PLUGIN_LIB})

# A quick installation target to copy the plugin library and plugin.json into VCV Rack plugin folder for development.
# CMAKE_INSTALL_PREFIX needs to point to the VCV Rack plugin folder in user documents.
set(RACK_QUICK_INSTALL ${RACK_BUILD_TARGET}_quick_install)
add_custom_target(${RACK_QUICK_INSTALL}
add_custom_target(build_plugin)
add_dependencies(build_plugin ${RACK_PLUGIN_LIB})

add_custom_target(build_plugin_quick_install
COMMAND cmake -E copy $<TARGET_FILE:${RACK_PLUGIN_LIB}> ${CMAKE_INSTALL_PREFIX}/${PLUGIN_NAME}
COMMAND cmake -E copy ${CMAKE_SOURCE_DIR}/plugin.json ${CMAKE_INSTALL_PREFIX}/${PLUGIN_NAME}
)
add_dependencies(${RACK_QUICK_INSTALL} ${RACK_BUILD_TARGET})
add_dependencies(build_plugin_quick_install ${RACK_PLUGIN_LIB})

0 comments on commit 60f366d

Please sign in to comment.