### Build scnlib with CMake Source: https://scnlib.dev Standard commands to build and install scnlib from source on a Unix-like system. ```bash $ mkdir build $ cd build $ cmake .. $ make -j $ make install ``` -------------------------------- ### Run runtime performance benchmarks Source: https://scnlib.dev Commands to configure, build, and execute performance benchmarks for scnlib. ```bash # create build directory like above $ cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON -DSCN_NATIVE_ARCH=ON .. $ make -j # disable CPU frequency scaling $ sudo cpupower frequency-set --governor performance # run the benchmark of your choosing $ ./benchmark/runtime/integer/scn_int_bench # re-enable CPU frequency scaling $ sudo cpupower frequency-set --governor powersave ``` -------------------------------- ### Build and run tests Source: https://scnlib.dev Commands to build and execute the test suite using CMake and ctest. ```bash $ mkdir build $ cd build $ cmake -DCMAKE_BUILD_TYPE=Debug .. $ make -j $ ctest -j ``` -------------------------------- ### Integrate scnlib with FetchContent Source: https://scnlib.dev Use CMake's FetchContent module to automatically download and include scnlib in your project. ```cmake FetchContent_Declare( scn GIT_REPOSITORY https://github.com/eliaskosunen/scnlib GIT_TAG v4.0.1 GIT_SHALLOW TRUE ) FetchContent_MakeAvailable(scn) # ... target_link_libraries(my_program scn::scn) ``` -------------------------------- ### Basic scanning with scn::scan Source: https://scnlib.dev Demonstrates how to use scn::scan to parse values from a string. The result object provides access to the parsed values. ```cpp #include #include // for std::println, C++23 int main() { auto result = scn::scan("42, 3.14", "{}, {}"); if (result) { auto [first, second] = result->values(); std::println("first: {}, second: {}", first, second); // Prints "first: 42, second: 3.14\n" } } ``` -------------------------------- ### Link libscn.a in a project Source: https://scnlib.dev Links the previously built libscn.a into a user project. The -L flag points to the build directory containing the library. ```shell # in your project $ c++ ... -Lpath-to-scn/build -lscn ``` -------------------------------- ### Build scnlib without CMake Source: https://scnlib.dev Compiles scnlib sources into a static library libscn.a. Requires fast_float headers available via -Ipath-to-fast-float. C++17 or newer is required. ```shell $ mkdir build $ cd build $ c++ -c -I../include/ ../src/*.cpp -Ipath-to-fast-float $ ar rcs libscn.a *.o ``` -------------------------------- ### Integrate scnlib with find_package Source: https://scnlib.dev Use find_package in your CMake project to link against scnlib. ```cmake # Find scnlib package find_package(scn CONFIG REQUIRED) # Target which you'd like to use scnlib add_executable(my_program ...) target_link_libraries(my_program scn::scn) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.