# This file is a 'toolchain description file' for CMake. # It teaches CMake about the Emscripten compiler, so that CMake can generate Unix Makefiles # from CMakeLists.txt that invoke emcc. # To use this toolchain file with CMake, invoke CMake with the following command line parameters # cmake -DEMSCRIPTEN=1 # -DCMAKE_TOOLCHAIN_FILE=/cmake/Platform/Emscripten.cmake # -DCMAKE_MODULE_PATH=/cmake # -DCMAKE_BUILD_TYPE= # -G "Unix Makefiles" # # Note, pass in here ONLY the path to the file, not the filename 'CMakeLists.txt' itself. # After that, build the generated Makefile with the command 'make'. On Windows, you may download and use 'mingw32-make' instead. # the name of the target operating system set(CMAKE_SYSTEM_NAME Emscripten) set(CMAKE_SYSTEM_VERSION 1) if ("$ENV{EMSCRIPTEN}" STREQUAL "") message(ERROR "Environment variable EMSCRIPTEN has not been set! Please point it to Emscripten root directory!") endif() set(CMAKE_FIND_ROOT_PATH $ENV{EMSCRIPTEN}) # Specify the compilers to use for C and C++ set(CMAKE_C_COMPILER "${EMCC_PATH}emcc") set(CMAKE_CXX_COMPILER "${EMCC_PATH}em++") set(CMAKE_AR "${EMCC_PATH}emar") set(CMAKE_RANLIB "${EMCC_PATH}emranlib") set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH) set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) # Specify the program to use when building static libraries. Force Emscripten-related command line options to clang. set(CMAKE_CXX_ARCHIVE_CREATE "${CMAKE_CXX_COMPILER} -o -emit-llvm ") set(CMAKE_C_ARCHIVE_CREATE "${CMAKE_C_COMPILER} -o -emit-llvm ") # Set a global EMSCRIPTEN variable that can be used in client CMakeLists.txt to detect when building using Emscripten. # There seems to be some kind of bug with CMake, so you might need to define this manually on the command line with "-DEMSCRIPTEN=1". set(EMSCRIPTEN 1)