0032463: Visualization - implement Image_AlienPixMap::Load() via emscripten_get_prelo...
[occt.git] / samples / webgl / CMakeLists.txt
1 cmake_minimum_required(VERSION 3.2)
2
3 project(occt-webgl-sample)
4
5 set(CMAKE_CXX_STANDARD 11)
6 set(APP_VERSION_MAJOR 1)
7 set(APP_VERSION_MINOR 0)
8 set(APP_TARGET occt-webgl-sample)
9
10 # option to enable or disable use of precompiled headers
11 if (NOT DEFINED SOURCE_MAP_BASE)
12   set (SOURCE_MAP_BASE "" CACHE STRING "Path to source map server for debugging C++ code; e.g. http://localhost:9090/")
13 endif()
14
15 # customize build
16 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --bind")
17 if (NOT "${SOURCE_MAP_BASE}" STREQUAL "")
18   set(CMAKE_CXX_FLAGS_DEBUG "-g4 --source-map-base ${SOURCE_MAP_BASE}")
19 endif()
20
21 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s WASM=1")
22 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s MAX_WEBGL_VERSION=2")
23 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s MODULARIZE=1")
24 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s EXPORT_NAME='createOccViewerModule'")
25
26 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s ALLOW_MEMORY_GROWTH=1")
27 #set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s TOTAL_MEMORY=16MB")
28
29 #set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --preload-file myFile")
30 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --extern-post-js ${CMAKE_CURRENT_SOURCE_DIR}/occt-webgl-viewer.js")
31
32 INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR})
33 file(GLOB SOURCES
34   *.h
35   *.cpp
36 )
37 source_group ("Headers" FILES
38   WasmOcctView.h)
39 source_group ("Sources" FILES
40   WasmOcctView.cpp
41   main.cpp)
42
43 # FreeType
44 find_package(freetype REQUIRED NO_DEFAULT_PATH)
45 if(freetype_FOUND)
46   message (STATUS "Using FreeType from \"${freetype_DIR}\"" )
47 else()
48   message(WARNING "Could not find FreeType, please set freetype_DIR variable." )
49 endif()
50
51 # Open CASCADE Technology
52 find_package(OpenCASCADE REQUIRED NO_DEFAULT_PATH)
53 if(OpenCASCADE_FOUND)
54   message (STATUS "Using OpenCASCADE from \"${OpenCASCADE_DIR}\"" )
55   INCLUDE_DIRECTORIES(${OpenCASCADE_INCLUDE_DIR})
56   LINK_DIRECTORIES(${OpenCASCADE_LIBRARY_DIR})
57 else()
58   message(WARNING "Could not find OpenCASCADE, please set OpenCASCADE_DIR variable." )
59   set(OCCT_LIBRARY_DIR)
60   set(OCCT_BIN_DIR)
61 endif()
62
63 set(OpenCASCADE_LIBS TKRWMesh TKBinXCAF TKBin TKBinL TKOpenGles TKXCAF TKVCAF TKCAF TKV3d TKHLR TKMesh TKService TKShHealing TKPrim TKTopAlgo TKGeomAlgo TKBRep TKGeomBase TKG3d TKG2d TKMath TKLCAF TKCDF TKernel)
64
65 add_executable(${APP_TARGET} ${SOURCES})
66 target_link_libraries(
67   ${APP_TARGET}
68   ${OpenCASCADE_LIBS}
69   freetype
70 )
71
72 install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" LIBRARY DESTINATION "${CMAKE_INSTALL_PREFIX}")
73 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.wasm DESTINATION ${CMAKE_INSTALL_PREFIX})
74 if (NOT "${SOURCE_MAP_BASE}" STREQUAL "")
75   if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
76     install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.wasm.map DESTINATION ${CMAKE_INSTALL_PREFIX})
77   endif()
78 endif()
79 install(FILES occt-webgl-sample.html DESTINATION ${CMAKE_INSTALL_PREFIX})
80 install(FILES ${OpenCASCADE_RESOURCE_DIR}/DrawResources/OCC_logo.png DESTINATION ${CMAKE_INSTALL_PREFIX})
81 install(FILES ${OpenCASCADE_RESOURCE_DIR}/DrawResources/lamp.ico DESTINATION ${CMAKE_INSTALL_PREFIX})