### Install Static Library and Headers Source: https://github.com/thatopen/engine_web-ifc/blob/main/src/cpp/CMakeLists.txt Defines installation rules for the static library and web-ifc headers. This ensures the library and its associated header files are placed in the correct directories upon installation. ```cmake install(TARGETS web-ifc-library EXPORT web-ifc-targets ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ) install(DIRECTORY web-ifc/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/web-ifc FILES_MATCHING PATTERN "*.h" ) install(FILES version.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/web-ifc ) ``` -------------------------------- ### Generate and Install CMake Config File Source: https://github.com/thatopen/engine_web-ifc/blob/main/src/cpp/CMakeLists.txt Generates the 'web-ifc-config.cmake' file from a template and installs it. This file is used by CMake to find and configure the web-ifc package in other projects. ```cmake configure_package_config_file( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/web-ifc-config.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/web-ifc-config.cmake INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/web-ifc ) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/web-ifc-config.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/web-ifc ) ``` -------------------------------- ### Monaco Editor Configuration and Initialization Source: https://github.com/thatopen/engine_web-ifc/blob/main/examples/viewer/index.html Configures Monaco editor paths and initializes the editor and the Web-IFC viewer. This setup is necessary for using the Monaco editor within the application. ```javascript require.config({ paths: { 'vs': 'https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.20.0/min/vs' } }); window.MonacoEnvironment = { getWorkerUrl: () => proxy }; let proxy = URL.createObjectURL(new Blob([ ` self.MonacoEnvironment = { baseUrl: 'https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.20.0/min' }; importScripts('https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.20.0/min/vs/base/worker/workerMain.min.js'); ` ], { type: 'text/javascript' })); require(["vs/editor/editor.main"], function () { InitMonaco(monaco); let editor = monaco.editor.create(document.getElementById('container'), { value: ``, language: 'typescript', theme: 'vs-dark' }); InitWebIfcViewer(editor); }); ``` -------------------------------- ### Install Bundled Dependency Headers Source: https://github.com/thatopen/engine_web-ifc/blob/main/src/cpp/CMakeLists.txt Installs header files from various bundled dependencies into the main include directory. This makes external library headers available to projects using web-ifc. ```cmake install(DIRECTORY ${fastfloat_SOURCE_DIR}/include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) install(DIRECTORY ${tinynurbs_SOURCE_DIR}/include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) install(DIRECTORY ${glm_SOURCE_DIR}/glm DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) install(DIRECTORY ${earcut_SOURCE_DIR}/include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) install(DIRECTORY ${cdt_SOURCE_DIR}/CDT/include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) install(DIRECTORY ${spdlog_SOURCE_DIR}/include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) install(DIRECTORY ${stduuid_SOURCE_DIR}/include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) install(DIRECTORY ${unordered_dense_SOURCE_DIR}/include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) ``` -------------------------------- ### Set Target Include Directories and Compile Options Source: https://github.com/thatopen/engine_web-ifc/blob/main/src/cpp/CMakeLists.txt Configures include directories and compile options for a given executable target. Includes common flags for C++20 and platform-specific options. ```cmake function(PARAM_SETTER THE_EXECUTABLE) target_include_directories(${THE_EXECUTABLE} PUBLIC $) target_include_directories(${THE_EXECUTABLE} PUBLIC $) target_include_directories(${THE_EXECUTABLE} PUBLIC $) target_include_directories(${THE_EXECUTABLE} PUBLIC $) target_include_directories(${THE_EXECUTABLE} PUBLIC $) target_include_directories(${THE_EXECUTABLE} PUBLIC $) target_include_directories(${THE_EXECUTABLE} PUBLIC $) target_include_directories(${THE_EXECUTABLE} PUBLIC $) target_include_directories(${THE_EXECUTABLE} PUBLIC $) if(NOT MSVC) target_compile_options(${THE_EXECUTABLE} PUBLIC "-Wall") target_compile_options(${THE_EXECUTABLE} PUBLIC "-Wextra") target_compile_options(${THE_EXECUTABLE} PUBLIC "-Wpedantic") target_compile_options(${THE_EXECUTABLE} PUBLIC "-pedantic") target_compile_options(${THE_EXECUTABLE} PUBLIC "-std=c++20") if(EMSCRIPTEN) target_compile_options(${THE_EXECUTABLE} PUBLIC "-fexperimental-library") endif() if(RELEASE) target_compile_options(${THE_EXECUTABLE} PUBLIC "-O3") endif() else() # Force UTF-8 for Windows MSVC target_compile_options(${THE_EXECUTABLE} PUBLIC "/utf-8") target_compile_options(${THE_EXECUTABLE} PUBLIC "-std:c++latest") endif() endfunction() ``` -------------------------------- ### Declare and Fetch TinyCppTest Source: https://github.com/thatopen/engine_web-ifc/blob/main/src/cpp/CMakeLists.txt Declares and fetches the TinyCppTest library from a specific Git tag. Ensures the library is available for use in the build. ```cmake Message("Downloading TinyCPPTest") FetchContent_Declare(tinycpptest GIT_REPOSITORY "https://github.com/kovacsv/TinyCppTest" GIT_TAG "12e42c8ac6e032ce450fb3f772ebdfd1ddc6008c" SOURCE_SUBDIR "../") FetchContent_MakeAvailable(tinycpptest) FetchContent_GetProperties(tinycpptest) ``` -------------------------------- ### Build Static Library Source: https://github.com/thatopen/engine_web-ifc/blob/main/src/cpp/CMakeLists.txt Builds the web-ifc project as a static library. This is used when Emscripten is not defined, typically for non-web environments. ```cmake add_library(web-ifc-library STATIC ${web-ifc-source}) param_setter(web-ifc-library) ``` -------------------------------- ### Declare and Fetch spdlog Source: https://github.com/thatopen/engine_web-ifc/blob/main/src/cpp/CMakeLists.txt Declares and fetches the spdlog library from a specific Git tag. Ensures the library is available for use in the build. ```cmake Message("Downloading spdlog") FetchContent_Declare(spdlog GIT_REPOSITORY "https://github.com/gabime/spdlog" GIT_TAG "f355b3d58f7067eee1706ff3c801c2361011f3d5" SOURCE_SUBDIR "../") FetchContent_MakeAvailable(spdlog) FetchContent_GetProperties(spdlog) ``` -------------------------------- ### Define Include Directories for Static Library Source: https://github.com/thatopen/engine_web-ifc/blob/main/src/cpp/CMakeLists.txt Configures include directories for the static library, differentiating between build-time and install-time paths using generator expressions. ```cmake target_include_directories(web-ifc-library PUBLIC $ $ $ $ ) ``` -------------------------------- ### Build Web-IFC Executable for Testing Source: https://github.com/thatopen/engine_web-ifc/blob/main/src/cpp/CMakeLists.txt Defines the main executable target for web-ifc, used within a testing environment. Includes source files and helper utilities. ```cmake add_executable(web-ifc ${web-ifc-source} "./test/web-ifc-test.cpp" "./test/io_helpers.cpp") param_setter(web-ifc) target_include_directories(web-ifc PUBLIC ${tinycpptest_SOURCE_DIR}/Sources) ``` -------------------------------- ### Project Definition and C++ Standard Source: https://github.com/thatopen/engine_web-ifc/blob/main/src/cpp/CMakeLists.txt Defines the project name and configures C++ standard requirements. ```cmake project(web-ifc LANGUAGES CXX) enable_testing() set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) set_property(GLOBAL PROPERTY USE_FOLDERS ON) ``` -------------------------------- ### Declare and Fetch FastFloat Source: https://github.com/thatopen/engine_web-ifc/blob/main/src/cpp/CMakeLists.txt Declares and fetches the FastFloat library from a specific Git tag. Ensures the library is available for use in the build. ```cmake Message("Downloading FastFloat") FetchContent_Declare(fastfloat GIT_REPOSITORY "https://github.com/fastfloat/fast_float" GIT_TAG "05087a303dad9c98768b33c829d398223a649bc6" SOURCE_SUBDIR "../") FetchContent_MakeAvailable(fastfloat) FetchContent_GetProperties(fastfloat) ``` -------------------------------- ### CMake Minimum Version and Policy Source: https://github.com/thatopen/engine_web-ifc/blob/main/src/cpp/CMakeLists.txt Sets the minimum required CMake version and enables a specific policy for handling include directories. ```cmake include(FetchContent) cmake_policy(SET CMP0054 NEW) cmake_minimum_required(VERSION 3.18) ``` -------------------------------- ### Initialize and Open IFC Model Source: https://github.com/thatopen/engine_web-ifc/blob/main/README.md Initializes the web-ifc API, opens an IFC model from data, and closes it. Ensure the library is initialized before opening models. The model ID can be used to fetch geometry or properties. ```JavaScript const WebIFC = require("web-ifc/web-ifc-api.js"); // initialize the API const ifcApi = new WebIFC.IfcAPI(); // initialize the library await ifcApi.Init(); // open a model from data let modelID = ifcApi.OpenModel(/* IFC data as a string or UInt8Array */, /* optional settings object */, ); // the model is now loaded! use modelID to fetch geometry or properties // checkout examples/usage for some details on how to read/write IFC // close the model, all memory is freed ifcApi.CloseModel(modelID); ``` -------------------------------- ### Declare and Fetch Earcut Source: https://github.com/thatopen/engine_web-ifc/blob/main/src/cpp/CMakeLists.txt Declares and fetches the Earcut library from a specific Git tag. Ensures the library is available for use in the build. ```cmake Message("Downloading Earcut") FetchContent_Declare(earcut GIT_REPOSITORY "https://github.com/mapbox/earcut.hpp" GIT_TAG "4811a2b69b91f6127a75e780de6e2113609ddabb" SOURCE_SUBDIR "../") FetchContent_MakeAvailable(earcut) FetchContent_GetProperties(earcut) ``` -------------------------------- ### Declare and Fetch CDT Source: https://github.com/thatopen/engine_web-ifc/blob/main/src/cpp/CMakeLists.txt Declares and fetches the CDT library from a specific Git tag. Ensures the library is available for use in the build. ```cmake Message("Downloading CDT") FetchContent_Declare(cdt GIT_REPOSITORY "https://github.com/artem-ogre/CDT" GIT_TAG "4d0c9026b8ec846fe544897e7111f8f9080d5f8a" SOURCE_SUBDIR "../") FetchContent_MakeAvailable(cdt) FetchContent_GetProperties(cdt) ``` -------------------------------- ### Emscripten Build for WebIFC Source: https://github.com/thatopen/engine_web-ifc/blob/main/src/cpp/CMakeLists.txt Configures an Emscripten executable target for web deployment. Sets specific linker flags for WASM, memory growth, and module export. ```cmake if(EMSCRIPTEN) # build parameters for web-ifc add_executable(web-ifc ${web-ifc-source} ${web-ifc-wasm}) param_setter(web-ifc) set_target_properties(web-ifc PROPERTIES LINK_FLAGS "${DEBUG_FLAG} --bind -msimd128 -flto --define-macro=REAL_T_IS_DOUBLE -s ALLOW_MEMORY_GROWTH=1 -s DYNAMIC_EXECUTION=0 -s MAXIMUM_MEMORY=4GB -sSTACK_SIZE=5MB -s EXPORT_NAME=WebIFCWasm -s MODULARIZE=1 -s ENVIRONMENT=web -sASSERTIONS=1 -s EXPORTED_RUNTIME_METHODS=\"['HEAPU8','HEAPU32','HEAPF32']\"") add_executable(web-ifc-node ${web-ifc-source} ${web-ifc-wasm}) param_setter(web-ifc-node) set_target_properties(web-ifc-node PROPERTIES LINK_FLAGS "${DEBUG_FLAG} --bind -msimd128 -flto --define-macro=REAL_T_IS_DOUBLE -s ALLOW_MEMORY_GROWTH=1 -s DYNAMIC_EXECUTION=0 -s MAXIMUM_MEMORY=4GB -sSTACK_SIZE=5MB -s EXPORT_NAME=WebIFCWasm -s MODULARIZE=1 -s EXPORTED_RUNTIME_METHODS=\"['HEAPU8','HEAPU32','HEAPF32']\"") endif() ``` -------------------------------- ### Add Test Case Source: https://github.com/thatopen/engine_web-ifc/blob/main/src/cpp/CMakeLists.txt Registers 'web-ifc-test' as a test case within CMake and assigns it the label 'web-ifc' for test filtering. ```cmake add_test(web-ifc-test web-ifc-test) set_tests_properties(web-ifc-test PROPERTIES LABELS "web-ifc") ``` -------------------------------- ### Build Test Executable Source: https://github.com/thatopen/engine_web-ifc/blob/main/src/cpp/CMakeLists.txt Defines an executable target for running tests. It includes source files for the main application and specific test files. ```cmake add_executable(web-ifc-test ${web-ifc-source} "./test/encoding_test.cpp" "./test/main.cpp" "./test/io_helpers.cpp") param_setter(web-ifc-test) target_include_directories(web-ifc-test PUBLIC ${tinycpptest_SOURCE_DIR}/Sources) ``` -------------------------------- ### Declare and Fetch unordered_dense Source: https://github.com/thatopen/engine_web-ifc/blob/main/src/cpp/CMakeLists.txt Declares and fetches the unordered_dense library from a specific Git tag. Ensures the library is available for use in the build. ```cmake Message("Downloading unordered_dense") FetchContent_Declare(unordered_dense GIT_REPOSITORY "https://github.com/martinus/unordered_dense" GIT_TAG "3234af2c03549bc85656bfd3a86993bf1cd8aef1" SOURCE_SUBDIR "../") FetchContent_MakeAvailable(unordered_dense) FetchContent_GetProperties(unordered_dense) ``` -------------------------------- ### Collecting Source Files with GLOB_RECURSE Source: https://github.com/thatopen/engine_web-ifc/blob/main/src/cpp/CMakeLists.txt Uses file globbing to recursively find all .cpp files for the main project and WebAssembly targets. ```cmake # collect source files file(GLOB_RECURSE web-ifc-source web-ifc/*.cpp) file(GLOB_RECURSE web-ifc-wasm wasm/*.cpp) ``` -------------------------------- ### Declare and Fetch TinyNURBS Source: https://github.com/thatopen/engine_web-ifc/blob/main/src/cpp/CMakeLists.txt Declares and fetches the TinyNURBS library from a specific Git tag. Ensures the library is available for use in the build. ```cmake Message("Downloading TinyNURBS") FetchContent_Declare(tinynurbs GIT_REPOSITORY "https://github.com/QuimMoya/tinynurbs" GIT_TAG "47115cd9b6e922b27bbc4ab01fdeac2e9ea597a4" SOURCE_SUBDIR "../") FetchContent_MakeAvailable(tinynurbs) FetchContent_GetProperties(tinynurbs) ``` -------------------------------- ### Declare and Fetch GLM Source: https://github.com/thatopen/engine_web-ifc/blob/main/src/cpp/CMakeLists.txt Declares and fetches the GLM library from a specific Git tag. Ensures the library is available for use in the build. ```cmake Message("Downloading GLM") FetchContent_Declare(glm GIT_REPOSITORY "https://github.com/g-truc/glm" GIT_TAG "8d1fd52e5ab5590e2c81768ace50c72bae28f2ed" SOURCE_SUBDIR "../") FetchContent_MakeAvailable(glm) FetchContent_GetProperties(glm) ``` -------------------------------- ### Build Multi-threaded Executable Source: https://github.com/thatopen/engine_web-ifc/blob/main/src/cpp/CMakeLists.txt Defines a multi-threaded executable target for web-ifc. Includes setting compile options for pthreads and specific linker flags for Emscripten. ```cmake add_executable(web-ifc-mt ${web-ifc-source} ${web-ifc-wasm}) param_setter(web-ifc-mt) target_compile_options(web-ifc-mt PUBLIC "-pthread") set_target_properties(web-ifc-mt PROPERTIES LINK_FLAGS "${DEBUG_FLAG} -pthread -s PTHREAD_POOL_SIZE=navigator.hardwareConcurrency --bind -flto --define-macro=REAL_T_IS_DOUBLE -sSTACK_SIZE=5MB -s ALLOW_MEMORY_GROWTH=1 -s DYNAMIC_EXECUTION=0 -s MAXIMUM_MEMORY=4GB -s EXPORT_NAME=WebIFCWasm -s MODULARIZE=1 -s ENVIRONMENT=web,worker") ``` -------------------------------- ### Declare and Fetch StdUUID (Exclude from All) Source: https://github.com/thatopen/engine_web-ifc/blob/main/src/cpp/CMakeLists.txt Declares and fetches the StdUUID library from a specific Git tag, excluding it from being built by default. Ensures the library is available for use. ```cmake Message("Downloading StdUUID") FetchContent_Declare(stduuid GIT_REPOSITORY "https://github.com/mariusbancila/stduuid" GIT_TAG "3afe7193facd5d674de709fccc44d5055e144d7a" EXCLUDE_FROM_ALL) FetchContent_MakeAvailable(stduuid) FetchContent_GetProperties(stduuid) ``` -------------------------------- ### Enable Debug Output Options Source: https://github.com/thatopen/engine_web-ifc/blob/main/src/cpp/CMakeLists.txt Conditionally enables debug output options for the 'web-ifc' executable when not in a release build. This includes enabling CSG debug output and debug dump of SVG. ```cmake if(NOT RELEASE) target_compile_options(web-ifc PUBLIC "-DCSG_DEBUG_OUTPUT") target_compile_options(web-ifc PUBLIC "-DDEBUG_DUMP_SVG") endif() ``` -------------------------------- ### Export CMake Targets Source: https://github.com/thatopen/engine_web-ifc/blob/main/src/cpp/CMakeLists.txt Exports the 'web-ifc-targets' for use by other CMake projects. This includes creating a CMake configuration file with a specified namespace. ```cmake install(EXPORT web-ifc-targets FILE web-ifc-targets.cmake NAMESPACE web-ifc:: DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/web-ifc ) ``` -------------------------------- ### CMake Build Type Configuration Source: https://github.com/thatopen/engine_web-ifc/blob/main/src/cpp/CMakeLists.txt Configures build settings based on CMAKE_BUILD_TYPE, setting release flags and debug information. ```cmake if(CMAKE_BUILD_TYPE STREQUAL "Debug") message("Building In Debug Mode") set(RELEASE false) set(DEBUG_FLAG "-g -O3") else() set(DEBUG_FLAG "-O3") set(RELEASE true) endif() ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.