From b3041b44552f50109760e7fa41a16636e4b4d5c0 Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Tue, 16 Oct 2018 21:50:37 -0500 Subject: [PATCH] make-derivation: set CMAKE_SYSTEM_* when cross compiling Uses uname data to find what to set these variables: - CMAKE_SYSTEM_NAME - CMAKE_SYSTEM_PROCESSOR - CMAKE_SYSTEM_VERSION - CMAKE_HOST_SYSTEM_NAME - CMAKE_HOST_SYSTEM_PROCESSOR - CMAKE_HOST_SYSTEM_VERSION --- pkgs/stdenv/generic/make-derivation.nix | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pkgs/stdenv/generic/make-derivation.nix b/pkgs/stdenv/generic/make-derivation.nix index 2db40fc43e36..e06faed30a1e 100644 --- a/pkgs/stdenv/generic/make-derivation.nix +++ b/pkgs/stdenv/generic/make-derivation.nix @@ -41,6 +41,7 @@ rec { # Configure Phase , configureFlags ? [] + , cmakeFlags ? [] , # Target is not included by default because most programs don't care. # Including it then would cause needless mass rebuilds. # @@ -225,6 +226,17 @@ rec { inherit doCheck doInstallCheck; inherit outputs; + } // lib.optionalAttrs (stdenv.hostPlatform != stdenv.buildPlatform) { + cmakeFlags = + (/**/ if lib.isString cmakeFlags then [cmakeFlags] + else if cmakeFlags == null then [] + else cmakeFlags) + ++ lib.optional (stdenv.hostPlatform.uname.system != null) "-DCMAKE_SYSTEM_NAME=${stdenv.hostPlatform.uname.system}" + ++ lib.optional (stdenv.hostPlatform.uname.processor != null) "-DCMAKE_SYSTEM_PROCESSOR=${stdenv.hostPlatform.uname.processor}" + ++ lib.optional (stdenv.hostPlatform.uname.release != null) "-DCMAKE_SYSTEM_VERSION=${stdenv.hostPlatform.release}" + ++ lib.optional (stdenv.buildPlatform.uname.system != null) "-DCMAKE_HOST_SYSTEM_NAME=${stdenv.buildPlatform.uname.system}" + ++ lib.optional (stdenv.buildPlatform.uname.processor != null) "-DCMAKE_HOST_SYSTEM_PROCESSOR=${stdenv.buildPlatform.uname.processor}" + ++ lib.optional (stdenv.buildPlatform.uname.release != null) "-DCMAKE_HOST_SYSTEM_VERSION=${stdenv.buildPlatform.uname.release}"; } // lib.optionalAttrs (attrs.enableParallelBuilding or false) { enableParallelChecking = attrs.enableParallelChecking or true; } // lib.optionalAttrs (hardeningDisable != [] || hardeningEnable != []) {