Fix multiple usages of nuget_add_...
This commit is contained in:
parent
545f6bf2ce
commit
52d7dc3993
1 changed files with 15 additions and 9 deletions
24
nuget.cmake
24
nuget.cmake
|
|
@ -5,24 +5,27 @@
|
||||||
# https://github.com/desktop-app/legal/blob/master/LEGAL
|
# https://github.com/desktop-app/legal/blob/master/LEGAL
|
||||||
|
|
||||||
function(nuget_add_package package_name package package_version)
|
function(nuget_add_package package_name package package_version)
|
||||||
if (NOT DEFINED NUGET_EXE_PATH)
|
get_property(nuget_exe_defined GLOBAL PROPERTY nuget_exe_path_property SET)
|
||||||
|
if (NOT nuget_exe_defined)
|
||||||
# Thanks https://github.com/clarkezone/flutter_win_webview/blob/master/webview_popupauth/windows/CMakeLists.txt
|
# Thanks https://github.com/clarkezone/flutter_win_webview/blob/master/webview_popupauth/windows/CMakeLists.txt
|
||||||
find_program(NUGET_EXE NAMES nuget)
|
find_program(NUGET_EXE NAMES nuget)
|
||||||
if (NOT NUGET_EXE)
|
if (NOT NUGET_EXE)
|
||||||
message("NUGET.EXE not found.")
|
message("NUGET.EXE not found.")
|
||||||
message(FATAL_ERROR "Please install this executable, and run CMake again.")
|
message(FATAL_ERROR "Please install this executable, and run CMake again.")
|
||||||
endif()
|
endif()
|
||||||
set(NUGET_EXE_PATH ${NUGET_EXE} PARENT_SCOPE)
|
message("Resolved NuGet executable: ${NUGET_EXE}")
|
||||||
|
set_property(GLOBAL PROPERTY nuget_exe_path_property ${NUGET_EXE})
|
||||||
else()
|
else()
|
||||||
set(NUGET_EXE ${NUGET_EXE_PATH})
|
get_property(NUGET_EXE GLOBAL PROPERTY nuget_exe_path_property)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(package_key NUGET_${package_name}_VERSION)
|
set(package_key nuget_${package_name}_version_property)
|
||||||
if (NOT DEFINED ${package_key})
|
get_property(package_version_defined GLOBAL PROPERTY ${package_key} SET)
|
||||||
|
if (NOT package_version_defined)
|
||||||
set(packages_loc ${CMAKE_BINARY_DIR}/packages)
|
set(packages_loc ${CMAKE_BINARY_DIR}/packages)
|
||||||
file(MAKE_DIRECTORY ${packages_loc})
|
file(MAKE_DIRECTORY ${packages_loc})
|
||||||
|
|
||||||
set(${package_key} ${package_version})
|
set_property(GLOBAL PROPERTY ${package_key} ${package_version})
|
||||||
execute_process(
|
execute_process(
|
||||||
COMMAND
|
COMMAND
|
||||||
${NUGET_EXE}
|
${NUGET_EXE}
|
||||||
|
|
@ -32,10 +35,13 @@ function(nuget_add_package package_name package package_version)
|
||||||
-ExcludeVersion
|
-ExcludeVersion
|
||||||
-OutputDirectory ${packages_loc}
|
-OutputDirectory ${packages_loc}
|
||||||
)
|
)
|
||||||
set(${package_name}_loc ${CMAKE_BINARY_DIR}/packages/${package} PARENT_SCOPE)
|
else()
|
||||||
elseif ("${${package_key}}" != ${package_version})
|
get_property(package_version_cached GLOBAL PROPERTY ${package_key})
|
||||||
message(FATAL_ERROR "Package ${package_name} requested with both ${${package_key}} and ${package_version}")
|
if (NOT (${package_version_cached} EQUAL ${package_version}))
|
||||||
|
message(FATAL_ERROR "Package ${package_name} requested with both ${package_version_cached} and ${package_version}")
|
||||||
endif()
|
endif()
|
||||||
|
endif()
|
||||||
|
set(${package_name}_loc ${CMAKE_BINARY_DIR}/packages/${package} PARENT_SCOPE)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
function(nuget_add_webview target_name)
|
function(nuget_add_webview target_name)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue