-
-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add cmakelists.txt to build tinyusdz wasm
- Loading branch information
Showing
1 changed file
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# Assume this project is invoked by emcmake. | ||
cmake_minimum_required(VERSION 3.5.1) | ||
|
||
set(BUILD_TARGET "tinyusdz") | ||
|
||
if (NOT EMSCRIPTEN) | ||
message(FATAL "Must be compiled with emscripten") | ||
endif() | ||
|
||
project(${BUILD_TARGET} CXX C) | ||
|
||
set(CMAKE_CXX_STANDARD 14) | ||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
set(CMAKE_CXX_EXTENSIONS OFF) | ||
|
||
# cmake modules | ||
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/../cmake) | ||
#list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/../../cmake/sanitizers) | ||
#find_package(Sanitizers) # Address sanitizer (-DSANITIZE_ADDRESS=ON) | ||
|
||
# [tinyusdz] | ||
add_subdirectory(../ tinyusdz) | ||
|
||
list( | ||
APPEND | ||
SOURCES | ||
binding.cc | ||
) | ||
|
||
|
||
add_executable(${BUILD_TARGET} ${SOURCES}) | ||
add_sanitizers(${BUILD_TARGET}) | ||
|
||
target_compile_options(${BUILD_TARGET} PRIVATE ${EXT_COMPILE_OPTIONS}) | ||
|
||
# tinyusdz dir | ||
target_include_directories(${BUILD_TARGET} | ||
PRIVATE "${PROJECT_SOURCE_DIR}/../src/") | ||
|
||
|
||
target_link_libraries(${BUILD_TARGET} PRIVATE tinyusdz::tinyusdz_static | ||
${EXT_LIBRARIES} PUBLIC ${CMAKE_DL_LIBS}) | ||
|
||
source_group("Source Files" FILES ${SOURCES}) | ||
|
||
if (EMSCRIPTEN) | ||
set_target_properties( | ||
${BUILD_TARGET} | ||
PROPERTIES OUTPUT_NAME tinyusdz | ||
SUFFIX ".js" | ||
RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/dist) | ||
#set(CMAKE_EXECUTABLE_SUFFIX ".html") | ||
endif() | ||
|
||
# TODO: Adjust memory size. | ||
set_target_properties(${BUILD_TARGET} PROPERTIES LINK_FLAGS "-s INITIAL_MEMORY=32MB -s TOTAL_MEMORY=256MB -sTOTAL_STACK=32MB -sASSERTIONS -s ALLOW_MEMORY_GROWTH=1 -s WASM=1 -sMODULARIZE -sEXPORT_ES6=1 --bind") | ||
|
||
# ENVIRONMENT=web | ||
# SINGLE_FILE=1 |