diff options
author | Peter Powell <petpow@saberuk.com> | 2015-02-18 15:16:40 +0000 |
---|---|---|
committer | Peter Powell <petpow@saberuk.com> | 2015-02-18 15:16:40 +0000 |
commit | 4e9af81504de220aee3fc41df9e405faa1b92738 (patch) | |
tree | 7d41b62cfd7f520abcd6d6c1e0e0747e25453eb6 /make/configure.pm | |
parent | 9b99c5ad31eb8de222d2b3aa1daa9412f0b25857 (diff) |
Improve compiler detection in configure.
- Split the detection and compatibility checks into two different
steps (previously it was confusing as it would say the compiler
was not available when it was really not compatible).
- Fix a minor bug where compilers detected using xcrun on Darwin
would not have xcrun returned as part of the compiler name from
find_compiler.
Diffstat (limited to 'make/configure.pm')
-rw-r--r-- | make/configure.pm | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/make/configure.pm b/make/configure.pm index 8653edaac..a89e139c9 100644 --- a/make/configure.pm +++ b/make/configure.pm @@ -93,6 +93,13 @@ sub __get_template_settings($$$) { return %settings; } +sub __test_compiler($) { + my $compiler = shift; + return 0 unless run_test("`$compiler`", !system "$compiler -v >/dev/null 2>&1"); + return 0 unless run_test("`$compiler`", test_file($compiler, 'compiler.cpp'), 'compatible'); + return 1; +} + sub cmd_clean { unlink CONFIGURE_CACHE_FILE; } @@ -177,9 +184,10 @@ sub cmd_update { exit 0; } -sub run_test($$) { - my ($what, $result) = @_; - print_format "Checking whether <|GREEN $what|> is available ... "; +sub run_test($$;$) { + my ($what, $result, $adjective) = @_; + $adjective ||= 'available'; + print_format "Checking whether <|GREEN $what|> is $adjective ... "; print_format $result ? "<|GREEN yes|>\n" : "<|RED no|>\n"; return $result; } @@ -244,10 +252,8 @@ sub get_compiler_info($) { sub find_compiler { my @compilers = qw(c++ g++ clang++ icpc); foreach my $compiler (shift || @compilers) { - return $compiler if run_test "`$compiler`", test_file $compiler, 'compiler.cpp'; - if ($^O eq 'darwin') { - return $compiler if run_test "`xcrun $compiler`", test_file "xcrun $compiler", 'compiler.cpp'; - } + return $compiler if __test_compiler $compiler; + return "xcrun $compiler" if $^O eq 'darwin' && __test_compiler "xcrun $compiler"; } } |