Windows: lazy load wlanapi.dll

Appearently wlanapi.dll (which we use to borrow the wlan password
from the computer running Imager) is not always present on the
server editions of Windows, so only load it if it exists.

Ref #584
This commit is contained in:
Floris Bos 2023-05-21 17:22:17 +02:00
parent a7acd80908
commit bb8b097c7d
3 changed files with 45 additions and 4 deletions

View file

@ -8,8 +8,8 @@ OPTION (ENABLE_TELEMETRY "Enable sending telemetry" ON)
project(rpi-imager LANGUAGES CXX C)
set(IMAGER_VERSION_MAJOR 1)
set(IMAGER_VERSION_MINOR 7)
set(IMAGER_VERSION_STR "${IMAGER_VERSION_MAJOR}.${IMAGER_VERSION_MINOR}.4.1")
set(IMAGER_VERSION_CSV "${IMAGER_VERSION_MAJOR},${IMAGER_VERSION_MINOR},4,1")
set(IMAGER_VERSION_STR "${IMAGER_VERSION_MAJOR}.${IMAGER_VERSION_MINOR}.5")
set(IMAGER_VERSION_CSV "${IMAGER_VERSION_MAJOR},${IMAGER_VERSION_MINOR},5,0")
add_definitions(-DIMAGER_VERSION_STR="${IMAGER_VERSION_STR}")
add_definitions(-DIMAGER_VERSION_CSV=${IMAGER_VERSION_CSV})
set(CMAKE_INCLUDE_CURRENT_DIR ON)
@ -48,8 +48,15 @@ elseif (UNIX)
elseif (WIN32)
set(DEPENDENCIES acceleratedcryptographichash.cpp dependencies/mountutils/src/windows/functions.cpp dependencies/drivelist/src/windows/list.cpp
windows/winfile.cpp windows/winfile.h windows/winwlancredentials.h windows/winwlancredentials.cpp
windows/rpi-imager.rc)
set(EXTRALIBS setupapi wlanapi)
windows/rpi-imager.rc wlanapi_delayed.lib)
set(EXTRALIBS setupapi ${CMAKE_CURRENT_BINARY_DIR}/wlanapi_delayed.lib)
add_custom_command(
OUTPUT wlanapi_delayed.lib
COMMAND ${CMAKE_DLLTOOL} --input-def "${CMAKE_CURRENT_SOURCE_DIR}/windows/wlanapi.def"
--output-delaylib "wlanapi_delayed.lib" --dllname "wlanapi.dll"
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/windows/wlanapi.def
VERBATIM
)
endif()
include_directories(BEFORE .)