Skip to content

Commit

Permalink
w
Browse files Browse the repository at this point in the history
  • Loading branch information
segoon committed Nov 8, 2024
1 parent 2695562 commit a2fa690
Showing 1 changed file with 25 additions and 11 deletions.
36 changes: 25 additions & 11 deletions cmake/DownloadUserver.cmake
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
include(FetchContent)
# Copied from get_cpm.cmake
set(CPM_DOWNLOAD_VERSION 0.39.0)
set(CPM_HASH_SUM "66639bcac9dd2907b2918de466783554c1334446b9874e90d38e3778d404c2ef")
set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
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})


function(download_userver)
set(OPTIONS)
set(ONE_VALUE_ARGS VERSION)
set(ONE_VALUE_ARGS VERSION TRY_DIR)
set(MULTI_VALUE_ARGS FEATURES FEATURES_OFF)
cmake_parse_arguments(
ARG "${OPTIONS}" "${ONE_VALUE_ARGS}" "${MULTI_VALUE_ARGS}" ${ARGN}
Expand All @@ -11,18 +20,23 @@ function(download_userver)
set(ARG_VERSION develop)
endif()

set(FETCHCONTENT_QUIET OFF CACHE BOOL "" FORCE)
FetchContent_Declare(
userver
GIT_REPOSITORY https://github.com/userver-framework/userver.git
GIT_TAG ${ARG_VERSION}
)
FetchContent_MakeAvailable(userver)
if(ARG_TRY_DIR AND EXISTS ${ARG_TRY_DIR})
add_subdirectory(${ARG_TRY_DIR})
return()
endif()

set(CMAKE_OPTIONS)
foreach(FEATURE ${ARG_FEATURES})
set(USERVER_FEATURE_${FEATURE} ON CACHE BOOL "" FORCE)
list(APPEND CMAKE_OPTIONS "USERVER_FEATURE_${FEATURE} ON")
endforeach()
foreach(FEATURE ${ARG_FEATURES_OFF})
set(USERVER_FEATURE_${FEATURE} OFF CACHE BOOL "" FORCE)
list(APPEND CMAKE_OPTIONS "USERVER_FEATURE_${FEATURE} OFF")
endforeach()

CPMAddPackage(
NAME userver
GITHUB_REPOSITORY userver-framework/userver
GIT_TAG ${ARG_VERSION}
OPTIONS ${CMAKE_OPTIONS}
)
endfunction()

0 comments on commit a2fa690

Please sign in to comment.