fork/fish-shell
git clone https://git.julia.blue/fork/fish-shell
c5e4fed02
master
1#[=======================================================================[.rst: 2Imported from Corrosion https://github.com/corrosion-rs/corrosion/ 3 4Copyright (c) 2018 Andrew Gaspar 5 6Licensed under the MIT license 7 8However this is absolutely gutted and reduced to the bare minimum. 9#]=======================================================================] 10include ( FindPackageHandleStandardArgs ) 11 12cmake_minimum_required ( VERSION 3.12 ) 13 14# List of user variables that will override any toolchain-provided setting 15set ( _Rust_USER_VARS Rust_COMPILER Rust_CARGO Rust_CARGO_TARGET ) 16foreach ( _VAR${ _Rust_USER_VARS }) 17if ( DEFINED " ${ _VAR } " ) 18set ( $ { _VAR } _CACHED " ${ $ { _VAR }} " CACHE INTERNAL "Internal cache of ${ _VAR } " ) 19else () 20unset ( $ { _VAR } _CACHED CACHE ) 21endif () 22endforeach () 23 24if ( NOT DEFINED Rust_CARGO_CACHED) 25find_program ( Rust_CARGO_CACHED cargo PATHS " $ ENV { HOME } /.cargo/bin" ) 26endif () 27 28if ( NOT EXISTS " ${ Rust_CARGO_CACHED } " ) 29message ( FATAL_ERROR "The cargo executable ${ Rust_CARGO_CACHED } was not found. " 30"Consider setting `Rust_CARGO_CACHED` to the absolute path of `cargo`." 31) 32endif () 33 34if ( NOT DEFINED Rust_COMPILER_CACHED) 35find_program ( Rust_COMPILER_CACHED rustc PATHS " $ ENV { HOME } /.cargo/bin" ) 36endif () 37 38 39if ( NOT EXISTS " ${ Rust_COMPILER_CACHED } " ) 40message ( FATAL_ERROR "The rustc executable ${ Rust_COMPILER } was not found. " 41"Consider setting `Rust_COMPILER` to the absolute path of `rustc`." 42) 43endif () 44 45# Figure out the target by just using the host target. 46# If you want to cross-compile, you'll have to set Rust_CARGO_TARGET 47if ( NOT Rust_CARGO_TARGET_CACHED) 48execute_process ( 49COMMAND " ${ Rust_COMPILER_CACHED } " --version --verbose 50OUTPUT_VARIABLE _RUSTC_VERSION_RAW 51RESULT_VARIABLE _RUSTC_VERSION_RESULT 52) 53 54if ( NOT ( " ${ _RUSTC_VERSION_RESULT } " EQUAL "0" )) 55message ( FATAL_ERROR "Failed to get rustc version.\n" 56" ${ Rust_COMPILER } --version failed with error: ` ${ _RUSTC_VERSION_RESULT } `" ) 57endif () 58 59if ( _RUSTC_VERSION_RAWMATCHES "host: ([a-zA-Z0-9_\\-]*)\n" ) 60set ( Rust_DEFAULT_HOST_TARGET " ${ CMAKE_MATCH_1 } " ) 61else () 62message ( FATAL_ERROR 63"Failed to parse rustc host target. `rustc --version --verbose` evaluated to:\n ${ _RUSTC_VERSION_RAW } " 64) 65endif () 66 67if ( CMAKE_CROSSCOMPILING) 68message ( FATAL_ERROR "CMake is in cross-compiling mode." 69"Manually set `Rust_CARGO_TARGET`." 70) 71endif () 72set ( Rust_CARGO_TARGET_CACHED " ${ Rust_DEFAULT_HOST_TARGET } " CACHE STRING "Target triple" ) 73endif () 74 75# Set the input variables as non-cache variables so that the variables are available after 76# `find_package`, even if the values were evaluated to defaults. 77foreach ( _VAR${ _Rust_USER_VARS }) 78set ( $ { _VAR } " ${ $ { _VAR } _CACHED } " ) 79# Ensure cached variables have type INTERNAL 80set ( $ { _VAR } _CACHED " ${ $ { _VAR } _CACHED } " CACHE INTERNAL "Internal cache of ${ _VAR } " ) 81endforeach () 82 83find_package_handle_standard_args ( 84Rust 85REQUIRED_VARS Rust_COMPILER Rust_CARGO Rust_CARGO_TARGET 86) 87