### Build and Install Release Version Source: https://github.com/asmaloney/libe57format/blob/master/README.md Configures, builds, and installs a release version of the libE57Format library with default settings. ```bash cmake -B E57-build -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=E57-install libE57Format cmake --build E57-build --parallel cmake --install E57-build ``` -------------------------------- ### Install Dependencies on Linux (Ubuntu) Source: https://github.com/asmaloney/libe57format/blob/master/README.md Installs the necessary development libraries for E57 format processing on Ubuntu systems. ```bash $ sudo apt install libxerces-c-dev clang-format ``` -------------------------------- ### Install Package Configuration Files Source: https://github.com/asmaloney/libe57format/blob/master/CMakeLists.txt Installs the main package configuration file ('e57format-config.cmake') and the generated version file ('e57format-config-version.cmake') to the designated CMake installation directory. ```cmake install( FILES ${CMAKE_CURRENT_SOURCE_DIR}/cmake/e57format-config.cmake ${CMAKE_CURRENT_BINARY_DIR}/e57format-config-version.cmake DESTINATION "${E57_INSTALL_CMAKEDIR}" ) ``` -------------------------------- ### CMake Build and Test Setup Source: https://github.com/asmaloney/libe57format/blob/master/extern/CRCpp/README.md Configure the build using CMake, build the tests, and generate documentation. Assumes an out-of-source build in the 'build' directory. ```bash mkdir -p build cd build cmake .. [-DBUILD_DOC=ON] # Build and run unit tests make tests # Build documentation make doxygen # Install header file sudo make install ``` -------------------------------- ### Install Target Source: https://github.com/asmaloney/libe57format/blob/master/CMakeLists.txt Installs the E57Format target and creates an export set for it, allowing other projects to find and use this library. ```cmake install( TARGETS E57Format EXPORT E57Format-export ) ``` -------------------------------- ### Install Dependencies on macOS (homebrew) Source: https://github.com/asmaloney/libe57format/blob/master/README.md Installs required development tools and libraries for E57 format processing on macOS using Homebrew. ```bash $ brew install ccache clang-format xerces-c ``` -------------------------------- ### Install Export Set Source: https://github.com/asmaloney/libe57format/blob/master/CMakeLists.txt Installs the export set for the E57Format target to the configured CMake directory, enabling package configuration. ```cmake install( EXPORT E57Format-export DESTINATION "${E57_INSTALL_CMAKEDIR}" ) ``` -------------------------------- ### Build with Custom Xerces-C++ Path Source: https://github.com/asmaloney/libe57format/blob/master/README.md Builds the libE57Format library, specifying a custom installation path for Xerces-C++ if CMake cannot locate it automatically. ```bash cmake -B E57-build \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX=E57-install \ -DCMAKE_PREFIX_PATH=/path/to/xerces-c \ libE57Format ``` -------------------------------- ### Set Install Directory for CMake Package Files Source: https://github.com/asmaloney/libe57format/blob/master/CMakeLists.txt Defines the installation path for CMake package configuration files, typically within the 'cmake' subdirectory of the library directory. ```cmake set( E57_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}" CACHE STRING "Install path for ${PROJECT_NAME} CMake files" ) message( STATUS "[${PROJECT_NAME}] CMake files install to ${CMAKE_INSTALL_PREFIX}/${E57_INSTALL_CMAKEDIR}" ) ``` -------------------------------- ### Build Unit Tests with Make Source: https://github.com/asmaloney/libe57format/blob/master/extern/CRCpp/README.md Instructions to build the unit tests using Make. Change directory to the GCC project and run 'make' with either 'debug' or 'release' argument. ```bash # Build cd test/prj/gcc make [debug|release] ``` -------------------------------- ### Build Documentation with Doxygen Source: https://github.com/asmaloney/libe57format/blob/master/extern/CRCpp/README.md Command to build the project's documentation using Doxygen. Navigate to the 'doxygen' directory and run the 'doxygen' command with the 'Doxyfile.dox' configuration. ```bash cd doxygen doxygen Doxyfile.dox ``` -------------------------------- ### Run Tests Source: https://github.com/asmaloney/libe57format/blob/master/README.md Executes the test suite for the libE57Format library after building it. Assumes the build directory is the current directory. ```bash cd E57-build ./test/testE57 [==========] Running 36 tests from 8 test suites. [----------] Global test environment set-up. [----------] 1 test from TestData [ RUN ] TestData.RepoExists ... ``` -------------------------------- ### Run Unit Tests (Executable) Source: https://github.com/asmaloney/libe57format/blob/master/extern/CRCpp/README.md Execute the pre-compiled unit test executable. ```bash bin/unittest ``` -------------------------------- ### Enable Testing and Add Test Subdirectory Source: https://github.com/asmaloney/libe57format/blob/master/CMakeLists.txt If E57_BUILD_TEST is enabled, this section enables testing for the project and adds the 'test' subdirectory, which likely contains test executables and scripts. ```cmake if ( E57_BUILD_TEST ) message( STATUS "[${PROJECT_NAME}] Testing enabled" ) enable_testing() add_subdirectory( test ) endif() ``` -------------------------------- ### Generate Package Version File Source: https://github.com/asmaloney/libe57format/blob/master/CMakeLists.txt Uses CMake's 'write_basic_package_version_file' to create a version file for the package configuration, specifying the project version and compatibility. ```cmake write_basic_package_version_file ( e57format-config-version.cmake VERSION ${PROJECT_VERSION} COMPATIBILITY SameMajorVersion ) ``` -------------------------------- ### Run clang-format for Code Formatting Source: https://github.com/asmaloney/libe57format/blob/master/CONTRIBUTING.md Before submitting pull requests, ensure your code adheres to the project's formatting standards by running the clang-format cmake target. This command formats all source files according to the project's configuration. ```sh cmake --build . --target e57-clang-format ``` -------------------------------- ### Enable ccache if Found Source: https://github.com/asmaloney/libe57format/blob/master/CMakeLists.txt Includes the 'ccache' module, which automatically enables the use of ccache for compilation if it is found on the system. ```cmake include( ccache ) ``` -------------------------------- ### Link Xerces-C Library Source: https://github.com/asmaloney/libe57format/blob/master/CMakeLists.txt Links the E57Format target against the Xerces-C library, which is required for XML parsing. ```cmake target_link_libraries( E57Format PRIVATE XercesC::XercesC ) ``` -------------------------------- ### Configure Release LTO Option Source: https://github.com/asmaloney/libe57format/blob/master/CMakeLists.txt Sets an option to control Link-Time Optimization for release builds. This is typically turned off for distributing static release builds. ```cmake option( E57_RELEASE_LTO "Compile release library with link-time optimization" ON ) ``` -------------------------------- ### Calculate CRC-32 using Auto Lookup Table Source: https://github.com/asmaloney/libe57format/blob/master/extern/CRCpp/README.md Demonstrates using the `auto` keyword to create a CRC-32 lookup table. This approach simplifies table instantiation. ```cpp int main(int argc, char ** argv) { const char myHelloString[] = { 'H', 'E', 'L', 'L', 'O', ' ' }; const char myWorldString[] = { 'W', 'O', 'R', 'L', 'D' }; auto table = CRC::CRC_32().MakeTable(); std::uint32_t crc; crc = CRC::Calculate(myHelloString, sizeof(myHelloString), table); crc = CRC::Calculate(myWorldString, sizeof(myWorldString), table, crc); std::cout << std::hex << crc; return 0; } ``` -------------------------------- ### Add Library Target (Shared or Static) Source: https://github.com/asmaloney/libe57format/blob/master/CMakeLists.txt Adds the main library target 'E57Format', choosing between SHARED or STATIC based on the E57_BUILD_SHARED option. A status message indicates the build type. ```cmake if ( E57_BUILD_SHARED ) message( STATUS "[${PROJECT_NAME}] Building shared library" ) add_library( E57Format SHARED ) else() message( STATUS "[${PROJECT_NAME}] Building static library" ) add_library( E57Format STATIC ) endif() ``` -------------------------------- ### Set CRCpp Include Directories Source: https://github.com/asmaloney/libe57format/blob/master/extern/CRCpp/CMakeLists.txt Specifies the include directory for CRCpp headers. ```cmake target_include_directories( ${PROJECT_NAME} PRIVATE inc ) ``` -------------------------------- ### Set Target Properties Source: https://github.com/asmaloney/libe57format/blob/master/CMakeLists.txt Configures properties for the E57Format target, including C++ extensions, export compile commands, position-independent code, and interprocedural optimization settings. ```cmake set_target_properties( E57Format PROPERTIES CXX_EXTENSIONS NO EXPORT_COMPILE_COMMANDS ON POSITION_INDEPENDENT_CODE ON INTERPROCEDURAL_OPTIMIZATION ${E57_RELEASE_LTO} INTERPROCEDURAL_OPTIMIZATION_DEBUG OFF ) ``` -------------------------------- ### Configure Testing Option Source: https://github.com/asmaloney/libe57format/blob/master/CMakeLists.txt Sets an option to control whether tests are built. The default value is determined by the E57_BUILDING_SELF variable. ```cmake option( E57_BUILD_TEST "Build tests" ${E57_BUILDING_SELF} ) ``` -------------------------------- ### Conditional Test Execution in GoogleTest Source: https://github.com/asmaloney/libe57format/blob/master/test/README.md Demonstrates how to define tests that conditionally run based on the availability of test data. Test suites requiring data should have names ending with 'Data'. ```cpp TEST( SimpleWriter, WriteFoo ) { // Will always run } TEST( SimpleWriterData, WriteFoo ) { // Will only run if the test data is available } ``` -------------------------------- ### Set Shared Library Version Properties Source: https://github.com/asmaloney/libe57format/blob/master/CMakeLists.txt Configures the VERSION and SOVERSION properties for the E57Format target when building a shared library, using the project's version variables. ```cmake if ( E57_BUILD_SHARED ) set_target_properties( E57Format PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR} ) endif() ``` -------------------------------- ### Add CRCpp Source Files Source: https://github.com/asmaloney/libe57format/blob/master/extern/CRCpp/CMakeLists.txt Includes the CRCpp header file in the project's private sources. ```cmake target_sources( ${PROJECT_NAME} PRIVATE inc/CRC.h ) ``` -------------------------------- ### Define Compile-Time Macros Source: https://github.com/asmaloney/libe57format/blob/master/CMakeLists.txt Sets compile definitions for the E57Format target, including REVISION_ID, E57_VALIDATION_LEVEL, and conditional definitions for diagnostic output, verbosity, and packet mode. ```cmake target_compile_definitions( E57Format PRIVATE REVISION_ID="${REVISION_ID}" E57_VALIDATION_LEVEL=${E57_VALIDATION_LEVEL} $<$:E57_ENABLE_DIAGNOSTIC_OUTPUT> $<$:E57_VERBOSE> $<$:E57_WRITE_CRAZY_PACKET_MODE> ) ``` -------------------------------- ### Set CRCPP Compile Definitions Source: https://github.com/asmaloney/libe57format/blob/master/extern/CRCpp/CMakeLists.txt Configures compile definitions for CRCpp, enabling C++11 support and branchless operations. ```cmake target_compile_definitions( ${PROJECT_NAME} PRIVATE CRCPP_USE_CPP11 CRCPP_BRANCHLESS ) ``` -------------------------------- ### Set C++ Standard to C++14 Source: https://github.com/asmaloney/libe57format/blob/master/CMakeLists.txt Specifies that the C++14 standard should be used for the project's target. ```cmake target_compile_features( ${PROJECT_NAME} PRIVATE cxx_std_14 ) ``` -------------------------------- ### Set Debug Postfix if Undefined Source: https://github.com/asmaloney/libe57format/blob/master/CMakeLists.txt Ensures a debug postfix is set for the target if CMAKE_DEBUG_POSTFIX is not already defined, typically to '-d'. ```cmake if ( NOT DEFINED CMAKE_DEBUG_POSTFIX ) set_target_properties( E57Format PROPERTIES DEBUG_POSTFIX "-d" ) endif() ``` -------------------------------- ### Calculate CRC-32 using a Lookup Table Source: https://github.com/asmaloney/libe57format/blob/master/extern/CRCpp/README.md Utilizes a pre-computed lookup table for faster CRC-32 calculations. The table is created once and can be reused for multiple CRC computations. ```cpp int main(int argc, char ** argv) { const char myHelloString[] = { 'H', 'E', 'L', 'L', 'O', ' ' }; const char myWorldString[] = { 'W', 'O', 'R', 'L', 'D' }; CRC::Table table(CRC::CRC_32()); std::uint32_t crc; crc = CRC::Calculate(myHelloString, sizeof(myHelloString), table); crc = CRC::Calculate(myWorldString, sizeof(myWorldString), table, crc); std::cout << std::hex << crc; return 0; } ``` -------------------------------- ### Calculate Multi-Part CRC-32 Source: https://github.com/asmaloney/libe57format/blob/master/extern/CRCpp/README.md Calculates a CRC-32 checksum incrementally for multiple byte arrays. The result of the first calculation is passed as an argument to the subsequent calculation. ```cpp int main(int argc, char ** argv) { const char myHelloString[] = { 'H', 'E', 'L', 'L', 'O', ' ' }; const char myWorldString[] = { 'W', 'O', 'R', 'L', 'D' }; std::uint32_t crc; crc = CRC::Calculate(myHelloString, sizeof(myHelloString), CRC::CRC_32()); crc = CRC::Calculate(myWorldString, sizeof(myWorldString), CRC::CRC_32(), crc); std::cout << std::hex << crc; return 0; } ``` -------------------------------- ### Validate E57_VALIDATION_LEVEL Source: https://github.com/asmaloney/libe57format/blob/master/CMakeLists.txt Strips whitespace from E57_VALIDATION_LEVEL and checks if it's within the valid range of 0-2. If not, it issues a fatal error; otherwise, it reports the set level. ```cmake string( STRIP "${E57_VALIDATION_LEVEL}" E57_VALIDATION_LEVEL ) if ( NOT E57_VALIDATION_LEVEL MATCHES "^[0-2]$" ) message( FATAL_ERROR "[${PROJECT_NAME}] E57_VALIDATION_LEVEL should be 0-2: '${E57_VALIDATION_LEVEL}'" ) else() message( STATUS "[${PROJECT_NAME}] Setting validation level to ${E57_VALIDATION_LEVEL}" ) endif () ``` -------------------------------- ### Calculate CRC-32 for a String Source: https://github.com/asmaloney/libe57format/blob/master/extern/CRCpp/README.md Computes the CRC-32 checksum for a given byte array. Include the CRC.h header and standard C++ headers for I/O and integer types. ```cpp #include "CRC.h" #include #include #include int main(int argc, char ** argv) { const char myString[] = { 'H', 'E', 'L', 'L', 'O', ' ', 'W', 'O', 'R', 'L', 'D' }; std::uint32_t crc = CRC::Calculate(myString, sizeof(myString), CRC::CRC_32()); std::cout << std::hex << crc; return 0; } ``` -------------------------------- ### Define Revision ID Source: https://github.com/asmaloney/libe57format/blob/master/CMakeLists.txt Constructs a revision identifier string based on project name, version, build tag, and latest Git tag if available. This ID is then used for status messages. ```cmake set( REVISION_ID "${PROJECT_NAME}-${PROJECT_VERSION}-${${PROJECT_NAME}_BUILD_TAG}" ) if ( GIT_LATEST_TAG ) set( REVISION_ID "${REVISION_ID} (git ${GIT_LATEST_TAG})" ) endif() message( STATUS "[${PROJECT_NAME}] Revision ID: ${REVISION_ID}" ) ``` -------------------------------- ### Calculate CRC-32 for Specific Bits Source: https://github.com/asmaloney/libe57format/blob/master/extern/CRCpp/README.md Computes a CRC-32 checksum for a specified number of bits within a byte array. The second argument to `CalculateBits` is the total number of bits to process. ```cpp int main(int argc, char ** argv) { const unsigned char data[] = { 0x98, 0x76, 0x54, 0x32, 0x10 }; // Second argument is the number of bits. The input data must // be a whole number of bytes. Pad any used bits with zeros. std::uint32_t crc = CRC::CalculateBits(data, 37, CRC::CRC_32()); std::cout << std::hex << crc; return 0; } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.