Skip to content

Commit

Permalink
Merge pull request #122 from sudara/juce7
Browse files Browse the repository at this point in the history
JUCE 7 support in CI
  • Loading branch information
sudara authored Jul 31, 2024
2 parents a8131a4 + 528771a commit b03a1b0
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 16 deletions.
39 changes: 34 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
- next

env:
CMAKE_BUILD_PARALLEL_LEVEL: 3 # Use up to 3 cpus to build juceaide, etc
SCCACHE_GHA_ENABLED: "true"

concurrency:
group: ${{ github.workflow }}.${{ github.ref }}
Expand All @@ -34,18 +34,32 @@ jobs:
matrix:
app: [ member_enabled, member_disabled, unique_ptr_enabled, unique_ptr_disabled ]
os: [ macos-14, windows-2022, ubuntu-latest ]
juce: [ JUCE7, JUCE8 ]

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Use dev command prompt (Windows)
uses: ilammy/msvc-dev-cmd@v1
with:
sdk: 10.0.22621.0 # fixed to break random CI breakage

- name: Install Ninja (Windows)
if: runner.os == 'Windows'
run: choco install ninja

- name: Install macOS Deps
if: ${{ runner.os == 'macOS' }}
run: brew install ninja osxutils

- name: Install Linux Deps
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt install libasound2-dev libx11-dev libxcomposite-dev libxcursor-dev libxext-dev libxinerama-dev libxrandr-dev libxrender-dev libfreetype6-dev libglu1-mesa-dev libjack-jackd2-dev
sudo apt install libasound2-dev libx11-dev libxcomposite-dev libxcursor-dev libxext-dev libxinerama-dev libxrandr-dev libxrender-dev libfreetype6-dev libglu1-mesa-dev libjack-jackd2-dev ninja-build
# This block can be removed once 15.1 is default (JUCE requires it when building on macOS 14)
- name: Use latest Xcode on system (macOS)
Expand All @@ -55,10 +69,25 @@ jobs:
xcode-version: latest-stable

- name: Run sccache-cache
uses: mozilla-actions/[email protected].4
uses: mozilla-actions/[email protected].5

- name: Configure
run: cmake -B Builds -DTARGET_NAME:STRING=${{ matrix.app }}
- name: Configure (Windows without Ninja)
if: runner.os == 'Windows'
run: |
if [ "${{ matrix.juce }}" == "JUCE7" ]; then
cmake -B Builds -DTARGET_NAME:STRING=${{ matrix.app }} -DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache . -DJUCE7=ON
else
cmake -B Builds -DTARGET_NAME:STRING=${{ matrix.app }} -DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache .
fi
- name: Configure (Non-Windows with Ninja)
if: runner.os != 'Windows'
run: |
if [ "${{ matrix.juce }}" == "JUCE7" ]; then
cmake -B Builds -G Ninja -DTARGET_NAME:STRING=${{ matrix.app }} -DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache . -DJUCE7=ON
else
cmake -B Builds -G Ninja -DTARGET_NAME:STRING=${{ matrix.app }} -DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache .
fi
- name: Build
run: cmake --build Builds --parallel 4
Expand Down
41 changes: 31 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,35 +1,56 @@
cmake_minimum_required(VERSION 3.20)

project(MelatoninInspector VERSION 1.3.0 LANGUAGES CXX
DESCRIPTION "JUCE module for inspecting Components"
HOMEPAGE_URL "https://github.com/sudara/melatonin_inspector")
DESCRIPTION "JUCE module for inspecting Components"
HOMEPAGE_URL "https://github.com/sudara/melatonin_inspector")

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED YES)

include(FetchContent)
if (MelatoninInspector_IS_TOP_LEVEL)
option(JUCE7 "Run tests on JUCE 7" OFF)

message(STATUS "Cloning JUCE...")
if (JUCE7)
FetchContent_Declare(JUCE
GIT_REPOSITORY https://github.com/juce-framework/JUCE.git
GIT_TAG 7.0.12
GIT_PROGRESS TRUE
)
else ()

FetchContent_Declare(JUCE
FetchContent_Declare(JUCE
GIT_REPOSITORY https://github.com/juce-framework/JUCE.git
GIT_TAG origin/master
GIT_SHALLOW TRUE
GIT_TAG develop
GIT_PROGRESS TRUE
FIND_PACKAGE_ARGS 7.0.6)
)
endif ()

FetchContent_MakeAvailable(JUCE)

SET(TARGET_NAME "unique_ptr_disabled" CACHE STRING "Name of cpp and target to compile")

juce_add_gui_app ("${TARGET_NAME}" VERSION 1.0.0)
juce_add_gui_app("${TARGET_NAME}" VERSION 1.0.0)
target_sources("${TARGET_NAME}" PRIVATE "tests/${TARGET_NAME}.cpp")

target_compile_definitions("${TARGET_NAME}" PUBLIC
JUCE_USE_CURL=0
JUCE_WEB_BROWSER=0
)

# Windows errors due to sccache issues
# see https://github.com/mozilla/sccache/pull/963/files
if (MSVC)
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
string(REPLACE "/Zi" "/Z7" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
string(REPLACE "/MP" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
elseif (CMAKE_BUILD_TYPE STREQUAL "Release")
string(REPLACE "/Zi" "/Z7" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
string(REPLACE "/MP" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
endif ()
endif ()

set_target_properties("${TARGET_NAME}" PROPERTIES COMPILE_WARNING_AS_ERROR ON)

endif ()
Expand All @@ -44,9 +65,9 @@ add_library(Melatonin::Inspector ALIAS melatonin_inspector)

if (MelatoninInspector_IS_TOP_LEVEL)
target_link_libraries("${TARGET_NAME}" PRIVATE melatonin_inspector
juce::juce_recommended_config_flags
juce::juce_recommended_lto_flags
juce::juce_recommended_warning_flags)
juce::juce_recommended_config_flags
juce::juce_recommended_lto_flags
juce::juce_recommended_warning_flags)
endif ()

# Assets are precompiled in the module to make it Projucer friendly
Expand Down
2 changes: 1 addition & 1 deletion melatonin/lookandfeel.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ namespace melatonin
#if JUCE_MAJOR_VERSION == 8
juce::Font testFont = juce::FontOptions { "Verdana", 12, juce::Font::FontStyleFlags::plain };
#else
juce::Font testFont = { "Verdana", 12, juce::Font::FontStyleFlags::plain }
juce::Font testFont = { "Verdana", 12, juce::Font::FontStyleFlags::plain };
#endif
if (juce::Typeface::createSystemTypefaceFor (testFont)) {
inspectorFont = "Verdana";
Expand Down

0 comments on commit b03a1b0

Please sign in to comment.