Skip to content

Commit

Permalink
Removed CMake warnings from blank plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
ypujante committed Nov 25, 2024
1 parent 2c61c5b commit 2522b89
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 71 deletions.
72 changes: 26 additions & 46 deletions blank-plugin/fetch_jamba.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down
51 changes: 26 additions & 25 deletions cmake/JambaFetchContent.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 2522b89

Please sign in to comment.