From afd044548fe0312d5f49df730115645256829ed8 Mon Sep 17 00:00:00 2001 From: Alexandros Liarokapis Date: Thu, 25 Jan 2024 00:10:11 +0200 Subject: [PATCH] Disable compiler runtime-test for cmake when cross-compiling to None platform. CMake implicitly runs a compiler test when it detects a new project. This normally compiles a minimal executable and runs it. When cross-compiling to a None platform this will fail for all CMake packages and the user is forced to override this manually through overlays. This commit changes Cmake's behavior when cross compiling so that it compiles a static library as a test instead. --- pkgs/build-support/lib/cmake.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkgs/build-support/lib/cmake.nix b/pkgs/build-support/lib/cmake.nix index 57fa586d3455..84c44619e9e2 100644 --- a/pkgs/build-support/lib/cmake.nix +++ b/pkgs/build-support/lib/cmake.nix @@ -20,11 +20,13 @@ let "-DCMAKE_HOST_SYSTEM_VERSION=${stdenv.buildPlatform.uname.release}" ] ++ optionals (stdenv.buildPlatform.canExecute stdenv.hostPlatform) [ "-DCMAKE_CROSSCOMPILING_EMULATOR=env" + ] ++ optionals (stdenv.hostPlatform.isNone) [ + "-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY" ] ++ optionals stdenv.hostPlatform.isStatic [ "-DCMAKE_LINK_SEARCH_START_STATIC=ON" ]); - makeCMakeFlags = { cmakeFlags ? [], ... }: cmakeFlags ++ cmakeFlags'; + makeCMakeFlags = { cmakeFlags ? [ ], ... }: cmakeFlags ++ cmakeFlags'; in {