0032315: Configuration, CMake - fix building Draw Harness plugins as static libraries
[occt.git] / src / DRAWEXE / CMakeLists.txt
index bdf6279..45e9f4d 100644 (file)
@@ -1,5 +1,41 @@
 project(DRAWEXE)
 
+unset (CUSTOM_EXTERNLIB)
+if (NOT BUILD_SHARED_LIBS)
+  # link specific list of plugins explicitly
+  FILE_TO_LIST ("src/${PROJECT_NAME}/EXTERNLIB_STATIC" CUSTOM_EXTERNLIB)
+  if (USE_OPENGL)
+    list (REMOVE_ITEM CUSTOM_EXTERNLIB TKOpenGles)
+    list (REMOVE_ITEM CUSTOM_EXTERNLIB TKOpenGlesTest)
+    list (REMOVE_ITEM CUSTOM_EXTERNLIB CSF_OpenGlesLibs)
+  elseif(USE_GLES2)
+    list (REMOVE_ITEM CUSTOM_EXTERNLIB TKOpenGl)
+    list (REMOVE_ITEM CUSTOM_EXTERNLIB TKOpenGlTest)
+    list (REMOVE_ITEM CUSTOM_EXTERNLIB CSF_OpenGlLibs)
+  else()
+    list (REMOVE_ITEM CUSTOM_EXTERNLIB TKOpenGles)
+    list (REMOVE_ITEM CUSTOM_EXTERNLIB TKOpenGlesTest)
+    list (REMOVE_ITEM CUSTOM_EXTERNLIB CSF_OpenGlesLibs)
+    list (REMOVE_ITEM CUSTOM_EXTERNLIB TKOpenGl)
+    list (REMOVE_ITEM CUSTOM_EXTERNLIB TKOpenGlTest)
+    list (REMOVE_ITEM CUSTOM_EXTERNLIB CSF_OpenGlLibs)
+  endif()
+endif()
+
 set (EXECUTABLE_PROJECT ON)
 OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit)
 unset (EXECUTABLE_PROJECT)
+unset (CUSTOM_EXTERNLIB)
+
+if (EMSCRIPTEN)
+  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s WASM=1")
+  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s MAX_WEBGL_VERSION=2")
+  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s ALLOW_MEMORY_GROWTH=1")
+  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --bind")
+
+  set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s MODULARIZE=1")
+  set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s EXPORT_NAME='createDRAWEXE'")
+
+  install(FILES ${PROJECT_NAME}.html      DESTINATION "${INSTALL_DIR_BIN}/${OCCT_INSTALL_BIN_LETTER}")
+  install(FILES ../DrawResources/lamp.ico DESTINATION "${INSTALL_DIR_BIN}/${OCCT_INSTALL_BIN_LETTER}")
+endif()