diff options
author | João Valverde <j@v6e.pt> | 2021-09-20 14:14:03 +0100 |
---|---|---|
committer | João Valverde <j@v6e.pt> | 2021-09-20 15:11:52 +0100 |
commit | bb12a187df01c3789fae3c1a1d07e3bf9837e5e1 (patch) | |
tree | 16e22fd80e736e5faaf093cef90810ec9b3d711a /CMakeLists.txt | |
parent | 8726c652674a5f8f8e2d45abc7205b9ad054f69f (diff) |
CMake: Add guards for PLATFORM sanity check
The sanity check is specific for Visual Studio so add those
guards. The PLATFORM variable is not standard for other toolchains.
Add a default "windows target platform" of Win64.
Add error output for win-setup.ps1.
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 7b9acd8340..990b5dcea7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -93,8 +93,11 @@ if(WIN32) set(WIRESHARK_TARGET_PLATFORM win64) elseif(CMAKE_GENERATOR MATCHES "Visual Studio") set(WIRESHARK_TARGET_PLATFORM win32) - else() + elseif(DEFINED ENV{WIRESHARK_TARGET_PLATFORM}) set(WIRESHARK_TARGET_PLATFORM $ENV{WIRESHARK_TARGET_PLATFORM}) + else() + message(WARNING "Assuming \"Win64\" target platform") + set(WIRESHARK_TARGET_PLATFORM win64) endif() if(WIRESHARK_TARGET_PLATFORM MATCHES "win64") @@ -104,18 +107,20 @@ if(WIN32) endif() # Sanity check - if(DEFINED ENV{PLATFORM}) - string(TOLOWER $ENV{PLATFORM} _vs_platform) - else() - set(_vs_platform "[undefined]") # x86 - endif() - if( - (_vs_platform STREQUAL "x64" AND NOT WIRESHARK_TARGET_PLATFORM STREQUAL "win64") - OR - (_vs_platform STREQUAL "[undefined]" AND NOT WIRESHARK_TARGET_PLATFORM STREQUAL "win32") - ) - message(FATAL_ERROR "The PLATFORM environment variable (${_vs_platform})" - " doesn't match the generator platform (${WIRESHARK_TARGET_PLATFORM})") + if(MSVC) + if(DEFINED ENV{PLATFORM}) + string(TOLOWER $ENV{PLATFORM} _vs_platform) + else() + set(_vs_platform "[undefined]") # x86 + endif() + if( + (_vs_platform STREQUAL "x64" AND NOT WIRESHARK_TARGET_PLATFORM STREQUAL "win64") + OR + (_vs_platform STREQUAL "[undefined]" AND NOT WIRESHARK_TARGET_PLATFORM STREQUAL "win32") + ) + message(FATAL_ERROR "The PLATFORM environment variable (${_vs_platform})" + " doesn't match the generator platform (${WIRESHARK_TARGET_PLATFORM})") + endif() endif() message(STATUS "Building for ${WIRESHARK_TARGET_PLATFORM} using ${CMAKE_GENERATOR}") @@ -141,9 +146,10 @@ if(WIN32) execute_process( COMMAND ${POWERSHELL_COMMAND} "\"${_win_setup}\"" -Destination "${_ws_lib_dir}" -Platform ${WIRESHARK_TARGET_PLATFORM} RESULT_VARIABLE _win_setup_failed + ERROR_VARIABLE _win_setup_error_output ) if(_win_setup_failed) - message(FATAL_ERROR "Windows setup (win-setup.ps1) failed.") + message(FATAL_ERROR "Windows setup (win-setup.ps1) failed: ${_win_setup_error_output}.") endif() set(EXTRA_INSTALLER_DIR ${_ws_lib_dir}) |