build: cmake: Add support for Fuchsia. (#3062)
This small patch adds support for the Fuchsia operating system
to the CMakeLists.txt file and source/print.cpp, the only source
file that contains platform-specific code.
This should not change the build for other platforms. To use it,
one needs a Fuchsia-specific CMake toolchain file, as in:
mkdir build-fuchsia && cd build-fuchsia
cmake .. -DCMAKE_TOOLCHAIN_FILE=/path/to/fuchsia-toolchain.cmake
make -j8
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 946fc1d..6ed56a8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -53,6 +53,8 @@
set(SPIRV_TIMER_ENABLED ${SPIRV_ALLOW_TIMERS})
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "FreeBSD")
add_definitions(-DSPIRV_FREEBSD)
+elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Fuchsia")
+ add_definitions(-DSPIRV_FUCHSIA)
else()
message(FATAL_ERROR "Your platform '${CMAKE_SYSTEM_NAME}' is not supported!")
endif()
diff --git a/source/print.cpp b/source/print.cpp
index 1d9829d..128587a 100644
--- a/source/print.cpp
+++ b/source/print.cpp
@@ -15,7 +15,8 @@
#include "source/print.h"
#if defined(SPIRV_ANDROID) || defined(SPIRV_LINUX) || defined(SPIRV_MAC) || \
- defined(SPIRV_IOS) || defined(SPIRV_FREEBSD) || defined(SPIRV_EMSCRIPTEN)
+ defined(SPIRV_IOS) || defined(SPIRV_FREEBSD) || \
+ defined(SPIRV_EMSCRIPTEN) || defined(SPIRV_FUCHSIA)
namespace spvtools {
clr::reset::operator const char*() { return "\x1b[0m"; }