gollvm: extract goarch/goos settings into separate module

Separate out the cmake code that sets up goarch/goos from other libgo
config-related setup, placing it into a new module (will make it
easier to reuse in gotools).

Change-Id: I11d6dd89a88fd2ae74c46c2f019650ded6c87bd9
Reviewed-on: https://go-review.googlesource.com/92706
Reviewed-by: Cherry Zhang <cherryyz@google.com>
diff --git a/cmake/ConfigSetup.cmake b/cmake/ConfigSetup.cmake
index 7f099a5..0622883 100644
--- a/cmake/ConfigSetup.cmake
+++ b/cmake/ConfigSetup.cmake
@@ -1,27 +1,5 @@
 
-# Set goarch/goos based on what we see in the LLVM triple.
-string(REGEX REPLACE "-" " " lht_components ${LLVM_DEFAULT_TARGET_TRIPLE})
-separate_arguments(lht_components)
-list(GET lht_components 0 goarch)
-list(GET lht_components 2 goos)
-
-# LLVM's "x86_64" is the same as Go's "amd64".
-if( ${goarch} STREQUAL "x86_64" )
-  set(goarch "amd64")
-endif()
-
-# List of all architectures, families, os flavors.
-set(allgoarch "386" "alpha" "amd64" "amd64p32" "arm" "armbe" "arm64" "arm64be" "ia64" "m68k" "mips" "mipsle" "mips64" "mips64le" "mips64p32" "mips64p32le" "ppc" "ppc64" "ppc64le" "s390" "s390x" "sparc" "sparc64")
-set(allgoarchfamily "I386" "ALPHA" "AMD64" "ARM" "ARM64" "IA64" "M68K" "MIPS" "MIPS64" "PPC" "PPC64" "S390" "S390X" "SPARC" "SPARC64")
-set(allgoos "aix" "android" "darwin" "dragonfly" "freebsd" "irix" "linux" "netbsd" "openbsd" "plan9" "rtems" "solaris" "windows")
-
-# FIXME: write code to insure that this is set and that the shell
-# in question behaves properly.
-set(shell $ENV{SHELL})
-
-# FIXME: write cmake to discover awk, test to make sure it works
-set(awk "/usr/bin/awk")
-
+# Small atomic test case.
 set(atomicstuff "
 int i;
 int main () {
diff --git a/cmake/GoVars.cmake b/cmake/GoVars.cmake
new file mode 100644
index 0000000..4fa05a1
--- /dev/null
+++ b/cmake/GoVars.cmake
@@ -0,0 +1,24 @@
+
+# Set goarch/goos based on what we see in the LLVM triple.
+string(REGEX REPLACE "-" " " lht_components ${LLVM_DEFAULT_TARGET_TRIPLE})
+separate_arguments(lht_components)
+list(GET lht_components 0 goarch)
+list(GET lht_components 2 goos)
+
+# LLVM's "x86_64" is the same as Go's "amd64".
+if( ${goarch} STREQUAL "x86_64" )
+  set(goarch "amd64")
+endif()
+
+# List of all architectures, families, os flavors.
+set(allgoarch "386" "alpha" "amd64" "amd64p32" "arm" "armbe" "arm64" "arm64be" "ia64" "m68k" "mips" "mipsle" "mips64" "mips64le" "mips64p32" "mips64p32le" "ppc" "ppc64" "ppc64le" "s390" "s390x" "sparc" "sparc64")
+set(allgoarchfamily "I386" "ALPHA" "AMD64" "ARM" "ARM64" "IA64" "M68K" "MIPS" "MIPS64" "PPC" "PPC64" "S390" "S390X" "SPARC" "SPARC64")
+set(allgoos "aix" "android" "darwin" "dragonfly" "freebsd" "irix" "linux" "netbsd" "openbsd" "plan9" "rtems" "solaris" "windows")
+
+# FIXME: write code to insure that this is set and that the shell
+# in question behaves properly.
+set(shell $ENV{SHELL})
+
+# FIXME: write cmake to discover awk, test to make sure it works
+set(awk "/usr/bin/awk")
+
diff --git a/libgo/CMakeLists.txt b/libgo/CMakeLists.txt
index 96fe373..7147860 100644
--- a/libgo/CMakeLists.txt
+++ b/libgo/CMakeLists.txt
@@ -8,6 +8,7 @@
 
 message(STATUS "starting libgo configuration.")
 
+include(GoVars)
 include(AutoGenGo)
 include(CheckTypeSize)
 include(ConfigSetup)