### Installing Microsoft GSL with vcpkg (Windows) Source: https://github.com/gabrieldosreis/ifc/blob/main/BUILDING.md This command installs the Microsoft GSL (Guidelines Support Library) using vcpkg for Windows platforms, specifically targeting the x64 architecture. It's a prerequisite for building the IFC SDK if not using the 'try it without installing' method. ```sh ./vckpg install --triplet x64-windows ms-gsl ``` -------------------------------- ### Configuring, Building, and Testing with CMake Presets (Shell) Source: https://github.com/gabrieldosreis/ifc/blob/main/HACKING.md These shell commands demonstrate how to configure, build, and test the project using the 'dev' preset defined in `CMakeUserPresets.json`. They provide a consistent way to manage the development workflow across different operating systems and build systems. The commands can be enhanced with the `-j` flag for parallel execution. ```Shell cmake --preset=dev cmake --build --preset=dev ctest --preset=dev ``` -------------------------------- ### Configuring CMake User Presets for Developer Mode (JSON) Source: https://github.com/gabrieldosreis/ifc/blob/main/HACKING.md This JSON snippet defines a `CMakeUserPresets.json` file, crucial for developers to configure the project. It sets up 'dev' presets for configuring, building, and testing, enabling developer mode, and integrating with vcpkg. Users must replace `` with their specific operating system (e.g., `win64`, `linux`, `darwin`). ```JSON { "version": 2, "cmakeMinimumRequired": { "major": 3, "minor": 14, "patch": 0 }, "configurePresets": [ { "name": "dev", "binaryDir": "${sourceDir}/build/dev", "inherits": ["dev-mode", "vcpkg", "ci-"], "cacheVariables": { "CMAKE_BUILD_TYPE": "Debug" } } ], "buildPresets": [ { "name": "dev", "configurePreset": "dev", "configuration": "Debug" } ], "testPresets": [ { "name": "dev", "configurePreset": "dev", "configuration": "Debug", "output": { "outputOnFailure": true } } ] } ``` -------------------------------- ### Including Install Rules and Handling Developer Mode Source: https://github.com/gabrieldosreis/ifc/blob/main/CMakeLists.txt This snippet conditionally includes installation rules from `cmake/install-rules.cmake` unless `CMAKE_SKIP_INSTALL_RULES` is set. It then exits the current CMake processing if `DEVELOPER_MODE` is not enabled. Finally, if `BUILD_TESTING` is enabled, it includes CTest and adds the `test` subdirectory for building tests. ```CMake if(NOT CMAKE_SKIP_INSTALL_RULES) include(cmake/install-rules.cmake) endif() if(NOT DEVELOPER_MODE) return() endif() include(CTest) if(BUILD_TESTING) add_subdirectory(test) endif() ``` -------------------------------- ### Installing IFC Artifacts (Multi-Config Generator) Source: https://github.com/gabrieldosreis/ifc/blob/main/BUILDING.md This command installs the compiled IFC project artifacts for the 'Release' configuration when using a multi-configuration CMake generator. It ensures only release-mode outputs are installed. ```sh cmake --install build --config Release ``` -------------------------------- ### Installing IFC Artifacts (Single-Config Generator) Source: https://github.com/gabrieldosreis/ifc/blob/main/BUILDING.md This command installs the compiled IFC project artifacts when using a single-configuration CMake generator. It places the build outputs in the system's standard installation paths. ```sh cmake --install build ``` -------------------------------- ### Setting Up CMake Project and Version Source: https://github.com/gabrieldosreis/ifc/blob/main/CMakeLists.txt This snippet initializes the CMake project, sets the minimum required CMake version, defines the IFC specification version, and configures the project name, version, and supported languages (C++). ```CMake cmake_minimum_required(VERSION 3.28) # Corresponds to https://github.com/microsoft/ifc-spec set(ifc_spec_version 0.43) project( ifc-sdk VERSION "${ifc_spec_version}.5" LANGUAGES CXX ) ``` -------------------------------- ### Configuring and Building for Unit Testing (MSVC) Source: https://github.com/gabrieldosreis/ifc/blob/main/BUILDING.md These commands configure the project for unit testing specifically with MSVC, build the test executables, navigate into the build directory, and then run the tests in debug configuration. This requires 'doctest' as a dependency. ```sh cmake -B build --preset=test-msvc cmake --build build/test cd build ctest -C debug test ``` -------------------------------- ### General `ifc` Tool Invocation Pattern - Shell Source: https://github.com/gabrieldosreis/ifc/blob/main/ifc-driver.md This snippet illustrates the general command-line pattern for invoking the `ifc` tool. It shows how a command (`_cmd_`) and one or more IFC files (`_file1_`, `_file2_`, etc.) are passed as arguments to the `ifc` executable. ```Shell ifc cmd file1 file2 ... ``` -------------------------------- ### Configuring Developer Mode and External Dependencies Source: https://github.com/gabrieldosreis/ifc/blob/main/CMakeLists.txt This section defines a `DEVELOPER_MODE` option to enable developer-specific features, marks it as advanced, and includes `CMakeDependentOption`. It also finds the required `Microsoft.GSL` package and adds `NOMINMAX` compile definition for Windows to prevent conflicts with `min`/`max` macros. ```CMake option(DEVELOPER_MODE "Enable project options and targets for developers of ifc-sdk" OFF) mark_as_advanced(DEVELOPER_MODE) include(CMakeDependentOption) find_package(Microsoft.GSL REQUIRED) # Those pesky min/max macros. if(WIN32) add_compile_definitions(NOMINMAX) endif() ``` -------------------------------- ### Building the IFC Reader Static Library Source: https://github.com/gabrieldosreis/ifc/blob/main/CMakeLists.txt This snippet defines the `ifc-reader` static library, listing its source files. It creates an alias `Microsoft.IFC::Core` and sets its export name. Conditional compilation adds Windows-specific sources (`hash_win.cxx`) and links `bcrypt`, or `sha256.cxx` for other platforms. It links to `Microsoft.GSL` and sets C++23 standard and public include directories. ```CMake add_library( ifc-reader STATIC src/file.cxx src/sgraph.cxx src/ifc-reader/operators.cxx src/ifc-reader/reader.cxx src/ifc-reader/util.cxx ) add_library(Microsoft.IFC::Core ALIAS ifc-reader) set_property(TARGET ifc-reader PROPERTY EXPORT_NAME Core) if(WIN32) target_compile_definitions(ifc-reader PRIVATE NOMINMAX) target_link_libraries(ifc-reader PRIVATE bcrypt) target_sources(ifc-reader PRIVATE src/hash_win.cxx) else() target_sources(ifc-reader PRIVATE src/sha256.cxx) endif() target_link_libraries(ifc-reader PUBLIC Microsoft.GSL::GSL) target_compile_features(ifc-reader PUBLIC cxx_std_23) target_include_directories(ifc-reader PUBLIC "$") ``` -------------------------------- ### Updating vcpkg Baseline and Configuring for Testing Source: https://github.com/gabrieldosreis/ifc/blob/main/BUILDING.md This sequence of commands updates the vcpkg baseline to include necessary dependencies like 'doctest' and then configures the CMake project for testing using the specified vcpkg toolchain file and MSVC preset. Note that this method will locally modify 'vcpkg.json'. ```sh vcpkg x-update-baseline --add-initial-baseline cmake -B build -DCMAKE_TOOLCHAIN_FILE=/vcpkg.cmake --preset=test-msvc ``` -------------------------------- ### Building the IFC DOM Static Library Source: https://github.com/gabrieldosreis/ifc/blob/main/CMakeLists.txt This snippet defines the `ifc-dom` static library, listing its source files. It creates an alias `Microsoft.IFC::DOM` and sets its export name. It links publicly to the `ifc-reader` library, sets the C++23 standard, and configures public include directories for the build interface. ```CMake add_library( ifc-dom STATIC src/ifc-dom/charts.cxx src/ifc-dom/decls.cxx src/ifc-dom/exprs.cxx src/ifc-dom/literals.cxx src/ifc-dom/names.cxx src/ifc-dom/sentences.cxx src/ifc-dom/stmts.cxx src/ifc-dom/syntax.cxx src/ifc-dom/types.cxx ) add_library(Microsoft.IFC::DOM ALIAS ifc-dom) set_property(TARGET ifc-dom PROPERTY EXPORT_NAME DOM) target_link_libraries(ifc-dom PUBLIC ifc-reader) target_compile_features(ifc-dom PUBLIC cxx_std_23) target_include_directories(ifc-dom PUBLIC "$") ``` -------------------------------- ### Building IFC in Release Mode (Multi-Config Generator) Source: https://github.com/gabrieldosreis/ifc/blob/main/BUILDING.md These commands configure and build the IFC project in release mode using a multi-configuration generator like MSBuild. The first command configures the build directory, and the second compiles the project with the 'Release' configuration. ```sh cmake -B build cmake --build build --config Release ``` -------------------------------- ### Building IFC in Release Mode (Single-Config Generator) Source: https://github.com/gabrieldosreis/ifc/blob/main/BUILDING.md These commands configure and build the IFC project in release mode using a single-configuration generator like Unix Makefiles. The first command configures the build directory, and the second compiles the project. ```sh cmake -B build -D CMAKE_BUILD_TYPE=Release cmake --build build ``` -------------------------------- ### Defining the IFC SDK Interface Library Source: https://github.com/gabrieldosreis/ifc/blob/main/CMakeLists.txt This snippet defines an `SDK` interface library, which serves as a meta-target to group the core components. It creates an alias `Microsoft.IFC::SDK` and links it to the `ifc-reader` and `ifc-dom` libraries, making them available to projects that link against the SDK. ```CMake add_library(SDK INTERFACE) add_library(Microsoft.IFC::SDK ALIAS SDK) target_link_libraries(SDK INTERFACE ifc-reader ifc-dom) ``` -------------------------------- ### Building the IFC Command-Line Tool Executable Source: https://github.com/gabrieldosreis/ifc/blob/main/CMakeLists.txt This snippet defines the `ifc` executable target from `src/tools/ifc.cxx`. It creates an alias `Microsoft.IFC::Tool` and sets its export name. The executable is configured to use C++23 features, links to the `ifc-reader` library, and includes the project's public include directories. ```CMake add_executable( ifc src/tools/ifc.cxx ) add_executable(Microsoft.IFC::Tool ALIAS ifc) set_property(TARGET ifc PROPERTY EXPORT_NAME Tool) target_compile_features(ifc PUBLIC cxx_std_23) target_link_libraries(ifc ifc-reader) target_include_directories(ifc PUBLIC "$") ``` -------------------------------- ### `ifc` Version Command Invocation - Shell Source: https://github.com/gabrieldosreis/ifc/blob/main/ifc-driver.md This snippet demonstrates the usage of the `version` built-in command with the `ifc` tool. When invoked, it displays the IFC Specification version for each specified IFC file. ```Shell ifc version file1 file2 ... ``` -------------------------------- ### Dumping IFC File Contents with ifc-printer (Shell) Source: https://github.com/gabrieldosreis/ifc/blob/main/README.md This command uses the `ifc-printer.exe` utility to display the contents of the `test.cpp.ifc` file. The `--color` flag enables colored output for better readability. It's typically used to inspect the generated IFC file. ```shell ifc-printer.exe --color test.cpp.ifc ``` -------------------------------- ### Linking IFC SDK and Doctest to ifc-basic on Windows - CMake Source: https://github.com/gabrieldosreis/ifc/blob/main/test/CMakeLists.txt This command links both the 'Microsoft.IFC::SDK' and 'doctest::doctest' libraries to the 'ifc-basic' executable. These are private dependencies, meaning they are only required for the 'ifc-basic' target itself, encapsulating its library requirements. ```CMake target_link_libraries(ifc-basic PRIVATE Microsoft.IFC::SDK)\n target_link_libraries(ifc-basic PRIVATE doctest::doctest) ``` -------------------------------- ### Adding Dependency for ifc-basic on Windows - CMake Source: https://github.com/gabrieldosreis/ifc/blob/main/test/CMakeLists.txt This command establishes a build dependency, ensuring that the 'test-ifcs' custom target (which compiles the IFC module) is built before 'ifc-basic'. This is crucial for 'ifc-basic' to have the necessary IFC file available during its compilation. ```CMake add_dependencies(ifc-basic test-ifcs) ``` -------------------------------- ### Generating IFC File with Visual C++ Compiler (Shell) Source: https://github.com/gabrieldosreis/ifc/blob/main/README.md This command uses the Microsoft Visual C++ compiler (`cl`) to compile `test.cpp` with C++20 standard and export header information, resulting in an IFC file named `test.cpp.ifc`. It's used for generating IFC files from C++ source code, though it currently has limitations regarding non-inline functions. ```shell cl /std:c++20 /exportHeader test.cpp ``` -------------------------------- ### Linking Microsoft IFC SDK in CMake Source: https://github.com/gabrieldosreis/ifc/blob/main/BUILDING.md This CMake snippet shows how to link the Microsoft IFC SDK to a specific project target. The `target_link_libraries` command is used to add `Microsoft.IFC::SDK` as a private dependency to `project_target`, ensuring the SDK is available during compilation and linking. ```CMake target_link_libraries( project_target PRIVATE Microsoft.IFC::SDK ) ``` -------------------------------- ### Compiling ifc-basic with C++23 Features on Windows - CMake Source: https://github.com/gabrieldosreis/ifc/blob/main/test/CMakeLists.txt This command ensures that the 'ifc-basic' executable, specific to Windows, is compiled using C++23 standard features. This maintains consistency in language standard usage across different targets and leverages modern C++ capabilities. ```CMake target_compile_features(ifc-basic PRIVATE cxx_std_23) ``` -------------------------------- ### Creating Custom Target for IFC Module Compilation on Windows - CMake Source: https://github.com/gabrieldosreis/ifc/blob/main/test/CMakeLists.txt This Windows-specific custom target 'test-ifcs' compiles 'm.ixx' using the C++ compiler to produce an IFC output file named 'm.ifc' in the binary directory. It uses MSVC-specific compiler flags like '/nologo' and '/std:c++20' for module compilation. ```CMake add_custom_target(test-ifcs\n COMMAND\n ${CMAKE_CXX_COMPILER}\n /nologo\n /std:c++20\n /ifcOutput${CMAKE_BINARY_DIR}/m.ifc\n /c\n ${CMAKE_CURRENT_SOURCE_DIR}/m.ixx) ``` -------------------------------- ### Adding ifc-basic Executable for Windows - CMake Source: https://github.com/gabrieldosreis/ifc/blob/main/test/CMakeLists.txt This block is conditional on 'WIN32', meaning it only executes on Windows platforms. It defines an executable target named 'ifc-basic' from 'basic.cxx', intended for MSVC-specific testing and demonstrating platform-specific build rules. ```CMake if (WIN32)\n # Only enabled for MSVC for now.\n add_executable(ifc-basic basic.cxx) ``` -------------------------------- ### Enabling CTest Testing Framework - CMake Source: https://github.com/gabrieldosreis/ifc/blob/main/test/CMakeLists.txt This command enables testing for the project using CTest, CMake's testing utility. It must be called before any 'add_test' commands to properly register and manage tests within the build system. ```CMake enable_testing() ``` -------------------------------- ### Finding and Using IFC CMake Package Source: https://github.com/gabrieldosreis/ifc/blob/main/BUILDING.md This CMake snippet demonstrates how to find and use the exported 'Microsoft.IFC' package within another CMake project. It specifies that the package is required and recommends linking against the 'Microsoft.IFC::SDK' target for comprehensive functionality. ```cmake find_package(Microsoft.IFC REQUIRED) # Declare the imported target as a build requirement using PRIVATE, where ``` -------------------------------- ### Finding Doctest Testing Framework - CMake Source: https://github.com/gabrieldosreis/ifc/blob/main/test/CMakeLists.txt This command locates the 'doctest' configuration package, which is a lightweight C++ testing framework. It's marked as 'REQUIRED', meaning CMake will fail if the package is not found, ensuring that the testing infrastructure is available. ```CMake find_package(doctest CONFIG REQUIRED) ``` -------------------------------- ### Adding ifc-basic to CTest Suite on Windows - CMake Source: https://github.com/gabrieldosreis/ifc/blob/main/test/CMakeLists.txt This Windows-specific command registers the 'ifc-basic' executable as a test named 'ifc-basic' within CTest. This test will only be available and run on Windows platforms, ensuring platform-specific test coverage. ```CMake if (WIN32)\n add_test(NAME ifc-basic COMMAND ifc-basic)\nendif() ``` -------------------------------- ### Setting Minimum CMake Version and Project Name - CMake Source: https://github.com/gabrieldosreis/ifc/blob/main/test/CMakeLists.txt This snippet sets the minimum required CMake version to 3.26 and defines the project name as 'ifc-sdk-tests' with CXX as the primary language. It's the foundational step for any CMake project, ensuring compatibility and defining the project scope. ```CMake cmake_minimum_required(VERSION 3.26)\n\nproject(ifc-sdk-tests CXX) ``` -------------------------------- ### Conditionally Building the IFC Printer Executable Source: https://github.com/gabrieldosreis/ifc/blob/main/CMakeLists.txt This snippet uses `cmake_dependent_option` to define `BUILD_PRINTER`, which is `OFF` by default but `ON` if `DEVELOPER_MODE` is not enabled. If `BUILD_PRINTER` is true, it defines the `ifc-printer` executable, listing its source files, and links it privately to `ifc-dom` and `ifc-reader` with C++23 features. ```CMake cmake_dependent_option(BUILD_PRINTER "Build the ifc-printer executable" OFF "NOT DEVELOPER_MODE" ON) if(BUILD_PRINTER) add_executable( ifc-printer src/ifc-printer/main.cxx src/ifc-printer/printer.cxx src/assert.cxx ) target_link_libraries(ifc-printer PRIVATE ifc-dom ifc-reader) target_compile_features(ifc-printer PRIVATE cxx_std_23) endif() ``` -------------------------------- ### Adding ifc-test Executable and C++23 Features - CMake Source: https://github.com/gabrieldosreis/ifc/blob/main/test/CMakeLists.txt This defines an executable target named 'ifc-test' from 'main.cxx'. It then specifies that this target should be compiled with C++23 standard features, ensuring modern C++ language support for the test suite. ```CMake add_executable(ifc-test main.cxx)\n\ntarget_compile_features(ifc-test PRIVATE cxx_std_23) ``` -------------------------------- ### Adding ifc-test to CTest Suite - CMake Source: https://github.com/gabrieldosreis/ifc/blob/main/test/CMakeLists.txt This command registers the 'ifc-test' executable as a test named 'ifc-test' within the CTest framework. When 'ctest' is run, it will execute this test, allowing for automated verification of the 'ifc-test' functionality. ```CMake add_test(NAME ifc-test COMMAND ifc-test) ``` -------------------------------- ### Defining IFC File Path for ifc-basic on Windows - CMake Source: https://github.com/gabrieldosreis/ifc/blob/main/test/CMakeLists.txt This command adds a private compile definition 'IFC_FILE' for the 'ifc-basic' target, setting its value to the path of the generated 'm.ifc' file. This allows the C++ source code to locate the IFC file at compile time, facilitating module import. ```CMake target_compile_definitions(ifc-basic PRIVATE IFC_FILE=\"${CMAKE_BINARY_DIR}/m.ifc\") ``` -------------------------------- ### Linking Microsoft IFC SDK to ifc-test - CMake Source: https://github.com/gabrieldosreis/ifc/blob/main/test/CMakeLists.txt This command links the 'Microsoft.IFC::SDK' library to the 'ifc-test' executable. The 'PRIVATE' keyword indicates that this dependency is only for the 'ifc-test' target itself and not propagated to other targets that link against 'ifc-test'. ```CMake target_link_libraries(ifc-test PRIVATE Microsoft.IFC::SDK) ``` -------------------------------- ### Styling Sidebar Layout and Navigation - CSS Source: https://github.com/gabrieldosreis/ifc/blob/main/samples/sgraph-js/index.html Defines the flexible box layout for the main wrapper and sets the dimensions and transition properties for the sidebar. It also styles the navigation links within the sidebar, including hover and active states, and the header and component list for consistent UI presentation. ```CSS .wrapper { display: flex; align-items: stretch; } #sidebar { min-width: 450px; max-width: 450px; transition: all 0.3s; } #sidebar a, #sidebar a:hover, #sidebar a:focus { color: inherit; } #sidebar.active { margin-left: 0px; } #sidebar .sidebar-header { padding: 20px; } #sidebar ul.components { padding: 20px 0; border-bottom: 1px solid #47748b; } #sidebar ul p { color: #fff; padding: 10px; } #sidebar ul li a { padding: 10px; font-size: 1.1em; display: block; } #sidebar ul li a:hover { color: #7386D5; background: #fff; } #sidebar ul li.active > a, a[aria-expanded="true"] { color: #fff; background: #6d7fcc; } a[data-toggle="collapse"] { position: relative; } ``` -------------------------------- ### Conditionally Finding Microsoft IFC Package - CMake Source: https://github.com/gabrieldosreis/ifc/blob/main/test/CMakeLists.txt This block attempts to find the Microsoft.IFC package, which is required for the project. The 'if' condition ensures this package is only searched for if the current source directory is the top-level source directory, preventing redundant searches in subdirectories. ```CMake if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)\n find_package(Microsoft.IFC REQUIRED)\nendif() ``` -------------------------------- ### Styling General Layout and File Selector - CSS Source: https://github.com/gabrieldosreis/ifc/blob/main/samples/sgraph-js/index.html Defines basic styling for SVG rectangles, general content containers, and the file selection area. The file selector is highlighted with a dashed red border, indicating its interactive nature for drag-and-drop operations. ```CSS rect { stroke: #fff; } .title-container { float: left; } #file-selector { border: 5px dashed red; width: 440px; height: 272px; } #output { padding-top: 5px; } .content-container { float: left; } ``` -------------------------------- ### Styling Color Selectors and Opacity Text - CSS Source: https://github.com/gabrieldosreis/ifc/blob/main/samples/sgraph-js/index.html Applies styles to color selection elements for declarations and classes, positioning them relative to their containers. It also defines a style for displaying bad opacity values in red, providing visual feedback to the user. ```CSS #decl-color-selector { height: 25px; top: 4px; position: relative; } #reset-decl-colors { vertical-align: top; } #class-color-selector { height: 25px; top: 4px; position: relative; } #reset-class-colors { vertical-align: top; } #bad-filter-opacity-text { color: red; } ``` -------------------------------- ### Styling IFC Explorer Elements - CSS Source: https://github.com/gabrieldosreis/ifc/blob/main/samples/sgraph-js/index.html Provides styling for interactive elements within the IFC Explorer, changing the cursor to a pointer on hover for clickable elements. It also reduces the font size for history entries to maintain a compact display. ```CSS .explorer-element:hover { cursor: pointer; } .explorer-history { font-size: 0.6em; } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.