|
| 1 | +cmake_minimum_required(VERSION 3.11 FATAL_ERROR) |
| 2 | +cmake_policy(SET CMP0091 NEW) |
| 3 | + |
| 4 | +######### |
| 5 | + |
| 6 | +# To setup the build (change CMAKE_BUILD_TYPE as desired): |
| 7 | +# cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug |
| 8 | +# To build the VST2 version: |
| 9 | +# cmake --build build --target vst2 |
| 10 | +# To build the VST3 version: |
| 11 | +# cmake --build build --target vst3 |
| 12 | +# To build the AUv2 version (macOS only): |
| 13 | +# cmake --build build --target auv2 |
| 14 | + |
| 15 | +project(TemplateProject VERSION 1.0.0 LANGUAGES C CXX) |
| 16 | + |
| 17 | +set(IPLUG2_DIR ${CMAKE_SOURCE_DIR}/../iPlug2) |
| 18 | +include(${IPLUG2_DIR}/iPlug2.cmake) |
| 19 | +find_package(iPlug2) |
| 20 | +#find_package(iPlug2 REQUIRED COMPONENTS Skia) |
| 21 | + |
| 22 | +set(PROJECT_DIR "${CMAKE_SOURCE_DIR}") |
| 23 | +set(SRC_FILES |
| 24 | + "${PROJECT_DIR}/config.h" |
| 25 | + "${PROJECT_DIR}/TemplateProject.h" |
| 26 | + "${PROJECT_DIR}/TemplateProject.cpp" |
| 27 | +) |
| 28 | +source_group(TREE ${PROJECT_DIR} FILES ${SRC_FILES}) |
| 29 | + |
| 30 | +set(RESOURCES |
| 31 | + "${PROJECT_DIR}/resources/fonts/Roboto-Regular.ttf" |
| 32 | +) |
| 33 | + |
| 34 | +# While not required, creating a base interface for includes and settings seems like a good idea. |
| 35 | +add_library(_base INTERFACE) |
| 36 | +# iplug_target_add() is a shorthand function for adding sources and include directories, |
| 37 | +# linking libraries, adding resources, setting compile options, etc. |
| 38 | +iplug_target_add(_base INTERFACE |
| 39 | + INCLUDE ${PROJECT_DIR} ${PROJECT_DIR}/resources |
| 40 | + LINK iPlug2_NanoVG_GL2 |
| 41 | + FEATURE cxx_std_17) |
| 42 | + |
| 43 | +# For typing convenience the TARGET name is put into a variable. |
| 44 | +set(TARGET app) |
| 45 | +add_executable(${TARGET} WIN32 MACOSX_BUNDLE ${SRC_FILES}) |
| 46 | +iplug_target_add(${TARGET} PUBLIC LINK iPlug2_APP _base RESOURCE ${RESOURCES}) |
| 47 | +# You MUST call iplug_configure_target(<target_name> <app|vst2|vst3|...>) for things to build correctly. |
| 48 | +iplug_configure_target(${TARGET} app) |
| 49 | + |
| 50 | +# set(TARGET vst2) |
| 51 | +# add_library(${TARGET} MODULE ${SRC_FILES}) |
| 52 | +# iplug_target_add(${TARGET} PUBLIC LINK iPlug2_VST2 _base RESOURCE ${RESOURCES}) |
| 53 | +# iplug_configure_target(${TARGET} vst2) |
| 54 | + |
| 55 | +set(TARGET vst3) |
| 56 | +add_library(${TARGET} MODULE ${SRC_FILES}) |
| 57 | +iplug_target_add(${TARGET} PUBLIC LINK iPlug2_VST3 _base RESOURCE ${RESOURCES}) |
| 58 | +iplug_configure_target(${TARGET} vst3) |
| 59 | + |
| 60 | +# set(TARGET clap) |
| 61 | +# add_library(${TARGET} MODULE ${SRC_FILES}) |
| 62 | +# iplug_target_add(${TARGET} PUBLIC LINK iPlug2_CLAP _base RESOURCE ${RESOURCES}) |
| 63 | +# iplug_configure_target(${TARGET} clap) |
| 64 | + |
| 65 | +if (CMAKE_SYSTEM_NAME MATCHES "Darwin") |
| 66 | + set(TARGET auv2) |
| 67 | + add_library(${TARGET} MODULE ${SRC_FILES}) |
| 68 | + iplug_target_add(${TARGET} PUBLIC LINK iPlug2_AUv2 _base RESOURCE ${RESOURCES}) |
| 69 | + iplug_configure_target(${TARGET} auv2) |
| 70 | +endif() |
| 71 | + |
| 72 | +if (WIN32) |
| 73 | + set(CMAKE_RC_FLAGS "/I${PROJECT_DIR}/resources /I${PROJECT_DIR}/resources/fonts /I${PROJECT_DIR}/resources/img ${CMAKE_RC_FLAGS}") |
| 74 | +endif() |
0 commit comments