Support compilation via emscripten
It turns out that emcc does not like "-ggdb" flag. Disable it if we
detect that we're being compiled by Emscripten toolchain (e.g., when
compiling to WebAssembly).
Change-Id: Ic6a11251a79cdb370c1bdce48aec5428b2f2f306
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/37344
Reviewed-by: Adam Langley <alangley@gmail.com>
Reviewed-by: Adam Langley <agl@google.com>
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c3992a9..761778a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -104,6 +104,10 @@
set(CLANG 1)
endif()
+if(CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
+ set(EMSCRIPTEN 1)
+endif()
+
if(CMAKE_COMPILER_IS_GNUCXX OR CLANG)
# Note clang-cl is odd and sets both CLANG and MSVC. We base our configuration
# primarily on our normal Clang one.
@@ -117,7 +121,14 @@
# honor it. Suppress it here to compensate. See https://crbug.com/772117.
set(C_CXX_FLAGS "${C_CXX_FLAGS} -Wno-deprecated-declarations")
else()
- set(C_CXX_FLAGS "${C_CXX_FLAGS} -Wall -ggdb -fvisibility=hidden -fno-common")
+ if(EMSCRIPTEN)
+ # emscripten's emcc/clang does not accept the "-ggdb" flag.
+ set(C_CXX_FLAGS "${C_CXX_FLAGS} -g")
+ else()
+ set(C_CXX_FLAGS "${C_CXX_FLAGS} -ggdb")
+ endif()
+
+ set(C_CXX_FLAGS "${C_CXX_FLAGS} -Wall -fvisibility=hidden -fno-common")
endif()
if(CLANG)