Skip to content

CMake cross compilation error #59

Closed
@kimwalisch

Description

@kimwalisch

The following bug showed up when trying to package libdivide for Microsoft's vpkg package manager: microsoft/vcpkg#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()

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions