Remove remnants of the old Android CMake toolchain

The PATH-related workarounds for the old third-party Android toolchain
don't seem to apply to the official NDK one, so just remove them. The
official one does define the ANDROID variable, but only in an
"android-legacy.toolchain.cmake". I think the standard way to do this is
CMAKE_SYSTEM_NAME so switch to that.

Change-Id: I3f3fa69d482893c333ae06f54ac39434c3c6a56c
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/65670
Reviewed-by: Bob Beck <bbe@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4c7926d..0639217 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -43,15 +43,7 @@
   endif()
 endfunction()
 
-if(ANDROID)
-  # Android-NDK CMake files reconfigure the path and so Perl won't be found.
-  # However, ninja will still find them in $PATH if we just name them.
-  if(NOT PERL_EXECUTABLE)
-    set(PERL_EXECUTABLE "perl")
-  endif()
-else()
-  find_package(Perl REQUIRED)
-endif()
+find_package(Perl REQUIRED)
 
 if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND NOT CMAKE_CROSSCOMPILING)
   find_package(PkgConfig QUIET)
diff --git a/cmake/go.cmake b/cmake/go.cmake
index 966ad32..51ecb45 100644
--- a/cmake/go.cmake
+++ b/cmake/go.cmake
@@ -1,13 +1,4 @@
-if(ANDROID)
-  # Android-NDK CMake files reconfigure the path and so Go won't be found.
-  # However, ninja will still find them in $PATH if we just name them.
-  if(NOT GO_EXECUTABLE)
-    set(GO_EXECUTABLE "go")
-  endif()
-else()
-  find_program(GO_EXECUTABLE go)
-endif()
-
+find_program(GO_EXECUTABLE go)
 if(NOT GO_EXECUTABLE)
   message(FATAL_ERROR "Could not find Go")
 endif()
diff --git a/crypto/CMakeLists.txt b/crypto/CMakeLists.txt
index 94327cc..3263e9e 100644
--- a/crypto/CMakeLists.txt
+++ b/crypto/CMakeLists.txt
@@ -345,8 +345,10 @@
 # CMAKE_SYSTEM_NAME is "Generic" for embedded OSes:
 # https://cmake.org/cmake/help/book/mastering-cmake/chapter/Cross%20Compiling%20With%20CMake.html#toolchain-files
 #
-# For now we assume embedded OSes do not have threads.
-if(NOT (ANDROID OR CMAKE_SYSTEM_NAME STREQUAL "Generic"))
+# For now we assume embedded OSes do not have threads. Additionally, the Threads
+# package does not work with Android, but Android does not require any extra
+# parameters to link pthreads.
+if(NOT CMAKE_SYSTEM_NAME MATCHES "^(Generic|Android)$")
   find_package(Threads REQUIRED)
   target_link_libraries(crypto Threads::Threads)
 endif()
diff --git a/util/generate_build_files.py b/util/generate_build_files.py
index 864febf..41d5a50 100644
--- a/util/generate_build_files.py
+++ b/util/generate_build_files.py
@@ -547,7 +547,7 @@
       self.PrintExe(cmake, 'bssl', files['tool'], ['ssl', 'crypto'])
 
       cmake.write(
-R'''if(NOT ANDROID)
+R'''if(NOT CMAKE_SYSTEM_NAME STREQUAL "Android")
   find_package(Threads REQUIRED)
   target_link_libraries(crypto Threads::Threads)
 endif()