ridiculousfish / libdivide

Official git repository for libdivide: optimized integer division
http://libdivide.com
Other
1.09k stars 77 forks source link

CMake cross compilation error #59

Closed kimwalisch closed 4 years ago

kimwalisch commented 4 years ago

The following bug showed up when trying to package libdivide for Microsoft's vpkg package manager: https://github.com/microsoft/vcpkg/pull/8320.

CMake Error: TRY_RUN() invoked in cross-compiling mode, please set the following cache variables appropriately:
   cpu_x86_EXITCODE (advanced)
   cpu_x86_EXITCODE__TRYRUN_OUTPUT (advanced)
For details see C:/vsts/_work/2/s/buildtrees/libdivide/x64-uwp-rel/TryRunResults.cmake
-- Performing Test cpu_x86 - Failed
-- Performing Test march_native
-- Performing Test march_native - Failed
-- Performing Test avx512
CMake Error: TRY_RUN() invoked in cross-compiling mode, please set the following cache variables appropriately:
   avx512_EXITCODE (advanced)
   avx512_EXITCODE__TRYRUN_OUTPUT (advanced)

We always use try_run even for cross compilation. However on cross compilation try_run must not be used. I came across the same issue in primesieve and fixed the issue there by only running try_run when we are not cross compiling:


if(CMAKE_SYSTEM_NAME AND
   CMAKE_HOST_SYSTEM_NAME AND
   NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "${CMAKE_HOST_SYSTEM_NAME}")
    set(IS_CROSS_COMPILIATION ON)
endif()

if(CMAKE_SYSTEM_PROCESSOR AND
   CMAKE_HOST_SYSTEM_PROCESSOR AND
   NOT "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "${CMAKE_HOST_SYSTEM_PROCESSOR}")
    set(IS_CROSS_COMPILIATION ON)
endif()

if(NOT IS_CROSS_COMPILIATION)
    # ...
endif()
kimwalisch commented 4 years ago

Fixed.