@@ -54,6 +54,7 @@ OPTION(USE_VLD "Use Visual Leak Detector for debugging memory leaks, MSVC-only."
5454OPTION (USE_MMAP "Adds a command line options to parse IFC files from memory mapped files using Boost.Iostreams" OFF )
5555OPTION (BUILD_SHARED_LIBS "Build IfcParse and IfcGeom as shared libs (SO/DLL)." OFF )
5656OPTION (MSVC_PARALLEL_BUILD "Multi-threaded compilation in Microsoft Visual Studio (/MP)" OFF )
57+ OPTION (WASM_BUILD OFF )
5758if (${HAS_MAX} )
5859OPTION (BUILD_IFCMAX "Build IfcMax, a 3ds Max plug-in, Windows-only." OFF )
5960endif ()
@@ -149,6 +150,14 @@ UNIFY_ENVVARS_AND_CACHE(MPFR_INCLUDE_DIR)
149150UNIFY_ENVVARS_AND_CACHE (MPFR_LIBRARY_DIR )
150151endif ()
151152
153+ if (WASM_BUILD)
154+ # when using the nix/build-all.py build script we should not
155+ # look into the sysroot for most of the dependencies but rather
156+ # in the designated build/ folder created by the script.
157+ set (CMAKE_FIND_ROOT_PATH_BACKUP "${CMAKE_FIND_ROOT_PATH} " )
158+ set (CMAKE_FIND_ROOT_PATH "" )
159+ endif ()
160+
152161if (NOT MINIMAL_BUILD AND GLTF_SUPPORT AND BUILD_CONVERT)
153162UNIFY_ENVVARS_AND_CACHE (JSON_INCLUDE_DIR )
154163FIND_FILE (json_hpp "json.hpp" ${JSON_INCLUDE_DIR} /nlohmann )
@@ -199,7 +208,14 @@ ELSE()
199208 ENDIF ()
200209ENDIF ()
201210
202- set (BOOST_COMPONENTS system program_options regex thread date_time)
211+ if (WASM_BUILD)
212+ set (BOOST_COMPONENTS)
213+ else ()
214+ # @todo review this, shouldn't this be all possible header-only now?
215+ # ... or rewritten using C++17 features?
216+ set (BOOST_COMPONENTS system program_options regex thread date_time)
217+ endif ()
218+
203219if (USE_MMAP)
204220 if (MSVC )
205221 # filesystem is necessary for the utf-16 wpath
@@ -210,6 +226,10 @@ if(USE_MMAP)
210226 add_definitions (-DUSE_MMAP )
211227endif ()
212228
229+ FIND_PACKAGE (Boost REQUIRED COMPONENTS ${BOOST_COMPONENTS} )
230+ MESSAGE (STATUS "Boost include files found in ${Boost_INCLUDE_DIRS} " )
231+ MESSAGE (STATUS "Boost libraries found in ${Boost_LIBRARY_DIRS} " )
232+
213233if (NOT MINIMAL_BUILD)
214234# libxml2 is required for IFCXML (optional) and SVGFILL (mandatory)
215235 find_package (LibXml2 REQUIRED )
@@ -220,11 +240,6 @@ if (NOT MINIMAL_BUILD AND IFCXML_SUPPORT)
220240 set (SWIG_DEFINES ${SWIG_DEFINES} -DWITH_IFCXML)
221241endif ()
222242
223- FIND_PACKAGE (Boost REQUIRED COMPONENTS ${BOOST_COMPONENTS} )
224- MESSAGE (STATUS "Boost include files found in ${Boost_INCLUDE_DIRS} " )
225- MESSAGE (STATUS "Boost libraries found in ${Boost_LIBRARY_DIRS} " )
226-
227-
228243# Usage:
229244# set(SOME_LIRARIES foo bar)
230245# add_debug_variants(SOME_LIRARIES "${SOME_LIRARIES}" d)
@@ -343,10 +358,21 @@ if("${libTKernelExt}" STREQUAL ".a")
343358 set (OCCT_STATIC ON )
344359endif ()
345360
361+ if (WASM_BUILD)
362+ set (CMAKE_FIND_ROOT_PATH "${CMAKE_FIND_ROOT_PATH_BACKUP} " )
363+ endif ()
364+
346365if (OCCT_STATIC)
347366 find_package (Threads )
348- # OPENCASCADE_LIBRARIES repeated three times below in order to fix cyclic dependencies - use --start-group ... --end-group instead?
349- set (OPENCASCADE_LIBRARIES ${OPENCASCADE_LIBRARIES} ${OPENCASCADE_LIBRARIES} ${OPENCASCADE_LIBRARIES} ${OPENCASCADE_LIBRARIES} ${OPENCASCADE_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} )
367+
368+ if (WASM_BUILD)
369+ set (OPENCASCADE_LIBRARIES ${OPENCASCADE_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} )
370+ else ()
371+ # OPENCASCADE_LIBRARIES repeated N times below in order to fix cyclic dependencies - use --start-group ... --end-group instead?
372+ # tfk: --start-group ... --end-group didn't work on the apple linker when last tested
373+ set (OPENCASCADE_LIBRARIES ${OPENCASCADE_LIBRARIES} ${OPENCASCADE_LIBRARIES} ${OPENCASCADE_LIBRARIES} ${OPENCASCADE_LIBRARIES} ${OPENCASCADE_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} )
374+ endif ()
375+
350376 if (NOT APPLE AND NOT WIN32 )
351377 set (OPENCASCADE_LIBRARIES ${OPENCASCADE_LIBRARIES} "rt" )
352378 endif ()
@@ -620,7 +646,12 @@ function(files_for_ifc_version IFC_VERSION RESULT_NAME)
620646endfunction ()
621647
622648if (NOT SCHEMA_VERSIONS)
623- set (SCHEMA_VERSIONS "2x3" "4" "4x1" "4x2" "4x3_rc1" "4x3_rc2" "4x3_rc3" "4x3_rc4" "4x3" "4x3_tc1" "4x3_add1" )
649+ if (WASM_BUILD)
650+ # super arbitrarily try to keep size down at least a little bit
651+ set (SCHEMA_VERSIONS "2x3" "4" )
652+ else ()
653+ set (SCHEMA_VERSIONS "2x3" "4" "4x1" "4x2" "4x3_rc1" "4x3_rc2" "4x3_rc3" "4x3_rc4" "4x3" "4x3_tc1" "4x3_add1" )
654+ endif ()
624655endif ()
625656
626657foreach (s ${SCHEMA_VERSIONS} )
@@ -697,7 +728,11 @@ if (BUILD_IFCGEOM)
697728 foreach (s ${SCHEMA_VERSIONS} )
698729 set (IFCGEOM_SCHEMA_LIBRARIES ${IFCGEOM_SCHEMA_LIBRARIES} IfcGeom_ifc${s} )
699730 endforeach ()
700- set (IFCOPENSHELL_LIBRARIES ${IFCOPENSHELL_LIBRARIES} IfcGeom ${IFCGEOM_SCHEMA_LIBRARIES} IfcGeom ${IFCGEOM_SCHEMA_LIBRARIES} )
731+ if (WASM_BUILD)
732+ set (IFCOPENSHELL_LIBRARIES ${IFCOPENSHELL_LIBRARIES} IfcGeom ${IFCGEOM_SCHEMA_LIBRARIES} )
733+ else ()
734+ set (IFCOPENSHELL_LIBRARIES ${IFCOPENSHELL_LIBRARIES} IfcGeom ${IFCGEOM_SCHEMA_LIBRARIES} IfcGeom ${IFCGEOM_SCHEMA_LIBRARIES} )
735+ endif ()
701736endif ()
702737if (BUILD_CONVERT OR BUILD_IFCPYTHON)
703738 foreach (s ${SCHEMA_VERSIONS} )
@@ -741,7 +776,11 @@ set(IFCPARSE_FILES ${IFCPARSE_CPP_FILES} ${IFCPARSE_H_FILES})
741776add_library (IfcParse ${IFCPARSE_FILES} )
742777set_target_properties (IfcParse PROPERTIES COMPILE_FLAGS -DIFC_PARSE_EXPORTS VERSION "0.6.0" SOVERSION "0.6" )
743778
744- TARGET_LINK_LIBRARIES (IfcParse ${Boost_LIBRARIES} ${BCRYPT_LIBRARIES} ${LIBXML2_LIBRARIES} )
779+ if (WASM_BUILD)
780+ TARGET_LINK_LIBRARIES (IfcParse ${BCRYPT_LIBRARIES} ${LIBXML2_LIBRARIES} )
781+ else ()
782+ TARGET_LINK_LIBRARIES (IfcParse ${Boost_LIBRARIES} ${BCRYPT_LIBRARIES} ${LIBXML2_LIBRARIES} )
783+ endif ()
745784
746785if (BUILD_IFCGEOM)
747786
@@ -753,7 +792,9 @@ set(IFCGEOM_FILES ${IFCGEOM_CPP_FILES} ${IFCGEOM_H_FILES})
753792foreach (s ${SCHEMA_VERSIONS} )
754793 add_library (IfcGeom_ifc${s} STATIC ${IFCGEOM_FILES} )
755794 set_target_properties (IfcGeom_ifc${s} PROPERTIES COMPILE_FLAGS "-DIFC_GEOM_EXPORTS -DIfcSchema=Ifc${s} " )
756- TARGET_LINK_LIBRARIES (IfcGeom_ifc${s} IfcParse ${OPENCASCADE_LIBRARIES} )
795+ if (NOT WASM_BUILD)
796+ TARGET_LINK_LIBRARIES (IfcGeom_ifc${s} IfcParse ${OPENCASCADE_LIBRARIES} )
797+ endif ()
757798endforeach ()
758799
759800# IfcGeom (schema agnostic)
@@ -768,7 +809,11 @@ if (UNIX)
768809find_package (Threads )
769810endif ()
770811
771- TARGET_LINK_LIBRARIES (IfcGeom IfcParse ${IFCGEOM_SCHEMA_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} )
812+ if (WASM_BUILD)
813+ TARGET_LINK_LIBRARIES (IfcGeom ${IFCGEOM_SCHEMA_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} )
814+ else ()
815+ TARGET_LINK_LIBRARIES (IfcGeom IfcParse ${IFCGEOM_SCHEMA_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} )
816+ endif ()
772817
773818endif (BUILD_IFCGEOM )
774819
@@ -785,7 +830,12 @@ set(SERIALIZERS_S_FILES ${SERIALIZERS_S_H_FILES} ${SERIALIZERS_S_CPP_FILES})
785830foreach (s ${SCHEMA_VERSIONS} )
786831 add_library (Serializers_ifc${s} STATIC ${SERIALIZERS_S_FILES} )
787832 set_target_properties (Serializers_ifc${s} PROPERTIES COMPILE_FLAGS "-DIFC_GEOM_EXPORTS -DIfcSchema=Ifc${s} ${CONVERT_PRECISION} " )
788- TARGET_LINK_LIBRARIES (Serializers_ifc${s} IfcGeom ${OPENCASCADE_LIBRARIES} ${HDF5_LIBRARIES} )
833+
834+ if (WASM_BUILD)
835+ TARGET_LINK_LIBRARIES (Serializers_ifc${s} ${HDF5_LIBRARIES} )
836+ else ()
837+ TARGET_LINK_LIBRARIES (Serializers_ifc${s} IfcGeom ${OPENCASCADE_LIBRARIES} ${HDF5_LIBRARIES} )
838+ endif ()
789839endforeach ()
790840
791841add_library (Serializers ${SERIALIZERS_FILES} )
0 commit comments