Some fixes for you, see the comments:
cmake_minimum_required(VERSION 3.15)
project(DemoTape VERSION 1.0.0)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Find and include JUCE
set(JUCE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../JUCE" CACHE PATH "Path to JUCE library")
if(NOT EXISTS "${JUCE_PATH}/CMakeLists.txt")
message(FATAL_ERROR "JUCE path doesn't exist or isn't a JUCE repository: ${JUCE_PATH}")
endif()
# MSVC-specific settings should come before adding subdirectories
if(MSVC)
add_compile_definitions(_ITERATOR_DEBUG_LEVEL=0)
endif()
add_subdirectory(${JUCE_PATH} ${CMAKE_BINARY_DIR}/JUCE EXCLUDE_FROM_ALL)
# Define paths
set(RIVE_CPP_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../rive-runtime-main/include")
set(RIVE_RENDERER_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../rive-runtime-main/renderer/include")
set(RIVE_RENDERER_SRC_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../rive-runtime-main/renderer/src")
set(RIVE_CPP_LIB_PATH "E:/__Design/__/__VST/__Phoenix/rive-runtime-main/out/debug/rive.lib")
# Source and header files
set(PLUGIN_SOURCES
"Source/RiveOpenGLRenderer.cpp"
"Source/PluginProcessor.cpp"
"Source/PluginEditor.cpp"
"Source/RiveComponent.cpp"
)
set(PLUGIN_HEADERS
"Source/juce_config.h"
"Source/PluginEditor.h"
"Source/PluginProcessor.h"
"Source/RiveComponent.h"
"Source/RiveDemo.h"
"Source/RiveFactory.h"
"Source/RiveOpenGLRenderer.h"
)
# Define the plugin
juce_add_plugin(DemoTape
COMPANY_NAME "YourCompany"
PLUGIN_MANUFACTURER_CODE "Ydmo"
PLUGIN_CODE "Dmtp"
FORMATS VST3 Standalone
PRODUCT_NAME "DemoTape"
)
# Generate JUCE header
juce_generate_juce_header(DemoTape)
# Include directories
target_include_directories(DemoTape
PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/Source"
"${RIVE_CPP_INCLUDE_DIR}"
"${RIVE_RENDERER_INCLUDE_DIR}"
"${RIVE_RENDERER_SRC_INCLUDE_DIR}"
)
# Compile definitions
target_compile_definitions(DemoTape
PRIVATE
JUCE_VST3_CAN_REPLACE_VST2=0
JUCE_DISPLAY_SPLASH_SCREEN=0
)
# Platform-specific settings
if(WIN32)
target_compile_definitions(DemoTape
PRIVATE
_USE_MATH_DEFINES
WIN32_LEAN_AND_MEAN
)
endif()
# Link libraries
target_link_libraries(DemoTape
PRIVATE
juce::juce_audio_utils
juce::juce_opengl
juce::juce_audio_plugin_client
"${RIVE_CPP_LIB_PATH}"
PUBLIC
juce::juce_recommended_config_flags
juce::juce_recommended_lto_flags
)
# Add sources to target
target_sources(DemoTape
PRIVATE
${PLUGIN_SOURCES}
${PLUGIN_HEADERS}
)
# MSVC-specific compiler options
if(MSVC)
target_compile_options(DemoTape
PRIVATE
$<$<CONFIG:Debug>:/MDd>
)
target_link_options(DemoTape
PRIVATE
$<$<CONFIG:Debug>:/NODEFAULTLIB:MSVCPRTD>
$<$<CONFIG:Debug>:/NODEFAULTLIB:MSVCRTD>
$<$<CONFIG:Debug>:/NODEFAULTLIB:LIBCMTD>
$<$<CONFIG:Debug>:/FORCE:MULTIPLE>
)
endif()
# Diagnostic messages
message(STATUS "CMAKE_BINARY_DIR: ${CMAKE_BINARY_DIR}")
message(STATUS "CMAKE_CURRENT_SOURCE_DIR: ${CMAKE_CURRENT_SOURCE_DIR}")
message(STATUS "JUCE_PATH: ${JUCE_PATH}")
message(STATUS "C++ Compiler: ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}")
# Source grouping for IDEs
source_group("Source Files" FILES ${PLUGIN_SOURCES})
source_group("Header Files" FILES ${PLUGIN_HEADERS})
Key fixes and improvements:
-
Removed redundant preprocessor definitions (some were defined twice)
-
Simplified source file paths by making them relative to CMAKE_CURRENT_SOURCE_DIR
-
Added target_sources which is the proper way to add source files to a JUCE plugin target
-
Moved MSVC-specific definitions to appropriate sections
-
Removed commented-out code that’s not needed
-
Consolidated platform-specific settings
-
Improved organization and readability
-
Removed unnecessary generator expressions where simple if(MSVC) suffices
-
Removed redundant diagnostic check for RIVE_CPP_INCLUDE_DIR
-
Fixed source_group to use the variables instead of repeating file lists
Potential remaining considerations:
-
The absolute path to rive.lib might need to be configurable or have a debug/release variant
-
You might want to add checks for the existence of the Rive library path
-
Consider adding install rules if needed
-
You might want to add configuration-specific library paths for Debug/Release builds
The CMakeLists.txt should now build correctly assuming all the referenced files and paths exist on your system. Make sure to adjust the RIVE_CPP_LIB_PATH if it’s different on your build machine or if you need different paths for different configurations.
If this CMakeLists.txt works out, the next thing to do would be to get rive.lib through some better mechanism, as a build target perhaps. But, that’s over to you to work out (and don’t forget to share the details, because RIVE looks pretty good).. Disclaimer: I haven’t done anything in RIVE yet, I just like helping folks with easy JUCE stuff … ![]()
