0031668: Visualization - WebGL sample doesn't work on Emscripten 1.39
[occt.git] / samples / webgl / CMakeLists.txt
CommitLineData
565baee6 1cmake_minimum_required(VERSION 3.2)
2
3project(occt-webgl-sample)
4
5set(CMAKE_CXX_STANDARD 11)
6set(APP_VERSION_MAJOR 1)
7set(APP_VERSION_MINOR 0)
8set(APP_TARGET occt-webgl-sample)
9
10# customize build
11set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s WASM=1")
12set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s USE_WEBGL2=1")
13set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s ALLOW_MEMORY_GROWTH=1")
14#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s SAFE_HEAP=1")
15#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s NO_EXIT_RUNTIME=1")
16#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s TOTAL_MEMORY=16MB")
17#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s ABORTING_MALLOC=0")
18#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s FORCE_FILESYSTEM=1")
19#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --preload-file myFile")
20
21INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR})
22file(GLOB SOURCES
23 *.h
24 *.cpp
25)
26source_group ("Headers" FILES
27 WasmOcctView.h)
28source_group ("Sources" FILES
29 WasmOcctView.cpp
30 main.cpp)
31
32# FreeType
33find_package(freetype REQUIRED NO_DEFAULT_PATH)
34if(freetype_FOUND)
35 message (STATUS "Using FreeType from \"${freetype_DIR}\"" )
36else()
37 message(WARNING "Could not find FreeType, please set freetype_DIR variable." )
38endif()
39
40# Open CASCADE Technology
41find_package(OpenCASCADE REQUIRED NO_DEFAULT_PATH)
42if(OpenCASCADE_FOUND)
43 message (STATUS "Using OpenCASCADE from \"${OpenCASCADE_DIR}\"" )
44 INCLUDE_DIRECTORIES(${OpenCASCADE_INCLUDE_DIR})
45 LINK_DIRECTORIES(${OpenCASCADE_LIBRARY_DIR})
46else()
47 message(WARNING "Could not find OpenCASCADE, please set OpenCASCADE_DIR variable." )
48 set(OCCT_LIBRARY_DIR)
49 set(OCCT_BIN_DIR)
50endif()
51
52set(OpenCASCADE_LIBS TKRWMesh TKBinXCAF TKBin TKBinL TKOpenGl TKXCAF TKVCAF TKCAF TKV3d TKHLR TKMesh TKService TKShHealing TKPrim TKTopAlgo TKGeomAlgo TKBRep TKGeomBase TKG3d TKG2d TKMath TKLCAF TKCDF TKernel)
53
54add_executable(${APP_TARGET} ${SOURCES})
55target_link_libraries(
56 ${APP_TARGET}
57 ${OpenCASCADE_LIBS}
58 freetype
59)
60set_target_properties(${APP_TARGET} PROPERTIES LINK_FLAGS "-s EXPORTED_FUNCTIONS=['_main','_onFileDataRead'] -s EXTRA_EXPORTED_RUNTIME_METHODS=['ccall','cwrap']")
61
62install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" LIBRARY DESTINATION "${CMAKE_INSTALL_PREFIX}")
63install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.wasm DESTINATION ${CMAKE_INSTALL_PREFIX})
64install(FILES occt-webgl-sample.html DESTINATION ${CMAKE_INSTALL_PREFIX})
65install(FILES ${OpenCASCADE_RESOURCE_DIR}/DrawResources/OCC_logo.png DESTINATION ${CMAKE_INSTALL_PREFIX})
66install(FILES ${OpenCASCADE_RESOURCE_DIR}/DrawResources/lamp.ico DESTINATION ${CMAKE_INSTALL_PREFIX})