Specifying different logos for different platforms with CMake

With a juce plugin target in CMake, what’s the right way to set different icons for different platforms? (e.g. one icon for macOS, a different one for Windows).

With the projucer, each platform had its own configuration for the icons.

With CMake, it seems just one ICON_BIG can be specified in juce_add_plugin which would take effect for all platforms. JUCE’s CMake documentation warns against changing this later via modifying the JUCE_ICON_BIG property directly.

If there’s no general way currently, then in my specific case I’m interested just in a different icon for macOS. CUSTOM_XCASSETS_FOLDER is documented to have an effect only on iOS. Or does it also have an effect on macOS?

Thanks,
Dan

2 Likes

I think the simplest way to do this would be to switch based on the target platform:

if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
  set(app_icon "/path/to/mac/icon.png")
elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
  set(app_icon "/path/to/win/icon.png")
else()
  set(app_icon "/path/to/generic/icon.png")
endif()

juce_add_gui_app(MyApp ICON_BIG "${app_icon}")

Would something like that work for you?

4 Likes

Perfect. Thanks @reuk!