Fix cross-compilation from Windows to Linux due to CPACK logic (#436)

When determining value for CPACK_PACKAGE_ARCHITECTURE, prefer to use
value from CMAKE_SYSTEM_PROCESSOR before falling back to uname output.

Additionally, if building from a Windows host, emit a fatal error
instead of attempting to call uname.

Fix By: Bobby Reynolds (@reynoldsbd)
pull/445/head
Bobby Reynolds 3 years ago committed by GitHub
parent 49f1b1a48d
commit 65d0d76b01
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      CMakeLists.txt

@ -689,6 +689,12 @@ IF (CARES_INSTALL)
if( ${CMAKE_SYSTEM_NAME} STREQUAL "Linux" )
if ( "${CPACK_PACKAGE_ARCHITECTURE}" STREQUAL "" )
set( CPACK_PACKAGE_ARCHITECTURE "${CMAKE_SYSTEM_PROCESSOR}" )
endif()
if ( "${CPACK_PACKAGE_ARCHITECTURE}" STREQUAL "" )
if ( "${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows" )
message( FATAL_ERROR "Failed to determine CPACK_PACKAGE_ARCHITECTURE. Is CMAKE_SYSTEM_PROCESSOR set?" )
endif()
# Note: the architecture should default to the local architecture, but it
# in fact comes up empty. We call `uname -m` to ask the kernel instead.
EXECUTE_PROCESS( COMMAND uname -m COMMAND tr -d '\n' OUTPUT_VARIABLE CPACK_PACKAGE_ARCHITECTURE )

Loading…
Cancel
Save