Skip to content

Commit

Permalink
Merge pull request #32 from sudara/cpm
Browse files Browse the repository at this point in the history
Move dependencies to CPM for a better offline experience
  • Loading branch information
sudara authored Dec 5, 2024
2 parents 1fdceed + b54f4a9 commit e737307
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 21 deletions.
27 changes: 6 additions & 21 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,26 +1,18 @@
cmake_minimum_required(VERSION 3.24 FATAL_ERROR)

project(MelatoninPerfetto
VERSION 1.0.0
VERSION 1.1.0
LANGUAGES CXX
DESCRIPTION "JUCE module for profiling with Perfetto"
HOMEPAGE_URL "https://github.com/sudara/melatonin_perfetto")

set(missing_juce_error_message "JUCE must be added to your project before melatonin_perfetto!")

include(FetchContent)
include(cmake/CPM.cmake)

if (MelatoninPerfetto_IS_TOP_LEVEL)
message (STATUS "Cloning JUCE...")

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

FetchContent_MakeAvailable(JUCE)
message (STATUS "Grabbing JUCE...")
CPMAddPackage("gh:juce-framework/JUCE#master")
endif ()

if (NOT COMMAND juce_add_module)
Expand All @@ -33,15 +25,8 @@ set(MP_INSTALL_DEST "${CMAKE_INSTALL_LIBDIR}/cmake/melatonin_perfetto"
CACHE STRING
"Path below the install prefix where melatonin_perfetto package files will be installed to")

message (STATUS "Cloning Perfetto...")

FetchContent_Declare(Perfetto
GIT_REPOSITORY https://android.googlesource.com/platform/external/perfetto
GIT_TAG v41.0
GIT_SHALLOW TRUE
GIT_PROGRESS TRUE)

FetchContent_MakeAvailable(Perfetto)
message (STATUS "Grabbing Perfetto...")
CPMAddPackage(gh:google/perfetto@48.1)

# we need to manually set up a target for Perfetto
add_library(perfetto STATIC)
Expand Down
24 changes: 24 additions & 0 deletions cmake/CPM.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# SPDX-License-Identifier: MIT
#
# SPDX-FileCopyrightText: Copyright (c) 2019-2023 Lars Melchior and contributors

set(CPM_DOWNLOAD_VERSION 0.40.2)
set(CPM_HASH_SUM "c8cdc32c03816538ce22781ed72964dc864b2a34a310d3b7104812a5ca2d835d")

if(CPM_SOURCE_CACHE)
set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
elseif(DEFINED ENV{CPM_SOURCE_CACHE})
set(CPM_DOWNLOAD_LOCATION "$ENV{CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
else()
set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
endif()

# Expand relative path. This is important if the provided path contains a tilde (~)
get_filename_component(CPM_DOWNLOAD_LOCATION ${CPM_DOWNLOAD_LOCATION} ABSOLUTE)

file(DOWNLOAD
https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake
${CPM_DOWNLOAD_LOCATION} EXPECTED_HASH SHA256=${CPM_HASH_SUM}
)

include(${CPM_DOWNLOAD_LOCATION})

0 comments on commit e737307

Please sign in to comment.