question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Any plans of adding support for emscripten?

See original GitHub issue

I am getting while using version 0.8.

CMake Error at build/Debug/conan.cmake:61 (message):
  cmake system Emscripten is not supported by conan.  Use one of
  Windows;Linux;Macos;Android;iOS;FreeBSD

Here is how my CMakeList.txt looks like:

cmake_minimum_required(VERSION 3.9.3)

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_FLAGS "-s WASM=1 --bind")

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/")
if (NOT EXISTS "${CMAKE_BINARY_DIR}/conan.cmake")
    message(STATUS "Downloading conan.cmake from https://github.com/conan-io/cmake-conan")
    file(DOWNLOAD
        "https://raw.githubusercontent.com/conan-io/cmake-conan/v0.8/conan.cmake"
        "${CMAKE_BINARY_DIR}/conan.cmake"
        EXPECTED_MD5 58bc519cadc890b5c33235defadc1176)
endif ()
include(${CMAKE_BINARY_DIR}/conan.cmake)

project(aide VERSION 0.0.1)
conan_cmake_run(
    CONANFILE conanfile.txt
    BASIC_SETUP CMAKE_TARGETS
    BUILD missing
)

set(CMAKE_EXECUTABLE_SUFFIX ".html")
file(GLOB_RECURSE SOURCE_FILES src/*.cpp)

add_executable(index ${SOURCE_FILES})

When I call cmake I am actually passing the emscripten toolchain.cmake link:

cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_TOOLCHAIN_FILE=/path/to/emsdk/emscripten/1.37.28/cmake/Modules/Platform/Emscripten.cmake -G "Unix Makefiles" /path/to/project/aide

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:1
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
trivigycommented, Apr 9, 2018

Here is an example of how the emsdk is later being used by a dependent package. I am compiling here protobuf to emscripten. One weird thing to note is that I have an additional conanfile.py for the actual standard protobuf. That is because of the need for the executable. Unfortunately in em-Protobuf I remove the compilation of the executable since this will compile stuff into web-assembly and cannot run on localhost. Basically I am just grabbing protoc from the standard Protobuf conanfile.

conanfile.py

from conans import ConanFile, tools, AutoToolsBuildEnvironment
from conans.tools import os_info, SystemPackageTool


class ProtobufConan(ConanFile):
    name = "em-Protobuf"
    version = "3.5.2"
    folder = "protobuf"
    url = "https://github.com/google/protobuf"
    description = "Protocol Buffers - Google's data interchange format"
    license = "https://github.com/google/protobuf/blob/master/LICENSE"
    requires = "Protobuf/3.5.2@syncaide/stable", "emsdk/1.37.35@syncaide/stable"
    settings = "os", "compiler", "build_type", "arch"
    exports_sources = ["emscripten.patch"]
    generators = "cmake"
    packages = [
        "autoconf",
        "automake",
        "libtool",
        "curl",
        "make",
        "g++",
        "unzip"
    ]

    def source(self):
        self.run("git clone https://github.com/google/protobuf.git")
        self.run("git checkout tags/v{}".format(self.version), cwd=self.folder)
        self.run("git apply ../emscripten.patch", cwd=self.folder)

    def configure(self):
        self.options["Protobuf"].bin_only = True

    def system_requirements(self):
        if os_info.is_linux:
            installer = SystemPackageTool()
            for pkg in self.packages:
                installer.install(pkg)

    def build(self):
        protoc = self.deps_cpp_info["Protobuf"].rootpath + '/bin/protoc'

        env = AutoToolsBuildEnvironment(self)
        with tools.environment_append(env.vars):
            self.run("./autogen.sh", cwd=self.folder)

            args = ['--disable-shared', '--with-protoc={}'.format(protoc)]
            self.run("emconfigure ./configure {}".format(' '.join(args)), cwd=self.folder)
            self.run("emmake make -j {}".format(tools.cpu_count()), cwd=self.folder)

    def package(self):
        self.copy("*.h", "include", "{}/src".format(self.folder))
        self.copy("*.proto", "include", "{}/src".format(self.folder))
        self.copy("*.a", "lib", "{}/src/.libs".format(self.folder), keep_path=False)

    def package_info(self):
        self.cpp_info.libs = ["protobuf", "protobuf-lite"]

1reaction
jfaust-fycommented, Dec 15, 2020

This seems to work…

PROFILE "${CMAKE_CURRENT_SOURCE_DIR}/conan/emscripten.profile"
        ENV
            EMSDK="${EMSCRIPTEN_ROOT_PATH}/../../"
            EMSCRIPTEN="${EMSCRIPTEN_ROOT_PATH}"
            CONAN_CMAKE_TOOLCHAIN_FILE="${EMSCRIPTEN_ROOT_PATH}/cmake/Modules/Platform/Emscripten.cmake"
            PATH="$ENV{PATH}:${EMSCRIPTEN_ROOT_PATH}:${EMSCRIPTEN_ROOT_PATH}"
            CC="${EMSCRIPTEN_ROOT_PATH}/emcc"
            CXX="${EMSCRIPTEN_ROOT_PATH}/em++"
            RANLIB="${EMSCRIPTEN_ROOT_PATH}/ranlib"
            AR="${EMSCRIPTEN_ROOT_PATH}/ar"

when configuring with:

cmake -DCMAKE_TOOLCHAIN_FILE=$EMSCRIPTEN_ROOT_PATH/cmake/Modules/Platform/Emscripten.cmake
Read more comments on GitHub >

github_iconTop Results From Across the Web

Building Projects — Emscripten 3.1.26-git (dev) documentation
SDL1 has support for sdl-config, which is present in system/bin. Using the native sdl-config may result in compilation or missing-symbol errors. You will...
Read more >
FAQ — Emscripten 3.1.26-git (dev) documentation
What is “No WebAssembly support found. Build with -sWASM=0 to target JavaScript instead” or “no native wasm support detected”? Why do I get...
Read more >
Deploying Emscripten Compiled Pages
Deploying Emscripten Compiled Pages¶. Emscripten compiled output can either be run directly in a JS shell from command line, or hosted on a...
Read more >
Interacting with code — Emscripten 3.1.26-git (dev ...
The JavaScript object ENV contains the virtualised environment variables, and by modifying it you can pass variables to your compiled code.
Read more >
About Emscripten — Emscripten 3.1.26-git (dev) documentation
Emscripten support for portable C/C++ code is fairly comprehensive. Support for the C standard library, C++ standard library, C++ exceptions, etc. is very...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found