From a98dc7553b2026287d1edfa05fe9237d9b49edac Mon Sep 17 00:00:00 2001 From: reuk Date: Tue, 20 Oct 2020 11:15:10 +0100 Subject: [PATCH] CMake: Update example projects to use recommended targets --- examples/CMake/AudioPlugin/CMakeLists.txt | 26 +++++++++------- examples/CMake/AudioPlugin/PluginProcessor.h | 1 + examples/CMake/ConsoleApp/CMakeLists.txt | 24 +++++++++------ examples/CMake/GuiApp/CMakeLists.txt | 31 ++++++++++++-------- 4 files changed, 51 insertions(+), 31 deletions(-) diff --git a/examples/CMake/AudioPlugin/CMakeLists.txt b/examples/CMake/AudioPlugin/CMakeLists.txt index 2c6c1d1aff..6e05657218 100644 --- a/examples/CMake/AudioPlugin/CMakeLists.txt +++ b/examples/CMake/AudioPlugin/CMakeLists.txt @@ -66,9 +66,10 @@ juce_add_plugin(AudioPluginExample # although it doesn't really affect executable targets). Finally, we supply a list of source files # that will be built into the target. This is a standard CMake command. -target_sources(AudioPluginExample PRIVATE - PluginEditor.cpp - PluginProcessor.cpp) +target_sources(AudioPluginExample + PRIVATE + PluginEditor.cpp + PluginProcessor.cpp) # `target_compile_definitions` adds some preprocessor definitions to our target. In a Projucer # project, these might be passed in the 'Preprocessor Definitions' field. JUCE modules also make use @@ -79,10 +80,10 @@ target_sources(AudioPluginExample PRIVATE target_compile_definitions(AudioPluginExample PUBLIC - # JUCE_WEB_BROWSER and JUCE_USE_CURL would be on by default, but you might not need them. - JUCE_WEB_BROWSER=0 # If you remove this, add `NEEDS_WEB_BROWSER TRUE` to the `juce_add_plugin` call - JUCE_USE_CURL=0 # If you remove this, add `NEEDS_CURL TRUE` to the `juce_add_plugin` call - JUCE_VST3_CAN_REPLACE_VST2=0) + # JUCE_WEB_BROWSER and JUCE_USE_CURL would be on by default, but you might not need them. + JUCE_WEB_BROWSER=0 # If you remove this, add `NEEDS_WEB_BROWSER TRUE` to the `juce_add_plugin` call + JUCE_USE_CURL=0 # If you remove this, add `NEEDS_CURL TRUE` to the `juce_add_plugin` call + JUCE_VST3_CAN_REPLACE_VST2=0) # If your target needs extra binary assets, you can add them here. The first argument is the name of # a new static library target that will include all the binary resources. There is an optional @@ -99,6 +100,11 @@ target_compile_definitions(AudioPluginExample # linked automatically. If we'd generated a binary data target above, we would need to link to it # here too. This is a standard CMake command. -target_link_libraries(AudioPluginExample PRIVATE - # AudioPluginData # If we'd created a binary data target, we'd link to it here - juce::juce_audio_utils) +target_link_libraries(AudioPluginExample + PRIVATE + # AudioPluginData # If we'd created a binary data target, we'd link to it here + juce::juce_audio_utils + PUBLIC + juce::juce_recommended_config_flags + juce::juce_recommended_lto_flags + juce::juce_recommended_warning_flags) diff --git a/examples/CMake/AudioPlugin/PluginProcessor.h b/examples/CMake/AudioPlugin/PluginProcessor.h index d686ef3e7b..61413bb185 100644 --- a/examples/CMake/AudioPlugin/PluginProcessor.h +++ b/examples/CMake/AudioPlugin/PluginProcessor.h @@ -17,6 +17,7 @@ public: bool isBusesLayoutSupported (const BusesLayout& layouts) const override; void processBlock (juce::AudioBuffer&, juce::MidiBuffer&) override; + using AudioProcessor::processBlock; //============================================================================== juce::AudioProcessorEditor* createEditor() override; diff --git a/examples/CMake/ConsoleApp/CMakeLists.txt b/examples/CMake/ConsoleApp/CMakeLists.txt index 28ad5c77d1..49a3633377 100644 --- a/examples/CMake/ConsoleApp/CMakeLists.txt +++ b/examples/CMake/ConsoleApp/CMakeLists.txt @@ -48,8 +48,9 @@ juce_add_console_app(ConsoleAppExample # although it doesn't really affect executable targets). Finally, we supply a list of source files # that will be built into the target. This is a standard CMake command. -target_sources(ConsoleAppExample PRIVATE - Main.cpp) +target_sources(ConsoleAppExample + PRIVATE + Main.cpp) # `target_compile_definitions` adds some preprocessor definitions to our target. In a Projucer # project, these might be passed in the 'Preprocessor Definitions' field. JUCE modules also make use @@ -58,10 +59,11 @@ target_sources(ConsoleAppExample PRIVATE # definitions will be visible both to your code, and also the JUCE module code, so for new # definitions, pick unique names that are unlikely to collide! This is a standard CMake command. -target_compile_definitions(ConsoleAppExample PRIVATE - # JUCE_WEB_BROWSER and JUCE_USE_CURL would be on by default, but you might not need them. - JUCE_WEB_BROWSER=0 # If you remove this, add `NEEDS_WEB_BROWSER TRUE` to the `juce_add_console_app` call - JUCE_USE_CURL=0) # If you remove this, add `NEEDS_CURL TRUE` to the `juce_add_console_app` call +target_compile_definitions(ConsoleAppExample + PRIVATE + # JUCE_WEB_BROWSER and JUCE_USE_CURL would be on by default, but you might not need them. + JUCE_WEB_BROWSER=0 # If you remove this, add `NEEDS_WEB_BROWSER TRUE` to the `juce_add_console_app` call + JUCE_USE_CURL=0) # If you remove this, add `NEEDS_CURL TRUE` to the `juce_add_console_app` call # If the target needs extra binary assets, they can be added here. The first argument is the name of # a new static library target that will include all the binary resources. There is an optional @@ -77,6 +79,10 @@ target_compile_definitions(ConsoleAppExample PRIVATE # resolved automatically. If you'd generated a binary data target above, you would need to link to # it here too. This is a standard CMake command. -target_link_libraries(ConsoleAppExample PRIVATE - # ConsoleAppData # If you'd created a binary data target, you'd link to it here - juce::juce_core) +target_link_libraries(ConsoleAppExample + PRIVATE + # ConsoleAppData # If you'd created a binary data target, you'd link to it here + juce::juce_core + PUBLIC + juce::juce_recommended_config_flags + juce::juce_recommended_warning_flags) diff --git a/examples/CMake/GuiApp/CMakeLists.txt b/examples/CMake/GuiApp/CMakeLists.txt index 19859cd42a..ca31d4feb5 100644 --- a/examples/CMake/GuiApp/CMakeLists.txt +++ b/examples/CMake/GuiApp/CMakeLists.txt @@ -57,9 +57,10 @@ juce_add_gui_app(GuiAppExample # although it doesn't really affect executable targets). Finally, we supply a list of source files # that will be built into the target. This is a standard CMake command. -target_sources(GuiAppExample PRIVATE - Main.cpp - MainComponent.cpp) +target_sources(GuiAppExample + PRIVATE + Main.cpp + MainComponent.cpp) # `target_compile_definitions` adds some preprocessor definitions to our target. In a Projucer # project, these might be passed in the 'Preprocessor Definitions' field. JUCE modules also make use @@ -68,12 +69,13 @@ target_sources(GuiAppExample PRIVATE # definitions will be visible both to your code, and also the JUCE module code, so for new # definitions, pick unique names that are unlikely to collide! This is a standard CMake command. -target_compile_definitions(GuiAppExample PRIVATE - # JUCE_WEB_BROWSER and JUCE_USE_CURL would be on by default, but you might not need them. - JUCE_WEB_BROWSER=0 # If you remove this, add `NEEDS_WEB_BROWSER TRUE` to the `juce_add_gui_app` call - JUCE_USE_CURL=0 # If you remove this, add `NEEDS_CURL TRUE` to the `juce_add_gui_app` call - JUCE_APPLICATION_NAME_STRING="$" - JUCE_APPLICATION_VERSION_STRING="$") +target_compile_definitions(GuiAppExample + PRIVATE + # JUCE_WEB_BROWSER and JUCE_USE_CURL would be on by default, but you might not need them. + JUCE_WEB_BROWSER=0 # If you remove this, add `NEEDS_WEB_BROWSER TRUE` to the `juce_add_gui_app` call + JUCE_USE_CURL=0 # If you remove this, add `NEEDS_CURL TRUE` to the `juce_add_gui_app` call + JUCE_APPLICATION_NAME_STRING="$" + JUCE_APPLICATION_VERSION_STRING="$") # If your target needs extra binary assets, you can add them here. The first argument is the name of # a new static library target that will include all the binary resources. There is an optional @@ -90,6 +92,11 @@ target_compile_definitions(GuiAppExample PRIVATE # linked automatically. If we'd generated a binary data target above, we would need to link to it # here too. This is a standard CMake command. -target_link_libraries(GuiAppExample PRIVATE - # GuiAppData # If we'd created a binary data target, we'd link to it here - juce::juce_gui_extra) +target_link_libraries(GuiAppExample + PRIVATE + # GuiAppData # If we'd created a binary data target, we'd link to it here + juce::juce_gui_extra + PUBLIC + juce::juce_recommended_config_flags + juce::juce_recommended_lto_flags + juce::juce_recommended_warning_flags)