0032315: Configuration, CMake - fix building Draw Harness plugins as static libraries
[occt.git] / adm / cmake / occt_toolkit.cmake
index acbaac5..8f09fbe 100644 (file)
@@ -22,7 +22,7 @@ if ("${OCCT_TOOLKITS_NAME_SUFFIX}" STREQUAL "")
   set (OCCT_TOOLKITS_NAME_SUFFIX "TOOLKITS")
 endif()
 
-# parce PACKAGES file
+# parse PACKAGES file
 FILE_TO_LIST ("${RELATIVE_SOURCES_DIR}/${PROJECT_NAME}/PACKAGES" USED_PACKAGES)
 if ("${USED_PACKAGES}" STREQUAL "")
   set (USED_PACKAGES ${PROJECT_NAME})
@@ -39,7 +39,7 @@ set (PRECOMPILED_DEFS)
 
 if (NOT BUILD_SHARED_LIBS)
   list (APPEND PRECOMPILED_DEFS "-DOCCT_NO_PLUGINS")
-  if (WIN32)
+  if (WIN32 AND NOT EXECUTABLE_PROJECT)
     list (APPEND PRECOMPILED_DEFS "-DOCCT_STATIC_BUILD")
   endif()
 endif()
@@ -228,6 +228,10 @@ if (EXECUTABLE_PROJECT)
 
   install (TARGETS ${PROJECT_NAME}
            DESTINATION "${INSTALL_DIR_BIN}\${OCCT_INSTALL_BIN_LETTER}")
+
+  if (EMSCRIPTEN)
+    install(FILES ${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bin\${OCCT_INSTALL_BIN_LETTER}/${PROJECT_NAME}.wasm DESTINATION "${INSTALL_DIR_BIN}/${OCCT_INSTALL_BIN_LETTER}")
+  endif()
 else()
   add_library (${PROJECT_NAME} ${USED_SRCFILES} ${USED_INCFILES} ${USED_RCFILE} ${RESOURCE_FILES} ${${PROJECT_NAME}_MOC_FILES})
 
@@ -283,8 +287,12 @@ endif()
 set (USED_TOOLKITS_BY_CURRENT_PROJECT)
 set (USED_EXTERNAL_LIBS_BY_CURRENT_PROJECT)
 
-# parce EXTERNLIB file
-FILE_TO_LIST ("${RELATIVE_SOURCES_DIR}/${PROJECT_NAME}/EXTERNLIB" USED_EXTERNLIB_AND_TOOLKITS)
+# parse EXTERNLIB file
+if (CUSTOM_EXTERNLIB)
+  set (USED_EXTERNLIB_AND_TOOLKITS ${CUSTOM_EXTERNLIB})
+else()
+  FILE_TO_LIST ("${RELATIVE_SOURCES_DIR}/${PROJECT_NAME}/EXTERNLIB" USED_EXTERNLIB_AND_TOOLKITS)
+endif()
 foreach (USED_ITEM ${USED_EXTERNLIB_AND_TOOLKITS})
   string (REGEX MATCH "^ *#" COMMENT_FOUND ${USED_ITEM})
   if (NOT COMMENT_FOUND)
@@ -383,7 +391,7 @@ else()
   endif()
 endif()
 
-if (BUILD_SHARED_LIBS)
+if (BUILD_SHARED_LIBS OR EXECUTABLE_PROJECT)
   if(IS_VTK_9XX)
     string (REGEX REPLACE "vtk" "VTK::" USED_TOOLKITS_BY_CURRENT_PROJECT "${USED_TOOLKITS_BY_CURRENT_PROJECT}")
   endif()