Skip to content

Commit 4fea6f1

Browse files
committed
Add CLI option when dependency. Only compile docs when top-level.
1 parent 720945a commit 4fea6f1

File tree

1 file changed

+35
-23
lines changed

1 file changed

+35
-23
lines changed

CMakeLists.txt

Lines changed: 35 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.15)
33
file(STRINGS VERSION CURRENT_VERSION LIMIT_COUNT 1)
44
project(pluginval VERSION ${CURRENT_VERSION})
55

6-
# Executes when not compiling as a "dependency" of another CMake project
6+
# Just compliing pluginval
77
if (pluginval_IS_TOP_LEVEL)
88
add_subdirectory(modules/juce)
99

@@ -16,22 +16,10 @@ if (pluginval_IS_TOP_LEVEL)
1616
endif()
1717

1818
else()
19-
option(PLUGINVAL_STRICTNESS_LEVEL "Pluginval --strictness argument" 10)
20-
21-
if(APPLE)
22-
set(PLUGIN_TARGET "${CMAKE_PROJECT_NAME}_AU")
23-
else()
24-
set(PLUGIN_TARGET "${CMAKE_PROJECT_NAME}_VST3")
25-
endif()
26-
27-
add_custom_target(${CMAKE_PROJECT_NAME}_Pluginval
28-
COMMAND
29-
pluginval
30-
--validate ${artefact}
31-
--strictness-level ${PLUGINVAL_STRICTNESS_LEVEL}
32-
DEPENDS ${PLUGIN_TARGET} pluginval
33-
VERBATIM)
34-
19+
# compiling as a "dependency" of another JUCE CMake project
20+
if (NOT COMMAND juce_add_module)
21+
message(FATAL_ERROR "JUCE must be added to your project before pluginval!")
22+
endif ()
3523
endif()
3624

3725
# Uncomment to enable tsan
@@ -111,11 +99,35 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
11199
-static-libstdc++)
112100
endif()
113101

114-
set (cmdline_docs_out "${CMAKE_CURRENT_LIST_DIR}/docs/Command line options.md")
102+
if (pluginval_IS_TOP_LEVEL)
103+
set (cmdline_docs_out "${CMAKE_CURRENT_LIST_DIR}/docs/Command line options.md")
115104

116-
add_custom_command (OUTPUT "${cmdline_docs_out}"
117-
COMMAND pluginval --help > "${cmdline_docs_out}"
118-
COMMENT "Regenerating Command line options.md..."
119-
USES_TERMINAL)
105+
add_custom_command (OUTPUT "${cmdline_docs_out}"
106+
COMMAND pluginval --help > "${cmdline_docs_out}"
107+
COMMENT "Regenerating Command line options.md..."
108+
USES_TERMINAL)
109+
add_custom_target (PluginvalDocs DEPENDS "${cmdline_docs_out}")
110+
else()
120111

121-
add_custom_target (PluginvalDocs DEPENDS "${cmdline_docs_out}")
112+
# Custom pluginval CLI target
113+
set(PLUGINVAL_STRICTNESS_LEVEL 10 CACHE STRING "Pluginval --strictness argument (1-10)")
114+
set_property(CACHE PLUGINVAL_STRICTNESS_LEVEL PROPERTY STRINGS 1 2 3 4 5 6 7 8 9 10)
115+
116+
# Set the target based on the platform
117+
# Makes the assumption both are being built
118+
if(APPLE)
119+
set(PLUGINVAL_TARGET "${CMAKE_PROJECT_NAME}_AU")
120+
else()
121+
set(PLUGINVAL_TARGET "${CMAKE_PROJECT_NAME}_VST3")
122+
endif()
123+
124+
get_target_property(artefact ${PLUGINVAL_TARGET} JUCE_PLUGIN_ARTEFACT_FILE)
125+
126+
# TODO: This doesn't populate the executable in clion
127+
add_custom_target(${CMAKE_PROJECT_NAME}_pluginval_cli
128+
COMMAND $<TARGET_FILE:pluginval>
129+
--validate ${artefact}
130+
--strictness-level 10
131+
DEPENDS pluginval ${PLUGINVAL_TARGET}
132+
COMMENT "Run pluginval CLI with strict validation")
133+
endif()

0 commit comments

Comments
 (0)