cmake wasm

cmake_minimum_required(VERSION 3.20)
project(untitled121)

set(CMAKE_VERBOSE_MAKEFILE 1)
set(CMAKE_C_COMPILER emcc)
set(CMAKE_CXX_COMPILER emcc)
set(CMAKE_AR emar)



set(CMAKE_CXX_STANDARD 17)
set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_VERSION 1)
set(CMAKE_SYSTEM_PROCESSOR wasm)
set(CMAKE_C_COMPILER_WORKS 1)
set(CMAKE_CXX_COMPILER_WORKS 1)

set(triple wasm32)
set(CMAKE_C_COMPILER_TARGET ${triple})
set(CMAKE_CXX_COMPILER_TARGET ${triple})
set(CMAKE_SYSROOT /Users/jalyzhang/CLionProjects/untitled93/git/emsdk/upstream/emscripten/cache/sysroot)


#set(WASM_LINKER ${INSTALL_DIR}/wasm-ld)
set(WASM_LINKER /Users/jalyzhang/CLionProjects/untitled93/git/emsdk/upstream/bin/wasm-ld)
set(CMAKE_C_LINK_EXECUTABLE "${WASM_LINKER} <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
set(CMAKE_CXX_LINK_EXECUTABLE "${WASM_LINKER} <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")

add_executable(untitled121 main.cpp 1.cpp)

# Specify LLVM toolchain
set_target_properties(untitled121 PROPERTIES LINK_FLAGS "--strip-all --no-entry --allow-undefined --lto-O2 --demangle --export-all")








set_target_properties(demo PROPERTIES LINK_FLAGS " -std=c++17 -Os -s STANDALONE_WASM -s WASM_BIGINT -s ERROR_ON_UNDEFINED_SYMBOLS=0 --no-entry")

emcmake cmake .. 
emmake make VERBOSE=1









cmake_minimum_required(VERSION 3.20)
project(untitled121)

set(CMAKE_VERBOSE_MAKEFILE 1)
set(CMAKE_C_COMPILER emcc)
set(CMAKE_CXX_COMPILER emcc)
set(CMAKE_AR emar)
set(CMAKE_SYSROOT /Users/jalyzhang/CLionProjects/untitled93/git/emsdk/upstream/emscripten/cache/sysroot)
set(CMAKE_CXX_LINK_EXECUTABLE "<CMAKE_CXX_COMPILER> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
set(CMAKE_EXECUTABLE_SUFFIX ".wasm")

add_executable(untitled121 main.cpp 1.cpp e/12.c)


















posted @ 2022-07-28 17:29  zJanly  阅读(366)  评论(0编辑  收藏  举报