Makefile 如何使用emmake生成.wasm文件
我在项目上有这个项目框架,它允许使用SDL lib移动光标。之后我想将其移植到浏览器中。这些文件是基于此生成的 MouseMove/src/main.cpp: CMakeLists.txt:Makefile 如何使用emmake生成.wasm文件,makefile,cmake,sdl-2,emscripten,webassembly,Makefile,Cmake,Sdl 2,Emscripten,Webassembly,我在项目上有这个项目框架,它允许使用SDL lib移动光标。之后我想将其移植到浏览器中。这些文件是基于此生成的 MouseMove/src/main.cpp: CMakeLists.txt: project(MouseMove) add_executable(MouseMove src/main.cpp) target_link_libraries(MouseMove ${SDL2_LIBRARY}) install(TARGETS MouseMove RUNTIME DESTINATION
project(MouseMove)
add_executable(MouseMove src/main.cpp)
target_link_libraries(MouseMove ${SDL2_LIBRARY})
install(TARGETS MouseMove RUNTIME DESTINATION ${BIN_DIR})
cmake_minimum_required(VERSION 2.6)
project(webassembly_plugin)
# Use our modified FindSDL2* modules
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${webassembly_plugin_SOURCE_DIR}/cmake")
# Set an output directory for our binaries
set(BIN_DIR ${webassembly_plugin_SOURCE_DIR}/bin)
# Bump up warning levels appropriately for clang, gcc & msvc
# Also set debug/optimization flags depending on the build type. IDE users choose this when
# selecting the build mode in their IDE
if (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU" OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic -std=c++11")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_DEBUG} -g")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELEASE} -O2")
elseif (${CMAKE_CXX_COMPILER_ID} STREQUAL "MSVC")
if (CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
endif()
endif()
# Look up SDL2 and add the include directory to our include path
find_package(SDL2 REQUIRED)
include_directories(${SDL2_INCLUDE_DIR})
# Look in the Lesson0 subdirectory to find its CMakeLists.txt so we can build the executable
add_subdirectory(MouseMove)
我可以使用emake将其编译成可执行文件
mkdir构建和cd构建
cmake-G“Unix Makefiles”-DCMAKE\u BUILD\u TYPE=Debug../
emconfigure cmake.
emmake make
emcc
执行此操作,以便它接受cmake配置
cmake_minimum_required(VERSION 2.6)
project(webassembly_plugin)
# Use our modified FindSDL2* modules
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${webassembly_plugin_SOURCE_DIR}/cmake")
# Set an output directory for our binaries
set(BIN_DIR ${webassembly_plugin_SOURCE_DIR}/bin)
# Bump up warning levels appropriately for clang, gcc & msvc
# Also set debug/optimization flags depending on the build type. IDE users choose this when
# selecting the build mode in their IDE
if (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU" OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic -std=c++11")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_DEBUG} -g")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELEASE} -O2")
elseif (${CMAKE_CXX_COMPILER_ID} STREQUAL "MSVC")
if (CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
endif()
endif()
# Look up SDL2 and add the include directory to our include path
find_package(SDL2 REQUIRED)
include_directories(${SDL2_INCLUDE_DIR})
# Look in the Lesson0 subdirectory to find its CMakeLists.txt so we can build the executable
add_subdirectory(MouseMove)