From 2522b898804dd3b451b0570c891abbdc3f7cc673 Mon Sep 17 00:00:00 2001 From: Yan Pujante Date: Mon, 25 Nov 2024 10:50:02 -0800 Subject: [PATCH] Removed CMake warnings from blank plugin --- blank-plugin/fetch_jamba.cmake | 72 ++++++++++++---------------------- cmake/JambaFetchContent.cmake | 51 ++++++++++++------------ 2 files changed, 52 insertions(+), 71 deletions(-) diff --git a/blank-plugin/fetch_jamba.cmake b/blank-plugin/fetch_jamba.cmake index 9a0b453..a386c7b 100644 --- a/blank-plugin/fetch_jamba.cmake +++ b/blank-plugin/fetch_jamba.cmake @@ -2,61 +2,41 @@ cmake_minimum_required(VERSION 3.19) include(FetchContent) -if(JAMBA_ROOT_DIR) - # instructs FetchContent to not download or update but use the location instead - set(FETCHCONTENT_SOURCE_DIR_JAMBA ${JAMBA_ROOT_DIR}) -else() - set(FETCHCONTENT_SOURCE_DIR_JAMBA "") -endif() - set(JAMBA_GIT_REPO "https://github.com/pongasoft/jamba" CACHE STRING "Jamba git repository url") set(JAMBA_GIT_TAG [-jamba_git_hash-] CACHE STRING "Jamba git tag") set(JAMBA_DOWNLOAD_URL "${JAMBA_GIT_REPO}/archive/refs/tags/[-jamba_git_hash-].zip" CACHE STRING "Jamba download url") set(JAMBA_DOWNLOAD_URL_HASH "[-jamba_download_url_hash-]" CACHE STRING "Jamba download url hash") -if(JAMBA_DOWNLOAD_URL STREQUAL "" OR JAMBA_DOWNLOAD_URL_HASH STREQUAL "") - FetchContent_Declare(jamba - GIT_REPOSITORY ${JAMBA_GIT_REPO} - GIT_TAG ${JAMBA_GIT_TAG} - GIT_CONFIG advice.detachedHead=false - GIT_SHALLOW true - SOURCE_DIR "${CMAKE_BINARY_DIR}/jamba" +if(JAMBA_ROOT_DIR) + message(STATUS "Using jamba from local ${JAMBA_ROOT_DIR}") + FetchContent_Populate(jamba + QUIET + SOURCE_DIR "${JAMBA_ROOT_DIR}" BINARY_DIR "${CMAKE_BINARY_DIR}/jamba-build" - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - INSTALL_COMMAND "" - TEST_COMMAND "" - ) - set(JAMBA_FETCH_SOURCE "${JAMBA_GIT_REPO}/tree/${JAMBA_GIT_TAG}") + ) else() - FetchContent_Declare(jamba - URL "${JAMBA_DOWNLOAD_URL}" - URL_HASH "${JAMBA_DOWNLOAD_URL_HASH}" - DOWNLOAD_EXTRACT_TIMESTAMP true - SOURCE_DIR "${CMAKE_BINARY_DIR}/jamba" - BINARY_DIR "${CMAKE_BINARY_DIR}/jamba-build" - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - INSTALL_COMMAND "" - TEST_COMMAND "" - ) - set(JAMBA_FETCH_SOURCE "${JAMBA_DOWNLOAD_URL}") -endif() - - - -FetchContent_GetProperties(jamba) - -if(NOT jamba_POPULATED) - - if(FETCHCONTENT_SOURCE_DIR_JAMBA) - message(STATUS "Using jamba from local ${FETCHCONTENT_SOURCE_DIR_JAMBA}") + if(JAMBA_DOWNLOAD_URL STREQUAL "" OR JAMBA_DOWNLOAD_URL_HASH STREQUAL "") + message(STATUS "Fetching jamba from ${JAMBA_GIT_REPO}/tree/${JAMBA_GIT_TAG}") + FetchContent_Populate(jamba + QUIET + GIT_REPOSITORY ${JAMBA_GIT_REPO} + GIT_TAG ${JAMBA_GIT_TAG} + GIT_CONFIG advice.detachedHead=false + GIT_SHALLOW true + SOURCE_DIR "${CMAKE_BINARY_DIR}/jamba" + BINARY_DIR "${CMAKE_BINARY_DIR}/jamba-build" + ) else() - message(STATUS "Fetching jamba from ${JAMBA_FETCH_SOURCE}") + message(STATUS "Fetching jamba from ${JAMBA_DOWNLOAD_URL}") + FetchContent_Populate(jamba + QUIET + URL "${JAMBA_DOWNLOAD_URL}" + URL_HASH "${JAMBA_DOWNLOAD_URL_HASH}" + DOWNLOAD_EXTRACT_TIMESTAMP true + SOURCE_DIR "${CMAKE_BINARY_DIR}/jamba" + BINARY_DIR "${CMAKE_BINARY_DIR}/jamba-build" + ) endif() - - FetchContent_Populate(jamba) - endif() set(JAMBA_ROOT_DIR ${jamba_SOURCE_DIR}) diff --git a/cmake/JambaFetchContent.cmake b/cmake/JambaFetchContent.cmake index bed5061..b56a3cd 100644 --- a/cmake/JambaFetchContent.cmake +++ b/cmake/JambaFetchContent.cmake @@ -52,35 +52,36 @@ function(jamba_fetch_content) string(TOUPPER "${ARG_NAME}" UPPERCASE_NAME) - set(FETCHCONTENT_SOURCE_DIR_${UPPERCASE_NAME} ${ARG_ROOT_DIR}) - - if(ARG_DOWNLOAD_URL) - FetchContent_Populate( ${ARG_NAME} - QUIET - URL "${ARG_DOWNLOAD_URL}" - URL_HASH "${ARG_DOWNLOAD_URL_HASH}" - SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/${ARG_NAME}-src" - BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/${ARG_NAME}-build" - DOWNLOAD_EXTRACT_TIMESTAMP true - ) - set(FETCH_SOURCE "${ARG_DOWNLOAD_URL}") - else() + if(ARG_ROOT_DIR) + message(STATUS "Using ${ARG_NAME} from local ${ARG_ROOT_DIR}") FetchContent_Populate(${ARG_NAME} QUIET - GIT_REPOSITORY ${ARG_GIT_REPO} - GIT_TAG ${ARG_GIT_TAG} - GIT_CONFIG advice.detachedHead=false - GIT_SHALLOW true - SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/${ARG_NAME}-src" + SOURCE_DIR "${ARG_ROOT_DIR}" BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/${ARG_NAME}-build" - ) - set(FETCH_SOURCE "${ARG_GIT_REPO}/tree/${ARG_GIT_TAG}") - endif() - - if(FETCHCONTENT_SOURCE_DIR_${UPPERCASE_NAME}) - message(STATUS "Using ${ARG_NAME} from local ${FETCHCONTENT_SOURCE_DIR_${UPPERCASE_NAME}}") + ) else() - message(STATUS "Fetching ${ARG_NAME} from ${FETCH_SOURCE}") + if(ARG_DOWNLOAD_URL) + message(STATUS "Fetching ${ARG_NAME} from ${ARG_DOWNLOAD_URL}") + FetchContent_Populate( ${ARG_NAME} + QUIET + URL "${ARG_DOWNLOAD_URL}" + URL_HASH "${ARG_DOWNLOAD_URL_HASH}" + SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/${ARG_NAME}-src" + BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/${ARG_NAME}-build" + DOWNLOAD_EXTRACT_TIMESTAMP true + ) + else() + message(STATUS "Fetching ${ARG_NAME} from ${ARG_GIT_REPO}/tree/${ARG_GIT_TAG}") + FetchContent_Populate(${ARG_NAME} + QUIET + GIT_REPOSITORY ${ARG_GIT_REPO} + GIT_TAG ${ARG_GIT_TAG} + GIT_CONFIG advice.detachedHead=false + GIT_SHALLOW true + SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/${ARG_NAME}-src" + BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/${ARG_NAME}-build" + ) + endif() endif() set(${ARG_NAME}_ROOT_DIR "${${ARG_NAME}_SOURCE_DIR}" PARENT_SCOPE)