Fix enabling XCB and Wayland WSI builds on Linux

CMake variables need to be dereferenced using ${...} before passing them
as function arguments, so we can't just use LINUX as the default value
for the cache variables. However, we also can't use ${LINUX} because the
variable isn't defined on non-Linux platforms and the expression
evaluates to the empty string, meaning we're missing an argument for the
option_if_not_defined() function.

Instead this change simply does not define these cache variables if
we're not building for Linux, and sets the XCB and Wayland ones to
literal TRUE as default.

Bug: b/249015129
Change-Id: I2d171cf8dae025e75f4ce81f717f38051664c0f8
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/68749
Tested-by: Nicolas Capens <nicolascapens@google.com>
Kokoro-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2039fb8..fb7ef0d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -150,22 +150,24 @@
     set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS Debug Release MinSizeRel RelWithDebInfo)
 endif()
 
-function (option_if_not_defined name description default)
+function(option_if_not_defined name description default)
     if(NOT DEFINED ${name})
         option(${name} ${description} ${default})
     endif()
 endfunction()
 
-function (set_if_not_defined name value)
+function(set_if_not_defined name value)
     if(NOT DEFINED ${name})
         set(${name} ${value} PARENT_SCOPE)
     endif()
 endfunction()
 
-option_if_not_defined(SWIFTSHADER_BUILD_WSI_XCB "Build the XCB WSI support" LINUX)
-option_if_not_defined(SWIFTSHADER_BUILD_WSI_WAYLAND "Build the Wayland WSI support" LINUX)
-option_if_not_defined(SWIFTSHADER_BUILD_WSI_DIRECTFB "Build the DirectFB WSI support" FALSE)
-option_if_not_defined(SWIFTSHADER_BUILD_WSI_D2D "Build the Direct-to-Display WSI support" FALSE)
+if(LINUX)
+    option_if_not_defined(SWIFTSHADER_BUILD_WSI_XCB "Build the XCB WSI support" TRUE)
+    option_if_not_defined(SWIFTSHADER_BUILD_WSI_WAYLAND "Build the Wayland WSI support" TRUE)
+    option_if_not_defined(SWIFTSHADER_BUILD_WSI_DIRECTFB "Build the DirectFB WSI support" FALSE)
+    option_if_not_defined(SWIFTSHADER_BUILD_WSI_D2D "Build the Direct-to-Display WSI support" FALSE)
+endif()
 
 option_if_not_defined(SWIFTSHADER_BUILD_PVR "Build the PowerVR examples" FALSE)
 option_if_not_defined(SWIFTSHADER_BUILD_TESTS "Build unit tests" TRUE)